Wlo-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
January 2014
- 3 participants
- 33 discussions
r33 - in trunk: . src/fr/ifremer/wlo src/fr/ifremer/wlo/models src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils
by kmorin@users.forge.codelutin.com 28 Jan '14
by kmorin@users.forge.codelutin.com 28 Jan '14
28 Jan '14
Author: kmorin
Date: 2014-01-28 16:00:21 +0100 (Tue, 28 Jan 2014)
New Revision: 33
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/33
Log:
fixes #4242 ajout esp?\195?\168ce commerciale : ne pas demander l'enregistrement
fixes #4239 ?\195?\160 l'arriv?\195?\169e sur un nouvel ?\195?\169cran ne pas ?\195?\169tendre les listes d?\195?\169roulante du champ s?\195?\169lectionn?\195?\169 car cela cache les autres champs
refs #4083 Principe d'ergonomie
Modified:
trunk/pom.xml
trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java
trunk/src/fr/ifremer/wlo/models/BaseModel.java
trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
trunk/src/fr/ifremer/wlo/models/ContextModel.java
trunk/src/fr/ifremer/wlo/models/LocationModel.java
trunk/src/fr/ifremer/wlo/models/MeasurementModel.java
trunk/src/fr/ifremer/wlo/models/MetierModel.java
trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
trunk/src/fr/ifremer/wlo/models/VesselModel.java
trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/pom.xml 2014-01-28 15:00:21 UTC (rev 33)
@@ -251,7 +251,7 @@
</executions>
<configuration>
<sdk>
- <path>${env.ANDROID_HOME}</path>
+ <!--<path>${env.ANDROID_HOME}</path>-->
<platform>15</platform>
</sdk>
<!--<device>emulator</device>-->
Modified: trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -33,6 +33,7 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
@@ -88,6 +89,15 @@
} else {
setTitle(model.toString(this));
}
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ Log.d(TAG, "modified !");
+ model.setModified(true);
+ }
+ });
+ getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
@Override
@@ -111,34 +121,33 @@
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.new_item:
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == AlertDialog.BUTTON_POSITIVE) {
- saveModel();
+ if (model.isModified()) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == AlertDialog.BUTTON_POSITIVE) {
+ saveModel();
+ }
+ openNewModelEdition();
+
}
- Intent intent = new Intent(WloModelEditionActivity.this, WloModelEditionActivity.this.getClass());
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- BaseModel parentModel = hModel.getParent();
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
- }
- startActivity(intent);
- }
- };
- builder.setMessage(R.string.exit_form_confirmation)
- .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener())
- .setNeutralButton(R.string.no, listener)
- .setPositiveButton(R.string.yes, listener)
- .create()
- .show();
+ };
+ builder.setMessage(R.string.exit_form_confirmation)
+ .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener())
+ .setNeutralButton(R.string.no, listener)
+ .setPositiveButton(R.string.yes, listener)
+ .create()
+ .show();
+
+ } else {
+ openNewModelEdition();
+ }
return true;
}
return super.onOptionsItemSelected(item);
}
-
/* Method called by the view */
public void validate(View view) {
@@ -252,8 +261,10 @@
final String firtsLetterUpperCaseAttribute =
attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
- ArrayAdapter<R> adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, Lists.newArrayList(data));
- autoCompleteTextView.setAdapter(adapter);
+ if (!data.isEmpty()) {
+ ArrayAdapter<R> adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, Lists.newArrayList(data));
+ autoCompleteTextView.setAdapter(adapter);
+ }
autoCompleteTextView.setThreshold(0);
autoCompleteTextView.setTag(attribute);
@@ -283,4 +294,14 @@
});
}
+
+ protected void openNewModelEdition() {
+ Intent intent = new Intent(WloModelEditionActivity.this, WloModelEditionActivity.this.getClass());
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ BaseModel parentModel = hModel.getParent();
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
+ }
+ startActivity(intent);
+ }
}
Modified: trunk/src/fr/ifremer/wlo/models/BaseModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -33,10 +33,13 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
+import org.apache.commons.lang3.ObjectUtils;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
+import java.util.Objects;
import java.util.Set;
/**
@@ -63,8 +66,11 @@
protected String id;
- public BaseModel() {}
+ protected boolean modified;
+ public BaseModel() {
+ }
+
public BaseModel(Cursor cursor) {
id = cursor.getString(0);
}
@@ -74,13 +80,23 @@
}
public void setId(String id) {
+ String oldValue = this.id;
this.id = id;
+ firePropertyChange(_ID, oldValue, id);
}
public boolean isNew() {
return id == null;
}
+ public boolean isModified() {
+ return modified;
+ }
+
+ public void setModified(boolean modified) {
+ this.modified = modified;
+ }
+
public abstract String getTableName();
public String toString(android.content.Context context) {
@@ -101,6 +117,12 @@
changeSupport.addPropertyChangeListener(property, listener);
}
+ public void firePropertyChange(String property, Object oldValue, Object newValue) {
+ Log.d(TAG, "fire " + property + " " + oldValue + " " + newValue);
+ Log.d(TAG, "equals ? " + ObjectUtils.equals(oldValue, newValue));
+ changeSupport.firePropertyChange(property, oldValue, newValue);
+ }
+
public Set<String> getRequiredFields() {
return Sets.newHashSet();
}
Modified: trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -99,7 +99,9 @@
}
public void setFaoCode(CommercialSpecies faoCode) {
+ CommercialSpecies oldValue = this.faoCode;
this.faoCode = faoCode;
+ firePropertyChange(COLUMN_FAO_CODE, oldValue, faoCode);
}
public Mensuration getMeasurementMethod() {
@@ -107,7 +109,9 @@
}
public void setMeasurementMethod(Mensuration measurementMethod) {
+ Mensuration oldValue = this.measurementMethod;
this.measurementMethod = measurementMethod;
+ firePropertyChange(COLUMN_MEASUREMENT_METHOD, oldValue, measurementMethod);
}
public Mensuration.Precision getPrecision() {
@@ -115,7 +119,9 @@
}
public void setPrecision(Mensuration.Precision precision) {
+ Mensuration.Precision oldValue = this.precision;
this.precision = precision;
+ firePropertyChange(COLUMN_PRECISION, oldValue, precision);
}
public boolean isSpeciesMix() {
@@ -123,7 +129,10 @@
}
public void setSpeciesMix(boolean speciesMix) {
+ boolean oldValue = this.speciesMix;
this.speciesMix = speciesMix;
+ Log.d(TAG, "species mix change");
+ firePropertyChange(COLUMN_SPECIES_MIX, oldValue, speciesMix);
}
public String getSortCategory() {
@@ -131,7 +140,9 @@
}
public void setSortCategory(String sortCategory) {
+ String oldValue = this.sortCategory;
this.sortCategory = sortCategory;
+ firePropertyChange(COLUMN_SORT_CATEGORY, oldValue, sortCategory);
}
public State getState() {
@@ -139,7 +150,9 @@
}
public void setState(State state) {
+ State oldValue = this.state;
this.state = state;
+ firePropertyChange(COLUMN_STATE, oldValue, state);
}
public Presentation getPresentation() {
@@ -147,7 +160,9 @@
}
public void setPresentation(Presentation presentation) {
+ String oldValue = this.id;
this.presentation = presentation;
+ firePropertyChange(_ID, oldValue, id);
}
@Override
Modified: trunk/src/fr/ifremer/wlo/models/ContextModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -26,6 +26,7 @@
import android.content.ContentValues;
import android.database.Cursor;
+import android.util.Log;
import com.google.common.collect.Multimap;
import java.util.Set;
@@ -60,7 +61,9 @@
}
public void setName(String name) {
+ String oldValue = this.name;
this.name = name;
+ firePropertyChange(COLUMN_NAME, oldValue, name);
}
@Override
Modified: trunk/src/fr/ifremer/wlo/models/LocationModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -79,7 +79,9 @@
}
public void setOperator(String operator) {
+ Object oldValue = this.operator;
this.operator = operator;
+ firePropertyChange(COLUMN_OPERATOR, oldValue, operator);
}
public Calendar getStartDate() {
@@ -87,7 +89,9 @@
}
public void setStartDate(Calendar startDate) {
+ Object oldValue = this.startDate;
this.startDate = startDate;
+ firePropertyChange(COLUMN_START_DATE, oldValue, startDate);
}
public Calendar getEndDate() {
@@ -95,7 +99,9 @@
}
public void setEndDate(Calendar endDate) {
+ Object oldValue = this.endDate;
this.endDate = endDate;
+ firePropertyChange(COLUMN_END_DATE, oldValue, endDate);
}
public Location getLocation() {
@@ -103,7 +109,9 @@
}
public void setLocation(Location location) {
+ Object oldValue = this.location;
this.location = location;
+ firePropertyChange(COLUMN_LOCATION, oldValue, location);
}
@Override
Modified: trunk/src/fr/ifremer/wlo/models/MeasurementModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -3,8 +3,8 @@
/*
* #%L
* WLO
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2013 - 2014 Ifremer
* %%
@@ -94,7 +94,7 @@
Integer oldValue = this.size;
this.size = size;
Log.d(TAG, size + " " + oldValue + " " + size.equals(oldValue));
- changeSupport.firePropertyChange(COLUMN_SIZE, oldValue, size);
+ firePropertyChange(COLUMN_SIZE, oldValue, size);
}
public void incSize(int inc) {
@@ -123,7 +123,9 @@
}
public void setDate(Calendar date) {
+ Object oldValue = this.date;
this.date = date;
+ firePropertyChange(COLUMN_DATE, oldValue, date);
}
public String getCategory1() {
@@ -131,7 +133,9 @@
}
public void setCategory1(String category1) {
+ Object oldValue = this.category1;
this.category1 = category1;
+ firePropertyChange(COLUMN_CATEGORY_1, oldValue, category1);
}
public String getCategory2() {
@@ -139,7 +143,9 @@
}
public void setCategory2(String category2) {
+ Object oldValue = this.category2;
this.category2 = category2;
+ firePropertyChange(COLUMN_CATEGORY_2, oldValue, category2);
}
public String getCategory3() {
@@ -147,7 +153,9 @@
}
public void setCategory3(String category3) {
+ Object oldValue = this.category3;
this.category3 = category3;
+ firePropertyChange(COLUMN_CATEGORY_3, oldValue, category3);
}
public String toString(Context context, Mensuration.Precision precision) {
Modified: trunk/src/fr/ifremer/wlo/models/MetierModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -72,7 +72,9 @@
}
public void setGearSpecies(Metier gearSpecies) {
+ Object oldValue = this.gearSpecies;
this.gearSpecies = gearSpecies;
+ firePropertyChange(COLUMN_GEAR_SPECIES, oldValue, gearSpecies);
}
public String getZone() {
@@ -80,7 +82,9 @@
}
public void setZone(String zone) {
+ Object oldValue = this.zone;
this.zone = zone;
+ firePropertyChange(COLUMN_ZONE, oldValue, zone);
}
public String getSampleRowCode() {
@@ -88,7 +92,9 @@
}
public void setSampleRowCode(String sampleRowCode) {
+ Object oldValue = this.sampleRowCode;
this.sampleRowCode = sampleRowCode;
+ firePropertyChange(COLUMN_SAMPLE_ROW_CODE, oldValue, sampleRowCode);
}
@Override
Modified: trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -69,7 +69,9 @@
}
public void setName(ScientificSpecies name) {
+ Object oldValue = this.name;
this.name = name;
+ firePropertyChange(COLUMN_NAME, oldValue, name);
}
public boolean isTakingActivation() {
@@ -77,7 +79,9 @@
}
public void setTakingActivation(boolean takingActivation) {
+ Object oldValue = this.takingActivation;
this.takingActivation = takingActivation;
+ firePropertyChange(COLUMN_TAKING_ACTIVATION, oldValue, takingActivation);
}
@Override
Modified: trunk/src/fr/ifremer/wlo/models/VesselModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -3,8 +3,8 @@
/*
* #%L
* WLO
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2013 - 2014 Ifremer
* %%
@@ -83,7 +83,7 @@
public void setRegistrationNumber(String registrationNumber) {
Object oldValue = this.registrationNumber;
this.registrationNumber = registrationNumber;
- changeSupport.firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
+ firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
}
public String getName() {
@@ -93,7 +93,7 @@
public void setName(String name) {
Object oldValue = this.name;
this.name = name;
- changeSupport.firePropertyChange(COLUMN_NAME, oldValue, name);
+ firePropertyChange(COLUMN_NAME, oldValue, name);
}
public Calendar getLandingDate() {
@@ -101,7 +101,9 @@
}
public void setLandingDate(Calendar landingDate) {
+ Object oldValue = this.landingDate;
this.landingDate = landingDate;
+ firePropertyChange(COLUMN_LANDING_DATE, oldValue, landingDate);
}
public Location getLandingLocation() {
@@ -109,7 +111,9 @@
}
public void setLandingLocation(Location landingLocation) {
+ Object oldValue = this.landingLocation;
this.landingLocation = landingLocation;
+ firePropertyChange(COLUMN_LANDING_LOCATION, oldValue, landingLocation);
}
@Override
Modified: trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -612,6 +612,7 @@
} else {
db.update(tableName, values, BaseModel._ID + " = ?", new String[]{ model.getId() });
}
+ model.setModified(false);
}
db.setTransactionSuccessful();
Modified: trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-28 13:32:42 UTC (rev 32)
+++ trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-28 15:00:21 UTC (rev 33)
@@ -53,22 +53,24 @@
}
protected void init() {
- setOnFocusChangeListener(new OnFocusChangeListener() {
+// setOnFocusChangeListener(new OnFocusChangeListener() {
+// @Override
+// public void onFocusChange(View v, boolean hasFocus) {
+// if (hasFocus) {
+// showDropDown();
+// } else {
+// dismissDropDown();
+// }
+// }
+// });
+ setOnClickListener(new OnClickListener() {
@Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
+ public void onClick(View v) {
+ if (getAdapter() != null && !getAdapter().isEmpty()) {
showDropDown();
- } else {
- dismissDropDown();
}
}
});
- setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- showDropDown();
- }
- });
}
@Override
1
0
See <http://ci-ng.forge.codelutin.com/jenkins/job/wlo/1/>
------------------------------------------
[...truncated 597 lines...]
[INFO] Downloading: http://repo.maven.apache.org/maven2/javax/enterprise/cdi-api/1.0/cdi-api-1.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/bouncycastle/bcprov-jdk15on/1.48/bc… (2264 KB at 20033.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/4.0/asm-analys… (20 KB at 766.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/javax/inject/javax.inject/1/javax.injec…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/javax/enterprise/cdi-api/1.0/cdi-api-1.… (44 KB at 1686.7 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/eclipse/sisu/org.eclipse.sisu.injec…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/external/lombok/lombo… (1036 KB at 15009.0 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interpolatio…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint-checks/22.4… (460 KB at 6858.6 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/emma/emma/2.0.5312/emma-2.0.5312.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-… (6 KB at 228.4 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/eclipse/aether/aether-connector-wag…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/javax/inject/javax.inject/1/javax.injec… (3 KB at 97.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-pa…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interpolatio… (61 KB at 2410.0 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/madgag/animated-gif-lib/1.0/animate…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/eclipse/aether/aether-connector-wag… (34 KB at 1332.7 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-ce…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/eclipse/sisu/org.eclipse.sisu.injec… (285 KB at 6054.6 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-pa… (15 KB at 564.5 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/emma/emma/2.0.5312/emma-2.0.5312.jar (419 KB at 8712.1 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/madgag/animated-gif-lib/1.0/animate… (20 KB at 823.3 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-ce… (4 KB at 136.8 KB/sec)
[INFO] Downloading: http://repository.jboss.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-a…
[INFO] Downloading: http://repository.jboss.org/maven2/javax/inject/javax.inject/1/javax.inject…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WLO 0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr… (3 KB at 53.2 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.… (6 KB at 203.5 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent… (16 KB at 580.5 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.… (5 KB at 179.6 KB/sec)
[INFO] Downloading: http://files.couchbase.com/maven2/org/apache/httpcomponents/httpcore/4.3.1/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent… (12 KB at 456.5 KB/sec)
[INFO] Downloading: http://files.couchbase.com/maven2/org/apache/httpcomponents/httpcomponents-…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/khr…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/khronos/opengl-a…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.… (2 KB at 59.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xerces/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xerces/xmlParserAPIs…
[INFO] Downloading: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI… (153 B at 6.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xpp3/xp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xpp3/xpp3/1.1.4c/xpp…
[INFO] Downloading: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.pom
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.pom (3 KB at 79.1 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/jso…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/json/json/200807…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.pom
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.pom (2 KB at 62.8 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4… (3 KB at 81.3 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (447 B at 5.6 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v7-appcom…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (405 B at 10.1 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v4/19.0.1…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/code/gson…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.… (8 KB at 261.7 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/ach…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach… (2 KB at 19.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/achartengine/achartengine/1.1.0/ach…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/khr…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xerces/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xpp3/xp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/jso…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/ach…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/khronos/opengl-a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xerces/xmlParserAPIs…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xpp3/xpp3/1.1.4c/xpp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/json/json/200807…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/code/gson…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (613 KB at 2049.7 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (296 KB at 924.6 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (336 KB at 996.1 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach… (120 KB at 112.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.…
[INFO] Downloading: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.… (19 KB at 384.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.… (572 KB at 7833.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI… (122 KB at 1416.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.jar (37 KB at 1056.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v7-appcom…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4… (40 KB at 1205.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v7-appcom…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar (118 KB at 1584.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v4/19.0.1…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.… (276 KB at 2187.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/achartengine/achartengine/1.1.0/ach…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.… (186 KB at 2043.6 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr… (12645 KB at 34266.4 KB/sec)
[INFO] Downloading: http://files.couchbase.com/maven2/org/apache/httpcomponents/httpcore/4.3.1/…
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wlo ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wlo ---
[INFO]
[INFO] --- android-maven-plugin:3.8.2:generate-sources (default-generate-sources) @ wlo ---
[DEBUG] Expanding: /var/local/forge/data/forge.codelutin.com/maven/repository/android/support/compatibility-v7-appcompat/19.0.1/compatibility-v7-appcompat-19.0.1.apklib into <http://ci-ng.forge.codelutin.com/jenkins/job/wlo/ws/trunk/target/unpacked-l…>
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME
at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidHomeOrThrow(AbstractAndroidMojo.java:1176)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidSdk(AbstractAndroidMojo.java:1129)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:481)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:216)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.256s
[INFO] Finished at: Mon Jan 27 12:56:55 CET 2014
[JENKINS] Archiving disabled
[INFO] Final Memory: 17M/237M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project wlo: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:generate-sources (default-generate-sources) on project wlo: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.maven.plugin.MojoExecutionException: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME
at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidHomeOrThrow(AbstractAndroidMojo.java:1176)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidSdk(AbstractAndroidMojo.java:1129)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:481)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:216)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 30 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Waiting for Jenkins to finish collecting data
Sending e-mails to: wlo-commits(a)list.forge.codelutin.com
channel stopped
1
1
28 Jan '14
See <http://ci-ng.forge.codelutin.com/jenkins/job/wlo/fr.ifremer$wlo/1/>
------------------------------------------
[...truncated 364 lines...]
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/javax/annotation/jsr…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/javax/inject/javax.i…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/eclipse/sisu/org…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/codehaus/plexus/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/emma/emma/2.0.5312/e…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/eclipse/aether/a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/github/rtyley/an…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/madgag/animated-…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/github/rtyley/an…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/jayway/maven/plugins/android/genera…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/common/22.4.2/common-…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/dvlib/22.4.2/dvlib-22…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/sdk-common/22.4.2/sdk…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/sdklib/22.4.2/sdklib-…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/dvlib/22.4.2/dvlib-22… (15 KB at 322.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/common/22.4.2/common-… (71 KB at 1078.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.1/…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/sdk-common/22.4.2/sdk… (268 KB at 2497.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.4/commons…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/jayway/maven/plugins/android/genera… (397 KB at 3671.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpmime/4.1/…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.1/… (177 KB at 2638.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/commons/commons-compress/1.0…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.4/commons… (57 KB at 2271.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/build/builder/0.7.3/b…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpmime/4.1/… (27 KB at 1007.1 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/build/builder-model/0…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/sdklib/22.4.2/sdklib-… (614 KB at 4383.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/squareup/javawriter/2.2.1/javawrite…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.… (343 KB at 3089.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/build/builder-test-ap…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/build/builder-model/0… (12 KB at 448.4 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/bouncycastle/bcpkix-jdk15on/1.48/bc…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/squareup/javawriter/2.2.1/javawrite… (12 KB at 477.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/bouncycastle/bcprov-jdk15on/1.48/bc…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/build/builder/0.7.3/b… (130 KB at 3605.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/build/manifest-merger…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/commons/commons-compress/1.0… (141 KB at 3121.7 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/build/builder-test-ap… (4 KB at 150.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/ddms/ddmlib/22.4.2/dd…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/build/manifest-merger… (39 KB at 1520.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/layoutlib/layoutlib-a…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar (43 KB at 1713.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint/22.4.2/lint…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/layoutlib/layoutlib-a… (70 KB at 2792.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint-api/22.4.2/…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/bouncycastle/bcpkix-jdk15on/1.48/bc… (572 KB at 8529.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/external/lombok/lombo…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/ddms/ddmlib/22.4.2/dd… (259 KB at 5489.6 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/4.0/asm-tree-4.0.j…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint/22.4.2/lint… (73 KB at 2801.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint-checks/22.4…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/ow2/asm/asm-tree/4.0/asm-tree-4.0.j… (22 KB at 858.7 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/4.0/asm-analys…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint-api/22.4.2/… (145 KB at 3900.0 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/javax/enterprise/cdi-api/1.0/cdi-api-1.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/bouncycastle/bcprov-jdk15on/1.48/bc… (2264 KB at 20033.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/ow2/asm/asm-analysis/4.0/asm-analys… (20 KB at 766.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/javax/inject/javax.inject/1/javax.injec…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/javax/enterprise/cdi-api/1.0/cdi-api-1.… (44 KB at 1686.7 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/eclipse/sisu/org.eclipse.sisu.injec…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/external/lombok/lombo… (1036 KB at 15009.0 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interpolatio…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/android/tools/lint/lint-checks/22.4… (460 KB at 6858.6 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/emma/emma/2.0.5312/emma-2.0.5312.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-… (6 KB at 228.4 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/eclipse/aether/aether-connector-wag…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/javax/inject/javax.inject/1/javax.injec… (3 KB at 97.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-pa…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interpolatio… (61 KB at 2410.0 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/madgag/animated-gif-lib/1.0/animate…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/eclipse/aether/aether-connector-wag… (34 KB at 1332.7 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-ce…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/eclipse/sisu/org.eclipse.sisu.injec… (285 KB at 6054.6 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-pa… (15 KB at 564.5 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/emma/emma/2.0.5312/emma-2.0.5312.jar (419 KB at 8712.1 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/madgag/animated-gif-lib/1.0/animate… (20 KB at 823.3 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/github/rtyley/android-screenshot-ce… (4 KB at 136.8 KB/sec)
[INFO] Downloading: http://repository.jboss.org/maven2/javax/annotation/jsr250-api/1.0/jsr250-a…
[INFO] Downloading: http://repository.jboss.org/maven2/javax/inject/javax.inject/1/javax.inject…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WLO 0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr… (3 KB at 53.2 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.… (6 KB at 203.5 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent… (16 KB at 580.5 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.… (5 KB at 179.6 KB/sec)
[INFO] Downloading: http://files.couchbase.com/maven2/org/apache/httpcomponents/httpcore/4.3.1/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponent… (12 KB at 456.5 KB/sec)
[INFO] Downloading: http://files.couchbase.com/maven2/org/apache/httpcomponents/httpcomponents-…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/khr…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/khronos/opengl-a…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.… (2 KB at 59.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xerces/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xerces/xmlParserAPIs…
[INFO] Downloading: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI… (153 B at 6.0 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xpp3/xp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xpp3/xpp3/1.1.4c/xpp…
[INFO] Downloading: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.pom
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.pom (3 KB at 79.1 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/jso…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/json/json/200807…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.pom
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.pom (2 KB at 62.8 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4… (3 KB at 81.3 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (447 B at 5.6 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v7-appcom…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (405 B at 10.1 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v4/19.0.1…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/code/gson…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.… (8 KB at 261.7 KB/sec)
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/ach…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach… (2 KB at 19.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/achartengine/achartengine/1.1.0/ach…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/apa…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/khr…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xerces/…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/xpp3/xp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/jso…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/android…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/com/goo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/repositories/central-releases/org/ach…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/apache/httpcompo…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/khronos/opengl-a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xerces/xmlParserAPIs…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/xpp3/xpp3/1.1.4c/xpp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/json/json/200807…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/android/a…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/com/google/code/gson…
[INFO] Downloading: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach…
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (613 KB at 2049.7 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (296 KB at 924.6 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/android/support/comp… (336 KB at 996.1 KB/sec)
[INFO] Downloaded: http://nexus.nuiton.org/nexus/content/groups/wlo-group/org/achartengine/ach… (120 KB at 112.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.…
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.…
[INFO] Downloading: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/khronos/opengl-api/gl1.1-android-2.… (19 KB at 384.2 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.… (572 KB at 7833.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.jar
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xerces/xmlParserAPIs/2.6.2/xmlParserAPI… (122 KB at 1416.3 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.jar (37 KB at 1056.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v7-appcom…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android-test/4.1.1.4… (40 KB at 1205.9 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v7-appcom…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar (118 KB at 1584.5 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/android/support/compatibility-v4/19.0.1…
[INFO] Downloading: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.3.… (276 KB at 2187.8 KB/sec)
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/achartengine/achartengine/1.1.0/ach…
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.… (186 KB at 2043.6 KB/sec)
[INFO] Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/andr… (12645 KB at 34266.4 KB/sec)
[INFO] Downloading: http://files.couchbase.com/maven2/org/apache/httpcomponents/httpcore/4.3.1/…
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ wlo ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ wlo ---
[INFO]
[INFO] --- android-maven-plugin:3.8.2:generate-sources (default-generate-sources) @ wlo ---
[DEBUG] Expanding: /var/local/forge/data/forge.codelutin.com/maven/repository/android/support/compatibility-v7-appcompat/19.0.1/compatibility-v7-appcompat-19.0.1.apklib into <http://ci-ng.forge.codelutin.com/jenkins/job/wlo/fr.ifremer$wlo/ws/target/u…>
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] Manifest merging disabled. Using project manifest only
[ERROR] Error when generating sources.
org.apache.maven.plugin.MojoExecutionException: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME
at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidHomeOrThrow(AbstractAndroidMojo.java:1176)
at com.jayway.maven.plugins.android.AbstractAndroidMojo.getAndroidSdk(AbstractAndroidMojo.java:1129)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateR(GenerateSourcesMojo.java:481)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:216)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238)
at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:134)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:69)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
[JENKINS] Archiving disabled
1
1
Author: kmorin
Date: 2014-01-28 14:32:42 +0100 (Tue, 28 Jan 2014)
New Revision: 32
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/32
Log:
fixes #4246 Contextes : changer le titre en "Saisie/Voir les donn?\195?\169es"
Modified:
trunk/res/values-fr/strings.xml
trunk/res/values/strings.xml
Modified: trunk/res/values/strings.xml
===================================================================
--- trunk/res/values/strings.xml 2014-01-27 09:12:53 UTC (rev 31)
+++ trunk/res/values/strings.xml 2014-01-28 13:32:42 UTC (rev 32)
@@ -62,7 +62,7 @@
<string name="undefined">Undefined</string>
<!-- Home screen -->
- <string name="main_open_contexts">Contexts</string>
+ <string name="main_open_contexts">Watch/Input data</string>
<string name="main_export_data">Export data</string>
<string name="main_connect_ichtyometer">Connect an ichtyometer</string>
<string name="main_disconnect_ichtyometer">Disconnect the ichtyometer</string>
Modified: trunk/res/values-fr/strings.xml
===================================================================
--- trunk/res/values-fr/strings.xml 2014-01-27 09:12:53 UTC (rev 31)
+++ trunk/res/values-fr/strings.xml 2014-01-28 13:32:42 UTC (rev 32)
@@ -58,7 +58,7 @@
<string name="undefined">Non défini</string>
<!-- Home screen -->
- <string name="main_open_contexts">Contextes</string>
+ <string name="main_open_contexts">Voir / saisir des données</string>
<string name="main_export_data">Export des données</string>
<string name="main_connect_ichtyometer">Connecter un ichtyomètre</string>
<string name="main_disconnect_ichtyometer">Déconnecter l\'ichtyomètre</string>
1
0
Author: kmorin
Date: 2014-01-27 10:12:53 +0100 (Mon, 27 Jan 2014)
New Revision: 31
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/31
Log:
start 0.2-snapshot
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-01-27 09:11:33 UTC (rev 30)
+++ trunk/pom.xml 2014-01-27 09:12:53 UTC (rev 31)
@@ -34,7 +34,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wlo</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <version>0.2-SNAPSHOT</version>
<name>WLO</name>
<description>
1
0
Author: kmorin
Date: 2014-01-27 10:11:33 +0100 (Mon, 27 Jan 2014)
New Revision: 30
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/30
Log:
remove wrongly named tag
Removed:
tags/0.1/
1
0
r29 - in tags: . wlo-0.1 wlo-0.1/res/layout wlo-0.1/src wlo-0.1/src/fr/ifremer/wlo wlo-0.1/src/fr/ifremer/wlo/measurement wlo-0.1/src/fr/ifremer/wlo/models wlo-0.1/src/fr/ifremer/wlo/models/referentials wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports wlo-0.1/src/fr/ifremer/wlo/preferences wlo-0.1/src/fr/ifremer/wlo/storage wlo-0.1/src/fr/ifremer/wlo/utils wlo-0.1/src/fr/ifremer/wlo/utils/filechooser
by kmorin@users.forge.codelutin.com 27 Jan '14
by kmorin@users.forge.codelutin.com 27 Jan '14
27 Jan '14
Author: kmorin
Date: 2014-01-27 10:03:16 +0100 (Mon, 27 Jan 2014)
New Revision: 29
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/29
Log:
Added:
tags/wlo-0.1/
tags/wlo-0.1/LICENSE.txt
tags/wlo-0.1/default.properties
tags/wlo-0.1/pom.xml
tags/wlo-0.1/res/layout/measurement.xml
tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java
tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/Home.java
tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java
tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java
tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java
tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java
tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java
tags/wlo-0.1/src/license/
Removed:
tags/wlo-0.1/LICENSE.txt
tags/wlo-0.1/default.properties
tags/wlo-0.1/pom.xml
tags/wlo-0.1/res/layout/measurement.xml
tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java
tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/Home.java
tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java
tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java
tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java
tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java
tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java
tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java
tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java
tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java
tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java
Deleted: tags/wlo-0.1/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/LICENSE.txt 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program 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 3 of the License, or
- (at your option) any later version.
-
- This program 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, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Copied: tags/wlo-0.1/LICENSE.txt (from rev 26, trunk/LICENSE.txt)
===================================================================
--- tags/wlo-0.1/LICENSE.txt (rev 0)
+++ tags/wlo-0.1/LICENSE.txt 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Deleted: tags/wlo-0.1/default.properties
===================================================================
--- trunk/default.properties 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/default.properties 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,13 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Indicates whether an apk should be generated for each density.
-split.density=false
-# Project target.
-target=android-4
Copied: tags/wlo-0.1/default.properties (from rev 26, trunk/default.properties)
===================================================================
--- tags/wlo-0.1/default.properties (rev 0)
+++ tags/wlo-0.1/default.properties 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,13 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Indicates whether an apk should be generated for each density.
+split.density=false
+# Project target.
+target=android-15
Deleted: tags/wlo-0.1/pom.xml
===================================================================
--- trunk/pom.xml 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/pom.xml 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,578 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>mavenpom4redmine</artifactId>
- <version>4.5</version>
- </parent>
-
- <groupId>fr.ifremer</groupId>
- <artifactId>wlo</artifactId>
- <version>0.1-SNAPSHOT</version>
-
- <name>WLO</name>
- <description>
- Application pour les missions de recueil d'information sur les stockes pour l'observation en criée et en mer.
- </description>
- <inceptionYear>2013</inceptionYear>
- <url>http://forge.codelutin.com/projects/wlo</url>
-
- <licenses>
- <license>
- <name>General Public License (GPL)</name>
- <url>http://www.gnu.org/licenses/gpl.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
-
- <developers>
- <developer>
- <id>chemit</id>
- <name>Tony Chemit</name>
- <email>chemit at codelutin dot com</email>
- <organization>CodeLutin</organization>
- <organizationUrl>http://www.codelutin.com</organizationUrl>
- <roles>
- <role>developer</role>
- </roles>
- <timezone>Europe/Paris</timezone>
- </developer>
- <developer>
- <id>morin</id>
- <name>Kevin Morin</name>
- <email>morin at codelutin dot com</email>
- <organization>CodeLutin</organization>
- <organizationUrl>http://www.codelutin.com</organizationUrl>
- <roles>
- <role>developer</role>
- </roles>
- <timezone>Europe/Paris</timezone>
- </developer>
- </developers>
-
- <scm>
- <url>https://forge.codelutin.com/svn/wlo/trunk</url>
- <connection>
- scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
- </connection>
- <developerConnection>
- scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
- </developerConnection>
- </scm>
- <distributionManagement>
- <site>
- <id>${platform}</id>
- <url>${our.site.repository}/${projectId}</url>
- </site>
- </distributionManagement>
-
- <packaging>apk</packaging>
-
- <properties>
-
- <!-- Java version -->
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- <signatureArtifactId>java17</signatureArtifactId>
- <signatureVersion>1.0</signatureVersion>
-
- <platform>forge.codelutin.com</platform>
- <projectId>wlo</projectId>
- <maven.test.skip>true</maven.test.skip>
- <!-- locales for the site generation, by default only french -->
- <locales>fr</locales>
-
- <!-- do not relatize links in generated site -->
- <relativizeDecorationLinks>false</relativizeDecorationLinks>
-
- <!-- license header configuration -->
- <license.organizationName>Ifremer</license.organizationName>
- <license.licenseName>gpl_v3</license.licenseName>
-
- <!-- Post Release configuration -->
- <skipPostRelease>false</skipPostRelease>
-
- <gsonVersion>2.2.4</gsonVersion>
- <sdkVersion>19.0.1</sdkVersion>
-
- </properties>
-
-
- <dependencies>
-
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android</artifactId>
- <version>4.1.1.4</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android-test</artifactId>
- <version>4.1.1.4</version>
- <scope>test</scope>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>support-v4</artifactId>-->
- <!--<version>19.0.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>/opt/android/extras/android/m2repository/com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar</systemPath>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>appcompat-v7</artifactId>-->
- <!--<version>19.0.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>/opt/android/extras/android/m2repository/com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.aar</systemPath>-->
- <!--</dependency>-->
-
- <dependency>
- <groupId>android.support</groupId>
- <artifactId>compatibility-v7-appcompat</artifactId>
- <version>${sdkVersion}</version>
- <type>apklib</type>
- </dependency>
-
- <dependency>
- <groupId>android.support</groupId>
- <artifactId>compatibility-v7-appcompat</artifactId>
- <version>${sdkVersion}</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>android.support</groupId>
- <artifactId>compatibility-v4</artifactId>
- <version>${sdkVersion}</version>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>support-v4</artifactId>-->
- <!--<version>18.0.0</version>-->
- <!--<scope>compile</scope>-->
- <!--</dependency>-->
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guavaVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>${gsonVersion}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.achartengine</groupId>
- <artifactId>achartengine</artifactId>
- <version>1.1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-csv</artifactId>
- <version>3.0-alpha-1</version>
- <exclusions>
- <exclusion>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- </dependencies>
-
- <repositories>
- <repository>
- <id>wlo-group</id>
- <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- </repository>
-
- <!--<repository>-->
- <!--<id>android.support-mvn-repo</id>-->
- <!--<url>https://raw.github.com/kmchugh/android.support/mvn-repo</url>-->
- <!--<snapshots>-->
- <!--<enabled>true</enabled>-->
- <!--<updatePolicy>daily</updatePolicy>-->
- <!--</snapshots>-->
- <!--</repository>-->
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>wlo-group</id>
- <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- </pluginRepository>
- </pluginRepositories>
-
- <build>
- <sourceDirectory>src</sourceDirectory>
- <resources>
- <resource>
- <directory>res</directory>
- <filtering>false</filtering>
- </resource>
- </resources>
-
- <plugins>
-
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>android-maven-plugin</artifactId>
- <version>3.8.2</version>
- <executions>
- <execution>
- <id>alignApk</id>
- <phase>install</phase>
- <goals>
- <goal>zipalign</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <sdk>
- <path>/opt/android</path>
- <platform>15</platform>
- </sdk>
- <!--<deleteConflictingFiles>true</deleteConflictingFiles>-->
- <!--<device>emulator</device>-->
- <device>usb</device>
- <zipalign>
- <verbose>true</verbose>
- <skip>false</skip>
- <inputApk>
- ${project.build.directory}/${project.artifactId}-${project.version}.apk
- </inputApk>
- <outputApk>
- ${project.build.directory}/${project.artifactId}-${project.version}-aligned.apk
- </outputApk>
- </zipalign>
- <extractDuplicates>true</extractDuplicates>
- </configuration>
- <extensions>true</extensions>
- </plugin>
-
- <!-- plugin site -->
- <!--<plugin>-->
- <!--<artifactId>maven-site-plugin</artifactId>-->
- <!--<dependencies>-->
- <!--<dependency>-->
- <!--<groupId>org.nuiton.jrst</groupId>-->
- <!--<artifactId>doxia-module-jrst</artifactId>-->
- <!--<version>${jrstPluginVersion}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>hsqldb</groupId>-->
- <!--<artifactId>hsqldb</artifactId>-->
- <!--<version>${jdbc.hsqldb.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.hibernate</groupId>-->
- <!--<artifactId>hibernate-core</artifactId>-->
- <!--<version>${hibernateVersion}</version>-->
- <!--</dependency>-->
- <!--</dependencies>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<groupId>org.codehaus.mojo</groupId>-->
- <!--<artifactId>animal-sniffer-maven-plugin</artifactId>-->
- <!--<version>${animalSnifferPluginVersion}</version>-->
- <!--<configuration>-->
- <!--<signature>-->
- <!--<groupId>org.codehaus.mojo.signature</groupId>-->
- <!--<artifactId>java16-sun</artifactId>-->
- <!--<version>1.10</version>-->
- <!--</signature>-->
- <!--</configuration>-->
- <!--</plugin>-->
-
- </plugins>
-
- </build>
-
- <reporting>
- <excludeDefaults>true</excludeDefaults>
- </reporting>
-
- <profiles>
-
- <profile>
- <id>check-release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>check-release-properties</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <phase>initialize</phase>
- <configuration>
- <rules>
- <requireProperty>
- <property>dbVersion</property>
- <message>You must set a dbVersion property!</message>
- </requireProperty>
- </rules>
- <ignoreCache>true</ignoreCache>
- <failFast>true</failFast>
- <fail>true</fail>
-
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- </profile>
- <profile>
- <id>license-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <defaultGoal>generate-resources</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>update-file-header-on-pom</id>
- <goals>
- <goal>update-file-header</goal>
- </goals>
- <phase>generate-resources</phase>
- <configuration>
- <roots>
- <root>${project.basedir}</root>
- </roots>
- <includes>
- <include>pom.xml</include>
- </includes>
- <addSvnKeyWords>false</addSvnKeyWords>
- <verbose>false</verbose>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>deploy-update</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <!--<plugin>-->
- <!--<artifactId>maven-antrun-plugin</artifactId>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<id>copy update-properties to site</id>-->
- <!--<phase>package</phase>-->
- <!--<inherited>false</inherited>-->
- <!--<configuration>-->
- <!--<tasks>-->
- <!--<echo message="Copy model to site" />-->
- <!--<copy verbose="true" failonerror="false" overwrite="true" filtering="true" todir="${project.build.directory}/update">-->
- <!--<filterset>-->
- <!--<filter value="${project.version}" token="projectVersion" />-->
- <!--<filter value="${jreVersion}" token="jreVersion" />-->
- <!--<filter value="${dbVersion}" token="dbVersion" />-->
- <!--</filterset>-->
- <!--<fileset dir="${basedir}/src/update/">-->
- <!--<include name="update-tutti.properties" />-->
- <!--</fileset>-->
- <!--</copy>-->
- <!--</tasks>-->
- <!--</configuration>-->
- <!--<goals>-->
- <!--<goal>run</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<groupId>org.codehaus.mojo</groupId>-->
- <!--<artifactId>wagon-maven-plugin</artifactId>-->
- <!--<version>1.0-beta-4</version>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<phase>deploy</phase>-->
- <!--<inherited>false</inherited>-->
- <!--<goals>-->
- <!--<goal>upload-single</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<serverId>forge.codelutin.com</serverId>-->
- <!--<fromFile>-->
- <!--${project.build.directory}/update/update-tutti.properties-->
- <!--</fromFile>-->
- <!--<url>-->
- <!--scpexe://forge.codelutin.com/var/www/ApplicationUpdate/http/tutti-->
- <!--</url>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--</executions>-->
-
- <!--</plugin>-->
- </plugins>
- </build>
-
- </profile>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <reporting>
- <plugins>
-
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <version>${projectInfoReportsPluginVersion}</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependencies</report>
- <report>dependency-convergence</report>
- <report>dependency-info</report>
- <report>plugin-management</report>
- <report>plugins</report>
- <report>dependency-management</report>
- <report>summary</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
-
- <!--<plugin>-->
- <!--<groupId>org.nuiton</groupId>-->
- <!--<artifactId>nuiton-maven-report-plugin</artifactId>-->
- <!--<version>3.0-alpha-1</version>-->
- <!--<inherited>false</inherited>-->
- <!--<reportSets>-->
- <!--<reportSet>-->
- <!--<reports>-->
- <!--<report>aggregate-config-report</report>-->
- <!--</reports>-->
- <!--</reportSet>-->
- <!--</reportSets>-->
- <!--<configuration>-->
- <!--<i18nBundleName>tutti-i18n</i18nBundleName>-->
- <!--</configuration>-->
- <!--</plugin>-->
-
- </plugins>
- </reporting>
-
- </profile>
-
- <!-- This profile update license stuff with new goal update-file-header -->
- <profile>
- <id>update-file-header</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <properties>
- <license.descriptor>src/license/project.xml</license.descriptor>
- </properties>
- <build>
- <defaultGoal>process-resources</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>update-file-header</id>
- <goals>
- <goal>update-file-header</goal>
- </goals>
- <configuration>
- <addSvnKeyWords>true</addSvnKeyWords>
- <excludes>
- <exclude>**/i18n/*.properties</exclude>
- <exclude>**/THIRD-PARTY.properties</exclude>
- <!-- since sh scripts must begins by the line #!/bin/sh,
- can not use the mojo for the mojo -->
- <exclude>**/*.sh</exclude>
- </excludes>
- </configuration>
- <phase>process-resources</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- </profiles>
-
-</project>
Copied: tags/wlo-0.1/pom.xml (from rev 26, trunk/pom.xml)
===================================================================
--- tags/wlo-0.1/pom.xml (rev 0)
+++ tags/wlo-0.1/pom.xml 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,539 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ WLO
+ %%
+ Copyright (C) 2013 - 2014 Ifremer
+ %%
+ This program 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 3 of the
+ License, or (at your option) any later version.
+
+ This program 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, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom4redmine</artifactId>
+ <version>4.5</version>
+ </parent>
+
+ <groupId>fr.ifremer</groupId>
+ <artifactId>wlo</artifactId>
+ <version>0.1</version>
+
+ <name>WLO</name>
+ <description>
+ Application pour les missions de recueil d'information sur les stockes pour l'observation en criée et en mer.
+ </description>
+ <inceptionYear>2013</inceptionYear>
+ <url>http://forge.codelutin.com/projects/wlo</url>
+
+ <licenses>
+ <license>
+ <name>General Public License (GPL)</name>
+ <url>http://www.gnu.org/licenses/gpl.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <developers>
+ <developer>
+ <id>chemit</id>
+ <name>Tony Chemit</name>
+ <email>chemit at codelutin dot com</email>
+ <organization>CodeLutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <roles>
+ <role>developer</role>
+ </roles>
+ <timezone>Europe/Paris</timezone>
+ </developer>
+ <developer>
+ <id>morin</id>
+ <name>Kevin Morin</name>
+ <email>morin at codelutin dot com</email>
+ <organization>CodeLutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <roles>
+ <role>developer</role>
+ </roles>
+ <timezone>Europe/Paris</timezone>
+ </developer>
+ </developers>
+
+ <scm>
+ <url>https://forge.codelutin.com/svn/wlo/trunk</url>
+ <connection>
+ scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
+ </developerConnection>
+ </scm>
+ <distributionManagement>
+ <site>
+ <id>${platform}</id>
+ <url>${our.site.repository}/${projectId}</url>
+ </site>
+ </distributionManagement>
+
+ <packaging>apk</packaging>
+
+ <properties>
+
+ <!-- Java version -->
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
+ <signatureArtifactId>java17</signatureArtifactId>
+ <signatureVersion>1.0</signatureVersion>
+
+ <platform>forge.codelutin.com</platform>
+ <projectId>wlo</projectId>
+ <maven.test.skip>true</maven.test.skip>
+ <!-- locales for the site generation, by default only french -->
+ <locales>fr</locales>
+
+ <!-- do not relatize links in generated site -->
+ <relativizeDecorationLinks>false</relativizeDecorationLinks>
+
+ <!-- license header configuration -->
+ <license.organizationName>Ifremer</license.organizationName>
+ <license.licenseName>gpl_v3</license.licenseName>
+
+ <!-- Post Release configuration -->
+ <skipPostRelease>false</skipPostRelease>
+
+ <gsonVersion>2.2.4</gsonVersion>
+ <sdkVersion>19.0.1</sdkVersion>
+
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android</artifactId>
+ <version>4.1.1.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android-test</artifactId>
+ <version>4.1.1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>android.support</groupId>
+ <artifactId>compatibility-v7-appcompat</artifactId>
+ <version>${sdkVersion}</version>
+ <type>apklib</type>
+ </dependency>
+
+ <dependency>
+ <groupId>android.support</groupId>
+ <artifactId>compatibility-v7-appcompat</artifactId>
+ <version>${sdkVersion}</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>android.support</groupId>
+ <artifactId>compatibility-v4</artifactId>
+ <version>${sdkVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guavaVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gsonVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.achartengine</groupId>
+ <artifactId>achartengine</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ <version>3.0-alpha-1</version>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>wlo-group</id>
+ <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ </repository>
+
+ <!--<repository>-->
+ <!--<id>android.support-mvn-repo</id>-->
+ <!--<url>https://raw.github.com/kmchugh/android.support/mvn-repo</url>-->
+ <!--<snapshots>-->
+ <!--<enabled>true</enabled>-->
+ <!--<updatePolicy>daily</updatePolicy>-->
+ <!--</snapshots>-->
+ <!--</repository>-->
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>wlo-group</id>
+ <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>res</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
+ <artifactId>android-maven-plugin</artifactId>
+ <version>3.8.2</version>
+ <executions>
+ <execution>
+ <id>alignApk</id>
+ <phase>install</phase>
+ <goals>
+ <goal>zipalign</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <sdk>
+ <path>${env.ANDROID_HOME}</path>
+ <platform>15</platform>
+ </sdk>
+ <!--<device>emulator</device>-->
+ <device>usb</device>
+ <zipalign>
+ <verbose>true</verbose>
+ <skip>false</skip>
+ <inputApk>
+ ${project.build.directory}/${project.artifactId}-${project.version}.apk
+ </inputApk>
+ <outputApk>
+ ${project.build.directory}/${project.artifactId}-${project.version}-aligned.apk
+ </outputApk>
+ </zipalign>
+ <extractDuplicates>true</extractDuplicates>
+ </configuration>
+ <extensions>true</extensions>
+ </plugin>
+
+ <!-- plugin site -->
+ <!--<plugin>-->
+ <!--<artifactId>maven-site-plugin</artifactId>-->
+ <!--<dependencies>-->
+ <!--<dependency>-->
+ <!--<groupId>org.nuiton.jrst</groupId>-->
+ <!--<artifactId>doxia-module-jrst</artifactId>-->
+ <!--<version>${jrstPluginVersion}</version>-->
+ <!--</dependency>-->
+ <!--<dependency>-->
+ <!--<groupId>hsqldb</groupId>-->
+ <!--<artifactId>hsqldb</artifactId>-->
+ <!--<version>${jdbc.hsqldb.version}</version>-->
+ <!--</dependency>-->
+ <!--<dependency>-->
+ <!--<groupId>org.hibernate</groupId>-->
+ <!--<artifactId>hibernate-core</artifactId>-->
+ <!--<version>${hibernateVersion}</version>-->
+ <!--</dependency>-->
+ <!--</dependencies>-->
+ <!--</plugin>-->
+
+ <!--<plugin>-->
+ <!--<groupId>org.codehaus.mojo</groupId>-->
+ <!--<artifactId>animal-sniffer-maven-plugin</artifactId>-->
+ <!--<version>${animalSnifferPluginVersion}</version>-->
+ <!--<configuration>-->
+ <!--<signature>-->
+ <!--<groupId>org.codehaus.mojo.signature</groupId>-->
+ <!--<artifactId>java16-sun</artifactId>-->
+ <!--<version>1.10</version>-->
+ <!--</signature>-->
+ <!--</configuration>-->
+ <!--</plugin>-->
+
+ </plugins>
+
+ </build>
+
+ <reporting>
+ <excludeDefaults>true</excludeDefaults>
+ </reporting>
+
+ <profiles>
+
+ <profile>
+ <id>check-release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ </profile>
+ <profile>
+ <id>license-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <defaultGoal>generate-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-file-header-on-pom</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <roots>
+ <root>${project.basedir}</root>
+ </roots>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ <addSvnKeyWords>false</addSvnKeyWords>
+ <verbose>false</verbose>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>deploy-update</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <!--<plugin>-->
+ <!--<artifactId>maven-antrun-plugin</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<id>copy update-properties to site</id>-->
+ <!--<phase>package</phase>-->
+ <!--<inherited>false</inherited>-->
+ <!--<configuration>-->
+ <!--<tasks>-->
+ <!--<echo message="Copy model to site" />-->
+ <!--<copy verbose="true" failonerror="false" overwrite="true" filtering="true" todir="${project.build.directory}/update">-->
+ <!--<filterset>-->
+ <!--<filter value="${project.version}" token="projectVersion" />-->
+ <!--<filter value="${jreVersion}" token="jreVersion" />-->
+ <!--<filter value="${dbVersion}" token="dbVersion" />-->
+ <!--</filterset>-->
+ <!--<fileset dir="${basedir}/src/update/">-->
+ <!--<include name="update-tutti.properties" />-->
+ <!--</fileset>-->
+ <!--</copy>-->
+ <!--</tasks>-->
+ <!--</configuration>-->
+ <!--<goals>-->
+ <!--<goal>run</goal>-->
+ <!--</goals>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--</plugin>-->
+
+ <!--<plugin>-->
+ <!--<groupId>org.codehaus.mojo</groupId>-->
+ <!--<artifactId>wagon-maven-plugin</artifactId>-->
+ <!--<version>1.0-beta-4</version>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<phase>deploy</phase>-->
+ <!--<inherited>false</inherited>-->
+ <!--<goals>-->
+ <!--<goal>upload-single</goal>-->
+ <!--</goals>-->
+ <!--<configuration>-->
+ <!--<serverId>forge.codelutin.com</serverId>-->
+ <!--<fromFile>-->
+ <!--${project.build.directory}/update/update-tutti.properties-->
+ <!--</fromFile>-->
+ <!--<url>-->
+ <!--scpexe://forge.codelutin.com/var/www/ApplicationUpdate/http/tutti-->
+ <!--</url>-->
+ <!--</configuration>-->
+ <!--</execution>-->
+ <!--</executions>-->
+
+ <!--</plugin>-->
+ </plugins>
+ </build>
+
+ </profile>
+
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>${projectInfoReportsPluginVersion}</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>project-team</report>
+ <report>mailing-list</report>
+ <report>cim</report>
+ <report>issue-tracking</report>
+ <report>license</report>
+ <report>scm</report>
+ <report>dependencies</report>
+ <report>dependency-convergence</report>
+ <report>dependency-info</report>
+ <report>plugin-management</report>
+ <report>plugins</report>
+ <report>dependency-management</report>
+ <report>summary</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <!--<plugin>-->
+ <!--<groupId>org.nuiton</groupId>-->
+ <!--<artifactId>nuiton-maven-report-plugin</artifactId>-->
+ <!--<version>3.0-alpha-1</version>-->
+ <!--<inherited>false</inherited>-->
+ <!--<reportSets>-->
+ <!--<reportSet>-->
+ <!--<reports>-->
+ <!--<report>aggregate-config-report</report>-->
+ <!--</reports>-->
+ <!--</reportSet>-->
+ <!--</reportSets>-->
+ <!--<configuration>-->
+ <!--<i18nBundleName>tutti-i18n</i18nBundleName>-->
+ <!--</configuration>-->
+ <!--</plugin>-->
+
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <!-- This profile update license stuff with new goal update-file-header -->
+ <profile>
+ <id>update-file-header</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <properties>
+ <license.descriptor>src/license/project.xml</license.descriptor>
+ </properties>
+ <build>
+ <defaultGoal>process-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-file-header</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <configuration>
+ <addSvnKeyWords>true</addSvnKeyWords>
+ <excludes>
+ <exclude>**/i18n/*.properties</exclude>
+ <exclude>**/THIRD-PARTY.properties</exclude>
+ <!-- since sh scripts must begins by the line #!/bin/sh,
+ can not use the mojo for the mojo -->
+ <exclude>**/*.sh</exclude>
+ </excludes>
+ </configuration>
+ <phase>process-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Deleted: tags/wlo-0.1/res/layout/measurement.xml
===================================================================
--- trunk/res/layout/measurement.xml 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/res/layout/measurement.xml 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,143 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<android.support.v4.widget.DrawerLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/drawer_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout android:id="@+id/form"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <TextView android:text="@string/gender"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:paddingLeft="10dp"
- android:paddingRight="5dp"/>
-
- <Spinner android:id="@+id/gender_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
- <TextView android:text="@string/maturity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:paddingLeft="10dp"
- android:paddingRight="5dp"/>
-
- <Spinner android:id="@+id/maturity_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
- <TextView android:text="@string/age"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:paddingLeft="10dp"
- android:paddingRight="5dp"/>
-
- <Spinner android:id="@+id/age_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button android:text="-"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="decSize"/>
-
- <EditText android:id="@+id/size"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:inputType="number"/>
-
- <Button android:text="+"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="incSize"/>
-
- </LinearLayout>
-
- <Button android:text="@android:string/ok"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:onClick="addMeasurement"/>
-
- </LinearLayout>
-
- <View android:layout_width="1px"
- android:layout_height="match_parent"
- android:background="@android:color/holo_blue_light"/>
-
- <TabHost android:id="@android:id/tabhost"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="match_parent">
-
- <LinearLayout android:id="@+id/fragment_placeholder"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <TabWidget android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-
- <View android:layout_width="match_parent"
- android:layout_height="2px"
- android:background="@android:color/holo_blue_light"/>
-
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <fragment android:name="fr.ifremer.wlo.measurement.GraphFragment"
- android:id="@+id/graph"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <fragment android:name="fr.ifremer.wlo.measurement.TableFragment"
- android:id="@+id/table"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <fragment android:name="fr.ifremer.wlo.measurement.LogsFragment"
- android:id="@+id/logs"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-
- </FrameLayout>
-
- </LinearLayout>
-
- </TabHost>
-
- </LinearLayout>
-
- <ListView android:id="@+id/left_drawer"
- android:layout_width="240dp"
- android:layout_height="match_parent"
- android:layout_gravity="start"
- android:choiceMode="singleChoice"
- android:background="@android:color/holo_blue_dark"/>
-
-</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
Copied: tags/wlo-0.1/res/layout/measurement.xml (from rev 24, trunk/res/layout/measurement.xml)
===================================================================
--- tags/wlo-0.1/res/layout/measurement.xml (rev 0)
+++ tags/wlo-0.1/res/layout/measurement.xml 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<android.support.v4.widget.DrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout android:id="@+id/form"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView android:text="@string/gender"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp"/>
+
+ <Spinner android:id="@+id/gender_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <TextView android:text="@string/maturity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp"/>
+
+ <Spinner android:id="@+id/maturity_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <TextView android:text="@string/age"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp"/>
+
+ <Spinner android:id="@+id/age_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button android:text="-"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="decSize"/>
+
+ <EditText android:id="@+id/size"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <Button android:text="+"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="incSize"/>
+
+ </LinearLayout>
+
+ <Button android:text="@android:string/ok"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="addMeasurement"/>
+
+ </LinearLayout>
+
+ <View android:layout_width="1px"
+ android:layout_height="match_parent"
+ android:background="@android:color/holo_blue_light"/>
+
+ <TabHost android:id="@android:id/tabhost"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent">
+
+ <LinearLayout android:id="@+id/fragment_placeholder"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TabWidget android:id="@android:id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <View android:layout_width="match_parent"
+ android:layout_height="2px"
+ android:background="@android:color/holo_blue_light"/>
+
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <fragment android:name="fr.ifremer.wlo.measurement.GraphFragment"
+ android:id="@+id/graph"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <fragment android:name="fr.ifremer.wlo.measurement.TableFragment"
+ android:id="@+id/table"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <fragment android:name="fr.ifremer.wlo.measurement.LogsFragment"
+ android:id="@+id/logs"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ </FrameLayout>
+
+ </LinearLayout>
+
+ </TabHost>
+
+ </LinearLayout>
+
+ <ListView android:id="@+id/left_drawer"
+ android:layout_width="240dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:choiceMode="singleChoice"
+ android:background="@android:color/holo_blue_dark"/>
+
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java
===================================================================
--- trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,606 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package fr.ifremer.wlo;
-
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothServerSocket;
-import android.bluetooth.BluetoothSocket;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.TaskStackBuilder;
-import android.util.Log;
-import com.google.common.collect.Lists;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * This class does all the work for setting up and managing Bluetooth
- * connections with other devices. It has a thread that listens for
- * incoming connections, a thread for connecting with a device, and a
- * thread for performing data transmissions when connected.
- */
-public class BigFinCommunicationService extends Service {
-
- private static final String TAG = "BigFinCommunicationService";
-
- // Unique UUID for this application
- private static final UUID MY_UUID =
- UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
- private static final int NOIFICATION_ID = 42;
-
- // Constants that indicate the current connection state
- public static final int STATE_NONE = 0; // we're doing nothing
- public static final int STATE_LISTEN = 1; // now listening for incoming connections
- public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
- public static final int STATE_CONNECTED = 3; // now connected to a remote device
-
- // OUTGOING MESSAGE
- public static final int MESSAGE_STATE_CHANGE = 1;
- public static final int MESSAGE_READ = 2;
- public static final int MESSAGE_WRITE = 3;
- public static final int MESSAGE_DEVICE_NAME = 4;
- public static final int MESSAGE_CONNECTION_LOST = 5;
- public static final int MESSAGE_CONNECTION_FAILED = 6;
-
- // INCOMING MESSAGE
- public static final int MESSAGE_REGISTER_CLIENT = 1;
- public static final int MESSAGE_UNREGISTER_CLIENT = 2;
- public static final int MESSAGE_CONNECT_DEVICE = 3;
- public static final int MESSAGE_SEND_DATA = 4;
- public static final int MESSAGE_DISCONNECT_DEVICE = 5;
-
- public static final String DEVICE_NAME = "device_name";
- public static final String TOAST = "toast";
- public static final String DEVICE_ADDRESS = "device_address";
- public static final String DATA_TO_SEND = "dataToSend";
-
- // Member fields
- protected BluetoothAdapter mAdapter;
- protected AcceptThread mAcceptThread;
- protected ConnectThread mConnectThread;
- protected ConnectedThread mConnectedThread;
- protected int mState;
-
- // Keeps track of all current registered clients.
- protected List<Messenger> mClients = Lists.newArrayList();
- // Target we publish for clients to send messages to IncomingHandler.
- protected final Messenger mMessenger = new Messenger(new IncomingHandler());
-
- protected NotificationCompat.Builder notificationBuilder;
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- mAdapter = BluetoothAdapter.getDefaultAdapter();
-
- setState(STATE_NONE);
-
- notificationBuilder = new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.wlo_ico);
-
- updateNotification(false);
-
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify(NOIFICATION_ID, notificationBuilder.build());
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- stop();
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.cancel(NOIFICATION_ID);
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return mMessenger.getBinder();
- }
-
- protected void updateNotification(boolean connected) {
- int title;
- int text;
-
-// TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
-// // Adds the Intent to the top of the stack
-// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
-
- if (connected) {
- title = R.string.bigfin_ichtyometer_connected_title;
- text = R.string.bigfin_ichtyometer_connected_text;
-
- } else {
- title = R.string.bigfin_no_ichtyometer_connected_title;
- text = R.string.bigfin_no_ichtyometer_connected_text;
-// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
- }
-
- // Gets a PendingIntent containing the entire back stack
-// PendingIntent pendingIntent =
-// stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
-
-// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-
- notificationBuilder.setContentTitle(getText(title))
- .setContentText(getText(text));
-// .setContentIntent(pendingIntent);
-
- if (connected) {
- startForeground(NOIFICATION_ID, notificationBuilder.build());
- } else {
- stopForeground(false);
- }
- }
-
- protected void sendMessage(int what, int arg1) {
- sendMessage(what, arg1, -1, null);
- }
-
- protected void sendMessage(int what, int arg1, int arg2) {
- sendMessage(what, arg1, arg2, null);
- }
-
- protected void sendMessage(int what, int arg1, int arg2, Object obj) {
- for (Messenger messenger : mClients) {
- try {
- Message message = Message.obtain(null, what, arg1, arg2, obj);
- messenger.send(message);
-
- } catch (RemoteException e) {
- mClients.remove(messenger);
- }
- }
- }
-
- protected void sendMessage(int what, String key, String value) {
- for (Messenger messenger : mClients) {
- try {
- Message message = Message.obtain(null, what);
- Bundle bundle = new Bundle();
- bundle.putString(key, value);
- message.setData(bundle);
- messenger.send(message);
-
- } catch (RemoteException e) {
- mClients.remove(messenger);
- }
- }
- }
-
- /**
- * Set the current state of the chat connection
- * @param state An integer defining the current connection state
- */
- protected synchronized void setState(int state) {
- Log.d(TAG, "setState() " + mState + " -> " + state);
- mState = state;
- sendMessage(MESSAGE_STATE_CHANGE, state);
- }
-
- /**
- * Stop all threads
- */
- protected synchronized void stop() {
- Log.d(TAG, "stop");
-
- if (mConnectThread != null) {
- mConnectThread.cancel();
- mConnectThread = null;
- }
-
- if (mConnectedThread != null) {
- mConnectedThread.cancel();
- mConnectedThread = null;
- }
-
- if (mAcceptThread != null) {
- mAcceptThread.cancel();
- mAcceptThread = null;
- }
-
- setState(STATE_NONE);
-
- notificationBuilder.setContentTitle(getText(R.string.bigfin_no_ichtyometer_connected_title))
- .setContentText(getText(R.string.bigfin_no_ichtyometer_connected_text));
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify(NOIFICATION_ID, notificationBuilder.build());
-
- }
-
- protected synchronized void reset() {
- Log.d(TAG, "reset");
-
- stop();
-
- setState(STATE_LISTEN);
-
- // Start the thread to listen on a BluetoothServerSocket
- mAcceptThread = new AcceptThread();
- mAcceptThread.start();
- }
-
- /**
- * Start the ConnectThread to initiate a connection to a remote device.
- * @param device The BluetoothDevice to connect
- */
- protected synchronized void connect(BluetoothDevice device) {
- Log.d(TAG, "connect to: " + device);
-
- // Cancel any thread attempting to make a connection
- if (mState == STATE_CONNECTING) {
- if (mConnectThread != null) {
- mConnectThread.cancel();
- mConnectThread = null;
- }
- }
-
- // Cancel any thread currently running a connection
- if (mConnectedThread != null) {
- mConnectedThread.cancel();
- mConnectedThread = null;
- }
-
- // Start the thread to connect with the given device
- mConnectThread = new ConnectThread(device);
- mConnectThread.start();
- setState(STATE_CONNECTING);
- }
-
- /**
- * Start the ConnectedThread to begin managing a Bluetooth connection
- * @param socket The BluetoothSocket on which the connection was made
- * @param device The BluetoothDevice that has been connected
- */
- protected synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
- Log.d(TAG, "connected");
-
- // Cancel the thread that completed the connection
- if (mConnectThread != null) {
- mConnectThread.cancel();
- mConnectThread = null;
- }
-
- // Cancel any thread currently running a connection
- if (mConnectedThread != null) {
- mConnectedThread.cancel();
- mConnectedThread = null;
- }
-
- // Cancel the accept thread because we only want to connect to one device
- if (mAcceptThread != null) {
- mAcceptThread.cancel();
- mAcceptThread = null;
- }
-
- // Start the thread to manage the connection and perform transmissions
- mConnectedThread = new ConnectedThread(socket);
- mConnectedThread.start();
-
- // Send the name of the connected device back to the UI Activity
- sendMessage(MESSAGE_DEVICE_NAME, DEVICE_NAME, device.getName());
-
- setState(STATE_CONNECTED);
-
- updateNotification(true);
-
- }
-
- /**
- * Write to the ConnectedThread in an unsynchronized manner
- * @param out The bytes to write
- * @see ConnectedThread#write(byte[])
- */
- protected void write(byte[] out) {
- // Create temporary object
- ConnectedThread r;
- // Synchronize a copy of the ConnectedThread
- synchronized (this) {
- if (mState != STATE_CONNECTED) return;
- r = mConnectedThread;
- }
- // Perform the write unsynchronized
- r.write(out);
- }
-
- /**
- * Indicate that the connection attempt failed and notify the UI Activity.
- */
- protected void connectionFailed() {
- // Send a failure message back to the Activity
- sendMessage(MESSAGE_CONNECTION_FAILED, TOAST, "Unable to connect device");
-
- // Start the service over to restart listening mode
- reset();
- }
-
- /**
- * Indicate that the connection was lost and notify the UI Activity.
- */
- protected void connectionLost() {
- // Send a failure message back to the Activity
- sendMessage(MESSAGE_CONNECTION_LOST, TOAST, "Device connection was lost");
-
- // Start the service over to restart listening mode
- reset();
- }
-
- /**
- * This thread runs while listening for incoming connections. It behaves
- * like a server-side client. It runs until a connection is accepted
- * (or until cancelled).
- */
- protected class AcceptThread extends Thread {
- // The local server socket
- private final BluetoothServerSocket mmServerSocket;
-
- public AcceptThread() {
- BluetoothServerSocket tmp = null;
-
- // Create a new listening server socket
- try {
- tmp = mAdapter.listenUsingRfcommWithServiceRecord("BigFinBtSocket", MY_UUID);
-
- } catch (IOException e) {
- Log.e(TAG, "Socket listen() failed", e);
- }
- mmServerSocket = tmp;
- }
-
- public void run() {
- Log.d(TAG, "BEGIN mAcceptThread" + this);
- setName("AcceptThread");
-
- BluetoothSocket socket = null;
-
- // Listen to the server socket if we're not connected
- while (mState != STATE_CONNECTED) {
- try {
- // This is a blocking call and will only return on a
- // successful connection or an exception
- socket = mmServerSocket.accept();
- } catch (IOException e) {
- Log.e(TAG, "Socket accept() failed", e);
- break;
- }
-
- // If a connection was accepted
- if (socket != null) {
- synchronized (BigFinCommunicationService.this) {
- switch (mState) {
- case STATE_LISTEN:
- case STATE_CONNECTING:
- // Situation normal. Start the connected thread.
- connected(socket, socket.getRemoteDevice());
- break;
- case STATE_NONE:
- case STATE_CONNECTED:
- // Either not ready or already connected. Terminate new socket.
- try {
- socket.close();
- } catch (IOException e) {
- Log.e(TAG, "Could not close unwanted socket", e);
- }
- break;
- }
- }
- }
- }
- Log.i(TAG, "END mAcceptThread");
-
- }
-
- public void cancel() {
- Log.d(TAG, "Socket cancel " + this);
- try {
- mmServerSocket.close();
- } catch (IOException e) {
- Log.e(TAG, "Socket close() of server failed", e);
- }
- }
- }
-
-
- /**
- * This thread runs while attempting to make an outgoing connection
- * with a device. It runs straight through; the connection either
- * succeeds or fails.
- */
- protected class ConnectThread extends Thread {
- protected final BluetoothSocket mmSocket;
- protected final BluetoothDevice mmDevice;
-
- public ConnectThread(BluetoothDevice device) {
- mmDevice = device;
- BluetoothSocket tmp = null;
-
- // Get a BluetoothSocket for a connection with the
- // given BluetoothDevice
- try {
- tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
- } catch (IOException e) {
- Log.e(TAG, "Socket create() failed", e);
- }
- mmSocket = tmp;
- }
-
- public void run() {
- Log.i(TAG, "BEGIN mConnectThread");
- setName("ConnectThread");
-
- // Make a connection to the BluetoothSocket
- try {
- // This is a blocking call and will only return on a
- // successful connection or an exception
- mmSocket.connect();
-
- } catch (IOException e) {
- Log.e(TAG, "Error while connecting", e);
- // Close the socket
- try {
- mmSocket.close();
- } catch (IOException e2) {
- Log.e(TAG, "unable to close() socket during connection failure", e2);
- }
- connectionFailed();
- return;
- }
-
- // Reset the ConnectThread because we're done
- synchronized (BigFinCommunicationService.this) {
- mConnectThread = null;
- }
-
- // Start the connected thread
- connected(mmSocket, mmDevice);
- }
-
- public void cancel() {
- try {
- mmSocket.close();
- } catch (IOException e) {
- Log.e(TAG, "close() of connect socket failed", e);
- }
- }
- }
-
- /**
- * This thread runs during a connection with a remote device.
- * It handles all incoming and outgoing transmissions.
- */
- protected class ConnectedThread extends Thread {
- protected final BluetoothSocket mmSocket;
- protected final InputStream mmInStream;
- protected final OutputStream mmOutStream;
-
- public ConnectedThread(BluetoothSocket socket) {
- Log.d(TAG, "create ConnectedThread");
- mmSocket = socket;
- InputStream tmpIn = null;
- OutputStream tmpOut = null;
-
- // Get the BluetoothSocket input and output streams
- try {
- tmpIn = socket.getInputStream();
- tmpOut = socket.getOutputStream();
- } catch (IOException e) {
- Log.e(TAG, "temp sockets not created", e);
- }
-
- mmInStream = tmpIn;
- mmOutStream = tmpOut;
- }
-
- public void run() {
- Log.i(TAG, "BEGIN mConnectedThread");
- byte[] buffer = new byte[1024];
- int bytes;
-
- // Keep listening to the InputStream while connected
- while (true) {
- try {
- // Read from the InputStream
- bytes = mmInStream.read(buffer);
-
- // Send the obtained bytes to the UI Activity
- sendMessage(MESSAGE_READ, bytes, -1, buffer);
-
- } catch (IOException e) {
- Log.e(TAG, "disconnected", e);
- connectionLost();
- break;
- }
- }
- }
-
- /**
- * Write to the connected OutStream.
- * @param buffer The bytes to write
- */
- public void write(byte[] buffer) {
- try {
- mmOutStream.write(buffer);
-
- // Share the sent message back to the UI Activity
- sendMessage(MESSAGE_WRITE, -1, -1, buffer);
-
- } catch (IOException e) {
- Log.e(TAG, "Exception during write", e);
- }
- }
-
- public void cancel() {
- try {
- mmSocket.close();
- } catch (IOException e) {
- Log.e(TAG, "close() of connect socket failed", e);
- }
- }
- }
-
- // Handler of incoming messages from clients.
- protected class IncomingHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MESSAGE_REGISTER_CLIENT:
- mClients.add(msg.replyTo);
- break;
-
- case MESSAGE_UNREGISTER_CLIENT:
- mClients.remove(msg.replyTo);
- break;
-
- case MESSAGE_CONNECT_DEVICE:
- reset();
-
- String deviceAddress = msg.getData().getString(DEVICE_ADDRESS);
- Log.d(TAG, "connect device " + deviceAddress);
- // Get the BluetoothDevice object
- BluetoothDevice device = mAdapter.getRemoteDevice(deviceAddress);
- connect(device);
- break;
-
- case MESSAGE_SEND_DATA:
- String dataToSend = msg.getData().getString(DATA_TO_SEND);
- write(dataToSend.getBytes());
- break;
-
- case MESSAGE_DISCONNECT_DEVICE:
- stop();
- break;
-
- default:
- super.handleMessage(msg);
- }
- }
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java (from rev 25, trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,630 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothServerSocket;
+import android.bluetooth.BluetoothSocket;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.support.v4.app.NotificationCompat;
+import android.support.v4.app.TaskStackBuilder;
+import android.util.Log;
+import com.google.common.collect.Lists;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * This class does all the work for setting up and managing Bluetooth
+ * connections with other devices. It has a thread that listens for
+ * incoming connections, a thread for connecting with a device, and a
+ * thread for performing data transmissions when connected.
+ */
+public class BigFinCommunicationService extends Service {
+
+ private static final String TAG = "BigFinCommunicationService";
+
+ // Unique UUID for this application
+ private static final UUID MY_UUID =
+ UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
+ private static final int NOIFICATION_ID = 42;
+
+ // Constants that indicate the current connection state
+ public static final int STATE_NONE = 0; // we're doing nothing
+ public static final int STATE_LISTEN = 1; // now listening for incoming connections
+ public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
+ public static final int STATE_CONNECTED = 3; // now connected to a remote device
+
+ // OUTGOING MESSAGE
+ public static final int MESSAGE_STATE_CHANGE = 1;
+ public static final int MESSAGE_READ = 2;
+ public static final int MESSAGE_WRITE = 3;
+ public static final int MESSAGE_DEVICE_NAME = 4;
+ public static final int MESSAGE_CONNECTION_LOST = 5;
+ public static final int MESSAGE_CONNECTION_FAILED = 6;
+
+ // INCOMING MESSAGE
+ public static final int MESSAGE_REGISTER_CLIENT = 1;
+ public static final int MESSAGE_UNREGISTER_CLIENT = 2;
+ public static final int MESSAGE_CONNECT_DEVICE = 3;
+ public static final int MESSAGE_SEND_DATA = 4;
+ public static final int MESSAGE_DISCONNECT_DEVICE = 5;
+
+ public static final String DEVICE_NAME = "device_name";
+ public static final String TOAST = "toast";
+ public static final String DEVICE_ADDRESS = "device_address";
+ public static final String DATA_TO_SEND = "dataToSend";
+
+ // Member fields
+ protected BluetoothAdapter mAdapter;
+ protected AcceptThread mAcceptThread;
+ protected ConnectThread mConnectThread;
+ protected ConnectedThread mConnectedThread;
+ protected int mState;
+
+ // Keeps track of all current registered clients.
+ protected List<Messenger> mClients = Lists.newArrayList();
+ // Target we publish for clients to send messages to IncomingHandler.
+ protected final Messenger mMessenger = new Messenger(new IncomingHandler());
+
+ protected NotificationCompat.Builder notificationBuilder;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ mAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ setState(STATE_NONE);
+
+ notificationBuilder = new NotificationCompat.Builder(this)
+ .setSmallIcon(R.drawable.wlo_ico);
+
+ updateNotification(false);
+
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ manager.notify(NOIFICATION_ID, notificationBuilder.build());
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ stop();
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ manager.cancel(NOIFICATION_ID);
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mMessenger.getBinder();
+ }
+
+ protected void updateNotification(boolean connected) {
+ int title;
+ int text;
+
+// TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
+// // Adds the Intent to the top of the stack
+// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
+
+ if (connected) {
+ title = R.string.bigfin_ichtyometer_connected_title;
+ text = R.string.bigfin_ichtyometer_connected_text;
+
+ } else {
+ title = R.string.bigfin_no_ichtyometer_connected_title;
+ text = R.string.bigfin_no_ichtyometer_connected_text;
+// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
+ }
+
+ // Gets a PendingIntent containing the entire back stack
+// PendingIntent pendingIntent =
+// stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
+
+// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ notificationBuilder.setContentTitle(getText(title))
+ .setContentText(getText(text));
+// .setContentIntent(pendingIntent);
+
+ if (connected) {
+ startForeground(NOIFICATION_ID, notificationBuilder.build());
+ } else {
+ stopForeground(false);
+ }
+ }
+
+ protected void sendMessage(int what, int arg1) {
+ sendMessage(what, arg1, -1, null);
+ }
+
+ protected void sendMessage(int what, int arg1, int arg2) {
+ sendMessage(what, arg1, arg2, null);
+ }
+
+ protected void sendMessage(int what, int arg1, int arg2, Object obj) {
+ for (Messenger messenger : mClients) {
+ try {
+ Message message = Message.obtain(null, what, arg1, arg2, obj);
+ messenger.send(message);
+
+ } catch (RemoteException e) {
+ mClients.remove(messenger);
+ }
+ }
+ }
+
+ protected void sendMessage(int what, String key, String value) {
+ for (Messenger messenger : mClients) {
+ try {
+ Message message = Message.obtain(null, what);
+ Bundle bundle = new Bundle();
+ bundle.putString(key, value);
+ message.setData(bundle);
+ messenger.send(message);
+
+ } catch (RemoteException e) {
+ mClients.remove(messenger);
+ }
+ }
+ }
+
+ /**
+ * Set the current state of the chat connection
+ * @param state An integer defining the current connection state
+ */
+ protected synchronized void setState(int state) {
+ Log.d(TAG, "setState() " + mState + " -> " + state);
+ mState = state;
+ sendMessage(MESSAGE_STATE_CHANGE, state);
+ }
+
+ /**
+ * Stop all threads
+ */
+ protected synchronized void stop() {
+ Log.d(TAG, "stop");
+
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
+ }
+
+ if (mConnectedThread != null) {
+ mConnectedThread.cancel();
+ mConnectedThread = null;
+ }
+
+ if (mAcceptThread != null) {
+ mAcceptThread.cancel();
+ mAcceptThread = null;
+ }
+
+ setState(STATE_NONE);
+
+ notificationBuilder.setContentTitle(getText(R.string.bigfin_no_ichtyometer_connected_title))
+ .setContentText(getText(R.string.bigfin_no_ichtyometer_connected_text));
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ manager.notify(NOIFICATION_ID, notificationBuilder.build());
+
+ }
+
+ protected synchronized void reset() {
+ Log.d(TAG, "reset");
+
+ stop();
+
+ setState(STATE_LISTEN);
+
+ // Start the thread to listen on a BluetoothServerSocket
+ mAcceptThread = new AcceptThread();
+ mAcceptThread.start();
+ }
+
+ /**
+ * Start the ConnectThread to initiate a connection to a remote device.
+ * @param device The BluetoothDevice to connect
+ */
+ protected synchronized void connect(BluetoothDevice device) {
+ Log.d(TAG, "connect to: " + device);
+
+ // Cancel any thread attempting to make a connection
+ if (mState == STATE_CONNECTING) {
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
+ }
+ }
+
+ // Cancel any thread currently running a connection
+ if (mConnectedThread != null) {
+ mConnectedThread.cancel();
+ mConnectedThread = null;
+ }
+
+ // Start the thread to connect with the given device
+ mConnectThread = new ConnectThread(device);
+ mConnectThread.start();
+ setState(STATE_CONNECTING);
+ }
+
+ /**
+ * Start the ConnectedThread to begin managing a Bluetooth connection
+ * @param socket The BluetoothSocket on which the connection was made
+ * @param device The BluetoothDevice that has been connected
+ */
+ protected synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
+ Log.d(TAG, "connected");
+
+ // Cancel the thread that completed the connection
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
+ }
+
+ // Cancel any thread currently running a connection
+ if (mConnectedThread != null) {
+ mConnectedThread.cancel();
+ mConnectedThread = null;
+ }
+
+ // Cancel the accept thread because we only want to connect to one device
+ if (mAcceptThread != null) {
+ mAcceptThread.cancel();
+ mAcceptThread = null;
+ }
+
+ // Start the thread to manage the connection and perform transmissions
+ mConnectedThread = new ConnectedThread(socket);
+ mConnectedThread.start();
+
+ // Send the name of the connected device back to the UI Activity
+ sendMessage(MESSAGE_DEVICE_NAME, DEVICE_NAME, device.getName());
+
+ setState(STATE_CONNECTED);
+
+ updateNotification(true);
+
+ }
+
+ /**
+ * Write to the ConnectedThread in an unsynchronized manner
+ * @param out The bytes to write
+ * @see ConnectedThread#write(byte[])
+ */
+ protected void write(byte[] out) {
+ // Create temporary object
+ ConnectedThread r;
+ // Synchronize a copy of the ConnectedThread
+ synchronized (this) {
+ if (mState != STATE_CONNECTED) return;
+ r = mConnectedThread;
+ }
+ // Perform the write unsynchronized
+ r.write(out);
+ }
+
+ /**
+ * Indicate that the connection attempt failed and notify the UI Activity.
+ */
+ protected void connectionFailed() {
+ // Send a failure message back to the Activity
+ sendMessage(MESSAGE_CONNECTION_FAILED, TOAST, "Unable to connect device");
+
+ // Start the service over to restart listening mode
+ reset();
+ }
+
+ /**
+ * Indicate that the connection was lost and notify the UI Activity.
+ */
+ protected void connectionLost() {
+ // Send a failure message back to the Activity
+ sendMessage(MESSAGE_CONNECTION_LOST, TOAST, "Device connection was lost");
+
+ // Start the service over to restart listening mode
+ reset();
+ }
+
+ /**
+ * This thread runs while listening for incoming connections. It behaves
+ * like a server-side client. It runs until a connection is accepted
+ * (or until cancelled).
+ */
+ protected class AcceptThread extends Thread {
+ // The local server socket
+ private final BluetoothServerSocket mmServerSocket;
+
+ public AcceptThread() {
+ BluetoothServerSocket tmp = null;
+
+ // Create a new listening server socket
+ try {
+ tmp = mAdapter.listenUsingRfcommWithServiceRecord("BigFinBtSocket", MY_UUID);
+
+ } catch (IOException e) {
+ Log.e(TAG, "Socket listen() failed", e);
+ }
+ mmServerSocket = tmp;
+ }
+
+ public void run() {
+ Log.d(TAG, "BEGIN mAcceptThread" + this);
+ setName("AcceptThread");
+
+ BluetoothSocket socket = null;
+
+ // Listen to the server socket if we're not connected
+ while (mState != STATE_CONNECTED) {
+ try {
+ // This is a blocking call and will only return on a
+ // successful connection or an exception
+ socket = mmServerSocket.accept();
+ } catch (IOException e) {
+ Log.e(TAG, "Socket accept() failed", e);
+ break;
+ }
+
+ // If a connection was accepted
+ if (socket != null) {
+ synchronized (BigFinCommunicationService.this) {
+ switch (mState) {
+ case STATE_LISTEN:
+ case STATE_CONNECTING:
+ // Situation normal. Start the connected thread.
+ connected(socket, socket.getRemoteDevice());
+ break;
+ case STATE_NONE:
+ case STATE_CONNECTED:
+ // Either not ready or already connected. Terminate new socket.
+ try {
+ socket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Could not close unwanted socket", e);
+ }
+ break;
+ }
+ }
+ }
+ }
+ Log.i(TAG, "END mAcceptThread");
+
+ }
+
+ public void cancel() {
+ Log.d(TAG, "Socket cancel " + this);
+ try {
+ mmServerSocket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Socket close() of server failed", e);
+ }
+ }
+ }
+
+
+ /**
+ * This thread runs while attempting to make an outgoing connection
+ * with a device. It runs straight through; the connection either
+ * succeeds or fails.
+ */
+ protected class ConnectThread extends Thread {
+ protected final BluetoothSocket mmSocket;
+ protected final BluetoothDevice mmDevice;
+
+ public ConnectThread(BluetoothDevice device) {
+ mmDevice = device;
+ BluetoothSocket tmp = null;
+
+ // Get a BluetoothSocket for a connection with the
+ // given BluetoothDevice
+ try {
+ tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
+ } catch (IOException e) {
+ Log.e(TAG, "Socket create() failed", e);
+ }
+ mmSocket = tmp;
+ }
+
+ public void run() {
+ Log.i(TAG, "BEGIN mConnectThread");
+ setName("ConnectThread");
+
+ // Make a connection to the BluetoothSocket
+ try {
+ // This is a blocking call and will only return on a
+ // successful connection or an exception
+ mmSocket.connect();
+
+ } catch (IOException e) {
+ Log.e(TAG, "Error while connecting", e);
+ // Close the socket
+ try {
+ mmSocket.close();
+ } catch (IOException e2) {
+ Log.e(TAG, "unable to close() socket during connection failure", e2);
+ }
+ connectionFailed();
+ return;
+ }
+
+ // Reset the ConnectThread because we're done
+ synchronized (BigFinCommunicationService.this) {
+ mConnectThread = null;
+ }
+
+ // Start the connected thread
+ connected(mmSocket, mmDevice);
+ }
+
+ public void cancel() {
+ try {
+ mmSocket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "close() of connect socket failed", e);
+ }
+ }
+ }
+
+ /**
+ * This thread runs during a connection with a remote device.
+ * It handles all incoming and outgoing transmissions.
+ */
+ protected class ConnectedThread extends Thread {
+ protected final BluetoothSocket mmSocket;
+ protected final InputStream mmInStream;
+ protected final OutputStream mmOutStream;
+
+ public ConnectedThread(BluetoothSocket socket) {
+ Log.d(TAG, "create ConnectedThread");
+ mmSocket = socket;
+ InputStream tmpIn = null;
+ OutputStream tmpOut = null;
+
+ // Get the BluetoothSocket input and output streams
+ try {
+ tmpIn = socket.getInputStream();
+ tmpOut = socket.getOutputStream();
+ } catch (IOException e) {
+ Log.e(TAG, "temp sockets not created", e);
+ }
+
+ mmInStream = tmpIn;
+ mmOutStream = tmpOut;
+ }
+
+ public void run() {
+ Log.i(TAG, "BEGIN mConnectedThread");
+ byte[] buffer = new byte[1024];
+ int bytes;
+
+ // Keep listening to the InputStream while connected
+ while (true) {
+ try {
+ // Read from the InputStream
+ bytes = mmInStream.read(buffer);
+
+ // Send the obtained bytes to the UI Activity
+ sendMessage(MESSAGE_READ, bytes, -1, buffer);
+
+ } catch (IOException e) {
+ Log.e(TAG, "disconnected", e);
+ connectionLost();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Write to the connected OutStream.
+ * @param buffer The bytes to write
+ */
+ public void write(byte[] buffer) {
+ try {
+ mmOutStream.write(buffer);
+
+ // Share the sent message back to the UI Activity
+ sendMessage(MESSAGE_WRITE, -1, -1, buffer);
+
+ } catch (IOException e) {
+ Log.e(TAG, "Exception during write", e);
+ }
+ }
+
+ public void cancel() {
+ try {
+ mmSocket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "close() of connect socket failed", e);
+ }
+ }
+ }
+
+ // Handler of incoming messages from clients.
+ protected class IncomingHandler extends Handler {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MESSAGE_REGISTER_CLIENT:
+ mClients.add(msg.replyTo);
+ break;
+
+ case MESSAGE_UNREGISTER_CLIENT:
+ mClients.remove(msg.replyTo);
+ break;
+
+ case MESSAGE_CONNECT_DEVICE:
+ reset();
+
+ String deviceAddress = msg.getData().getString(DEVICE_ADDRESS);
+ Log.d(TAG, "connect device " + deviceAddress);
+ // Get the BluetoothDevice object
+ BluetoothDevice device = mAdapter.getRemoteDevice(deviceAddress);
+ connect(device);
+ break;
+
+ case MESSAGE_SEND_DATA:
+ String dataToSend = msg.getData().getString(DATA_TO_SEND);
+ write(dataToSend.getBytes());
+ break;
+
+ case MESSAGE_DISCONNECT_DEVICE:
+ stop();
+ break;
+
+ default:
+ super.handleMessage(msg);
+ }
+ }
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/CommercialSpeciesActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,68 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesActivity extends WloBaseListActivity<CommercialSpeciesModel> {
-
- private static final String TAG = "CommercialSpeciesActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { CommercialSpeciesModel.COLUMN_FAO_CODE },
- new int[] { android.R.id.text1 }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllCommercialSpecies(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected CommercialSpeciesModel createNewModel(Cursor cursor) {
- return new CommercialSpeciesModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return ScientificSpeciesActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return CommercialSpeciesFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.commercial_species_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MetiersActivity.class;
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(1, WloItemListViewBinder.DataType.COMMERCIAL_SPECIES);
- types.put(2, WloItemListViewBinder.DataType.MENSURATION);
- types.put(3, WloItemListViewBinder.DataType.STATE);
- types.put(4, WloItemListViewBinder.DataType.PRESENTATION);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/CommercialSpeciesActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,92 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesActivity extends WloBaseListActivity<CommercialSpeciesModel> {
+
+ private static final String TAG = "CommercialSpeciesActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { CommercialSpeciesModel.COLUMN_FAO_CODE },
+ new int[] { android.R.id.text1 }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllCommercialSpecies(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected CommercialSpeciesModel createNewModel(Cursor cursor) {
+ return new CommercialSpeciesModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return ScientificSpeciesActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return CommercialSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.commercial_species_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MetiersActivity.class;
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(1, WloItemListViewBinder.DataType.COMMERCIAL_SPECIES);
+ types.put(2, WloItemListViewBinder.DataType.MENSURATION);
+ types.put(3, WloItemListViewBinder.DataType.STATE);
+ types.put(4, WloItemListViewBinder.DataType.PRESENTATION);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,111 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.Spinner;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesFormActivity extends WloModelEditionActivity<CommercialSpeciesModel> {
-
- private static final String TAG = "CommercialSpeciesFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.commercial_species_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return CommercialSpeciesActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return ScientificSpeciesFormActivity.class;
- }
-
- @Override
- protected CommercialSpeciesModel createNewModel() {
- return new CommercialSpeciesModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // editors
-
- // init editors
- List<CommercialSpecies> commercialSpecies = Lists.newArrayList(DataCache.getAllCommercialSpecies(this));
- initAutoCompleteTextView(R.id.commercial_species_form_fao_code, CommercialSpeciesModel.COLUMN_FAO_CODE, commercialSpecies);
-
- if (model.getMeasurementMethod() == null) {
- Mensuration defaultMensuration = DataCache.getDefaultMensuration(this);
- model.setMeasurementMethod(defaultMensuration);
- }
- List<Mensuration> mensurations = Lists.newArrayList(DataCache.getAllMensurations(this));
- initAutoCompleteTextView(R.id.commercial_species_form_measurement_method, CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD, mensurations);
-
- Spinner precisionSpinner = (Spinner) findViewById(R.id.commercial_species_form_precision);
- ArrayAdapter<Mensuration.Precision> precisions = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
- Mensuration.Precision.values());
- precisionSpinner.setAdapter(precisions);
- precisionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
- model.setPrecision((Mensuration.Precision) adapterView.getItemAtPosition(i));
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> adapterView) {
- model.setPrecision(null);
- }
- });
-
- Set<String> sortCategories = DataCache.getAllSortCategories(this);
- initAutoCompleteTextView(R.id.commercial_species_form_sortCategory, CommercialSpeciesModel.COLUMN_SORT_CATEGORY, sortCategories);
-
- List<State> states = Lists.newArrayList(DataCache.getAllStates(this));
- initAutoCompleteTextView(R.id.commercial_species_form_state, CommercialSpeciesModel.COLUMN_STATE, states);
-
- List<Presentation> presentations = Lists.newArrayList(DataCache.getAllPresentations(this));
- initAutoCompleteTextView(R.id.commercial_species_form_presentation, CommercialSpeciesModel.COLUMN_PRESENTATION, presentations);
-
- CheckBox speciesMixEditor = (CheckBox) findViewById(R.id.commercial_species_form_species_mix);
- speciesMixEditor.setChecked(model.isSpeciesMix());
- speciesMixEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- model.setSpeciesMix(b);
- }
- });
-
- }
-
- @Override
- protected void saveModel() {
- super.saveModel();
- DataCache.invalidateSortCategories();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,136 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.Spinner;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesFormActivity extends WloModelEditionActivity<CommercialSpeciesModel> {
+
+ private static final String TAG = "CommercialSpeciesFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.commercial_species_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return CommercialSpeciesActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return ScientificSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected CommercialSpeciesModel createNewModel() {
+ return new CommercialSpeciesModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // editors
+
+ // init editors
+ List<CommercialSpecies> commercialSpecies = Lists.newArrayList(DataCache.getAllCommercialSpecies(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_fao_code, CommercialSpeciesModel.COLUMN_FAO_CODE, commercialSpecies);
+
+ if (model.getMeasurementMethod() == null) {
+ Mensuration defaultMensuration = DataCache.getDefaultMensuration(this);
+ model.setMeasurementMethod(defaultMensuration);
+ }
+ List<Mensuration> mensurations = Lists.newArrayList(DataCache.getAllMensurations(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_measurement_method, CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD, mensurations);
+
+ Spinner precisionSpinner = (Spinner) findViewById(R.id.commercial_species_form_precision);
+ ArrayAdapter<Mensuration.Precision> precisions = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
+ Mensuration.Precision.values());
+ precisionSpinner.setAdapter(precisions);
+ precisionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
+ model.setPrecision((Mensuration.Precision) adapterView.getItemAtPosition(i));
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> adapterView) {
+ model.setPrecision(null);
+ }
+ });
+ precisionSpinner.setSelection(model.getPrecision().ordinal());
+
+ Set<String> sortCategories = DataCache.getAllSortCategories(this);
+ initAutoCompleteTextView(R.id.commercial_species_form_sortCategory, CommercialSpeciesModel.COLUMN_SORT_CATEGORY, sortCategories);
+
+ List<State> states = Lists.newArrayList(DataCache.getAllStates(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_state, CommercialSpeciesModel.COLUMN_STATE, states);
+
+ List<Presentation> presentations = Lists.newArrayList(DataCache.getAllPresentations(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_presentation, CommercialSpeciesModel.COLUMN_PRESENTATION, presentations);
+
+ CheckBox speciesMixEditor = (CheckBox) findViewById(R.id.commercial_species_form_species_mix);
+ speciesMixEditor.setChecked(model.isSpeciesMix());
+ speciesMixEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ model.setSpeciesMix(b);
+ }
+ });
+
+ }
+
+ @Override
+ protected void saveModel() {
+ super.saveModel();
+ DataCache.invalidateSortCategories();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ContextFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,44 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.util.Log;
-import fr.ifremer.wlo.models.ContextModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ContextFormActivity extends WloModelEditionActivity<ContextModel> {
-
- private static final String TAG = "ContextFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.context_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ContextsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return LocationFormActivity.class;
- }
-
- @Override
- protected ContextModel createNewModel() {
- return new ContextModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- initEditText(R.id.context_form_name, ContextModel.COLUMN_NAME);
-
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ContextFormActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ContextFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,68 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.util.Log;
+import fr.ifremer.wlo.models.ContextModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ContextFormActivity extends WloModelEditionActivity<ContextModel> {
+
+ private static final String TAG = "ContextFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.context_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ContextsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return LocationFormActivity.class;
+ }
+
+ @Override
+ protected ContextModel createNewModel() {
+ return new ContextModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ initEditText(R.id.context_form_name, ContextModel.COLUMN_NAME);
+
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ContextsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,65 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import fr.ifremer.wlo.models.ContextModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ContextsActivity extends WloBaseListActivity<ContextModel> {
-
- private static final String TAG = "ContextsActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { ContextModel.COLUMN_NAME },
- new int[] { android.R.id.text1 }, 0
- );
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllContexts();
- return cursor;
- }
-
- @Override
- protected ContextModel createNewModel(Cursor cursor) {
- return new ContextModel(cursor);
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return ContextFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return null;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return LocationsActivity.class;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MainActivity.class;
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- Cursor cursor = getAllData();
- Log.d(TAG, "cursor size : " + cursor.getCount());
- adapter.swapCursor(cursor);
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ContextsActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ContextsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,89 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import fr.ifremer.wlo.models.ContextModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ContextsActivity extends WloBaseListActivity<ContextModel> {
+
+ private static final String TAG = "ContextsActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { ContextModel.COLUMN_NAME },
+ new int[] { android.R.id.text1 }, 0
+ );
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllContexts();
+ return cursor;
+ }
+
+ @Override
+ protected ContextModel createNewModel(Cursor cursor) {
+ return new ContextModel(cursor);
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return ContextFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return LocationsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MainActivity.class;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ Cursor cursor = getAllData();
+ Log.d(TAG, "cursor size : " + cursor.getCount());
+ adapter.swapCursor(cursor);
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/DeviceListActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package fr.ifremer.wlo;
-
-import android.app.ListActivity;
-import android.app.ProgressDialog;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.util.Set;
-
-/**
- * This Activity appears as a dialog. It lists any paired devices and
- * devices detected in the area after discovery. When a device is chosen
- * by the user, the MAC address of the device is sent back to the parent
- * Activity in the result Intent.
- */
-public class DeviceListActivity extends ListActivity implements ServiceConnection {
- // Debugging
- private static final String TAG = "DeviceListActivity";
-
- // Return Intent extra
- public static final String EXTRA_DEVICE_ADDRESS = "device_address";
-
- // Member fields
- protected BluetoothAdapter mBtAdapter;
- protected ArrayAdapter<String> mPairedDevicesArrayAdapter;
-// private ArrayAdapter<String> mNewDevicesArrayAdapter;
-
- protected Messenger mServiceMessenger = null;
- protected Messenger mMessenger = new Messenger(new IncomingHandler());
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Initialize the button to perform device discovery
-// Button scanButton = (Button) findViewById(R.id.button_scan);
-// scanButton.setOnClickListener(new OnClickListener() {
-// public void onClick(View v) {
-// doDiscovery();
-// v.setVisibility(View.GONE);
-// }
-// });
-
- // Initialize array adapters. One for already paired devices and
- // one for newly discovered devices
- mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
-// mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
-
- // Find and set up the ListView for paired devices
-// ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
- ListView pairedListView = getListView();
- pairedListView.setAdapter(mPairedDevicesArrayAdapter);
- pairedListView.setOnItemClickListener(mDeviceClickListener);
-
- // Find and set up the ListView for newly discovered devices
-// ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
-// newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
-// newDevicesListView.setOnItemClickListener(mDeviceClickListener);
-
- // Register for broadcasts when a device is discovered
-// IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
-// this.registerReceiver(mReceiver, filter);
-
- // Register for broadcasts when discovery has finished
-// filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
-// this.registerReceiver(mReceiver, filter);
-
- // Get the local Bluetooth adapter
- mBtAdapter = BluetoothAdapter.getDefaultAdapter();
-
- // Get a set of currently paired devices
- Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
-
- // If there are paired devices, add each one to the ArrayAdapter
- if (pairedDevices.size() > 0) {
-// findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
- for (BluetoothDevice device : pairedDevices) {
- mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
- }
- } else {
- String noDevices = getResources().getText(R.string.devices_none_paired).toString();
- mPairedDevicesArrayAdapter.add(noDevices);
- }
-
- bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- // Make sure we're not doing discovery anymore
- if (mBtAdapter != null) {
- mBtAdapter.cancelDiscovery();
- }
-
- // Unregister broadcast listeners
-// this.unregisterReceiver(mReceiver);
- doUnbindService();
- }
-
- /**
- * Start device discover with the BluetoothAdapter
- */
-// private void doDiscovery() {
-// Log.d(TAG, "doDiscovery()");
-//
-// // Indicate scanning in the title
-// setProgressBarIndeterminateVisibility(true);
-// setTitle(R.string.scanning);
-//
-// // Turn on sub-title for new devices
-// findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
-//
-// // If we're already discovering, stop it
-// if (mBtAdapter.isDiscovering()) {
-// mBtAdapter.cancelDiscovery();
-// }
-//
-// // Request discover from BluetoothAdapter
-// mBtAdapter.startDiscovery();
-// }
-
- /**
- * Un-bind this Activity to MyService
- */
- protected void doUnbindService() {
- // If we have received the service, and hence registered with it, then now is the time to unregister.
- if (mServiceMessenger != null) {
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
- // Detach our existing connection.
- unbindService(this);
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mServiceMessenger = new Messenger(service);
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
- }
- catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mServiceMessenger = null;
- }
-
- // The on-click listener for all devices in the ListViews
- protected OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
- public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
- // Cancel discovery because it's costly and we're about to connect
- mBtAdapter.cancelDiscovery();
-
- // Get the device MAC address, which is the last 17 chars in the View
- String info = ((TextView) v).getText().toString();
- String address = info.substring(info.length() - 17);
-
- // Create the result Intent and include the MAC address
-// Intent intent = new Intent();
-// intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
-
- // Attempt to connect to the device
- Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_CONNECT_DEVICE);
- Bundle bundle = new Bundle();
- bundle.putString(BigFinCommunicationService.DEVICE_ADDRESS, address);
- message.setData(bundle);
- try {
- mServiceMessenger.send(message);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
-
- // Set result and finish this Activity
-// setResult(Activity.RESULT_OK, intent);
-// finish();
- }
- };
-
- // The BroadcastReceiver that listens for discovered devices and
- // changes the title when discovery is finished
-// private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
-// @Override
-// public void onReceive(Context context, Intent intent) {
-// String action = intent.getAction();
-//
-// // When discovery finds a device
-// if (BluetoothDevice.ACTION_FOUND.equals(action)) {
-// // Get the BluetoothDevice object from the Intent
-// BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-// // If it's already paired, skip it, because it's been listed already
-// if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
-// mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
-// }
-// // When discovery is finished, change the Activity title
-// } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
-// setProgressBarIndeterminateVisibility(false);
-// setTitle(R.string.select_device);
-// if (mNewDevicesArrayAdapter.getCount() == 0) {
-// String noDevices = getResources().getText(R.string.none_found).toString();
-// mNewDevicesArrayAdapter.add(noDevices);
-// }
-// }
-// }
-// };
-
- protected void sendDataToDevice(String data) {
- Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_SEND_DATA);
- Bundle bundle = new Bundle();
- bundle.putString(BigFinCommunicationService.DATA_TO_SEND, data);
- message.setData(bundle);
- try {
- mServiceMessenger.send(message);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
-
- // The Handler that gets information back from the BluetoothChatService
- class IncomingHandler extends Handler {
-
- ProgressDialog dialog;
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
- switch (msg.arg1) {
- case BigFinCommunicationService.STATE_CONNECTED:
- sendDataToDevice("a");
- sendDataToDevice("b");
-
- dialog.dismiss();
- finish();
-
- break;
-
- case BigFinCommunicationService.STATE_CONNECTING:
- dialog = ProgressDialog.show(DeviceListActivity.this, "",
- "Connecting. Please wait...", true);
- break;
-
- }
- break;
-
- case BigFinCommunicationService.MESSAGE_WRITE:
- byte[] writeBuf = (byte[]) msg.obj;
- // construct a string from the buffer
- String writeMessage = new String(writeBuf);
- Log.d(TAG, "write " + writeMessage);
- break;
-
- case BigFinCommunicationService.MESSAGE_READ:
- byte[] readBuf = (byte[]) msg.obj;
- // construct a string from the valid bytes in the buffer
- String readMessage = new String(readBuf, 0, msg.arg1);
- Log.d(TAG, "read " + readMessage);
- break;
-
- case BigFinCommunicationService.MESSAGE_DEVICE_NAME:
- // save the connected device's name
- String mConnectedDeviceName = msg.getData().getString(BigFinCommunicationService.DEVICE_NAME);
- Toast.makeText(getApplicationContext(), "Connected to "
- + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
- break;
-
- case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
- case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
- if (dialog != null) {
- dialog.dismiss();
- }
- Toast.makeText(getApplicationContext(), msg.getData().getString(BigFinCommunicationService.TOAST),
- Toast.LENGTH_SHORT).show();
- break;
- }
- }
-
- };
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/DeviceListActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/DeviceListActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,352 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.ListActivity;
+import android.app.ProgressDialog;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.Set;
+
+/**
+ * This Activity appears as a dialog. It lists any paired devices and
+ * devices detected in the area after discovery. When a device is chosen
+ * by the user, the MAC address of the device is sent back to the parent
+ * Activity in the result Intent.
+ */
+public class DeviceListActivity extends ListActivity implements ServiceConnection {
+ // Debugging
+ private static final String TAG = "DeviceListActivity";
+
+ // Return Intent extra
+ public static final String EXTRA_DEVICE_ADDRESS = "device_address";
+
+ // Member fields
+ protected BluetoothAdapter mBtAdapter;
+ protected ArrayAdapter<String> mPairedDevicesArrayAdapter;
+// private ArrayAdapter<String> mNewDevicesArrayAdapter;
+
+ protected Messenger mServiceMessenger = null;
+ protected Messenger mMessenger = new Messenger(new IncomingHandler());
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Initialize the button to perform device discovery
+// Button scanButton = (Button) findViewById(R.id.button_scan);
+// scanButton.setOnClickListener(new OnClickListener() {
+// public void onClick(View v) {
+// doDiscovery();
+// v.setVisibility(View.GONE);
+// }
+// });
+
+ // Initialize array adapters. One for already paired devices and
+ // one for newly discovered devices
+ mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
+// mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
+
+ // Find and set up the ListView for paired devices
+// ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
+ ListView pairedListView = getListView();
+ pairedListView.setAdapter(mPairedDevicesArrayAdapter);
+ pairedListView.setOnItemClickListener(mDeviceClickListener);
+
+ // Find and set up the ListView for newly discovered devices
+// ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
+// newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
+// newDevicesListView.setOnItemClickListener(mDeviceClickListener);
+
+ // Register for broadcasts when a device is discovered
+// IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
+// this.registerReceiver(mReceiver, filter);
+
+ // Register for broadcasts when discovery has finished
+// filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
+// this.registerReceiver(mReceiver, filter);
+
+ // Get the local Bluetooth adapter
+ mBtAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // Get a set of currently paired devices
+ Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
+
+ // If there are paired devices, add each one to the ArrayAdapter
+ if (pairedDevices.size() > 0) {
+// findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
+ for (BluetoothDevice device : pairedDevices) {
+ mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
+ }
+ } else {
+ String noDevices = getResources().getText(R.string.devices_none_paired).toString();
+ mPairedDevicesArrayAdapter.add(noDevices);
+ }
+
+ bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+
+ // Make sure we're not doing discovery anymore
+ if (mBtAdapter != null) {
+ mBtAdapter.cancelDiscovery();
+ }
+
+ // Unregister broadcast listeners
+// this.unregisterReceiver(mReceiver);
+ doUnbindService();
+ }
+
+ /**
+ * Start device discover with the BluetoothAdapter
+ */
+// private void doDiscovery() {
+// Log.d(TAG, "doDiscovery()");
+//
+// // Indicate scanning in the title
+// setProgressBarIndeterminateVisibility(true);
+// setTitle(R.string.scanning);
+//
+// // Turn on sub-title for new devices
+// findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
+//
+// // If we're already discovering, stop it
+// if (mBtAdapter.isDiscovering()) {
+// mBtAdapter.cancelDiscovery();
+// }
+//
+// // Request discover from BluetoothAdapter
+// mBtAdapter.startDiscovery();
+// }
+
+ /**
+ * Un-bind this Activity to MyService
+ */
+ protected void doUnbindService() {
+ // If we have received the service, and hence registered with it, then now is the time to unregister.
+ if (mServiceMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ // Detach our existing connection.
+ unbindService(this);
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mServiceMessenger = new Messenger(service);
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+ }
+ catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mServiceMessenger = null;
+ }
+
+ // The on-click listener for all devices in the ListViews
+ protected OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
+ public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
+ // Cancel discovery because it's costly and we're about to connect
+ mBtAdapter.cancelDiscovery();
+
+ // Get the device MAC address, which is the last 17 chars in the View
+ String info = ((TextView) v).getText().toString();
+ String address = info.substring(info.length() - 17);
+
+ // Create the result Intent and include the MAC address
+// Intent intent = new Intent();
+// intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
+
+ // Attempt to connect to the device
+ Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_CONNECT_DEVICE);
+ Bundle bundle = new Bundle();
+ bundle.putString(BigFinCommunicationService.DEVICE_ADDRESS, address);
+ message.setData(bundle);
+ try {
+ mServiceMessenger.send(message);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+
+ // Set result and finish this Activity
+// setResult(Activity.RESULT_OK, intent);
+// finish();
+ }
+ };
+
+ // The BroadcastReceiver that listens for discovered devices and
+ // changes the title when discovery is finished
+// private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+// @Override
+// public void onReceive(Context context, Intent intent) {
+// String action = intent.getAction();
+//
+// // When discovery finds a device
+// if (BluetoothDevice.ACTION_FOUND.equals(action)) {
+// // Get the BluetoothDevice object from the Intent
+// BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+// // If it's already paired, skip it, because it's been listed already
+// if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
+// mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
+// }
+// // When discovery is finished, change the Activity title
+// } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
+// setProgressBarIndeterminateVisibility(false);
+// setTitle(R.string.select_device);
+// if (mNewDevicesArrayAdapter.getCount() == 0) {
+// String noDevices = getResources().getText(R.string.none_found).toString();
+// mNewDevicesArrayAdapter.add(noDevices);
+// }
+// }
+// }
+// };
+
+ protected void sendDataToDevice(String data) {
+ Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_SEND_DATA);
+ Bundle bundle = new Bundle();
+ bundle.putString(BigFinCommunicationService.DATA_TO_SEND, data);
+ message.setData(bundle);
+ try {
+ mServiceMessenger.send(message);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+
+ // The Handler that gets information back from the BluetoothChatService
+ class IncomingHandler extends Handler {
+
+ ProgressDialog dialog;
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
+ switch (msg.arg1) {
+ case BigFinCommunicationService.STATE_CONNECTED:
+ sendDataToDevice("a");
+ sendDataToDevice("b");
+
+ dialog.dismiss();
+ finish();
+
+ break;
+
+ case BigFinCommunicationService.STATE_CONNECTING:
+ dialog = ProgressDialog.show(DeviceListActivity.this, "",
+ "Connecting. Please wait...", true);
+ break;
+
+ }
+ break;
+
+ case BigFinCommunicationService.MESSAGE_WRITE:
+ byte[] writeBuf = (byte[]) msg.obj;
+ // construct a string from the buffer
+ String writeMessage = new String(writeBuf);
+ Log.d(TAG, "write " + writeMessage);
+ break;
+
+ case BigFinCommunicationService.MESSAGE_READ:
+ byte[] readBuf = (byte[]) msg.obj;
+ // construct a string from the valid bytes in the buffer
+ String readMessage = new String(readBuf, 0, msg.arg1);
+ Log.d(TAG, "read " + readMessage);
+ break;
+
+ case BigFinCommunicationService.MESSAGE_DEVICE_NAME:
+ // save the connected device's name
+ String mConnectedDeviceName = msg.getData().getString(BigFinCommunicationService.DEVICE_NAME);
+ Toast.makeText(getApplicationContext(), "Connected to "
+ + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
+ break;
+
+ case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
+ case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
+ if (dialog != null) {
+ dialog.dismiss();
+ }
+ Toast.makeText(getApplicationContext(), msg.getData().getString(BigFinCommunicationService.TOAST),
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+
+ };
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/Home.java
===================================================================
--- trunk/src/fr/ifremer/wlo/Home.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/Home.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package fr.ifremer.wlo;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.speech.tts.TextToSpeech;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.Toast;
-import fr.ifremer.wlo.measurement.MeasurementActivity;
-
-/**
- * This is the main Activity that displays the current chat location.
- */
-public class Home extends Activity implements TextToSpeech.OnInitListener {
-
- // Debugging
- private static final String TAG = "Home";
-
- // Message types sent from the BluetoothChatService Handler
- public static final int MESSAGE_STATE_CHANGE = 1;
- public static final int MESSAGE_READ = 2;
- public static final int MESSAGE_WRITE = 3;
- public static final int MESSAGE_DEVICE_NAME = 4;
- public static final int MESSAGE_TOAST = 5;
-
- // Key names received from the BluetoothChatService Handler
- public static final String DEVICE_NAME = "device_name";
- public static final String TOAST = "toast";
-
- // Intent request codes
- protected static final int REQUEST_CONNECT_DEVICE = 1;
- protected static final int REQUEST_ENABLE_BT = 2;
- protected static final int REQUEST_CHECK_TTS = 3;
-
- // Layout Views
- protected ListView mConversationView;
-
- // Name of the connected device
- protected String mConnectedDeviceName = null;
- // Array adapter for the conversation thread
- protected ArrayAdapter<String> mConversationArrayAdapter;
- // Local Bluetooth adapter
- protected BluetoothAdapter mBluetoothAdapter = null;
- // Member object for the chat services
- protected BigFinCommunicationService mBFCommunicationService = null;
-
-// protected TextToSpeech mTts;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Set up the window layout
-// setContentView(R.layout.home);
-
- // Get local Bluetooth adapter
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-
- // If the adapter is null, then Bluetooth is not supported
- if (mBluetoothAdapter == null) {
- Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
- finish();
- return;
- }
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- // If BT is not on, request that it be enabled.
- // setupChat() will then be called during onActivityResult
- if (!mBluetoothAdapter.isEnabled()) {
- Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
-
- // Otherwise, setup the chat location
- } else {
-// Intent checkIntent = new Intent();
-// checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
-// startActivityForResult(checkIntent, REQUEST_CHECK_TTS);
- setupChat();
- }
- }
-
- @Override
- public synchronized void onResume() {
- super.onResume();
-
- // Performing this check in onResume() covers the case in which BT was
- // not enabled during onStart(), so we were paused to enable it...
- // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
- if (mBFCommunicationService != null) {
- // Only if the state is STATE_NONE, do we know that we haven't started already
-// if (mBFCommunicationService.getState() == BigFinCommunicationService.STATE_NONE) {
- // Start the Bluetooth chat services
-// mBFCommunicationService.start();
- selectDevice();
-// }
- }
- }
-
- protected void selectDevice() {
- // Launch the DeviceListActivity to see devices and do scan
- Intent serverIntent = new Intent(this, DeviceListActivity.class);
- startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
- }
-
- private void setupChat() {
- Log.d(TAG, "setupChat()");
-
- // Initialize the array adapter for the conversation thread
- mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
-// mConversationView = (ListView) findViewById(R.id.in);
- mConversationView.setAdapter(mConversationArrayAdapter);
-
- // Initialize the BluetoothChatService to perform bluetooth connections
-// mBFCommunicationService = new BigFinCommunicationService(this, mHandler);
-
- }
-
- @Override
- public void onStop() {
- super.onStop();
-// mTts.shutdown();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- // Stop the Bluetooth chat services
-// if (mBFCommunicationService != null) mBFCommunicationService.stop();
- }
-
- protected final void setStatus(int resId) {
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setSubtitle(resId);
- }
- }
-
- protected final void setStatus(CharSequence subTitle) {
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setSubtitle(subTitle);
- }
- }
-
- // The Handler that gets information back from the BluetoothChatService
- protected final Handler mHandler = new Handler() {
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MESSAGE_STATE_CHANGE:
- Log.d(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
- switch (msg.arg1) {
- case BigFinCommunicationService.STATE_CONNECTED:
-// setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
- mConversationArrayAdapter.clear();
- mBFCommunicationService.write("a".getBytes());
- mBFCommunicationService.write("b".getBytes());
-
- Intent intent = new Intent(Home.this, MeasurementActivity.class);
- startActivity(intent);
-
- break;
-
- case BigFinCommunicationService.STATE_CONNECTING:
-// setStatus(R.string.title_connecting);
-
- break;
-
- case BigFinCommunicationService.STATE_LISTEN:
- case BigFinCommunicationService.STATE_NONE:
-// setStatus(R.string.title_not_connected);
- break;
- }
- break;
-
- case MESSAGE_WRITE:
- byte[] writeBuf = (byte[]) msg.obj;
- // construct a string from the buffer
- String writeMessage = new String(writeBuf);
-// mConversationArrayAdapter.add("Me: " + writeMessage);
- break;
-
- case MESSAGE_READ:
- byte[] readBuf = (byte[]) msg.obj;
- // construct a string from the valid bytes in the buffer
- String readMessage = new String(readBuf, 0, msg.arg1);
- mConversationArrayAdapter.add(readMessage);
-// mTts.speak(readMessage, TextToSpeech.QUEUE_ADD, null);
- break;
-
- case MESSAGE_DEVICE_NAME:
- // save the connected device's name
- mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
- Toast.makeText(getApplicationContext(), "Connected to "
- + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
- break;
-
- case MESSAGE_TOAST:
- Toast.makeText(getApplicationContext(), msg.getData().getString(TOAST),
- Toast.LENGTH_SHORT).show();
- break;
- }
- }
- };
-
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- switch (requestCode) {
- case REQUEST_CONNECT_DEVICE:
- // When DeviceListActivity returns with a device to connect
- if (resultCode == Activity.RESULT_OK) {
- connectDevice(data);
- }
- break;
-
- case REQUEST_ENABLE_BT:
- // When the request to enable Bluetooth returns
- if (resultCode == Activity.RESULT_OK) {
- // Bluetooth is now enabled, so set up a chat location
- setupChat();
-
- } else {
- // User did not enable Bluetooth or an error occurred
- Log.d(TAG, "BT not enabled");
-// Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
- finish();
- }
- break;
-
- case REQUEST_CHECK_TTS:
- if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
- // Succès, au moins un moteur de TTS à été trouvé, on l'instancie
-// mTts = new TextToSpeech(this, this);
-
- } else {
- // Echec, aucun moteur n'a été trouvé, on propose à l'utilisateur d'en installer un depuis le Market
- Intent installIntent = new Intent();
- installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
- startActivity(installIntent);
- }
- break;
- }
-
- }
-
- protected void connectDevice(Intent data) {
- // Get the device MAC address
- String address = data.getExtras()
- .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
- // Get the BluetoothDevice object
- BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
- // Attempt to connect to the device
- mBFCommunicationService.connect(device);
-
- Intent intent = new Intent(this, MeasurementActivity.class);
- startActivity(intent);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
-// inflater.inflate(R.menu.option_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-// switch (item.getItemId()) {
-// case R.id.connect_scan:
-// selectDevice();
-// return true;
-// case R.id.disconnect:
-//// mBFCommunicationService.start();
-// return true;
-// }
- return false;
- }
-
- @Override
- public void onInit(int status) {
- if (status == TextToSpeech.SUCCESS) {
-// if (mTts.isLanguageAvailable(Locale.FRANCE) == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
-// mTts.setLanguage(Locale.FRANCE);
-// }
- }
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/Home.java (from rev 25, trunk/src/fr/ifremer/wlo/Home.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/Home.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/Home.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.speech.tts.TextToSpeech;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+import fr.ifremer.wlo.measurement.MeasurementActivity;
+
+/**
+ * This is the main Activity that displays the current chat location.
+ */
+public class Home extends Activity implements TextToSpeech.OnInitListener {
+
+ // Debugging
+ private static final String TAG = "Home";
+
+ // Message types sent from the BluetoothChatService Handler
+ public static final int MESSAGE_STATE_CHANGE = 1;
+ public static final int MESSAGE_READ = 2;
+ public static final int MESSAGE_WRITE = 3;
+ public static final int MESSAGE_DEVICE_NAME = 4;
+ public static final int MESSAGE_TOAST = 5;
+
+ // Key names received from the BluetoothChatService Handler
+ public static final String DEVICE_NAME = "device_name";
+ public static final String TOAST = "toast";
+
+ // Intent request codes
+ protected static final int REQUEST_CONNECT_DEVICE = 1;
+ protected static final int REQUEST_ENABLE_BT = 2;
+ protected static final int REQUEST_CHECK_TTS = 3;
+
+ // Layout Views
+ protected ListView mConversationView;
+
+ // Name of the connected device
+ protected String mConnectedDeviceName = null;
+ // Array adapter for the conversation thread
+ protected ArrayAdapter<String> mConversationArrayAdapter;
+ // Local Bluetooth adapter
+ protected BluetoothAdapter mBluetoothAdapter = null;
+ // Member object for the chat services
+ protected BigFinCommunicationService mBFCommunicationService = null;
+
+// protected TextToSpeech mTts;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Set up the window layout
+// setContentView(R.layout.home);
+
+ // Get local Bluetooth adapter
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // If the adapter is null, then Bluetooth is not supported
+ if (mBluetoothAdapter == null) {
+ Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
+ finish();
+ return;
+ }
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ // If BT is not on, request that it be enabled.
+ // setupChat() will then be called during onActivityResult
+ if (!mBluetoothAdapter.isEnabled()) {
+ Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
+
+ // Otherwise, setup the chat location
+ } else {
+// Intent checkIntent = new Intent();
+// checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
+// startActivityForResult(checkIntent, REQUEST_CHECK_TTS);
+ setupChat();
+ }
+ }
+
+ @Override
+ public synchronized void onResume() {
+ super.onResume();
+
+ // Performing this check in onResume() covers the case in which BT was
+ // not enabled during onStart(), so we were paused to enable it...
+ // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
+ if (mBFCommunicationService != null) {
+ // Only if the state is STATE_NONE, do we know that we haven't started already
+// if (mBFCommunicationService.getState() == BigFinCommunicationService.STATE_NONE) {
+ // Start the Bluetooth chat services
+// mBFCommunicationService.start();
+ selectDevice();
+// }
+ }
+ }
+
+ protected void selectDevice() {
+ // Launch the DeviceListActivity to see devices and do scan
+ Intent serverIntent = new Intent(this, DeviceListActivity.class);
+ startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
+ }
+
+ private void setupChat() {
+ Log.d(TAG, "setupChat()");
+
+ // Initialize the array adapter for the conversation thread
+ mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
+// mConversationView = (ListView) findViewById(R.id.in);
+ mConversationView.setAdapter(mConversationArrayAdapter);
+
+ // Initialize the BluetoothChatService to perform bluetooth connections
+// mBFCommunicationService = new BigFinCommunicationService(this, mHandler);
+
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+// mTts.shutdown();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ // Stop the Bluetooth chat services
+// if (mBFCommunicationService != null) mBFCommunicationService.stop();
+ }
+
+ protected final void setStatus(int resId) {
+ final ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(resId);
+ }
+ }
+
+ protected final void setStatus(CharSequence subTitle) {
+ final ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(subTitle);
+ }
+ }
+
+ // The Handler that gets information back from the BluetoothChatService
+ protected final Handler mHandler = new Handler() {
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MESSAGE_STATE_CHANGE:
+ Log.d(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
+ switch (msg.arg1) {
+ case BigFinCommunicationService.STATE_CONNECTED:
+// setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
+ mConversationArrayAdapter.clear();
+ mBFCommunicationService.write("a".getBytes());
+ mBFCommunicationService.write("b".getBytes());
+
+ Intent intent = new Intent(Home.this, MeasurementActivity.class);
+ startActivity(intent);
+
+ break;
+
+ case BigFinCommunicationService.STATE_CONNECTING:
+// setStatus(R.string.title_connecting);
+
+ break;
+
+ case BigFinCommunicationService.STATE_LISTEN:
+ case BigFinCommunicationService.STATE_NONE:
+// setStatus(R.string.title_not_connected);
+ break;
+ }
+ break;
+
+ case MESSAGE_WRITE:
+ byte[] writeBuf = (byte[]) msg.obj;
+ // construct a string from the buffer
+ String writeMessage = new String(writeBuf);
+// mConversationArrayAdapter.add("Me: " + writeMessage);
+ break;
+
+ case MESSAGE_READ:
+ byte[] readBuf = (byte[]) msg.obj;
+ // construct a string from the valid bytes in the buffer
+ String readMessage = new String(readBuf, 0, msg.arg1);
+ mConversationArrayAdapter.add(readMessage);
+// mTts.speak(readMessage, TextToSpeech.QUEUE_ADD, null);
+ break;
+
+ case MESSAGE_DEVICE_NAME:
+ // save the connected device's name
+ mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
+ Toast.makeText(getApplicationContext(), "Connected to "
+ + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
+ break;
+
+ case MESSAGE_TOAST:
+ Toast.makeText(getApplicationContext(), msg.getData().getString(TOAST),
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+ };
+
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ switch (requestCode) {
+ case REQUEST_CONNECT_DEVICE:
+ // When DeviceListActivity returns with a device to connect
+ if (resultCode == Activity.RESULT_OK) {
+ connectDevice(data);
+ }
+ break;
+
+ case REQUEST_ENABLE_BT:
+ // When the request to enable Bluetooth returns
+ if (resultCode == Activity.RESULT_OK) {
+ // Bluetooth is now enabled, so set up a chat location
+ setupChat();
+
+ } else {
+ // User did not enable Bluetooth or an error occurred
+ Log.d(TAG, "BT not enabled");
+// Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
+ finish();
+ }
+ break;
+
+ case REQUEST_CHECK_TTS:
+ if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
+ // Succès, au moins un moteur de TTS à été trouvé, on l'instancie
+// mTts = new TextToSpeech(this, this);
+
+ } else {
+ // Echec, aucun moteur n'a été trouvé, on propose à l'utilisateur d'en installer un depuis le Market
+ Intent installIntent = new Intent();
+ installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
+ startActivity(installIntent);
+ }
+ break;
+ }
+
+ }
+
+ protected void connectDevice(Intent data) {
+ // Get the device MAC address
+ String address = data.getExtras()
+ .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
+ // Get the BluetoothDevice object
+ BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
+ // Attempt to connect to the device
+ mBFCommunicationService.connect(device);
+
+ Intent intent = new Intent(this, MeasurementActivity.class);
+ startActivity(intent);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+// inflater.inflate(R.menu.option_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+// switch (item.getItemId()) {
+// case R.id.connect_scan:
+// selectDevice();
+// return true;
+// case R.id.disconnect:
+//// mBFCommunicationService.start();
+// return true;
+// }
+ return false;
+ }
+
+ @Override
+ public void onInit(int status) {
+ if (status == TextToSpeech.SUCCESS) {
+// if (mTts.isLanguageAvailable(Locale.FRANCE) == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
+// mTts.setLanguage(Locale.FRANCE);
+// }
+ }
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/LocationFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,124 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.preferences.StringPreference;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.DatePickerFragment;
-import fr.ifremer.wlo.utils.TimePickerFragment;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Calendar;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationFormActivity extends WloModelEditionActivity<LocationModel> {
-
- private static final String TAG = "LocationFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.location_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return LocationsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return VesselFormActivity.class;
- }
-
- @Override
- protected LocationModel createNewModel() {
- return new LocationModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // init editors
- String defaultOperator = null;
- if (model.isNew()) {
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
- defaultOperator = sharedPref.getString(StringPreference.DEFAULT_OPERATOR.getKey(), null);
- }
- initEditText(R.id.location_form_operator, LocationModel.COLUMN_OPERATOR, defaultOperator);
-
- List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
- initAutoCompleteTextView(R.id.location_form_location, LocationModel.COLUMN_LOCATION, locations);
-
- TextView startDateTextView = (TextView) findViewById(R.id.location_form_start_date);
- TextView startTimeTextView = (TextView) findViewById(R.id.location_form_start_time);
- TextView endDateTextView = (TextView) findViewById(R.id.location_form_end_date);
- TextView endTimeTextView = (TextView) findViewById(R.id.location_form_end_time);
-
- String dateFormat = UIUtils.getDateFormat(this);
- // start date
- Calendar startDate = model.getStartDate();
- if (startDate != null) {
- startDateTextView.setText(String.format(dateFormat, startDate.getTime()));
- startTimeTextView.setText(getString(R.string.time_format, startDate.getTime()));
- }
-
- // end date
- Calendar endDate = model.getEndDate();
- if (endDate != null) {
- endDateTextView.setText(String.format(dateFormat, endDate.getTime()));
- endTimeTextView.setText(getString(R.string.time_format, endDate.getTime()));
- }
-
- }
-
- public void pickDate(View v) {
- String attribute;
- switch (v.getId()) {
- case R.id.location_form_start_date:
- attribute = LocationModel.COLUMN_START_DATE;
- break;
-
- case R.id.location_form_end_date:
- attribute = LocationModel.COLUMN_END_DATE;
- break;
-
- default:
- return;
- }
- DialogFragment newFragment = new DatePickerFragment(model, attribute, (TextView) v);
- newFragment.show(getSupportFragmentManager(), "datePicker");
- }
-
- public void pickTime(View v) {
- String attribute;
- switch (v.getId()) {
- case R.id.location_form_start_time:
- attribute = LocationModel.COLUMN_START_DATE;
- break;
-
- case R.id.location_form_end_time:
- attribute = LocationModel.COLUMN_END_DATE;
- break;
-
- default:
- return;
- }
- DialogFragment newFragment = new TimePickerFragment(model, attribute, (TextView) v);
- newFragment.show(getSupportFragmentManager(), "timePicker");
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/LocationFormActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/LocationFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,148 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.preferences.StringPreference;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.DatePickerFragment;
+import fr.ifremer.wlo.utils.TimePickerFragment;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationFormActivity extends WloModelEditionActivity<LocationModel> {
+
+ private static final String TAG = "LocationFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.location_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return LocationsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return VesselFormActivity.class;
+ }
+
+ @Override
+ protected LocationModel createNewModel() {
+ return new LocationModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // init editors
+ String defaultOperator = null;
+ if (model.isNew()) {
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+ defaultOperator = sharedPref.getString(StringPreference.DEFAULT_OPERATOR.getKey(), null);
+ }
+ initEditText(R.id.location_form_operator, LocationModel.COLUMN_OPERATOR, defaultOperator);
+
+ List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
+ initAutoCompleteTextView(R.id.location_form_location, LocationModel.COLUMN_LOCATION, locations);
+
+ TextView startDateTextView = (TextView) findViewById(R.id.location_form_start_date);
+ TextView startTimeTextView = (TextView) findViewById(R.id.location_form_start_time);
+ TextView endDateTextView = (TextView) findViewById(R.id.location_form_end_date);
+ TextView endTimeTextView = (TextView) findViewById(R.id.location_form_end_time);
+
+ String dateFormat = UIUtils.getDateFormat(this);
+ // start date
+ Calendar startDate = model.getStartDate();
+ if (startDate != null) {
+ startDateTextView.setText(String.format(dateFormat, startDate.getTime()));
+ startTimeTextView.setText(getString(R.string.time_format, startDate.getTime()));
+ }
+
+ // end date
+ Calendar endDate = model.getEndDate();
+ if (endDate != null) {
+ endDateTextView.setText(String.format(dateFormat, endDate.getTime()));
+ endTimeTextView.setText(getString(R.string.time_format, endDate.getTime()));
+ }
+
+ }
+
+ public void pickDate(View v) {
+ String attribute;
+ switch (v.getId()) {
+ case R.id.location_form_start_date:
+ attribute = LocationModel.COLUMN_START_DATE;
+ break;
+
+ case R.id.location_form_end_date:
+ attribute = LocationModel.COLUMN_END_DATE;
+ break;
+
+ default:
+ return;
+ }
+ DialogFragment newFragment = new DatePickerFragment(model, attribute, (TextView) v);
+ newFragment.show(getSupportFragmentManager(), "datePicker");
+ }
+
+ public void pickTime(View v) {
+ String attribute;
+ switch (v.getId()) {
+ case R.id.location_form_start_time:
+ attribute = LocationModel.COLUMN_START_DATE;
+ break;
+
+ case R.id.location_form_end_time:
+ attribute = LocationModel.COLUMN_END_DATE;
+ break;
+
+ default:
+ return;
+ }
+ DialogFragment newFragment = new TimePickerFragment(model, attribute, (TextView) v);
+ newFragment.show(getSupportFragmentManager(), "timePicker");
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/LocationsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,67 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationsActivity extends WloBaseListActivity<LocationModel> {
-
- private static final String TAG = "LocationsActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, R.layout.location_list_item, null,
- new String[] { LocationModel.COLUMN_LOCATION, LocationModel.COLUMN_START_DATE, LocationModel.COLUMN_END_DATE },
- new int[] { R.id.location_location, R.id.location_start_date, R.id.location_end_date }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllLocations(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected LocationModel createNewModel(Cursor cursor) {
- return new LocationModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return VesselsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return LocationFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.locations_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ContextsActivity.class;
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(2, WloItemListViewBinder.DataType.DATETIME);
- types.put(3, WloItemListViewBinder.DataType.DATETIME);
- types.put(4, WloItemListViewBinder.DataType.LOCATION);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/LocationsActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/LocationsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,91 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationsActivity extends WloBaseListActivity<LocationModel> {
+
+ private static final String TAG = "LocationsActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, R.layout.location_list_item, null,
+ new String[] { LocationModel.COLUMN_LOCATION, LocationModel.COLUMN_START_DATE, LocationModel.COLUMN_END_DATE },
+ new int[] { R.id.location_location, R.id.location_start_date, R.id.location_end_date }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllLocations(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected LocationModel createNewModel(Cursor cursor) {
+ return new LocationModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return VesselsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return LocationFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.locations_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ContextsActivity.class;
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(2, WloItemListViewBinder.DataType.DATETIME);
+ types.put(3, WloItemListViewBinder.DataType.DATETIME);
+ types.put(4, WloItemListViewBinder.DataType.LOCATION);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,251 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.bluetooth.BluetoothAdapter;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Toast;
-import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
-import fr.ifremer.wlo.preferences.SettingsActivity;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-
-import java.io.IOException;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MainActivity extends WloBaseActivity {
-
- private static final String TAG = "MainActivity";
-
- protected static final int REQUEST_ENABLE_BT = 1;
- protected static final int REQUEST_CONNECT_ICHTYOMETER = 2;
-
- // Local Bluetooth adapter
- protected BluetoothAdapter mBluetoothAdapter = null;
-
- protected Button connectButton;
- protected Button disconnectButton;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "create");
-
- mMessenger = new Messenger(new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
- switch (msg.arg1) {
- case BigFinCommunicationService.STATE_CONNECTED:
- bigfinConnected();
- break;
-
- case BigFinCommunicationService.STATE_LISTEN:
- case BigFinCommunicationService.STATE_NONE:
- bigfinDisconnected();
- break;
- }
- break;
-
- case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
- case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
- bigfinDisconnected();
- break;
- }
- }
- });
-
- super.onCreate(savedInstanceState);
-
- // Get local Bluetooth adapter
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-
- // If the adapter is null, then Bluetooth is not supported
- if (mBluetoothAdapter == null) {
- findViewById(R.id.main_connect_ichtyometer_button).setEnabled(false);
- }
-
- connectButton = (Button) findViewById(R.id.main_connect_ichtyometer_button);
- disconnectButton = (Button) findViewById(R.id.main_disconnect_ichtyometer_button);
- bigfinDisconnected();
-
- final ProgressDialog dialog = new ProgressDialog(this);
- dialog.setIndeterminate(false);
- dialog.setCancelable(false);
- dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- dialog.setMax(11);
- dialog.setMessage(getString(R.string.main_loading_referential));
- dialog.show();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- if (DataCache.getAllAges(MainActivity.this).isEmpty()) {
- ImportUtil.importAges(MainActivity.this, getAssets().open("ref_import_ages.csv"));
- }
- dialog.setProgress(1);
- if (DataCache.getAllCommercialSpecies(MainActivity.this).isEmpty()) {
- ImportUtil.importCommercialSpecies(MainActivity.this, getAssets().open("ref_import_commercial_species.csv"));
- }
- dialog.setProgress(2);
- if (DataCache.getAllGenders(MainActivity.this).isEmpty()) {
- ImportUtil.importGenders(MainActivity.this, getAssets().open("ref_import_genders.csv"));
- }
- dialog.setProgress(3);
- if (DataCache.getAllLocations(MainActivity.this).isEmpty()) {
- ImportUtil.importLocations(MainActivity.this, getAssets().open("ref_import_locations.csv"));
- }
- dialog.setProgress(4);
- if (DataCache.getAllMaturities(MainActivity.this).isEmpty()) {
- ImportUtil.importMaturities(MainActivity.this, getAssets().open("ref_import_maturities.csv"));
- }
- dialog.setProgress(5);
- if (DataCache.getAllMensurations(MainActivity.this).isEmpty()) {
- ImportUtil.importMensurations(MainActivity.this, getAssets().open("ref_import_mensurations.csv"));
- }
- dialog.setProgress(6);
- if (DataCache.getAllMetiers(MainActivity.this).isEmpty()) {
- ImportUtil.importMetiers(MainActivity.this, getAssets().open("ref_import_metiers.csv"));
- }
- dialog.setProgress(7);
- if (DataCache.getAllPresentations(MainActivity.this).isEmpty()) {
- ImportUtil.importPresentations(MainActivity.this, getAssets().open("ref_import_presentations.csv"));
- }
- dialog.setProgress(8);
- if (DataCache.getAllScientificSpecies(MainActivity.this).isEmpty()) {
- ImportUtil.importScientificSpecies(MainActivity.this, getAssets().open("ref_import_scientific_species.csv"));
- }
- dialog.setProgress(9);
- if (DataCache.getAllStates(MainActivity.this).isEmpty()) {
- ImportUtil.importStates(MainActivity.this, getAssets().open("ref_import_states.csv"));
- }
- dialog.setProgress(10);
- if (DataCache.getAllVessels(MainActivity.this).isEmpty()) {
- ImportUtil.importVessels(MainActivity.this, getAssets().open("ref_import_vessels.csv"));
- }
- dialog.setProgress(11);
-
- } catch (IOException e) {
- Log.e(TAG, "error on initial import", e);
-
- } finally {
- dialog.dismiss();
- }
- }
- }).start();
-
- }
-
- protected void bigfinConnected() {
- disconnectButton.setVisibility(View.VISIBLE);
- connectButton.setVisibility(View.GONE);
- }
-
- protected void bigfinDisconnected() {
- connectButton.setVisibility(View.VISIBLE);
- disconnectButton.setVisibility(View.GONE);
- }
-
-// @Override
-// public synchronized void onResume() {
-// super.onResume();
-//
-// // Performing this check in onResume() covers the case in which BT was
-// // not enabled during onStart(), so we were paused to enable it...
-// // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
-// if (mBFCommunicationService != null) {
-// // Only if the state is STATE_NONE, do we know that we haven't started already
-// if (mBFCommunicationService.getState() == BigFinCommunicationService.STATE_NONE) {
-// // Start the Bluetooth chat services
-// mBFCommunicationService.start();
-// selectDevice();
-// }
-// }
-// }
-
- @Override
- protected Integer getContentView() {
- return R.layout.main;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return null;
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- switch (requestCode) {
- case REQUEST_CONNECT_ICHTYOMETER:
- // When DeviceListActivity returns with a device to connect
-// if (resultCode == Activity.RESULT_OK) {
-// connectDevice(data);
-// }
- break;
-
- case REQUEST_ENABLE_BT:
- // When the request to enable Bluetooth returns
- if (resultCode == Activity.RESULT_OK) {
- // Bluetooth is now enabled, so open the device list
- selectDevice();
-
- } else {
- // User did not enable Bluetooth or an error occurred
- Log.d(TAG, "BT not enabled");
- Toast.makeText(this, R.string.bt_not_enabled, Toast.LENGTH_SHORT).show();
- }
- break;
-
- }
-
- }
-
- public void openContexts(View source) {
- startActivity(new Intent(this, ContextsActivity.class));
- }
-
- public void connectIchtyometer(View source) {
- // If BT is not on, request that it be enabled.
- if (!mBluetoothAdapter.isEnabled()) {
- Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
-
- } else {
- selectDevice();
- }
- }
-
- public void disconnectIchtyometer(View source) {
- Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_DISCONNECT_DEVICE);
- try {
- mServiceMessenger.send(message);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
-
- public void openSettings(View source) {
- startActivity(new Intent(this, SettingsActivity.class));
- }
-
- protected void selectDevice() {
- // Launch the DeviceListActivity to see devices and do scan
- Intent serverIntent = new Intent(this, DeviceListActivity.class);
- startActivityForResult(serverIntent, REQUEST_CONNECT_ICHTYOMETER);
- }
-
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/MainActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/MainActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,259 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.bluetooth.BluetoothAdapter;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
+import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
+import fr.ifremer.wlo.preferences.SettingsActivity;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+
+import java.io.IOException;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MainActivity extends WloBaseActivity {
+
+ private static final String TAG = "MainActivity";
+
+ protected static final int REQUEST_ENABLE_BT = 1;
+ protected static final int REQUEST_CONNECT_ICHTYOMETER = 2;
+
+ // Local Bluetooth adapter
+ protected BluetoothAdapter mBluetoothAdapter = null;
+
+ protected Button connectButton;
+ protected Button disconnectButton;
+ protected ProgressDialog dialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "create");
+
+ mMessenger = new Messenger(new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
+ switch (msg.arg1) {
+ case BigFinCommunicationService.STATE_CONNECTED:
+ bigfinConnected();
+ break;
+
+ case BigFinCommunicationService.STATE_LISTEN:
+ case BigFinCommunicationService.STATE_NONE:
+ bigfinDisconnected();
+ break;
+ }
+ break;
+
+ case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
+ case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
+ bigfinDisconnected();
+ break;
+ }
+ }
+ });
+
+ super.onCreate(savedInstanceState);
+
+ // Get local Bluetooth adapter
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // If the adapter is null, then Bluetooth is not supported
+ if (mBluetoothAdapter == null) {
+ findViewById(R.id.main_connect_ichtyometer_button).setEnabled(false);
+ }
+
+ connectButton = (Button) findViewById(R.id.main_connect_ichtyometer_button);
+ disconnectButton = (Button) findViewById(R.id.main_disconnect_ichtyometer_button);
+ bigfinDisconnected();
+
+ dialog = new ProgressDialog(this);
+ dialog.setIndeterminate(false);
+ dialog.setCancelable(false);
+ dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ dialog.setMax(11);
+ dialog.setMessage(getString(R.string.main_loading_referential));
+ dialog.show();
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (DataCache.getAllAges(MainActivity.this).isEmpty()) {
+ ImportUtil.importAges(MainActivity.this, getAssets().open("ref_import_ages.csv"));
+ }
+ dialog.setProgress(1);
+ if (DataCache.getAllCommercialSpecies(MainActivity.this).isEmpty()) {
+ ImportUtil.importCommercialSpecies(MainActivity.this, getAssets().open("ref_import_commercial_species.csv"));
+ }
+ dialog.setProgress(2);
+ if (DataCache.getAllGenders(MainActivity.this).isEmpty()) {
+ ImportUtil.importGenders(MainActivity.this, getAssets().open("ref_import_genders.csv"));
+ }
+ dialog.setProgress(3);
+ if (DataCache.getAllLocations(MainActivity.this).isEmpty()) {
+ ImportUtil.importLocations(MainActivity.this, getAssets().open("ref_import_locations.csv"));
+ }
+ dialog.setProgress(4);
+ if (DataCache.getAllMaturities(MainActivity.this).isEmpty()) {
+ ImportUtil.importMaturities(MainActivity.this, getAssets().open("ref_import_maturities.csv"));
+ }
+ dialog.setProgress(5);
+ if (DataCache.getAllMensurations(MainActivity.this).isEmpty()) {
+ ImportUtil.importMensurations(MainActivity.this, getAssets().open("ref_import_mensurations.csv"));
+ }
+ dialog.setProgress(6);
+ if (DataCache.getAllMetiers(MainActivity.this).isEmpty()) {
+ ImportUtil.importMetiers(MainActivity.this, getAssets().open("ref_import_metiers.csv"));
+ }
+ dialog.setProgress(7);
+ if (DataCache.getAllPresentations(MainActivity.this).isEmpty()) {
+ ImportUtil.importPresentations(MainActivity.this, getAssets().open("ref_import_presentations.csv"));
+ }
+ dialog.setProgress(8);
+ if (DataCache.getAllScientificSpecies(MainActivity.this).isEmpty()) {
+ ImportUtil.importScientificSpecies(MainActivity.this, getAssets().open("ref_import_scientific_species.csv"));
+ }
+ dialog.setProgress(9);
+ if (DataCache.getAllStates(MainActivity.this).isEmpty()) {
+ ImportUtil.importStates(MainActivity.this, getAssets().open("ref_import_states.csv"));
+ }
+ dialog.setProgress(10);
+ if (DataCache.getAllVessels(MainActivity.this).isEmpty()) {
+ ImportUtil.importVessels(MainActivity.this, getAssets().open("ref_import_vessels.csv"));
+ }
+ dialog.setProgress(11);
+
+ } catch (IOException e) {
+ Log.e(TAG, "error on initial import", e);
+
+ } finally {
+ dialog.dismiss();
+ }
+ }
+ }).start();
+
+ }
+
+ protected void bigfinConnected() {
+ disconnectButton.setVisibility(View.VISIBLE);
+ connectButton.setVisibility(View.GONE);
+ }
+
+ protected void bigfinDisconnected() {
+ connectButton.setVisibility(View.VISIBLE);
+ disconnectButton.setVisibility(View.GONE);
+ }
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.main;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return null;
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ switch (requestCode) {
+ case REQUEST_CONNECT_ICHTYOMETER:
+ // When DeviceListActivity returns with a device to connect
+// if (resultCode == Activity.RESULT_OK) {
+// connectDevice(data);
+// }
+ break;
+
+ case REQUEST_ENABLE_BT:
+ // When the request to enable Bluetooth returns
+ if (resultCode == Activity.RESULT_OK) {
+ // Bluetooth is now enabled, so open the device list
+ selectDevice();
+
+ } else {
+ // User did not enable Bluetooth or an error occurred
+ Log.d(TAG, "BT not enabled");
+ Toast.makeText(this, R.string.bt_not_enabled, Toast.LENGTH_SHORT).show();
+ }
+ break;
+
+ }
+
+ }
+
+ public void openContexts(View source) {
+ startActivity(new Intent(this, ContextsActivity.class));
+ }
+
+ public void connectIchtyometer(View source) {
+ // If BT is not on, request that it be enabled.
+ if (!mBluetoothAdapter.isEnabled()) {
+ Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
+
+ } else {
+ selectDevice();
+ }
+ }
+
+ public void disconnectIchtyometer(View source) {
+ Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_DISCONNECT_DEVICE);
+ try {
+ mServiceMessenger.send(message);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+
+ public void openSettings(View source) {
+ startActivity(new Intent(this, SettingsActivity.class));
+ }
+
+ protected void selectDevice() {
+ // Launch the DeviceListActivity to see devices and do scan
+ Intent serverIntent = new Intent(this, DeviceListActivity.class);
+ startActivityForResult(serverIntent, REQUEST_CONNECT_ICHTYOMETER);
+ }
+
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MetierFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,56 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.util.Log;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.storage.DataCache;
-
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetierFormActivity extends WloModelEditionActivity<MetierModel> {
-
- private static final String TAG = "MetierFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.metier_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MetiersActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return CommercialSpeciesFormActivity.class;
- }
-
- @Override
- protected MetierModel createNewModel() {
- return new MetierModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // init editors
- List<Metier> metiers = Lists.newArrayList(DataCache.getAllMetiers(this));
- initAutoCompleteTextView(R.id.metier_form_gear_species, MetierModel.COLUMN_GEAR_SPECIES, metiers);
-
- initEditText(R.id.metier_form_zone, MetierModel.COLUMN_ZONE);
- initEditText(R.id.metier_form_sample_row_code, MetierModel.COLUMN_SAMPLE_ROW_CODE);
-
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/MetierFormActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/MetierFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,80 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.util.Log;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.storage.DataCache;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetierFormActivity extends WloModelEditionActivity<MetierModel> {
+
+ private static final String TAG = "MetierFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.metier_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MetiersActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return CommercialSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected MetierModel createNewModel() {
+ return new MetierModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // init editors
+ List<Metier> metiers = Lists.newArrayList(DataCache.getAllMetiers(this));
+ initAutoCompleteTextView(R.id.metier_form_gear_species, MetierModel.COLUMN_GEAR_SPECIES, metiers);
+
+ initEditText(R.id.metier_form_zone, MetierModel.COLUMN_ZONE);
+ initEditText(R.id.metier_form_sample_row_code, MetierModel.COLUMN_SAMPLE_ROW_CODE);
+
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MetiersActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,65 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetiersActivity extends WloBaseListActivity<MetierModel> {
-
- private static final String TAG = "MetierActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { MetierModel.COLUMN_GEAR_SPECIES },
- new int[] { android.R.id.text1 }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllMetiers(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected MetierModel createNewModel(Cursor cursor) {
- return new MetierModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return MetierFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.metiers_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return VesselsActivity.class;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return CommercialSpeciesActivity.class;
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(1, WloItemListViewBinder.DataType.METIER);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/MetiersActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/MetiersActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,89 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetiersActivity extends WloBaseListActivity<MetierModel> {
+
+ private static final String TAG = "MetierActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { MetierModel.COLUMN_GEAR_SPECIES },
+ new int[] { android.R.id.text1 }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllMetiers(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected MetierModel createNewModel(Cursor cursor) {
+ return new MetierModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return MetierFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.metiers_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return VesselsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return CommercialSpeciesActivity.class;
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(1, WloItemListViewBinder.DataType.METIER);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,93 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.Intent;
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.View;
-import android.widget.ListView;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.measurement.MeasurementActivity;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesActivity extends WloBaseListActivity<ScientificSpeciesModel> {
-
- private static final String TAG = "ScientificSpeciesActivity";
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { ScientificSpeciesModel.COLUMN_NAME },
- new int[] { android.R.id.text1 }, 0);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- CommercialSpeciesModel parent = (CommercialSpeciesModel) parentModel;
- //TODO handle npe
- if (parent == null || parent.isSpeciesMix() || adapter.getCount() == 0) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.model_list_menu, menu);
- }
- return true;
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllScientificSpecies(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected ScientificSpeciesModel createNewModel(Cursor cursor) {
- return new ScientificSpeciesModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return ScientificSpeciesFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.scientific_species_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return MeasurementActivity.class;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return CommercialSpeciesActivity.class;
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- ScientificSpeciesModel model = createNewModel(l, position);
-
- Log.d(TAG, model.toString(this) + " clicked");
-
- Intent intent = new Intent(this, getNextActivity());
- intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
- startActivity(intent);
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(1, WloItemListViewBinder.DataType.SCIENTIFIC_SPECIES);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,117 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.View;
+import android.widget.ListView;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.measurement.MeasurementActivity;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesActivity extends WloBaseListActivity<ScientificSpeciesModel> {
+
+ private static final String TAG = "ScientificSpeciesActivity";
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { ScientificSpeciesModel.COLUMN_NAME },
+ new int[] { android.R.id.text1 }, 0);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ CommercialSpeciesModel parent = (CommercialSpeciesModel) parentModel;
+ //TODO handle npe
+ if (parent == null || parent.isSpeciesMix() || adapter.getCount() == 0) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.model_list_menu, menu);
+ }
+ return true;
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllScientificSpecies(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected ScientificSpeciesModel createNewModel(Cursor cursor) {
+ return new ScientificSpeciesModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return ScientificSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.scientific_species_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return MeasurementActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return CommercialSpeciesActivity.class;
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ ScientificSpeciesModel model = createNewModel(l, position);
+
+ Log.d(TAG, model.toString(this) + " clicked");
+
+ Intent intent = new Intent(this, getNextActivity());
+ intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
+ startActivity(intent);
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(1, WloItemListViewBinder.DataType.SCIENTIFIC_SPECIES);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,85 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.measurement.MeasurementActivity;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesFormActivity extends WloModelEditionActivity<ScientificSpeciesModel> {
-
- private static final String TAG = "ScientificSpeciesFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.scientific_species_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ScientificSpeciesActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return null;
- }
-
- @Override
- protected ScientificSpeciesModel createNewModel() {
- return new ScientificSpeciesModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // editors
-
- // init editors
- List<ScientificSpecies> scientificSpecies = Lists.newArrayList(DataCache.getAllScientificSpecies(this));
- initAutoCompleteTextView(R.id.scientific_species_form_name, ScientificSpeciesModel.COLUMN_NAME, scientificSpecies);
-
- CheckBox takingActivationEditor = (CheckBox) findViewById(R.id.scientific_species_form_takingActivation);
- takingActivationEditor.setChecked(model.isTakingActivation());
- takingActivationEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- model.setTakingActivation(b);
- }
- });
- }
-
- @Override
- public void validate(View view) {
- boolean newModel = model.isNew();
-
- WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
- woh.saveData(model);
- woh.close();
-
- if (newModel) {
- Intent intent = new Intent(this, MeasurementActivity.class);
- intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
- startActivity(intent);
-
- } else {
- finish();
- }
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,109 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.measurement.MeasurementActivity;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesFormActivity extends WloModelEditionActivity<ScientificSpeciesModel> {
+
+ private static final String TAG = "ScientificSpeciesFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.scientific_species_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ScientificSpeciesActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return null;
+ }
+
+ @Override
+ protected ScientificSpeciesModel createNewModel() {
+ return new ScientificSpeciesModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // editors
+
+ // init editors
+ List<ScientificSpecies> scientificSpecies = Lists.newArrayList(DataCache.getAllScientificSpecies(this));
+ initAutoCompleteTextView(R.id.scientific_species_form_name, ScientificSpeciesModel.COLUMN_NAME, scientificSpecies);
+
+ CheckBox takingActivationEditor = (CheckBox) findViewById(R.id.scientific_species_form_takingActivation);
+ takingActivationEditor.setChecked(model.isTakingActivation());
+ takingActivationEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ model.setTakingActivation(b);
+ }
+ });
+ }
+
+ @Override
+ public void validate(View view) {
+ boolean newModel = model.isNew();
+
+ WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
+ woh.saveData(model);
+ woh.close();
+
+ if (newModel) {
+ Intent intent = new Intent(this, MeasurementActivity.class);
+ intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
+ startActivity(intent);
+
+ } else {
+ finish();
+ }
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/VesselFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,103 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.TextView;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.HasCode;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Vessel;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.DatePickerFragment;
-import fr.ifremer.wlo.utils.UIUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselFormActivity extends WloModelEditionActivity<VesselModel> {
-
- private static final String TAG = "VesselFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.vessel_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return VesselsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return MetierFormActivity.class;
- }
-
- @Override
- protected VesselModel createNewModel() {
- return new VesselModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // init editors
- Collection<Vessel> vessels = DataCache.getAllVessels(this);
- List<String> vesselCodes = Lists.newArrayList(Collections2.transform(vessels, HasCode.GET_CODE_FUNCTION));
- final Map<String, Vessel> vesselsByCode = Maps.uniqueIndex(vessels, HasCode.GET_CODE_FUNCTION);
- initAutoCompleteTextView(R.id.vessel_form_registration_number, VesselModel.COLUMN_REGISTRATION_NUMBER, vesselCodes);
-
- initEditText(R.id.vessel_form_name, VesselModel.COLUMN_NAME);
-
- List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
- initAutoCompleteTextView(R.id.vessel_form_landing_location, VesselModel.COLUMN_LANDING_LOCATION, locations);
-
- EditText landingDateEditor = (EditText) findViewById(R.id.vessel_form_landing_date);
- // landing date
- Calendar landingDate = model.getLandingDate();
- if (landingDate != null) {
- String dateFormat = UIUtils.getDateFormat(this);
- landingDateEditor.setText(String.format(dateFormat, landingDate.getTime()));
- }
-
- model.addPropertyChangeListener(VesselModel.COLUMN_REGISTRATION_NUMBER, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- Log.d(TAG, "registration number changed ! " + event.getNewValue());
- VesselModel vesselModel = (VesselModel) event.getSource();
- Log.d(TAG, "name " + vesselModel.getName());
- if (StringUtils.isEmpty(vesselModel.getName())) {
- String newCode = (String) event.getNewValue();
- Vessel vessel = vesselsByCode.get(newCode);
- vesselModel.setName(vessel != null ? vessel.getName() : getString(R.string.undefined));
- }
- }
- });
-
- }
-
- /* Method called by the view */
-
- public void pickLandingDate(View v) {
- DialogFragment newFragment = new DatePickerFragment(model, VesselModel.COLUMN_LANDING_DATE, (TextView) v);
- newFragment.show(getSupportFragmentManager(), "datePicker");
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/VesselFormActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/VesselFormActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,127 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.referentials.HasCode;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Vessel;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.DatePickerFragment;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselFormActivity extends WloModelEditionActivity<VesselModel> {
+
+ private static final String TAG = "VesselFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.vessel_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return VesselsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return MetierFormActivity.class;
+ }
+
+ @Override
+ protected VesselModel createNewModel() {
+ return new VesselModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // init editors
+ Collection<Vessel> vessels = DataCache.getAllVessels(this);
+ List<String> vesselCodes = Lists.newArrayList(Collections2.transform(vessels, HasCode.GET_CODE_FUNCTION));
+ final Map<String, Vessel> vesselsByCode = Maps.uniqueIndex(vessels, HasCode.GET_CODE_FUNCTION);
+ initAutoCompleteTextView(R.id.vessel_form_registration_number, VesselModel.COLUMN_REGISTRATION_NUMBER, vesselCodes);
+
+ initEditText(R.id.vessel_form_name, VesselModel.COLUMN_NAME);
+
+ List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
+ initAutoCompleteTextView(R.id.vessel_form_landing_location, VesselModel.COLUMN_LANDING_LOCATION, locations);
+
+ EditText landingDateEditor = (EditText) findViewById(R.id.vessel_form_landing_date);
+ // landing date
+ Calendar landingDate = model.getLandingDate();
+ if (landingDate != null) {
+ String dateFormat = UIUtils.getDateFormat(this);
+ landingDateEditor.setText(String.format(dateFormat, landingDate.getTime()));
+ }
+
+ model.addPropertyChangeListener(VesselModel.COLUMN_REGISTRATION_NUMBER, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ Log.d(TAG, "registration number changed ! " + event.getNewValue());
+ VesselModel vesselModel = (VesselModel) event.getSource();
+ Log.d(TAG, "name " + vesselModel.getName());
+ if (StringUtils.isEmpty(vesselModel.getName())) {
+ String newCode = (String) event.getNewValue();
+ Vessel vessel = vesselsByCode.get(newCode);
+ vesselModel.setName(vessel != null ? vessel.getName() : getString(R.string.undefined));
+ }
+ }
+ });
+
+ }
+
+ /* Method called by the view */
+
+ public void pickLandingDate(View v) {
+ DialogFragment newFragment = new DatePickerFragment(model, VesselModel.COLUMN_LANDING_DATE, (TextView) v);
+ newFragment.show(getSupportFragmentManager(), "datePicker");
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/VesselsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,54 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import fr.ifremer.wlo.models.VesselModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselsActivity extends WloBaseListActivity<VesselModel> {
-
- private static final String TAG = "VesselsActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, null,
- new String[] { VesselModel.COLUMN_REGISTRATION_NUMBER, VesselModel.COLUMN_NAME },
- new int[] { android.R.id.text1, android.R.id.text2 }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllVessels(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected VesselModel createNewModel(Cursor cursor) {
- return new VesselModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloBaseListActivity> getNextActivity() {
- return MetiersActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return VesselFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.vessels_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return LocationsActivity.class;
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/VesselsActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/VesselsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,78 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import fr.ifremer.wlo.models.VesselModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselsActivity extends WloBaseListActivity<VesselModel> {
+
+ private static final String TAG = "VesselsActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, null,
+ new String[] { VesselModel.COLUMN_REGISTRATION_NUMBER, VesselModel.COLUMN_NAME },
+ new int[] { android.R.id.text1, android.R.id.text2 }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllVessels(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected VesselModel createNewModel(Cursor cursor) {
+ return new VesselModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloBaseListActivity> getNextActivity() {
+ return MetiersActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return VesselFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.vessels_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return LocationsActivity.class;
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloBaseActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,107 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
-import android.util.Log;
-import android.view.View;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class WloBaseActivity extends ActionBarActivity implements ServiceConnection {
-
- private static final String TAG = "WloBaseActivity";
-
- protected Messenger mServiceMessenger = null;
- protected Messenger mMessenger = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Integer viewId = getContentView();
- if (viewId != null) {
- setContentView(viewId);
- }
-
- ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
-
- bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
- }
-
- @Override
- protected void onDestroy() {
- Log.d(TAG, "destroy");
- super.onDestroy();
- doUnbindService();
- }
-
- protected void doUnbindService() {
- Log.d(TAG, "doUnbindService");
- // If we have received the service, and hence registered with it, then now is the time to unregister.
- if (mServiceMessenger != null && mMessenger != null) {
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
- // Detach our existing connection.
- unbindService(this);
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mServiceMessenger = new Messenger(service);
- Log.d(TAG, "mMessenger " + mMessenger);
- if (mMessenger != null) {
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
- }
- catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- Log.d(TAG, "onServiceDisconnected");
- mServiceMessenger = null;
- }
-
- public void cancel(View view) {
- setResult(RESULT_CANCELED);
- finish();
- }
-
- protected abstract Integer getContentView();
-
- protected abstract Class<? extends WloBaseActivity> getUpActivity();
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Class upClass = getUpActivity();
- if (upClass == null) {
- return null;
- }
- Intent intent = new Intent(this, upClass);
- return intent;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/WloBaseActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,131 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
+import android.util.Log;
+import android.view.View;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class WloBaseActivity extends ActionBarActivity implements ServiceConnection {
+
+ private static final String TAG = "WloBaseActivity";
+
+ protected Messenger mServiceMessenger = null;
+ protected Messenger mMessenger = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Integer viewId = getContentView();
+ if (viewId != null) {
+ setContentView(viewId);
+ }
+
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
+ }
+
+ @Override
+ protected void onDestroy() {
+ Log.d(TAG, "destroy");
+ super.onDestroy();
+ doUnbindService();
+ }
+
+ protected void doUnbindService() {
+ Log.d(TAG, "doUnbindService");
+ // If we have received the service, and hence registered with it, then now is the time to unregister.
+ if (mServiceMessenger != null && mMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ // Detach our existing connection.
+ unbindService(this);
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mServiceMessenger = new Messenger(service);
+ Log.d(TAG, "mMessenger " + mMessenger);
+ if (mMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+ }
+ catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.d(TAG, "onServiceDisconnected");
+ mServiceMessenger = null;
+ }
+
+ public void cancel(View view) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
+ protected abstract Integer getContentView();
+
+ protected abstract Class<? extends WloBaseActivity> getUpActivity();
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Class upClass = getUpActivity();
+ if (upClass == null) {
+ return null;
+ }
+ Intent intent = new Intent(this, upClass);
+ return intent;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,445 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package fr.ifremer.wlo;
-
-import android.content.Intent;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.HierarchicalModel;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-/**
- * An activity that displays a list of items by binding to a data source such as
- * an array or Cursor, and exposes event handlers when the user selects an item.
- * <p>
- * ListActivity hosts a {@link android.widget.ListView ListView} object that can
- * be bound to different data sources, typically either an array or a Cursor
- * holding query results. Binding, screen layout, and row layout are discussed
- * in the following sections.
- * <p>
- * <strong>Screen Layout</strong>
- * </p>
- * <p>
- * ListActivity has a default layout that consists of a single, full-screen list
- * in the center of the screen. However, if you desire, you can customize the
- * screen layout by setting your own view layout with setContentView() in
- * onCreate(). To do this, your own view MUST contain a ListView object with the
- * id "@android:id/list" (or {@link android.R.id#list} if it's in code)
- * <p>
- * Optionally, your custom view can contain another view object of any type to
- * display when the list view is empty. This "empty list" notifier must have an
- * id "android:empty". Note that when an empty view is present, the list view
- * will be hidden when there is no data to display.
- * <p>
- * The following code demonstrates an (ugly) custom screen layout. It has a list
- * with a green background, and an alternate red "no data" message.
- * </p>
- *
- * <pre>
- * <?xml version="1.0" encoding="utf-8"?>
- * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- * android:orientation="vertical"
- * android:layout_width="fill_parent"
- * android:layout_height="fill_parent"
- * android:paddingLeft="8dp"
- * android:paddingRight="8dp">
- *
- * <ListView android:id="@id/android:list"
- * android:layout_width="fill_parent"
- * android:layout_height="fill_parent"
- * android:background="#00FF00"
- * android:layout_weight="1"
- * android:drawSelectorOnTop="false"/>
- *
- * <TextView id="@id/android:empty"
- * android:layout_width="fill_parent"
- * android:layout_height="fill_parent"
- * android:background="#FF0000"
- * android:text="No data"/>
- * </LinearLayout>
- * </pre>
- *
- * <p>
- * <strong>Row Layout</strong>
- * </p>
- * <p>
- * You can specify the layout of individual rows in the list. You do this by
- * specifying a layout resource in the ListAdapter object hosted by the activity
- * (the ListAdapter binds the ListView to the data; more on this later).
- * <p>
- * A ListAdapter constructor takes a parameter that specifies a layout resource
- * for each row. It also has two additional parameters that let you specify
- * which data field to associate with which object in the row layout resource.
- * These two parameters are typically parallel arrays.
- * </p>
- * <p>
- * Android provides some standard row layout resources. These are in the
- * {@link android.R.layout} class, and have names such as simple_list_item_1,
- * simple_list_item_2, and two_line_list_item. The following layout XML is the
- * source for the resource two_line_list_item, which displays two data
- * fields,one above the other, for each list row.
- * </p>
- *
- * <pre>
- * <?xml version="1.0" encoding="utf-8"?>
- * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- * android:layout_width="fill_parent"
- * android:layout_height="wrap_content"
- * android:orientation="vertical">
- *
- * <TextView android:id="@+id/text1"
- * android:textSize="16sp"
- * android:textStyle="bold"
- * android:layout_width="fill_parent"
- * android:layout_height="wrap_content"/>
- *
- * <TextView android:id="@+id/text2"
- * android:textSize="16sp"
- * android:layout_width="fill_parent"
- * android:layout_height="wrap_content"/>
- * </LinearLayout>
- * </pre>
- *
- * <p>
- * You must identify the data bound to each TextView object in this layout. The
- * syntax for this is discussed in the next section.
- * </p>
- * <p>
- * <strong>Binding to Data</strong>
- * </p>
- * <p>
- * You bind the ListActivity's ListView object to data using a class that
- * implements the {@link android.widget.ListAdapter ListAdapter} interface.
- * Android provides two standard list adapters:
- * {@link android.widget.SimpleAdapter SimpleAdapter} for static data (Maps),
- * and {@link android.widget.SimpleCursorAdapter SimpleCursorAdapter} for Cursor
- * query results.
- * </p>
- * <p>
- * The following code from a custom ListActivity demonstrates querying the
- * Contacts provider for all contacts, then binding the Name and Company fields
- * to a two line row layout in the activity's ListView.
- * </p>
- *
- * <pre>
- * public class MyListAdapter extends ListActivity {
- *
- * @Override
- * protected void onCreate(Bundle savedInstanceState){
- * super.onCreate(savedInstanceState);
- *
- * // We'll define a custom screen layout here (the one shown above), but
- * // typically, you could just use the standard ListActivity layout.
- * setContentView(R.layout.custom_list_activity_view);
- *
- * // Query for all people contacts using the {@link android.provider.Contacts.People} convenience class.
- * // Put a managed wrapper around the retrieved cursor so we don't have to worry about
- * // requerying or closing it as the activity changes state.
- * mCursor = People.query(this.getContentResolver(), null);
- * startManagingCursor(mCursor);
- *
- * // Now create a new list adapter bound to the cursor.
- * // SimpleListAdapter is designed for binding to a Cursor.
- * ListAdapter adapter = new SimpleCursorAdapter(
- * this, // Context.
- * android.R.layout.two_line_list_item, // Specify the row template to use (here, two columns bound to the two retrieved cursor
- * rows).
- * mCursor, // Pass in the cursor to bind to.
- * new String[] {People.NAME, People.COMPANY}, // Array of cursor columns to bind to.
- * new int[]); // Parallel array of which template objects to bind to those columns.
- *
- * // Bind to our new adapter.
- * setListAdapter(adapter);
- * }
- * }
- * </pre>
- *
- * @see #setListAdapter
- * @see android.widget.ListView
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class WloBaseListActivity<M extends BaseModel> extends WloBaseActivity implements AdapterView.OnItemLongClickListener {
-
- private static final String TAG = "WloBaseListActivity";
-
- public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
-
- protected BaseModel parentModel;
-
- protected WloSqlOpenHelper woh;
- protected SimpleCursorAdapter adapter;
-
- /**
- * This field should be made private, so it is hidden from the SDK.
- * {@hide}
- */
- protected ListView mList;
-
- private Handler mHandler = new Handler();
- private boolean mFinishedStart = false;
-
- private Runnable mRequestFocus = new Runnable() {
- public void run() {
- mList.focusableViewAvailable(mList);
- }
- };
-
- protected abstract SimpleCursorAdapter createAdapter();
-
- protected abstract Cursor getAllData();
-
- protected abstract M createNewModel(Cursor cursor);
-
- protected M createNewModel(AdapterView l, int position) {
- Cursor cursor = (Cursor) l.getItemAtPosition(position);
- M model = createNewModel(cursor);
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- hModel.setParent(parentModel);
- }
- return model;
- }
-
- protected abstract Class<? extends WloBaseActivity> getNextActivity();
-
- protected abstract Class<? extends WloModelEditionActivity> getEditionActivity();
-
- protected abstract Integer getSubtitle();
-
- @Override
- protected Integer getContentView() {
- return android.R.layout.list_content;
- }
-
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- return new WloItemListViewBinder(this);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- woh = new WloSqlOpenHelper(this);
- adapter = createAdapter();
-
- adapter.setViewBinder(getAdapterBinder());
-
- setListAdapter(adapter);
- getListView().setOnItemLongClickListener(this);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- parentModel = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
- if (parentModel != null) {
- Cursor cursor = getAllData();
- Log.d(TAG, "cursor size : " + cursor.getCount());
- adapter.swapCursor(cursor);
-
- Integer subtitleId = getSubtitle();
- if (subtitleId != null) {
- String subtitle = getString(subtitleId, parentModel.toString(this));
- getSupportActionBar().setSubtitle(subtitle);
- }
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- woh.close();
- }
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Intent intent = super.getSupportParentActivityIntent();
- if (intent != null && parentModel != null && HierarchicalModel.class.isAssignableFrom(parentModel.getClass())) {
- HierarchicalModel hParentModel = (HierarchicalModel) parentModel;
- intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hParentModel.getParent());
- }
- return intent;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.model_list_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.add_item:
- Intent intent = new Intent(this, getEditionActivity());
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
- startActivity(intent);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * This method will be called when an item in the list is selected.
- * Subclasses should override. Subclasses can call
- * getListView().getItemAtPosition(position) if they need to access the
- * data associated with the selected item.
- *
- * @param l The ListView where the click happened
- * @param v The view that was clicked within the ListView
- * @param position The position of the view in the list
- * @param id The row id of the item that was clicked
- */
- protected void onListItemClick(ListView l, View v, int position, long id) {
- M model = createNewModel(l, position);
-
- Log.d(TAG, model.toString(this) + " clicked");
-
- Intent intent = new Intent(this, getNextActivity());
- intent.putExtra(INTENT_EXTRA_PARENT_MODEL, model);
- startActivity(intent);
- }
-
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
- M model = createNewModel(parent, position);
-
- Log.d(TAG, model.toString(this) + " long clicked");
- Intent intent = new Intent(this, getEditionActivity());
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
- startActivity(intent);
- return true;
- }
-
- /**
- * Ensures the list view has been created before Activity restores all
- * of the view states.
- *
- */
- @Override
- protected void onRestoreInstanceState(Bundle state) {
- ensureList();
- super.onRestoreInstanceState(state);
- }
-
- /**
- * Updates the screen state (current list and other views) when the
- * content changes.
- *
- */
- @Override
- public void onSupportContentChanged() {
- super.onSupportContentChanged();
- View emptyView = findViewById(android.R.id.empty);
- mList = (ListView)findViewById(android.R.id.list);
- if (mList == null) {
- throw new RuntimeException(
- "Your content must have a ListView whose id attribute is " +
- "'android.R.id.list'");
- }
- if (emptyView != null) {
- mList.setEmptyView(emptyView);
- }
- mList.setOnItemClickListener(mOnClickListener);
- if (mFinishedStart) {
- setListAdapter(adapter);
- }
- mHandler.post(mRequestFocus);
- mFinishedStart = true;
- }
-
- /**
- * Provide the cursor for the list view.
- */
- public void setListAdapter(SimpleCursorAdapter adapter) {
- synchronized (this) {
- ensureList();
- this.adapter = adapter;
- mList.setAdapter(adapter);
- }
- }
-
- /**
- * Set the currently selected list item to the specified
- * position with the adapter's data
- *
- * @param position
- */
- public void setSelection(int position) {
- mList.setSelection(position);
- }
-
- /**
- * Get the position of the currently selected list item.
- */
- public int getSelectedItemPosition() {
- return mList.getSelectedItemPosition();
- }
-
- /**
- * Get the cursor row ID of the currently selected list item.
- */
- public long getSelectedItemId() {
- return mList.getSelectedItemId();
- }
-
- /**
- * Get the activity's list view widget.
- */
- public ListView getListView() {
- ensureList();
- return mList;
- }
-
- /**
- * Get the ListAdapter associated with this activity's ListView.
- */
- public ListAdapter getListAdapter() {
- return adapter;
- }
-
- private void ensureList() {
- if (mList != null) {
- return;
- }
- setContentView(android.R.layout.list_content);
-
- }
-
- private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView parent, View v, int position, long id)
- {
- onListItemClick((ListView)parent, v, position, id);
- }
- };
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/WloBaseListActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,469 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.HierarchicalModel;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+/**
+ * An activity that displays a list of items by binding to a data source such as
+ * an array or Cursor, and exposes event handlers when the user selects an item.
+ * <p>
+ * ListActivity hosts a {@link android.widget.ListView ListView} object that can
+ * be bound to different data sources, typically either an array or a Cursor
+ * holding query results. Binding, screen layout, and row layout are discussed
+ * in the following sections.
+ * <p>
+ * <strong>Screen Layout</strong>
+ * </p>
+ * <p>
+ * ListActivity has a default layout that consists of a single, full-screen list
+ * in the center of the screen. However, if you desire, you can customize the
+ * screen layout by setting your own view layout with setContentView() in
+ * onCreate(). To do this, your own view MUST contain a ListView object with the
+ * id "@android:id/list" (or {@link android.R.id#list} if it's in code)
+ * <p>
+ * Optionally, your custom view can contain another view object of any type to
+ * display when the list view is empty. This "empty list" notifier must have an
+ * id "android:empty". Note that when an empty view is present, the list view
+ * will be hidden when there is no data to display.
+ * <p>
+ * The following code demonstrates an (ugly) custom screen layout. It has a list
+ * with a green background, and an alternate red "no data" message.
+ * </p>
+ *
+ * <pre>
+ * <?xml version="1.0" encoding="utf-8"?>
+ * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ * android:orientation="vertical"
+ * android:layout_width="fill_parent"
+ * android:layout_height="fill_parent"
+ * android:paddingLeft="8dp"
+ * android:paddingRight="8dp">
+ *
+ * <ListView android:id="@id/android:list"
+ * android:layout_width="fill_parent"
+ * android:layout_height="fill_parent"
+ * android:background="#00FF00"
+ * android:layout_weight="1"
+ * android:drawSelectorOnTop="false"/>
+ *
+ * <TextView id="@id/android:empty"
+ * android:layout_width="fill_parent"
+ * android:layout_height="fill_parent"
+ * android:background="#FF0000"
+ * android:text="No data"/>
+ * </LinearLayout>
+ * </pre>
+ *
+ * <p>
+ * <strong>Row Layout</strong>
+ * </p>
+ * <p>
+ * You can specify the layout of individual rows in the list. You do this by
+ * specifying a layout resource in the ListAdapter object hosted by the activity
+ * (the ListAdapter binds the ListView to the data; more on this later).
+ * <p>
+ * A ListAdapter constructor takes a parameter that specifies a layout resource
+ * for each row. It also has two additional parameters that let you specify
+ * which data field to associate with which object in the row layout resource.
+ * These two parameters are typically parallel arrays.
+ * </p>
+ * <p>
+ * Android provides some standard row layout resources. These are in the
+ * {@link android.R.layout} class, and have names such as simple_list_item_1,
+ * simple_list_item_2, and two_line_list_item. The following layout XML is the
+ * source for the resource two_line_list_item, which displays two data
+ * fields,one above the other, for each list row.
+ * </p>
+ *
+ * <pre>
+ * <?xml version="1.0" encoding="utf-8"?>
+ * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ * android:layout_width="fill_parent"
+ * android:layout_height="wrap_content"
+ * android:orientation="vertical">
+ *
+ * <TextView android:id="@+id/text1"
+ * android:textSize="16sp"
+ * android:textStyle="bold"
+ * android:layout_width="fill_parent"
+ * android:layout_height="wrap_content"/>
+ *
+ * <TextView android:id="@+id/text2"
+ * android:textSize="16sp"
+ * android:layout_width="fill_parent"
+ * android:layout_height="wrap_content"/>
+ * </LinearLayout>
+ * </pre>
+ *
+ * <p>
+ * You must identify the data bound to each TextView object in this layout. The
+ * syntax for this is discussed in the next section.
+ * </p>
+ * <p>
+ * <strong>Binding to Data</strong>
+ * </p>
+ * <p>
+ * You bind the ListActivity's ListView object to data using a class that
+ * implements the {@link android.widget.ListAdapter ListAdapter} interface.
+ * Android provides two standard list adapters:
+ * {@link android.widget.SimpleAdapter SimpleAdapter} for static data (Maps),
+ * and {@link android.widget.SimpleCursorAdapter SimpleCursorAdapter} for Cursor
+ * query results.
+ * </p>
+ * <p>
+ * The following code from a custom ListActivity demonstrates querying the
+ * Contacts provider for all contacts, then binding the Name and Company fields
+ * to a two line row layout in the activity's ListView.
+ * </p>
+ *
+ * <pre>
+ * public class MyListAdapter extends ListActivity {
+ *
+ * @Override
+ * protected void onCreate(Bundle savedInstanceState){
+ * super.onCreate(savedInstanceState);
+ *
+ * // We'll define a custom screen layout here (the one shown above), but
+ * // typically, you could just use the standard ListActivity layout.
+ * setContentView(R.layout.custom_list_activity_view);
+ *
+ * // Query for all people contacts using the {@link android.provider.Contacts.People} convenience class.
+ * // Put a managed wrapper around the retrieved cursor so we don't have to worry about
+ * // requerying or closing it as the activity changes state.
+ * mCursor = People.query(this.getContentResolver(), null);
+ * startManagingCursor(mCursor);
+ *
+ * // Now create a new list adapter bound to the cursor.
+ * // SimpleListAdapter is designed for binding to a Cursor.
+ * ListAdapter adapter = new SimpleCursorAdapter(
+ * this, // Context.
+ * android.R.layout.two_line_list_item, // Specify the row template to use (here, two columns bound to the two retrieved cursor
+ * rows).
+ * mCursor, // Pass in the cursor to bind to.
+ * new String[] {People.NAME, People.COMPANY}, // Array of cursor columns to bind to.
+ * new int[]); // Parallel array of which template objects to bind to those columns.
+ *
+ * // Bind to our new adapter.
+ * setListAdapter(adapter);
+ * }
+ * }
+ * </pre>
+ *
+ * @see #setListAdapter
+ * @see android.widget.ListView
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class WloBaseListActivity<M extends BaseModel> extends WloBaseActivity implements AdapterView.OnItemLongClickListener {
+
+ private static final String TAG = "WloBaseListActivity";
+
+ public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
+
+ protected BaseModel parentModel;
+
+ protected WloSqlOpenHelper woh;
+ protected SimpleCursorAdapter adapter;
+
+ /**
+ * This field should be made private, so it is hidden from the SDK.
+ * {@hide}
+ */
+ protected ListView mList;
+
+ private Handler mHandler = new Handler();
+ private boolean mFinishedStart = false;
+
+ private Runnable mRequestFocus = new Runnable() {
+ public void run() {
+ mList.focusableViewAvailable(mList);
+ }
+ };
+
+ protected abstract SimpleCursorAdapter createAdapter();
+
+ protected abstract Cursor getAllData();
+
+ protected abstract M createNewModel(Cursor cursor);
+
+ protected M createNewModel(AdapterView l, int position) {
+ Cursor cursor = (Cursor) l.getItemAtPosition(position);
+ M model = createNewModel(cursor);
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ hModel.setParent(parentModel);
+ }
+ return model;
+ }
+
+ protected abstract Class<? extends WloBaseActivity> getNextActivity();
+
+ protected abstract Class<? extends WloModelEditionActivity> getEditionActivity();
+
+ protected abstract Integer getSubtitle();
+
+ @Override
+ protected Integer getContentView() {
+ return android.R.layout.list_content;
+ }
+
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ return new WloItemListViewBinder(this);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ woh = new WloSqlOpenHelper(this);
+ adapter = createAdapter();
+
+ adapter.setViewBinder(getAdapterBinder());
+
+ setListAdapter(adapter);
+ getListView().setOnItemLongClickListener(this);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ parentModel = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
+ if (parentModel != null) {
+ Cursor cursor = getAllData();
+ Log.d(TAG, "cursor size : " + cursor.getCount());
+ adapter.swapCursor(cursor);
+
+ Integer subtitleId = getSubtitle();
+ if (subtitleId != null) {
+ String subtitle = getString(subtitleId, parentModel.toString(this));
+ getSupportActionBar().setSubtitle(subtitle);
+ }
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ woh.close();
+ }
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Intent intent = super.getSupportParentActivityIntent();
+ if (intent != null && parentModel != null && HierarchicalModel.class.isAssignableFrom(parentModel.getClass())) {
+ HierarchicalModel hParentModel = (HierarchicalModel) parentModel;
+ intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hParentModel.getParent());
+ }
+ return intent;
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.model_list_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.add_item:
+ Intent intent = new Intent(this, getEditionActivity());
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
+ startActivity(intent);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * This method will be called when an item in the list is selected.
+ * Subclasses should override. Subclasses can call
+ * getListView().getItemAtPosition(position) if they need to access the
+ * data associated with the selected item.
+ *
+ * @param l The ListView where the click happened
+ * @param v The view that was clicked within the ListView
+ * @param position The position of the view in the list
+ * @param id The row id of the item that was clicked
+ */
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ M model = createNewModel(l, position);
+
+ Log.d(TAG, model.toString(this) + " clicked");
+
+ Intent intent = new Intent(this, getNextActivity());
+ intent.putExtra(INTENT_EXTRA_PARENT_MODEL, model);
+ startActivity(intent);
+ }
+
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ M model = createNewModel(parent, position);
+
+ Log.d(TAG, model.toString(this) + " long clicked");
+ Intent intent = new Intent(this, getEditionActivity());
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
+ startActivity(intent);
+ return true;
+ }
+
+ /**
+ * Ensures the list view has been created before Activity restores all
+ * of the view states.
+ *
+ */
+ @Override
+ protected void onRestoreInstanceState(Bundle state) {
+ ensureList();
+ super.onRestoreInstanceState(state);
+ }
+
+ /**
+ * Updates the screen state (current list and other views) when the
+ * content changes.
+ *
+ */
+ @Override
+ public void onSupportContentChanged() {
+ super.onSupportContentChanged();
+ View emptyView = findViewById(android.R.id.empty);
+ mList = (ListView)findViewById(android.R.id.list);
+ if (mList == null) {
+ throw new RuntimeException(
+ "Your content must have a ListView whose id attribute is " +
+ "'android.R.id.list'");
+ }
+ if (emptyView != null) {
+ mList.setEmptyView(emptyView);
+ }
+ mList.setOnItemClickListener(mOnClickListener);
+ if (mFinishedStart) {
+ setListAdapter(adapter);
+ }
+ mHandler.post(mRequestFocus);
+ mFinishedStart = true;
+ }
+
+ /**
+ * Provide the cursor for the list view.
+ */
+ public void setListAdapter(SimpleCursorAdapter adapter) {
+ synchronized (this) {
+ ensureList();
+ this.adapter = adapter;
+ mList.setAdapter(adapter);
+ }
+ }
+
+ /**
+ * Set the currently selected list item to the specified
+ * position with the adapter's data
+ *
+ * @param position
+ */
+ public void setSelection(int position) {
+ mList.setSelection(position);
+ }
+
+ /**
+ * Get the position of the currently selected list item.
+ */
+ public int getSelectedItemPosition() {
+ return mList.getSelectedItemPosition();
+ }
+
+ /**
+ * Get the cursor row ID of the currently selected list item.
+ */
+ public long getSelectedItemId() {
+ return mList.getSelectedItemId();
+ }
+
+ /**
+ * Get the activity's list view widget.
+ */
+ public ListView getListView() {
+ ensureList();
+ return mList;
+ }
+
+ /**
+ * Get the ListAdapter associated with this activity's ListView.
+ */
+ public ListAdapter getListAdapter() {
+ return adapter;
+ }
+
+ private void ensureList() {
+ if (mList != null) {
+ return;
+ }
+ setContentView(android.R.layout.list_content);
+
+ }
+
+ private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView parent, View v, int position, long id)
+ {
+ onListItemClick((ListView)parent, v, position, id);
+ }
+ };
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,262 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.EditText;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.HierarchicalModel;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.utils.BaseTextWatcher;
-import fr.ifremer.wlo.utils.UIUtils;
-import org.apache.commons.lang3.ObjectUtils;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class WloModelEditionActivity<M extends BaseModel> extends WloBaseActivity {
-
- private static final String TAG = "WloModelEditionActivity";
-
- public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
- public static final String INTENT_EXTRA_MODEL = "model";
-
- protected M model;
-
- protected abstract Class<? extends WloModelEditionActivity> getNextEditionActivity();
-
- protected abstract M createNewModel();
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // model
- model = (M) getIntent().getSerializableExtra(INTENT_EXTRA_MODEL);
- if (model == null) {
- model = createNewModel();
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- BaseModel parent = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
- HierarchicalModel hModel = (HierarchicalModel) model;
- hModel.setParent(parent);
- }
-
- } else {
- setTitle(model.toString(this));
- }
- }
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Intent intent = super.getSupportParentActivityIntent();
- if (intent != null && HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hModel.getParent());
- }
- return intent;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.form_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.new_item:
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == AlertDialog.BUTTON_POSITIVE) {
- saveModel();
- }
- Intent intent = new Intent(WloModelEditionActivity.this, WloModelEditionActivity.this.getClass());
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- BaseModel parentModel = hModel.getParent();
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
- }
- startActivity(intent);
- }
- };
- builder.setMessage(R.string.exit_form_confirmation)
- .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener())
- .setNeutralButton(R.string.no, listener)
- .setPositiveButton(R.string.yes, listener)
- .create()
- .show();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
-
- /* Method called by the view */
-
- public void validate(View view) {
- boolean newModel = model.isNew();
-
- Multimap<BaseModel.ErrorType, String> errors = model.checkValidity();
-
- if (errors.isEmpty()) {
- saveModel();
-
- if (newModel) {
- Intent intent = new Intent(this, getNextEditionActivity());
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, model);
- startActivity(intent);
-
- } else {
- Intent intent = new Intent();
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
- setResult(RESULT_OK, intent);
- finish();
- }
-
- } else {
- View root = findViewById(android.R.id.content);
-
- Collection<String> requiredFields = errors.get(BaseModel.ErrorType.REQUIRED);
- String errorMessage = getString(R.string.required_field_error_message);
- for (String field : requiredFields) {
- View v = root.findViewWithTag(field);
- if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
- ((EditText) v).setError(errorMessage);
- }
- }
-
- Collection<String> oneRequiredFields = errors.get(BaseModel.ErrorType.ONE_REQUIRED);
- errorMessage = getString(R.string.one_required_field_error_message);
- for (String field : oneRequiredFields) {
- View v = root.findViewWithTag(field);
- if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
- ((EditText) v).setError(errorMessage);
- }
- }
- }
- }
-
- /* Protected methods */
-
- protected void saveModel() {
- WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
- woh.saveData(model);
- woh.close();
- }
-
- protected void initEditText(int editorId, final String attribute) {
- initEditText(editorId, attribute, null);
- }
-
- protected void initEditText(int editorId, final String attribute, String defaultValue) {
- EditText editText = (EditText) findViewById(editorId);
- initEditText(editText, attribute, defaultValue);
- }
-
- protected void initEditText(final EditText editText, final String attribute, String defaultValue) {
- final Class clazz = model.getClass();
- final String firtsLetterUpperCaseAttribute =
- attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
-
- editText.setTag(attribute);
-
- try {
- Object value = clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
- editText.setText(value != null ? value.toString() : defaultValue);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
-
- editText.addTextChangedListener(new BaseTextWatcher() {
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- try {
- clazz.getMethod("set" + firtsLetterUpperCaseAttribute, String.class).invoke(model, s.toString());
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
- editText.setError(null);
- }
- });
-
- model.addPropertyChangeListener(attribute, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- Object newValue = event.getNewValue();
- if (!editText.isFocused()) {
- editText.setText(newValue != null ? newValue.toString() : getString(R.string.undefined));
- editText.setError(null);
- }
- }
- });
- }
-
- protected <R> AutoCompleteTextView initAutoCompleteTextView(int autoCompleteTextViewId, final String attribute, Collection<R> data) {
- AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(autoCompleteTextViewId);
- initAutoCompleteTextView(autoCompleteTextView, attribute, data);
- return autoCompleteTextView;
- }
-
- protected <R> void initAutoCompleteTextView(AutoCompleteTextView autoCompleteTextView, final String attribute, Collection<R> data) {
- final Class clazz = model.getClass();
- final String firtsLetterUpperCaseAttribute =
- attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
-
- ArrayAdapter<R> adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, Lists.newArrayList(data));
- autoCompleteTextView.setAdapter(adapter);
-
- autoCompleteTextView.setThreshold(0);
- autoCompleteTextView.setTag(attribute);
-
- try {
- R value = (R) clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
- if (value != null) {
- autoCompleteTextView.setText(value.toString());
- autoCompleteTextView.setError(null);
- }
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
-
- autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- R selectedData = (R) parent.getItemAtPosition(position);
- try {
- clazz.getMethod("set" + firtsLetterUpperCaseAttribute, selectedData.getClass()).invoke(model, selectedData);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
- }
- });
-
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,286 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.EditText;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.HierarchicalModel;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.BaseTextWatcher;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class WloModelEditionActivity<M extends BaseModel> extends WloBaseActivity {
+
+ private static final String TAG = "WloModelEditionActivity";
+
+ public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
+ public static final String INTENT_EXTRA_MODEL = "model";
+
+ protected M model;
+
+ protected abstract Class<? extends WloModelEditionActivity> getNextEditionActivity();
+
+ protected abstract M createNewModel();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // model
+ model = (M) getIntent().getSerializableExtra(INTENT_EXTRA_MODEL);
+ if (model == null) {
+ model = createNewModel();
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ BaseModel parent = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ hModel.setParent(parent);
+ }
+
+ } else {
+ setTitle(model.toString(this));
+ }
+ }
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Intent intent = super.getSupportParentActivityIntent();
+ if (intent != null && HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hModel.getParent());
+ }
+ return intent;
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.form_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.new_item:
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == AlertDialog.BUTTON_POSITIVE) {
+ saveModel();
+ }
+ Intent intent = new Intent(WloModelEditionActivity.this, WloModelEditionActivity.this.getClass());
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ BaseModel parentModel = hModel.getParent();
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
+ }
+ startActivity(intent);
+ }
+ };
+ builder.setMessage(R.string.exit_form_confirmation)
+ .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener())
+ .setNeutralButton(R.string.no, listener)
+ .setPositiveButton(R.string.yes, listener)
+ .create()
+ .show();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ /* Method called by the view */
+
+ public void validate(View view) {
+ boolean newModel = model.isNew();
+
+ Multimap<BaseModel.ErrorType, String> errors = model.checkValidity();
+
+ if (errors.isEmpty()) {
+ saveModel();
+
+ if (newModel) {
+ Intent intent = new Intent(this, getNextEditionActivity());
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, model);
+ startActivity(intent);
+
+ } else {
+ Intent intent = new Intent();
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+
+ } else {
+ View root = findViewById(android.R.id.content);
+
+ Collection<String> requiredFields = errors.get(BaseModel.ErrorType.REQUIRED);
+ String errorMessage = getString(R.string.required_field_error_message);
+ for (String field : requiredFields) {
+ View v = root.findViewWithTag(field);
+ if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
+ ((EditText) v).setError(errorMessage);
+ }
+ }
+
+ Collection<String> oneRequiredFields = errors.get(BaseModel.ErrorType.ONE_REQUIRED);
+ errorMessage = getString(R.string.one_required_field_error_message);
+ for (String field : oneRequiredFields) {
+ View v = root.findViewWithTag(field);
+ if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
+ ((EditText) v).setError(errorMessage);
+ }
+ }
+ }
+ }
+
+ /* Protected methods */
+
+ protected void saveModel() {
+ WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
+ woh.saveData(model);
+ woh.close();
+ }
+
+ protected void initEditText(int editorId, final String attribute) {
+ initEditText(editorId, attribute, null);
+ }
+
+ protected void initEditText(int editorId, final String attribute, String defaultValue) {
+ EditText editText = (EditText) findViewById(editorId);
+ initEditText(editText, attribute, defaultValue);
+ }
+
+ protected void initEditText(final EditText editText, final String attribute, String defaultValue) {
+ final Class clazz = model.getClass();
+ final String firtsLetterUpperCaseAttribute =
+ attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
+
+ editText.setTag(attribute);
+
+ try {
+ Object value = clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
+ editText.setText(value != null ? value.toString() : defaultValue);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+
+ editText.addTextChangedListener(new BaseTextWatcher() {
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ try {
+ clazz.getMethod("set" + firtsLetterUpperCaseAttribute, String.class).invoke(model, s.toString());
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+ editText.setError(null);
+ }
+ });
+
+ model.addPropertyChangeListener(attribute, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ Object newValue = event.getNewValue();
+ if (!editText.isFocused()) {
+ editText.setText(newValue != null ? newValue.toString() : getString(R.string.undefined));
+ editText.setError(null);
+ }
+ }
+ });
+ }
+
+ protected <R> AutoCompleteTextView initAutoCompleteTextView(int autoCompleteTextViewId, final String attribute, Collection<R> data) {
+ AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(autoCompleteTextViewId);
+ initAutoCompleteTextView(autoCompleteTextView, attribute, data);
+ return autoCompleteTextView;
+ }
+
+ protected <R> void initAutoCompleteTextView(AutoCompleteTextView autoCompleteTextView, final String attribute, Collection<R> data) {
+ final Class clazz = model.getClass();
+ final String firtsLetterUpperCaseAttribute =
+ attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
+
+ ArrayAdapter<R> adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, Lists.newArrayList(data));
+ autoCompleteTextView.setAdapter(adapter);
+
+ autoCompleteTextView.setThreshold(0);
+ autoCompleteTextView.setTag(attribute);
+
+ try {
+ R value = (R) clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
+ if (value != null) {
+ autoCompleteTextView.setText(value.toString());
+ autoCompleteTextView.setError(null);
+ }
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+
+ autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ R selectedData = (R) parent.getItemAtPosition(position);
+ try {
+ clazz.getMethod("set" + firtsLetterUpperCaseAttribute, selectedData.getClass()).invoke(model, selectedData);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+ }
+ });
+
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/GraphActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.widget.LinearLayout;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.WloBaseActivity;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import org.achartengine.ChartFactory;
-import org.achartengine.GraphicalView;
-import org.achartengine.chart.BarChart;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import java.text.NumberFormat;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class GraphActivity extends WloBaseActivity {
-
- private static final String TAG = "GraphActivity";
-
- public static final String INTENT_EXTRA_DATA = "data";
- public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
-
- protected MeasurementsModel measurements;
- protected GraphicalView mChartView;
- protected XYMultipleSeriesDataset mDataset;
- protected XYMultipleSeriesRenderer mRenderer;
-
- @Override
- protected Integer getContentView() {
- return R.layout.measurement_graph;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MeasurementActivity.class;
- }
-
- /* Activity methods */
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- LinearLayout root = (LinearLayout) findViewById(R.id.graphContainer);
-
- mDataset = new XYMultipleSeriesDataset();
- mRenderer = new XYMultipleSeriesRenderer();
-
- mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, BarChart.Type.DEFAULT);
- root.addView(mChartView);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
- XYSeries mCurrentSeries = (XYSeries) getIntent().getSerializableExtra(INTENT_EXTRA_DATA);
-
- XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
- mCurrentRenderer.setDisplayBoundingPoints(true);
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setDisplayChartValues(true);
-
- mRenderer.removeAllRenderers();
- mDataset.clear();
-
- mRenderer.addSeriesRenderer(mCurrentRenderer);
- mDataset.addSeries(mCurrentSeries);
-
- mChartView.repaint();
- }
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Intent intent = super.getSupportParentActivityIntent();
- if (intent != null) {
- intent.putExtra(MeasurementActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
- }
- return intent;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/GraphActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,114 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.LinearLayout;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.WloBaseActivity;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import org.achartengine.ChartFactory;
+import org.achartengine.GraphicalView;
+import org.achartengine.chart.BarChart;
+import org.achartengine.model.XYMultipleSeriesDataset;
+import org.achartengine.model.XYSeries;
+import org.achartengine.renderer.XYMultipleSeriesRenderer;
+import org.achartengine.renderer.XYSeriesRenderer;
+
+import java.text.NumberFormat;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class GraphActivity extends WloBaseActivity {
+
+ private static final String TAG = "GraphActivity";
+
+ public static final String INTENT_EXTRA_DATA = "data";
+ public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
+
+ protected MeasurementsModel measurements;
+ protected GraphicalView mChartView;
+ protected XYMultipleSeriesDataset mDataset;
+ protected XYMultipleSeriesRenderer mRenderer;
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.measurement_graph;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MeasurementActivity.class;
+ }
+
+ /* Activity methods */
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ LinearLayout root = (LinearLayout) findViewById(R.id.graphContainer);
+
+ mDataset = new XYMultipleSeriesDataset();
+ mRenderer = new XYMultipleSeriesRenderer();
+
+ mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, BarChart.Type.DEFAULT);
+ root.addView(mChartView);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
+ XYSeries mCurrentSeries = (XYSeries) getIntent().getSerializableExtra(INTENT_EXTRA_DATA);
+
+ XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
+ mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
+ mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
+ mCurrentRenderer.setDisplayBoundingPoints(true);
+ mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
+ mCurrentRenderer.setDisplayChartValues(true);
+
+ mRenderer.removeAllRenderers();
+ mDataset.clear();
+
+ mRenderer.addSeriesRenderer(mCurrentRenderer);
+ mDataset.addSeries(mCurrentSeries);
+
+ mChartView.repaint();
+ }
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Intent intent = super.getSupportParentActivityIntent();
+ if (intent != null) {
+ intent.putExtra(MeasurementActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
+ }
+ return intent;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/GraphFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,136 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import org.achartengine.ChartFactory;
-import org.achartengine.GraphicalView;
-import org.achartengine.chart.BarChart;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import java.text.NumberFormat;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since x.x
- */
-public class GraphFragment extends MeasurementsDisplayerFragment {
-
- private static final String TAG = "GraphFragment";
-
- protected GraphicalView mChartView;
- protected XYSeries mCurrentSeries;
- protected XYMultipleSeriesRenderer mRenderer;
-
- /* Fragment methods */
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View v = inflater.inflate(R.layout.measurement_graph_fragment, container, false);
- return v;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- LinearLayout root = (LinearLayout) getView();
-
- mCurrentSeries = new XYSeries(getString(R.string.measurement_graph_title));
- final XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();
- mDataset.addSeries(mCurrentSeries);
-
- XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
- mCurrentRenderer.setDisplayBoundingPoints(true);
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setDisplayChartValues(true);
-
- mRenderer = new XYMultipleSeriesRenderer();
- mRenderer.addSeriesRenderer(mCurrentRenderer);
- mRenderer.setZoomEnabled(false, false);
- mRenderer.setPanEnabled(false, false);
- mRenderer.setYAxisMin(0);
-
- mChartView = ChartFactory.getBarChartView(getActivity(), mDataset, mRenderer, BarChart.Type.DEFAULT);
- mChartView.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- Intent i = new Intent(getActivity(), GraphActivity.class);
- i.putExtra(GraphActivity.INTENT_EXTRA_DATA, mCurrentSeries);
- i.putExtra(GraphActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
- startActivity(i);
- return true;
- }
- });
-
- for (MeasurementModel measurement : measurements.getMeasurements().values()) {
- addMeasurement(measurement);
- }
-
- root.addView(mChartView);
-
- }
-
- /* MeasurementsListener methods */
-
- @Override
- public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
- addMeasurement(measurement);
- mChartView.repaint();
- }
-
- @Override
- public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
- int size = measurement.getSize();
-
- int nb = measurements.getMeasurementNb(size);
-
- int index = mCurrentSeries.getIndexForKey(size);
-
- mCurrentSeries.remove(index);
- mCurrentSeries.add(index, size, nb);
-
- mChartView.repaint();
- }
-
- /* Protected methods */
-
- protected void addMeasurement(MeasurementModel measurement) {
- int size = measurement.getSize();
- int nb = measurements.getMeasurementNb(size);
-
- int count = mCurrentSeries.getItemCount();
- if (size >= count) {
- for (int i = count ; i < size ; i++) {
- mCurrentSeries.add(i, 0);
- }
- mCurrentSeries.add(size, nb);
-
- } else {
- int index = mCurrentSeries.getIndexForKey(size);
- mCurrentSeries.remove(index);
- mCurrentSeries.add(index, size, nb);
- }
-
- updateAxis(size, nb);
- }
-
- protected void updateAxis(int size, int nb) {
- mRenderer.setXAxisMin(Math.min(mRenderer.getXAxisMin(), size - 1));
- mRenderer.setXAxisMax(Math.max(mRenderer.getXAxisMax(), size + 1));
- mRenderer.setYAxisMax(Math.max(mRenderer.getYAxisMax(), nb + 1));
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/GraphFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,171 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import org.achartengine.ChartFactory;
+import org.achartengine.GraphicalView;
+import org.achartengine.chart.BarChart;
+import org.achartengine.model.XYMultipleSeriesDataset;
+import org.achartengine.model.XYSeries;
+import org.achartengine.renderer.XYMultipleSeriesRenderer;
+import org.achartengine.renderer.XYSeriesRenderer;
+
+import java.text.NumberFormat;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since x.x
+ */
+public class GraphFragment extends MeasurementsDisplayerFragment {
+
+ private static final String TAG = "GraphFragment";
+
+ protected GraphicalView mChartView;
+ protected XYSeries mCurrentSeries;
+ protected XYMultipleSeriesRenderer mRenderer;
+
+ /* Fragment methods */
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ View v = inflater.inflate(R.layout.measurement_graph_fragment, container, false);
+ return v;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ LinearLayout root = (LinearLayout) getView();
+
+ mCurrentSeries = new XYSeries(getString(R.string.measurement_graph_title));
+ final XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();
+ mDataset.addSeries(mCurrentSeries);
+
+ XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
+ mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
+ mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
+ mCurrentRenderer.setDisplayBoundingPoints(true);
+ mCurrentRenderer.setDisplayChartValues(true);
+
+ mRenderer = new XYMultipleSeriesRenderer();
+ mRenderer.addSeriesRenderer(mCurrentRenderer);
+ mRenderer.setZoomEnabled(false, false);
+ mRenderer.setPanEnabled(false, false);
+ mRenderer.setYAxisMin(0);
+
+ mChartView = ChartFactory.getBarChartView(getActivity(), mDataset, mRenderer, BarChart.Type.DEFAULT);
+ mChartView.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Intent i = new Intent(getActivity(), GraphActivity.class);
+ i.putExtra(GraphActivity.INTENT_EXTRA_DATA, mCurrentSeries);
+ i.putExtra(GraphActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
+ startActivity(i);
+ return true;
+ }
+ });
+
+ for (MeasurementModel measurement : measurements.getMeasurements().values()) {
+ addMeasurement(measurement);
+ }
+
+ root.addView(mChartView);
+
+ }
+
+ /* MeasurementsListener methods */
+
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ addMeasurement(measurement);
+ mChartView.repaint();
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ int size = measurement.getSize();
+
+ int nb = measurements.getMeasurementNb(size);
+
+ Mensuration.Precision precision = measurements.getPrecision();
+ double dSize = (double) size / precision.getUnitDivider();
+ int index = mCurrentSeries.getIndexForKey(dSize);
+
+ mCurrentSeries.remove(index);
+ mCurrentSeries.add(index, dSize, nb);
+
+ mChartView.repaint();
+ }
+
+ /* Protected methods */
+
+ protected void addMeasurement(MeasurementModel measurement) {
+ int size = measurement.getSize();
+ int nb = measurements.getMeasurementNb(size);
+
+ Mensuration.Precision precision = measurements.getPrecision();
+ double dSize = (double) size / precision.getUnitDivider();
+ double step = (double) precision.getValue() / precision.getUnitDivider();
+ double count = mCurrentSeries.getItemCount();
+
+ if (precision.isDecimal()) {
+ count = count * precision.getValue() / precision.getUnitDivider();
+ }
+
+ if (dSize >= count) {
+ for (double i = count ; i < dSize ; i = i + step) {
+ mCurrentSeries.add(i, 0);
+ }
+ mCurrentSeries.add(dSize, nb);
+
+ } else {
+ int index = mCurrentSeries.getIndexForKey(dSize);
+ mCurrentSeries.remove(index);
+ mCurrentSeries.add(index, dSize, nb);
+ }
+
+ updateAxis(dSize, nb);
+ }
+
+ protected void updateAxis(double size, int nb) {
+ mRenderer.setXAxisMin(Math.min(mRenderer.getXAxisMin(), size - 1));
+ mRenderer.setXAxisMax(Math.max(mRenderer.getXAxisMax(), size + 1));
+ mRenderer.setYAxisMax(Math.max(mRenderer.getYAxisMax(), nb + 1));
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/LogsFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,122 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import com.google.common.base.Preconditions;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Date;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LogsFragment extends MeasurementsDisplayerFragment {
-
- private static final String TAG = "LogsFragment";
-
- protected ArrayAdapter<Log> adapter;
- protected AlertDialog.Builder dialogBuilder;
-
- /* Fragment methods */
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.measurement_logs_fragment, container, false);
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- Activity activity = getActivity();
- adapter = new ArrayAdapter<Log>(activity, android.R.layout.simple_list_item_1);
-
- dialogBuilder = new AlertDialog.Builder(activity)
- .setTitle(R.string.deletion_confirmation_title)
- .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener());
-
- // Find and set up the ListView for paired devices
- ListView logsList = (ListView) activity.findViewById(R.id.logs_list);
- logsList.setAdapter(adapter);
- logsList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
- final Log log = (Log) parent.getItemAtPosition(position);
-
- dialogBuilder.setMessage(getString(R.string.deletion_confirmation_message, log.toString()))
- .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- MeasurementModel measurement = log.getMeasurement();
- measurements.removeMeasurement(measurement);
- }
- })
- .create()
- .show();
- return true;
- }
- });
- }
-
- /* MeasurementsListener methods */
-
- @Override
- public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
- adapter.insert(new Log(measurement), 0);
- }
-
- @Override
- public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
- for (int i = 0 ; i < adapter.getCount() ; i++) {
- Log log = adapter.getItem(i);
- if (log.getMeasurement().equals(measurement)) {
- adapter.remove(log);
- break;
- }
- }
- }
-
- protected class Log {
-
- protected MeasurementModel measurement;
- protected Date date;
-
- private Log(MeasurementModel measurement) {
- Preconditions.checkNotNull(measurement);
- this.measurement = measurement;
- date = new Date();
- }
-
- public MeasurementModel getMeasurement() {
- return measurement;
- }
-
- @Override
- public String toString() {
- Context context = getActivity();
- String dateFormat = UIUtils.getDateFormat(getActivity()) +
- " " + getActivity().getString(R.string.fulltime_format);
- String result = String.format(dateFormat + " - %2$s - %3$s - %4$s - %5$s", date,
- measurement.getSize(),
- UIUtils.getStringOrUndefined(measurement.getGender(), context),
- UIUtils.getStringOrUndefined(measurement.getMaturity(), context),
- UIUtils.getStringOrUndefined(measurement.getAge(), context));
- return result;
- }
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/LogsFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,152 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.BaseModelArrayAdapter;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LogsFragment extends MeasurementsDisplayerFragment {
+
+ private static final String TAG = "LogsFragment";
+
+ protected ArrayAdapter<MeasurementModel> adapter;
+ protected AlertDialog.Builder dialogBuilder;
+
+ /* Fragment methods */
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.measurement_logs_fragment, container, false);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ Activity activity = getActivity();
+ adapter = new BaseModelArrayAdapter<MeasurementModel>(activity, android.R.layout.simple_list_item_1,
+ new Function<MeasurementModel, String>() {
+ @Override
+ public String apply(MeasurementModel measurement) {
+ Context context = getActivity();
+ String result = measurement.toString(context,measurements.getPrecision()) + "\n";
+
+ List<Object> cats = Lists.newArrayList();
+ Object cat1 = DataCache.getGenderById(context, measurement.getCategory1());
+ if (cat1 != null) {
+ cats.add(cat1);
+ }
+ Object cat2 = DataCache.getMaturityById(context, measurement.getCategory2());
+ if (cat2 != null) {
+ cats.add(cat2);
+ }
+ Object cat3 = DataCache.getAgeById(context, measurement.getCategory3());
+ if (cat3 != null) {
+ cats.add(cat3);
+ }
+ result += StringUtils.join(cats, " - ");
+ return result;
+ }
+ });
+
+ dialogBuilder = new AlertDialog.Builder(activity)
+ .setTitle(R.string.deletion_confirmation_title)
+ .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener());
+
+ // Find and set up the ListView for paired devices
+ ListView logsList = (ListView) activity.findViewById(R.id.logs_list);
+ logsList.setAdapter(adapter);
+ logsList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ final MeasurementModel measurement = (MeasurementModel) parent.getItemAtPosition(position);
+
+ dialogBuilder.setMessage(getString(R.string.deletion_confirmation_message,
+ measurement.toString(getActivity(), measurements.getPrecision())))
+ .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ measurements.removeMeasurement(measurement);
+ }
+ })
+ .create()
+ .show();
+ return true;
+ }
+ });
+
+ for (MeasurementModel measurement : measurements.getMeasurements().values()) {
+ onMeasurementAdded(measurements, measurement);
+ }
+ adapter.sort(new Comparator<MeasurementModel>() {
+ @Override
+ public int compare(MeasurementModel lhs, MeasurementModel rhs) {
+ return ObjectUtils.compare(rhs.getDate(), lhs.getDate());
+ }
+ });
+ }
+
+ /* MeasurementsListener methods */
+
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ adapter.insert(measurement, 0);
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ adapter.remove(measurement);
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,354 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.app.ActionBar;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.support.v4.app.ActionBarDrawerToggle;
-import android.support.v4.widget.DrawerLayout;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.RadioButton;
-import android.widget.RadioGroup;
-import android.widget.Spinner;
-import android.widget.TabHost;
-import android.widget.TextView;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.CommercialSpeciesFormActivity;
-import fr.ifremer.wlo.MainActivity;
-import fr.ifremer.wlo.MetierFormActivity;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.ScientificSpeciesActivity;
-import fr.ifremer.wlo.ScientificSpeciesFormActivity;
-import fr.ifremer.wlo.VesselFormActivity;
-import fr.ifremer.wlo.WloBaseActivity;
-import fr.ifremer.wlo.WloModelEditionActivity;
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.Maturity;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.Gender;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MeasurementActivity extends WloBaseActivity implements AdapterView.OnItemSelectedListener {
-
- private static final String TAG = "MeasurementActivity";
-
- public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
- public static final String INTENT_EXTRA_SCIENTIFIC_SPECIES = "scientificSpecies";
-
- protected static final String GRAPH_TAB = "graph";
- protected static final String TABLE_TAB = "table";
- protected static final String LOGS_TAB = "logs";
-
- protected TabHost tabs;
- protected EditText sizeText;
- protected ActionBarDrawerToggle mDrawerToggle;
-
- protected MeasurementModel measurement;
- protected MeasurementsModel measurements;
-
- protected ScientificSpeciesModel scientificSpecies;
- protected CommercialSpeciesModel commercialSpecies;
- protected MetierModel metier;
- protected VesselModel vessel;
-
- ListView mDrawerList;
-
- @Override
- protected Integer getContentView() {
- return R.layout.measurement;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ScientificSpeciesActivity.class;
- }
-
- /* Activity methods */
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
- if (measurements != null) {
- scientificSpecies = measurements.getScientificSpecies();
-
- } else {
- scientificSpecies = (ScientificSpeciesModel) getIntent().getSerializableExtra(INTENT_EXTRA_SCIENTIFIC_SPECIES);
- measurements = new MeasurementsModel();
- measurements.setScientificSpecies(scientificSpecies);
- }
- commercialSpecies = scientificSpecies.getParent();
- metier = commercialSpecies.getParent();
- vessel = metier.getParent();
- LocationModel location = vessel.getParent();
-
- tabs = (TabHost)findViewById(android.R.id.tabhost);
-
- tabs.setup();
-
- setupTab(R.id.graph, GRAPH_TAB, R.string.graph_tab);
- setupTab(R.id.table, TABLE_TAB, R.string.table_tab);
- setupTab(R.id.logs, LOGS_TAB, R.string.logs_tab);
-
- sizeText = (EditText) findViewById(R.id.size);
-
- Spinner genderSpinner = (Spinner) findViewById(R.id.gender_spinner);
- genderSpinner.setOnItemSelectedListener(this);
- List<Gender> genders = Lists.newArrayList(DataCache.getAllGenders(this));
- ArrayAdapter<Gender> gendersAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1, genders);
- genderSpinner.setAdapter(gendersAdapter);
-
- Spinner maturitySpinner = (Spinner) findViewById(R.id.maturity_spinner);
- maturitySpinner.setOnItemSelectedListener(this);
- List<Maturity> maturities = Lists.newArrayList(DataCache.getAllMaturities(this));
- ArrayAdapter<Maturity> maturitiesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1, maturities);
- maturitySpinner.setAdapter(maturitiesAdapter);
-
- Spinner ageSpinner = (Spinner) findViewById(R.id.age_spinner);
- ageSpinner.setOnItemSelectedListener(this);
- List<Age> ages = Lists.newArrayList(DataCache.getAllAges(this));
- ArrayAdapter<Age> agesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1, ages);
- ageSpinner.setAdapter(agesAdapter);
-
- initFishMeasurement(10, null);
-
- DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- mDrawerList = (ListView) findViewById(R.id.left_drawer);
-
- // Set the adapter for the list view
- setDrawerListAdapter();
-
- // Set the list's click listener
- mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
- mDrawerToggle = new ActionBarDrawerToggle(
- this, /* host Activity */
- mDrawerLayout, /* DrawerLayout object */
- R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
- R.string.drawer_open, /* "open drawer" description */
- R.string.drawer_close /* "close drawer" description */
- );
-
- // Set the drawer toggle as the DrawerListener
- mDrawerLayout.setDrawerListener(mDrawerToggle);
-
- ActionBar actionBar = getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
- actionBar.setTitle(vessel.toString(this) + " / " +
- metier.toString(this) + " / " +
- commercialSpecies.toString(this) + " / " +
- scientificSpecies.toString(this));
- actionBar.setSubtitle(commercialSpecies.getMeasurementMethod().toString(this));
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- // Sync the toggle state after onRestoreInstanceState has occurred.
- mDrawerToggle.syncState();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK) {
- switch (requestCode) {
- case 1:
- vessel = (VesselModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- case 2:
- metier = (MetierModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- case 3:
- commercialSpecies = (CommercialSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- case 4:
- scientificSpecies = (ScientificSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- }
- setDrawerListAdapter();
- }
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- mDrawerToggle.onConfigurationChanged(newConfig);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Pass the event to ActionBarDrawerToggle, if it returns
- // true, then it has handled the app icon touch event
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
- // Handle your other action bar items...
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
- switch(adapterView.getId()) {
- case R.id.gender_spinner:
- measurement.setGender((Gender) adapterView.getItemAtPosition(i));
- break;
- case R.id.maturity_spinner:
- measurement.setMaturity((Maturity) adapterView.getItemAtPosition(i));
- break;
- case R.id.age_spinner:
- measurement.setAge((Age) adapterView.getItemAtPosition(i));
- break;
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> adapterView) {
- }
-
- /* Public methods */
-
- public void incSize(View source) {
- measurement.incSize();
- }
-
- public void decSize(View source) {
- measurement.decSize();
- }
-
- public void addMeasurement(View source) {
- measurements.addMeasurement(measurement);
-
- Integer size = measurement.getSize();
- Gender gender = measurement.getGender();
- initFishMeasurement(size, gender);
- }
-
- /* Protected methods */
-
- protected void initFishMeasurement(Integer size, Gender gender) {
- measurement = new MeasurementModel();
- measurement.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String propertyName = event.getPropertyName();
-
- if (MeasurementModel.SIZE_PROPERTY.equals(propertyName)) {
- Integer newValue = (Integer) event.getNewValue();
- sizeText.setText(newValue != null ? newValue.toString() : null);
-
- } else if (MeasurementModel.GENDER_PROPERTY.equals(propertyName)) {
- Gender newValue = (Gender) event.getNewValue();
-// int radioId;
-// switch (newValue) {
-// case M:
-// radioId = R.id.genderMaleRadio;
-// break;
-// case F:
-// radioId = R.id.genderFemaleRadio;
-// break;
-// default:
-// radioId = R.id.genderUndefinedRadio;
-// }
-// genderGroup.check(radioId);
- }
- }
- });
- measurement.setSize(size);
- measurement.setGender(gender);
- }
-
- protected void setupTab(int contentId, String tag, int label) {
- View tabview = LayoutInflater.from(this).inflate(R.layout.tabs_bg, null);
- TextView tv = (TextView) tabview.findViewById(R.id.tabsText);
- tv.setText(label);
-
- TabHost.TabSpec content = tabs.newTabSpec(tag).setIndicator(tabview).setContent(contentId);
- tabs.addTab(content);
-
- MeasurementsDisplayerFragment fragment =
- (MeasurementsDisplayerFragment) getFragmentManager().findFragmentById(contentId);
- fragment.setMeasurements(measurements);
-
- }
-
- protected void setDrawerListAdapter() {
- mDrawerList.setAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_1,
- new String[]{
- getString(R.string.home_title),
- vessel.toString(this),
- metier.toString(this),
- commercialSpecies.toString(this),
- scientificSpecies.toString(this)
- }));
- }
-
- private class DrawerItemClickListener implements ListView.OnItemClickListener {
- @Override
- public void onItemClick(AdapterView parent, View view, int position, long id) {
- selectItem(position);
- }
- }
-
- /** Swaps fragments in the main content view */
- private void selectItem(int position) {
- Class clazz;
- BaseModel modelToEdit;
- switch (position) {
- case 0:
- clazz = MainActivity.class;
- modelToEdit = null;
- break;
- case 1:
- clazz = VesselFormActivity.class;
- modelToEdit = vessel;
- break;
- case 2:
- clazz = MetierFormActivity.class;
- modelToEdit = metier;
- break;
- case 3:
- clazz = CommercialSpeciesFormActivity.class;
- modelToEdit = commercialSpecies;
- break;
- case 4:
- clazz = ScientificSpeciesFormActivity.class;
- modelToEdit = scientificSpecies;
- break;
- default:
- clazz = null;
- modelToEdit = null;
- }
- Intent intent = new Intent(this, clazz);
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, modelToEdit);
- startActivityForResult(intent, position);
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,473 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.ActionBar;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.widget.DrawerLayout;
+import android.text.InputType;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.TabHost;
+import android.widget.TextView;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.CommercialSpeciesFormActivity;
+import fr.ifremer.wlo.MainActivity;
+import fr.ifremer.wlo.MetierFormActivity;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.ScientificSpeciesActivity;
+import fr.ifremer.wlo.ScientificSpeciesFormActivity;
+import fr.ifremer.wlo.VesselFormActivity;
+import fr.ifremer.wlo.WloBaseActivity;
+import fr.ifremer.wlo.WloModelEditionActivity;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.BaseTextWatcher;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MeasurementActivity extends WloBaseActivity implements AdapterView.OnItemSelectedListener {
+
+ private static final String TAG = "MeasurementActivity";
+
+ public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
+ public static final String INTENT_EXTRA_SCIENTIFIC_SPECIES = "scientificSpecies";
+
+ protected static final String GRAPH_TAB = "graph";
+ protected static final String TABLE_TAB = "table";
+ protected static final String LOGS_TAB = "logs";
+
+ protected WloSqlOpenHelper soh = new WloSqlOpenHelper(this);
+
+ protected TabHost tabs;
+ protected EditText sizeText;
+ protected ActionBarDrawerToggle mDrawerToggle;
+
+ protected MeasurementModel measurement;
+ protected MeasurementsModel measurements;
+
+ protected ScientificSpeciesModel scientificSpecies;
+ protected CommercialSpeciesModel commercialSpecies;
+ protected MetierModel metier;
+ protected VesselModel vessel;
+
+ ListView mDrawerList;
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.measurement;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ScientificSpeciesActivity.class;
+ }
+
+ /* Activity methods */
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
+ if (measurements != null) {
+ scientificSpecies = measurements.getScientificSpecies();
+
+ } else {
+ scientificSpecies = (ScientificSpeciesModel) getIntent().getSerializableExtra(INTENT_EXTRA_SCIENTIFIC_SPECIES);
+ measurements = new MeasurementsModel();
+ measurements.setScientificSpecies(scientificSpecies);
+
+ Cursor cursor = soh.getAllMeasurements(scientificSpecies.getId());
+ List<MeasurementModel> measurementList = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, MeasurementModel>() {
+ @Override
+ public MeasurementModel apply(Cursor cursor) {
+ return new MeasurementModel(cursor);
+ }
+ });
+ for (MeasurementModel measurement : measurementList) {
+ measurements.addMeasurement(measurement);
+ }
+ }
+ measurements.addMeasurementsListener(new MeasurementsModel.MeasurementsListener() {
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ soh.deleteMeasurement(measurement);
+ }
+ });
+
+ commercialSpecies = scientificSpecies.getParent();
+ measurements.setPrecision(commercialSpecies.getPrecision());
+ metier = commercialSpecies.getParent();
+ vessel = metier.getParent();
+
+ tabs = (TabHost)findViewById(android.R.id.tabhost);
+
+ tabs.setup();
+
+ setupTab(R.id.graph, GRAPH_TAB, R.string.graph_tab);
+ setupTab(R.id.table, TABLE_TAB, R.string.table_tab);
+ setupTab(R.id.logs, LOGS_TAB, R.string.logs_tab);
+
+ sizeText = (EditText) findViewById(R.id.size);
+ int inputType = InputType.TYPE_CLASS_NUMBER;
+ if (measurements.getPrecision().isDecimal()) {
+ inputType |= InputType.TYPE_NUMBER_FLAG_DECIMAL;
+ }
+ sizeText.setRawInputType(inputType);
+ sizeText.addTextChangedListener(new BaseTextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ Log.d(TAG, "beforetextchnage " + s);
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ Mensuration.Precision precision = measurements.getPrecision();
+ int multiplier = precision.getUnitDivider();
+ try {
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+ Number number = format.parse(s.toString());
+ double d = number.doubleValue();
+ int size = (int)(d * multiplier);
+ measurement.setSize(size);
+
+ } catch (ParseException e) {
+ Log.e(TAG, "ParseException ", e);
+ measurement.setSize(null);
+ }
+ }
+ });
+
+ Spinner genderSpinner = (Spinner) findViewById(R.id.gender_spinner);
+ genderSpinner.setOnItemSelectedListener(this);
+ List<Gender> genders = Lists.newArrayList(DataCache.getAllGenders(this));
+ ArrayAdapter<Gender> gendersAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, genders);
+ genderSpinner.setAdapter(gendersAdapter);
+
+ Spinner maturitySpinner = (Spinner) findViewById(R.id.maturity_spinner);
+ maturitySpinner.setOnItemSelectedListener(this);
+ List<Maturity> maturities = Lists.newArrayList(DataCache.getAllMaturities(this));
+ ArrayAdapter<Maturity> maturitiesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, maturities);
+ maturitySpinner.setAdapter(maturitiesAdapter);
+
+ Spinner ageSpinner = (Spinner) findViewById(R.id.age_spinner);
+ ageSpinner.setOnItemSelectedListener(this);
+ List<Age> ages = Lists.newArrayList(DataCache.getAllAges(this));
+ ArrayAdapter<Age> agesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, ages);
+ ageSpinner.setAdapter(agesAdapter);
+
+ initFishMeasurement(10 * measurements.getPrecision().getUnitDivider(), null, null, null);
+
+ DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerList = (ListView) findViewById(R.id.left_drawer);
+
+ // Set the adapter for the list view
+ setDrawerListAdapter();
+
+ // Set the list's click listener
+ mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
+ mDrawerToggle = new ActionBarDrawerToggle(
+ this, /* host Activity */
+ mDrawerLayout, /* DrawerLayout object */
+ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
+ R.string.drawer_open, /* "open drawer" description */
+ R.string.drawer_close /* "close drawer" description */
+ );
+
+ // Set the drawer toggle as the DrawerListener
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
+ actionBar.setTitle(commercialSpecies.toString(this) + " / " +
+ scientificSpecies.toString(this) + " / " +
+ commercialSpecies.getMeasurementMethod().toString(this) + " / " +
+ commercialSpecies.getPrecision());
+ actionBar.setSubtitle(vessel.toString(this) + " / " +
+ metier.toString(this));
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (resultCode == RESULT_OK) {
+ switch (requestCode) {
+ case 1:
+ vessel = (VesselModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ break;
+ case 2:
+ metier = (MetierModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ break;
+ case 3:
+ commercialSpecies = (CommercialSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ measurements.setPrecision(commercialSpecies.getPrecision());
+ break;
+ case 4:
+ scientificSpecies = (ScientificSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ break;
+ }
+ setDrawerListAdapter();
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Pass the event to ActionBarDrawerToggle, if it returns
+ // true, then it has handled the app icon touch event
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ // Handle your other action bar items...
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ soh.close();
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
+ BaseModel selected = (BaseModel) adapterView.getItemAtPosition(i);
+ switch(adapterView.getId()) {
+ case R.id.gender_spinner:
+ measurement.setCategory1(selected.getId());
+ break;
+ case R.id.maturity_spinner:
+ measurement.setCategory2(selected.getId());
+ break;
+ case R.id.age_spinner:
+ measurement.setCategory3(selected.getId());
+ break;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> adapterView) {
+ }
+
+ /* Public methods */
+
+ public void incSize(View source) {
+ measurement.incSize(measurements.getPrecision().getValue());
+ }
+
+ public void decSize(View source) {
+ measurement.decSize(measurements.getPrecision().getValue());
+ }
+
+ public void addMeasurement(View source) {
+ measurement.setDate(Calendar.getInstance());
+ measurement.roundSize(measurements.getPrecision());
+ soh.saveData(measurement);
+ measurements.addMeasurement(measurement);
+
+ Integer size = measurement.getSize();
+ String cat1 = measurement.getCategory1();
+ String cat2 = measurement.getCategory2();
+ String cat3 = measurement.getCategory3();
+ initFishMeasurement(size, cat1, cat2, cat3);
+ }
+
+ /* Protected methods */
+
+ protected void initFishMeasurement(Integer size, String cat1, String cat2, String cat3) {
+ measurement = new MeasurementModel();
+ measurement.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String propertyName = event.getPropertyName();
+
+ Object newValue = event.getNewValue();
+ switch(propertyName) {
+ case MeasurementModel.COLUMN_SIZE:
+ String text = null;
+ if (newValue != null) {
+ text = UIUtils.getFormattedSize((Integer) newValue, measurements.getPrecision());
+ }
+ sizeText.setText(text);
+ break;
+
+ case MeasurementModel.COLUMN_CATEGORY_1:
+ Spinner spinner = (Spinner) findViewById(R.id.gender_spinner);
+ ArrayAdapter adapter = (ArrayAdapter) spinner.getAdapter();
+ Object o = DataCache.getGenderById(MeasurementActivity.this, (String) newValue);
+ int position = adapter.getPosition(o);
+ spinner.setSelection(position);
+ break;
+
+ case MeasurementModel.COLUMN_CATEGORY_2:
+ newValue = event.getNewValue();
+ spinner = (Spinner) findViewById(R.id.maturity_spinner);
+ adapter = (ArrayAdapter) spinner.getAdapter();
+ o = DataCache.getMaturityById(MeasurementActivity.this, (String) newValue);
+ position = adapter.getPosition(o);
+ spinner.setSelection(position);
+ break;
+
+ case MeasurementModel.COLUMN_CATEGORY_3:
+ newValue = event.getNewValue();
+ spinner = (Spinner) findViewById(R.id.age_spinner);
+ adapter = (ArrayAdapter) spinner.getAdapter();
+ o = DataCache.getAgeById(MeasurementActivity.this, (String) newValue);
+ position = adapter.getPosition(o);
+ spinner.setSelection(position);
+ break;
+ }
+ }
+ });
+ measurement.setSize(size);
+ measurement.setCategory1(cat1);
+ measurement.setCategory2(cat2);
+ measurement.setCategory3(cat3);
+ measurement.setParent(scientificSpecies);
+ }
+
+ protected void setupTab(int contentId, String tag, int label) {
+ View tabview = LayoutInflater.from(this).inflate(R.layout.tabs_bg, null);
+ TextView tv = (TextView) tabview.findViewById(R.id.tabsText);
+ tv.setText(label);
+
+ TabHost.TabSpec content = tabs.newTabSpec(tag).setIndicator(tabview).setContent(contentId);
+ tabs.addTab(content);
+
+ MeasurementsDisplayerFragment fragment =
+ (MeasurementsDisplayerFragment) getFragmentManager().findFragmentById(contentId);
+ fragment.setMeasurements(measurements);
+
+ }
+
+ protected void setDrawerListAdapter() {
+ mDrawerList.setAdapter(new ArrayAdapter<String>(this,
+ android.R.layout.simple_list_item_1,
+ new String[]{
+ getString(R.string.home_title),
+ vessel.toString(this),
+ metier.toString(this),
+ commercialSpecies.toString(this),
+ scientificSpecies.toString(this)
+ }));
+ }
+
+ private class DrawerItemClickListener implements ListView.OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView parent, View view, int position, long id) {
+ selectItem(position);
+ }
+ }
+
+ /** Swaps fragments in the main content view */
+ private void selectItem(int position) {
+ Class clazz;
+ BaseModel modelToEdit;
+ switch (position) {
+ case 0:
+ clazz = MainActivity.class;
+ modelToEdit = null;
+ break;
+ case 1:
+ clazz = VesselFormActivity.class;
+ modelToEdit = vessel;
+ break;
+ case 2:
+ clazz = MetierFormActivity.class;
+ modelToEdit = metier;
+ break;
+ case 3:
+ clazz = CommercialSpeciesFormActivity.class;
+ modelToEdit = commercialSpecies;
+ break;
+ case 4:
+ clazz = ScientificSpeciesFormActivity.class;
+ modelToEdit = scientificSpecies;
+ break;
+ default:
+ clazz = null;
+ modelToEdit = null;
+ }
+ Intent intent = new Intent(this, clazz);
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, modelToEdit);
+ startActivityForResult(intent, position);
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,21 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.app.Fragment;
-import fr.ifremer.wlo.models.MeasurementsModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class MeasurementsDisplayerFragment extends Fragment
- implements MeasurementsModel.MeasurementsListener {
-
- private static final String TAG = "MeasurementsDisplayerFragment";
-
- protected MeasurementsModel measurements;
-
- public void setMeasurements(MeasurementsModel measurements) {
- this.measurements = measurements;
- this.measurements.addMeasurementsListener(this);
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,45 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Fragment;
+import fr.ifremer.wlo.models.MeasurementsModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class MeasurementsDisplayerFragment extends Fragment
+ implements MeasurementsModel.MeasurementsListener {
+
+ private static final String TAG = "MeasurementsDisplayerFragment";
+
+ protected MeasurementsModel measurements;
+
+ public void setMeasurements(MeasurementsModel measurements) {
+ this.measurements = measurements;
+ this.measurements.addMeasurementsListener(this);
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/TableAdapter.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,96 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-import fr.ifremer.wlo.R;
-
-import java.util.TreeMap;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class TableAdapter extends BaseAdapter {
-
- private static final String TAG = "TableAdapter";
-
- protected TreeMap<Integer, Integer> data = new TreeMap<Integer, Integer>();
- protected Context context;
-
- public TableAdapter(Context context) {
- this.context = context;
- }
-
- /* BaseAdapter methods */
-
- @Override
- public int getCount() {
- return data.size();
- }
-
- @Override
- public Object getItem(int position) {
- if (position < 0 || position >= data.size()) {
- return null;
- }
- return data.keySet().toArray()[position];
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder;
-
- if (convertView == null) {
- convertView = LayoutInflater.from(context)
- .inflate(R.layout.measurement_table_row, parent, false);
-// convertView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
-
- viewHolder = new ViewHolder();
- viewHolder.sizeText = (TextView) convertView.findViewById(R.id.table_size);
- viewHolder.nbText = (TextView) convertView.findViewById(R.id.table_nb);
- convertView.setTag(viewHolder);
-
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
-
- Integer size = (Integer) getItem(position);
- viewHolder.sizeText.setText(String.valueOf(size));
- viewHolder.nbText.setText(String.valueOf(data.get(size)));
-
- int color;
- if (position % 2 == 0) {
- color = android.R.color.holo_blue_dark;
- } else {
- color = android.R.color.black;
- }
- convertView.setBackgroundResource(color);
-
- return convertView;
- }
-
- public void set(int size, int nb) {
- if (nb == 0) {
- data.remove(size);
- } else {
- data.put(size, nb);
- }
- notifyDataSetChanged();
- }
-
- /* Cache for the views of the table items */
- static class ViewHolder {
- TextView sizeText;
- TextView nbText;
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/TableAdapter.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,124 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.TreeMap;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class TableAdapter extends BaseAdapter {
+
+ private static final String TAG = "TableAdapter";
+
+ protected TreeMap<Integer, Integer> data = new TreeMap<>();
+ protected Context context;
+ protected Mensuration.Precision precision;
+
+ public TableAdapter(Context context, Mensuration.Precision precision) {
+ this.context = context;
+ this.precision = precision;
+ }
+
+ /* BaseAdapter methods */
+
+ @Override
+ public int getCount() {
+ return data.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ if (position < 0 || position >= data.size()) {
+ return null;
+ }
+ return data.keySet().toArray()[position];
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder;
+
+ if (convertView == null) {
+ convertView = LayoutInflater.from(context)
+ .inflate(R.layout.measurement_table_row, parent, false);
+// convertView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
+
+ viewHolder = new ViewHolder();
+ viewHolder.sizeText = (TextView) convertView.findViewById(R.id.table_size);
+ viewHolder.nbText = (TextView) convertView.findViewById(R.id.table_nb);
+ convertView.setTag(viewHolder);
+
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+
+ Integer size = (Integer) getItem(position);
+ viewHolder.sizeText.setText(UIUtils.getFormattedSize(size, precision));
+ viewHolder.nbText.setText(String.valueOf(data.get(size)));
+
+ int color;
+ if (position % 2 == 0) {
+ color = android.R.color.holo_blue_dark;
+ } else {
+ color = android.R.color.black;
+ }
+ convertView.setBackgroundResource(color);
+
+ return convertView;
+ }
+
+ public void set(int size, int nb) {
+ if (nb == 0) {
+ data.remove(size);
+ } else {
+ data.put(size, nb);
+ }
+ notifyDataSetChanged();
+ }
+
+ /* Cache for the views of the table items */
+ static class ViewHolder {
+ TextView sizeText;
+ TextView nbText;
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/TableFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,53 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListView;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class TableFragment extends MeasurementsDisplayerFragment {
-
- private static final String TAG = "TableFragment";
-
- protected ListView table;
- protected TableAdapter adapter;
-
- /* Fragment methods */
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.measurement_table_fragment, container, false);
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- table = (ListView) getActivity().findViewById(R.id.table_content);
- adapter = new TableAdapter(getActivity());
- table.setAdapter(adapter);
- }
-
- /* MeasurementsListener methods */
-
- @Override
- public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
- int size = measurement.getSize();
- adapter.set(size, source.getMeasurementNb(size));
- }
-
- @Override
- public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
- int size = measurement.getSize();
- adapter.set(size, source.getMeasurementNb(size));
- }
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/TableFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/measurement/TableFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,81 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class TableFragment extends MeasurementsDisplayerFragment {
+
+ private static final String TAG = "TableFragment";
+
+ protected ListView table;
+ protected TableAdapter adapter;
+
+ /* Fragment methods */
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.measurement_table_fragment, container, false);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ table = (ListView) getActivity().findViewById(R.id.table_content);
+ adapter = new TableAdapter(getActivity(), measurements.getPrecision());
+ table.setAdapter(adapter);
+
+ for (MeasurementModel measurement : measurements.getMeasurements().values()) {
+ onMeasurementAdded(measurements, measurement);
+ }
+ }
+
+ /* MeasurementsListener methods */
+
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ int size = measurement.getSize();
+ adapter.set(size, source.getMeasurementNb(size));
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ int size = measurement.getSize();
+ adapter.set(size, source.getMeasurementNb(size));
+ }
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,156 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.provider.BaseColumns;
-import android.util.Log;
-import com.google.common.base.Function;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class BaseModel implements Serializable, BaseColumns {
-
- private static final String TAG = "BaseModel";
-
- public static final Function<BaseModel, String> GET_ID_FUNCTION = new Function<BaseModel, String>() {
- @Override
- public String apply(BaseModel input) {
- return input.getId();
- }
- };
-
- public enum ErrorType {
- REQUIRED,
- ONE_REQUIRED
- }
-
- protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
-
- protected String id;
-
- public BaseModel() {}
-
- public BaseModel(Cursor cursor) {
- id = cursor.getString(0);
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public boolean isNew() {
- return id == null;
- }
-
- public abstract String getTableName();
-
- public String toString(android.content.Context context) {
- return toString();
- }
-
- public ContentValues convertIntoContentValues() {
- ContentValues value = new ContentValues();
- value.put(_ID, id);
- return value;
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(property, listener);
- }
-
- public Set<String> getRequiredFields() {
- return Sets.newHashSet();
- }
-
- /**
- * @return A set of sets containing fields. At least one of these fields must have a value.
- */
- public Set<Set<String>> getOneRequiredFields() {
- return Sets.newHashSet();
- }
-
- /**
- * Check if the model is valid
- * @return a map of the fields in error by error type
- */
- public Multimap<ErrorType, String> checkValidity() {
- Multimap<ErrorType, String> result = HashMultimap.create();
- // check required
- for (String requiredField : getRequiredFields()) {
- try {
- if (getClass().getDeclaredField(requiredField).get(this) == null) {
- result.put(ErrorType.REQUIRED, requiredField);
- }
- } catch (Exception e) {
- Log.e(TAG, "Error while accessing the field " + requiredField, e);
- }
- }
-
- // check one required
- for (Set<String> oneRequiredFields : getOneRequiredFields()) {
- boolean notNull = false;
- for (String oneRequiredField : oneRequiredFields) {
- try {
- if (getClass().getDeclaredField(oneRequiredField).get(this) != null) {
- notNull = true;
- break;
- }
- } catch (Exception e) {
- Log.e(TAG, "Error while accessing the field " + oneRequiredField, e);
- }
- }
- if (!notNull) {
- result.putAll(ErrorType.ONE_REQUIRED, oneRequiredFields);
- }
- }
-
- return result;
- }
-
- protected void putValue(ContentValues values, String column, String value) {
- if (value == null) {
- values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
- } else {
- values.put(column, value);
- }
- }
-
- protected void putValue(ContentValues values, String column, Long value) {
- if (value == null) {
- values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
- } else {
- values.put(column, value);
- }
- }
-
- protected void putValue(ContentValues values, String column, Integer value) {
- if (value == null) {
- values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
- } else {
- values.put(column, value);
- }
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/BaseModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,180 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.provider.BaseColumns;
+import android.util.Log;
+import com.google.common.base.Function;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class BaseModel implements Serializable, BaseColumns {
+
+ private static final String TAG = "BaseModel";
+
+ public static final Function<BaseModel, String> GET_ID_FUNCTION = new Function<BaseModel, String>() {
+ @Override
+ public String apply(BaseModel input) {
+ return input.getId();
+ }
+ };
+
+ public enum ErrorType {
+ REQUIRED,
+ ONE_REQUIRED
+ }
+
+ protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
+
+ protected String id;
+
+ public BaseModel() {}
+
+ public BaseModel(Cursor cursor) {
+ id = cursor.getString(0);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public boolean isNew() {
+ return id == null;
+ }
+
+ public abstract String getTableName();
+
+ public String toString(android.content.Context context) {
+ return toString();
+ }
+
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = new ContentValues();
+ value.put(_ID, id);
+ return value;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ changeSupport.addPropertyChangeListener(property, listener);
+ }
+
+ public Set<String> getRequiredFields() {
+ return Sets.newHashSet();
+ }
+
+ /**
+ * @return A set of sets containing fields. At least one of these fields must have a value.
+ */
+ public Set<Set<String>> getOneRequiredFields() {
+ return Sets.newHashSet();
+ }
+
+ /**
+ * Check if the model is valid
+ * @return a map of the fields in error by error type
+ */
+ public Multimap<ErrorType, String> checkValidity() {
+ Multimap<ErrorType, String> result = HashMultimap.create();
+ // check required
+ for (String requiredField : getRequiredFields()) {
+ try {
+ if (getClass().getDeclaredField(requiredField).get(this) == null) {
+ result.put(ErrorType.REQUIRED, requiredField);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Error while accessing the field " + requiredField, e);
+ }
+ }
+
+ // check one required
+ for (Set<String> oneRequiredFields : getOneRequiredFields()) {
+ boolean notNull = false;
+ for (String oneRequiredField : oneRequiredFields) {
+ try {
+ if (getClass().getDeclaredField(oneRequiredField).get(this) != null) {
+ notNull = true;
+ break;
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Error while accessing the field " + oneRequiredField, e);
+ }
+ }
+ if (!notNull) {
+ result.putAll(ErrorType.ONE_REQUIRED, oneRequiredFields);
+ }
+ }
+
+ return result;
+ }
+
+ protected void putValue(ContentValues values, String column, String value) {
+ if (value == null) {
+ values.putNull(column);
+ Log.d(TAG, "put value null for column " + column);
+ } else {
+ values.put(column, value);
+ }
+ }
+
+ protected void putValue(ContentValues values, String column, Long value) {
+ if (value == null) {
+ values.putNull(column);
+ Log.d(TAG, "put value null for column " + column);
+ } else {
+ values.put(column, value);
+ }
+ }
+
+ protected void putValue(ContentValues values, String column, Integer value) {
+ if (value == null) {
+ values.putNull(column);
+ Log.d(TAG, "put value null for column " + column);
+ } else {
+ values.put(column, value);
+ }
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,159 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.util.Log;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesModel extends HierarchicalModel<MetierModel> {
-
- private static final String TAG = "CommercialSpecies";
-
- public static final String TABLE_NAME = "commercial_species";
- public static final String COLUMN_FAO_CODE = "faoCode";
- public static final String COLUMN_MEASUREMENT_METHOD = "measurementMethod";
- public static final String COLUMN_PRECISION = "precision";
- public static final String COLUMN_SPECIES_MIX = "speciesMix";
- public static final String COLUMN_SORT_CATEGORY = "sortCategory";
- public static final String COLUMN_STATE = "state";
- public static final String COLUMN_PRESENTATION = "presentation";
- public static final String COLUMN_METIER_ID = "metierId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_FAO_CODE,
- COLUMN_MEASUREMENT_METHOD,
- COLUMN_PRECISION,
- COLUMN_SPECIES_MIX,
- COLUMN_SORT_CATEGORY,
- COLUMN_STATE,
- COLUMN_PRESENTATION,
- COLUMN_METIER_ID
- };
-
- protected CommercialSpecies faoCode;
- protected Mensuration measurementMethod;
- protected Mensuration.Precision precision = Mensuration.Precision.CM1;
- protected boolean speciesMix;
- protected String sortCategory;
- protected State state;
- protected Presentation presentation;
-
- public CommercialSpeciesModel() {
- }
-
- public CommercialSpeciesModel(Context context, Cursor cursor) {
- super(cursor);
- String faoCodeId = cursor.getString(1);
- faoCode = DataCache.getCommercialSpeciesById(context, faoCodeId);
- String measurementMethodId = cursor.getString(2);
- measurementMethod = DataCache.getMensurationById(context, measurementMethodId);
- precision = Mensuration.Precision.valueOf(cursor.getString(3));
- speciesMix = cursor.getShort(4) > 0;
- sortCategory = cursor.getString(5);
- String stateId = cursor.getString(6);
- state = DataCache.getStateById(context, stateId);
- String presentationId = cursor.getString(7);
- presentation = DataCache.getPresentationById(context, presentationId);
- }
-
- public CommercialSpecies getFaoCode() {
- return faoCode;
- }
-
- public void setFaoCode(CommercialSpecies faoCode) {
- this.faoCode = faoCode;
- }
-
- public Mensuration getMeasurementMethod() {
- return measurementMethod;
- }
-
- public void setMeasurementMethod(Mensuration measurementMethod) {
- this.measurementMethod = measurementMethod;
- }
-
- public Mensuration.Precision getPrecision() {
- return precision;
- }
-
- public void setPrecision(Mensuration.Precision precision) {
- this.precision = precision;
- }
-
- public boolean isSpeciesMix() {
- return speciesMix;
- }
-
- public void setSpeciesMix(boolean speciesMix) {
- this.speciesMix = speciesMix;
- }
-
- public String getSortCategory() {
- return sortCategory;
- }
-
- public void setSortCategory(String sortCategory) {
- this.sortCategory = sortCategory;
- }
-
- public State getState() {
- return state;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- public Presentation getPresentation() {
- return presentation;
- }
-
- public void setPresentation(Presentation presentation) {
- this.presentation = presentation;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(faoCode, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_FAO_CODE, faoCode != null ? faoCode.getId() : null);
- putValue(value, COLUMN_MEASUREMENT_METHOD, measurementMethod != null ? measurementMethod.getId() : null);
- putValue(value, COLUMN_PRECISION, precision.name());
- putValue(value, COLUMN_SPECIES_MIX, speciesMix ? 1 : 0);
- putValue(value, COLUMN_SORT_CATEGORY, sortCategory);
- putValue(value, COLUMN_STATE, state != null ? state.getId() : null);
- putValue(value, COLUMN_PRESENTATION, presentation != null ? presentation.getId() : null);
- putValue(value, COLUMN_METIER_ID, getParentId());
- return value;
- }
-
- @Override
- public Set<String> getRequiredFields() {
- Set<String> result = super.getRequiredFields();
- result.add(COLUMN_FAO_CODE);
- result.add(COLUMN_MEASUREMENT_METHOD);
- result.add(COLUMN_PRECISION);
- return result;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,185 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesModel extends HierarchicalModel<MetierModel> {
+
+ private static final String TAG = "CommercialSpecies";
+
+ public static final String TABLE_NAME = "commercial_species";
+ public static final String COLUMN_FAO_CODE = "faoCode";
+ public static final String COLUMN_MEASUREMENT_METHOD = "measurementMethod";
+ public static final String COLUMN_PRECISION = "precision";
+ public static final String COLUMN_SPECIES_MIX = "speciesMix";
+ public static final String COLUMN_SORT_CATEGORY = "sortCategory";
+ public static final String COLUMN_STATE = "state";
+ public static final String COLUMN_PRESENTATION = "presentation";
+ public static final String COLUMN_METIER_ID = "metierId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_FAO_CODE,
+ COLUMN_MEASUREMENT_METHOD,
+ COLUMN_PRECISION,
+ COLUMN_SPECIES_MIX,
+ COLUMN_SORT_CATEGORY,
+ COLUMN_STATE,
+ COLUMN_PRESENTATION,
+ COLUMN_METIER_ID
+ };
+
+ protected CommercialSpecies faoCode;
+ protected Mensuration measurementMethod;
+ protected Mensuration.Precision precision = Mensuration.Precision.CM1;
+ protected boolean speciesMix;
+ protected String sortCategory;
+ protected State state;
+ protected Presentation presentation;
+
+ public CommercialSpeciesModel() {
+ }
+
+ public CommercialSpeciesModel(Context context, Cursor cursor) {
+ super(cursor);
+ String faoCodeId = cursor.getString(1);
+ faoCode = DataCache.getCommercialSpeciesById(context, faoCodeId);
+ String measurementMethodId = cursor.getString(2);
+ measurementMethod = DataCache.getMensurationById(context, measurementMethodId);
+ Log.d(TAG, cursor.getString(3));
+ precision = Mensuration.Precision.valueOf(cursor.getString(3));
+ Log.d(TAG, precision.toString());
+ speciesMix = cursor.getShort(4) > 0;
+ sortCategory = cursor.getString(5);
+ String stateId = cursor.getString(6);
+ state = DataCache.getStateById(context, stateId);
+ String presentationId = cursor.getString(7);
+ presentation = DataCache.getPresentationById(context, presentationId);
+ }
+
+ public CommercialSpecies getFaoCode() {
+ return faoCode;
+ }
+
+ public void setFaoCode(CommercialSpecies faoCode) {
+ this.faoCode = faoCode;
+ }
+
+ public Mensuration getMeasurementMethod() {
+ return measurementMethod;
+ }
+
+ public void setMeasurementMethod(Mensuration measurementMethod) {
+ this.measurementMethod = measurementMethod;
+ }
+
+ public Mensuration.Precision getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(Mensuration.Precision precision) {
+ this.precision = precision;
+ }
+
+ public boolean isSpeciesMix() {
+ return speciesMix;
+ }
+
+ public void setSpeciesMix(boolean speciesMix) {
+ this.speciesMix = speciesMix;
+ }
+
+ public String getSortCategory() {
+ return sortCategory;
+ }
+
+ public void setSortCategory(String sortCategory) {
+ this.sortCategory = sortCategory;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ public Presentation getPresentation() {
+ return presentation;
+ }
+
+ public void setPresentation(Presentation presentation) {
+ this.presentation = presentation;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(faoCode, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_FAO_CODE, faoCode != null ? faoCode.getId() : null);
+ putValue(value, COLUMN_MEASUREMENT_METHOD, measurementMethod != null ? measurementMethod.getId() : null);
+ putValue(value, COLUMN_PRECISION, precision.name());
+ putValue(value, COLUMN_SPECIES_MIX, speciesMix ? 1 : 0);
+ putValue(value, COLUMN_SORT_CATEGORY, sortCategory);
+ putValue(value, COLUMN_STATE, state != null ? state.getId() : null);
+ putValue(value, COLUMN_PRESENTATION, presentation != null ? presentation.getId() : null);
+ putValue(value, COLUMN_METIER_ID, getParentId());
+ return value;
+ }
+
+ @Override
+ public Set<String> getRequiredFields() {
+ Set<String> result = super.getRequiredFields();
+ result.add(COLUMN_FAO_CODE);
+ result.add(COLUMN_MEASUREMENT_METHOD);
+ result.add(COLUMN_PRECISION);
+ return result;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,65 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import com.google.common.collect.Multimap;
-
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ContextModel extends BaseModel {
-
- private static final String TAG = "Context";
-
- public static final String TABLE_NAME = "contexts";
- public static final String COLUMN_NAME = "name";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_NAME
- };
-
- protected String name;
-
- public ContextModel() {
- }
-
- public ContextModel(Cursor cursor) {
- super(cursor);
- name = cursor.getString(1);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return name;
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_NAME, name);
- return value;
- }
-
- @Override
- public Set<String> getRequiredFields() {
- Set<String> result = super.getRequiredFields();
- result.add(COLUMN_NAME);
- return result;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/ContextModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,89 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import com.google.common.collect.Multimap;
+
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ContextModel extends BaseModel {
+
+ private static final String TAG = "Context";
+
+ public static final String TABLE_NAME = "contexts";
+ public static final String COLUMN_NAME = "name";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_NAME
+ };
+
+ protected String name;
+
+ public ContextModel() {
+ }
+
+ public ContextModel(Cursor cursor) {
+ super(cursor);
+ name = cursor.getString(1);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return name;
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_NAME, name);
+ return value;
+ }
+
+ @Override
+ public Set<String> getRequiredFields() {
+ Set<String> result = super.getRequiredFields();
+ result.add(COLUMN_NAME);
+ return result;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,40 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.database.Cursor;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class HierarchicalModel<P extends BaseModel> extends BaseModel {
-
- protected P parent;
-
- public HierarchicalModel() {}
-
- public HierarchicalModel(Cursor cursor) {
- id = cursor.getString(0);
- }
-
- public P getParent() {
- return parent;
- }
-
- public BaseModel getParent(int level) {
- BaseModel result = this;
- //TODO kmorin 20131219 handle NPE
- for (int i = 0 ; i < level ; i++) {
- result = ((HierarchicalModel) result).getParent();
- }
- return result;
- }
-
- public void setParent(P parent) {
- this.parent = parent;
- }
-
- public String getParentId() {
- return parent != null ? parent.getId() : null;
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,64 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class HierarchicalModel<P extends BaseModel> extends BaseModel {
+
+ protected P parent;
+
+ public HierarchicalModel() {}
+
+ public HierarchicalModel(Cursor cursor) {
+ id = cursor.getString(0);
+ }
+
+ public P getParent() {
+ return parent;
+ }
+
+ public BaseModel getParent(int level) {
+ BaseModel result = this;
+ //TODO kmorin 20131219 handle NPE
+ for (int i = 0 ; i < level ; i++) {
+ result = ((HierarchicalModel) result).getParent();
+ }
+ return result;
+ }
+
+ public void setParent(P parent) {
+ this.parent = parent;
+ }
+
+ public String getParentId() {
+ return parent != null ? parent.getId() : null;
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,112 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Calendar;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationModel extends HierarchicalModel<ContextModel> {
-
- private static final String TAG = "Location";
-
- public static final String TABLE_NAME = "locations";
- public static final String COLUMN_OPERATOR = "operator";
- public static final String COLUMN_START_DATE = "startDate";
- public static final String COLUMN_END_DATE = "endDate";
- public static final String COLUMN_LOCATION = "location";
- public static final String COLUMN_CONTEXT_ID = "contextId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_OPERATOR,
- COLUMN_START_DATE,
- COLUMN_END_DATE,
- COLUMN_LOCATION,
- COLUMN_CONTEXT_ID
- };
-
- protected String operator;
- protected Calendar startDate;
- protected Calendar endDate;
- protected Location location;
-
- public LocationModel() {
- }
-
- public LocationModel(Context context, Cursor cursor) {
- super(cursor);
- operator = cursor.getString(1);
- startDate = UIUtils.getCalendarFromCursor(cursor, 2);
- endDate = UIUtils.getCalendarFromCursor(cursor, 3);
- String locationId = cursor.getString(4);
- location = DataCache.getLocationById(context, locationId);
- }
-
- public String getOperator() {
- return operator;
- }
-
- public void setOperator(String operator) {
- this.operator = operator;
- }
-
- public Calendar getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Calendar startDate) {
- this.startDate = startDate;
- }
-
- public Calendar getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Calendar endDate) {
- this.endDate = endDate;
- }
-
- public Location getLocation() {
- return location;
- }
-
- public void setLocation(Location location) {
- this.location = location;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(location, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_OPERATOR, operator);
- putValue(value, COLUMN_START_DATE, startDate != null ? startDate.getTimeInMillis() : null);
- putValue(value, COLUMN_END_DATE, endDate != null ? endDate.getTimeInMillis() : null);
- putValue(value, COLUMN_LOCATION, location != null ? location.getId() : null);
- putValue(value, COLUMN_CONTEXT_ID, getParentId());
- return value;
- }
-
- @Override
- public Set<String> getRequiredFields() {
- Set<String> result = super.getRequiredFields();
- result.add(COLUMN_LOCATION);
- return result;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/LocationModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,136 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationModel extends HierarchicalModel<ContextModel> {
+
+ private static final String TAG = "Location";
+
+ public static final String TABLE_NAME = "locations";
+ public static final String COLUMN_OPERATOR = "operator";
+ public static final String COLUMN_START_DATE = "startDate";
+ public static final String COLUMN_END_DATE = "endDate";
+ public static final String COLUMN_LOCATION = "location";
+ public static final String COLUMN_CONTEXT_ID = "contextId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_OPERATOR,
+ COLUMN_START_DATE,
+ COLUMN_END_DATE,
+ COLUMN_LOCATION,
+ COLUMN_CONTEXT_ID
+ };
+
+ protected String operator;
+ protected Calendar startDate;
+ protected Calendar endDate;
+ protected Location location;
+
+ public LocationModel() {
+ }
+
+ public LocationModel(Context context, Cursor cursor) {
+ super(cursor);
+ operator = cursor.getString(1);
+ startDate = UIUtils.getCalendarFromCursor(cursor, 2);
+ endDate = UIUtils.getCalendarFromCursor(cursor, 3);
+ String locationId = cursor.getString(4);
+ location = DataCache.getLocationById(context, locationId);
+ }
+
+ public String getOperator() {
+ return operator;
+ }
+
+ public void setOperator(String operator) {
+ this.operator = operator;
+ }
+
+ public Calendar getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Calendar startDate) {
+ this.startDate = startDate;
+ }
+
+ public Calendar getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Calendar endDate) {
+ this.endDate = endDate;
+ }
+
+ public Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(location, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_OPERATOR, operator);
+ putValue(value, COLUMN_START_DATE, startDate != null ? startDate.getTimeInMillis() : null);
+ putValue(value, COLUMN_END_DATE, endDate != null ? endDate.getTimeInMillis() : null);
+ putValue(value, COLUMN_LOCATION, location != null ? location.getId() : null);
+ putValue(value, COLUMN_CONTEXT_ID, getParentId());
+ return value;
+ }
+
+ @Override
+ public Set<String> getRequiredFields() {
+ Set<String> result = super.getRequiredFields();
+ result.add(COLUMN_LOCATION);
+ return result;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.Gender;
-import fr.ifremer.wlo.models.referentials.Maturity;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MeasurementModel implements Serializable {
-
- private static final String TAG = "Measurement";
-
- public static final String SIZE_PROPERTY = "size";
- public static final String GENDER_PROPERTY = "gender";
- public static final String MATURITY_PROPERTY = "maturity";
- public static final String AGE_PROPERTY = "age";
-
- protected Integer size;
- protected Gender gender;
- protected Maturity maturity;
- protected Age age;
-
- protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
-
- public Integer getSize() {
- return size;
- }
-
- public void setSize(Integer size) {
- Integer oldValue = this.size;
- this.size = size;
- changeSupport.firePropertyChange(SIZE_PROPERTY, oldValue, size);
- }
-
- public void incSize() {
- if (size != null) {
- setSize(size + 1);
- }
- }
-
- public void decSize() {
- if (size != null) {
- setSize(size - 1);
- }
- }
-
- public Gender getGender() {
- return gender;
- }
-
- public void setGender(Gender gender) {
- Object oldValue = this.gender;
- this.gender = gender;
- changeSupport.firePropertyChange(GENDER_PROPERTY, oldValue, gender);
- }
-
- public Maturity getMaturity() {
- return maturity;
- }
-
- public void setMaturity(Maturity maturity) {
- Object oldValue = this.maturity;
- this.maturity = maturity;
- changeSupport.firePropertyChange(MATURITY_PROPERTY, oldValue, maturity);
- }
-
- public Age getAge() {
- return age;
- }
-
- public void setAge(Age age) {
- Object oldValue = this.age;
- this.age = age;
- changeSupport.firePropertyChange(AGE_PROPERTY, oldValue, age);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(property, listener);
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/MeasurementModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,173 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MeasurementModel extends HierarchicalModel<ScientificSpeciesModel> {
+
+ private static final String TAG = "MeasurementModel";
+
+ public static final String TABLE_NAME = "measurements";
+ public static final String COLUMN_SIZE = "size";
+ public static final String COLUMN_DATE = "date";
+ public static final String COLUMN_CATEGORY_1 = "category1";
+ public static final String COLUMN_CATEGORY_2 = "category2";
+ public static final String COLUMN_CATEGORY_3 = "category3";
+ public static final String COLUMN_SCIENTIFIC_SPECIES_ID = "scientificSpeciesId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_SIZE,
+ COLUMN_DATE,
+ COLUMN_CATEGORY_1,
+ COLUMN_CATEGORY_2,
+ COLUMN_CATEGORY_3,
+ COLUMN_SCIENTIFIC_SPECIES_ID
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected Integer size;
+ protected Calendar date;
+ protected String category1;
+ protected String category2;
+ protected String category3;
+
+ public MeasurementModel() {
+ }
+
+ public MeasurementModel(Cursor cursor) {
+ super(cursor);
+ size = cursor.getInt(1);
+ date = UIUtils.getCalendarFromCursor(cursor, 2);
+ category1 = cursor.getString(3);
+ category2 = cursor.getString(4);
+ category3 = cursor.getString(5);
+ }
+
+ public Integer getSize() {
+ return size;
+ }
+
+ public void setSize(Integer size) {
+ Integer oldValue = this.size;
+ this.size = size;
+ Log.d(TAG, size + " " + oldValue + " " + size.equals(oldValue));
+ changeSupport.firePropertyChange(COLUMN_SIZE, oldValue, size);
+ }
+
+ public void incSize(int inc) {
+ if (size != null) {
+ setSize(size + inc);
+ }
+ }
+
+ public void decSize(int dec) {
+ if (size != null) {
+ setSize(size - dec);
+ }
+ }
+
+ public void roundSize(Mensuration.Precision precision) {
+ if (size == null) {
+ return;
+ }
+ int precisionValue = precision.getValue();
+ int roundedSize = (size / precisionValue) * precisionValue;
+ setSize(roundedSize);
+ }
+
+ public Calendar getDate() {
+ return date;
+ }
+
+ public void setDate(Calendar date) {
+ this.date = date;
+ }
+
+ public String getCategory1() {
+ return category1;
+ }
+
+ public void setCategory1(String category1) {
+ this.category1 = category1;
+ }
+
+ public String getCategory2() {
+ return category2;
+ }
+
+ public void setCategory2(String category2) {
+ this.category2 = category2;
+ }
+
+ public String getCategory3() {
+ return category3;
+ }
+
+ public void setCategory3(String category3) {
+ this.category3 = category3;
+ }
+
+ public String toString(Context context, Mensuration.Precision precision) {
+ String dateFormat = UIUtils.getDateFormat(context) +
+ " " + context.getString(R.string.fulltime_format);
+
+ String result = String.format(dateFormat, date);
+ result += " - " + UIUtils.getFormattedSize(size, precision);
+ return result;
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_SIZE, size);
+ putValue(value, COLUMN_DATE, date != null ? date.getTimeInMillis() : null);
+ putValue(value, COLUMN_CATEGORY_1, category1);
+ putValue(value, COLUMN_CATEGORY_2, category2);
+ putValue(value, COLUMN_CATEGORY_3, category3);
+ putValue(value, COLUMN_SCIENTIFIC_SPECIES_ID, getParentId());
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,92 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MeasurementsModel implements Serializable {
-
- private static final String TAG = "Measurements";
-
- protected ScientificSpeciesModel scientificSpecies;
-
- protected Multimap<Integer, MeasurementModel> measurements = HashMultimap.create();
-
- transient protected List<MeasurementsListener> listeners = new ArrayList<MeasurementsListener>();
-
- public ScientificSpeciesModel getScientificSpecies() {
- return scientificSpecies;
- }
-
- public void setScientificSpecies(ScientificSpeciesModel scientificSpecies) {
- this.scientificSpecies = scientificSpecies;
- }
-
- public Multimap<Integer, MeasurementModel> getMeasurements() {
- return measurements;
- }
-
- public List<MeasurementModel> getMeasurements(int size) {
- return Lists.newArrayList(measurements.get(size));
- }
-
- public int getMeasurementNb(int size) {
- return measurements.get(size).size();
- }
-
- public void addMeasurement(MeasurementModel fishMeasurement) {
- int size = fishMeasurement.getSize();
- measurements.put(size, fishMeasurement);
- fireMeasurementAdded(fishMeasurement);
- }
-
- public void removeMeasurement(MeasurementModel fishMeasurement) {
- int size = fishMeasurement.getSize();
- measurements.remove(size, fishMeasurement);
- fireMeasurementRemoved(fishMeasurement);
- }
-
- public void addMeasurementsListener(MeasurementsListener listener) {
- ensureListeners();
- listeners.add(listener);
- }
-
- public void removeMeasurementsListener(MeasurementsListener listener) {
- ensureListeners();
- listeners.remove(listener);
- }
-
- protected void fireMeasurementAdded(MeasurementModel measurement) {
- for (MeasurementsListener listener : listeners) {
- listener.onMeasurementAdded(this, measurement);
- }
- }
-
- protected void ensureListeners() {
- if (listeners == null) {
- listeners = Lists.newArrayList();
- }
- }
-
- protected void fireMeasurementRemoved(MeasurementModel measurement) {
- for (MeasurementsListener listener : listeners) {
- listener.onMeasurementRemoved(this, measurement);
- }
- }
-
- public static interface MeasurementsListener {
-
- void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement);
-
- void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement);
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,127 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MeasurementsModel implements Serializable {
+
+ private static final String TAG = "Measurements";
+
+ protected ScientificSpeciesModel scientificSpecies;
+
+ protected Mensuration.Precision precision;
+
+ protected Multimap<Integer, MeasurementModel> measurements = HashMultimap.create();
+
+ transient protected List<MeasurementsListener> listeners = new ArrayList<MeasurementsListener>();
+
+ public ScientificSpeciesModel getScientificSpecies() {
+ return scientificSpecies;
+ }
+
+ public void setScientificSpecies(ScientificSpeciesModel scientificSpecies) {
+ this.scientificSpecies = scientificSpecies;
+ }
+
+ public Mensuration.Precision getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(Mensuration.Precision precision) {
+ this.precision = precision;
+ }
+
+ public Multimap<Integer, MeasurementModel> getMeasurements() {
+ return measurements;
+ }
+
+ public List<MeasurementModel> getMeasurements(int size) {
+ return Lists.newArrayList(measurements.get(size));
+ }
+
+ public int getMeasurementNb(int size) {
+ return measurements.get(size).size();
+ }
+
+ public void addMeasurement(MeasurementModel fishMeasurement) {
+ int size = fishMeasurement.getSize();
+ measurements.put(size, fishMeasurement);
+ fireMeasurementAdded(fishMeasurement);
+ }
+
+ public void removeMeasurement(MeasurementModel fishMeasurement) {
+ int size = fishMeasurement.getSize();
+ measurements.remove(size, fishMeasurement);
+ fireMeasurementRemoved(fishMeasurement);
+ }
+
+ public void addMeasurementsListener(MeasurementsListener listener) {
+ ensureListeners();
+ listeners.add(listener);
+ }
+
+ public void removeMeasurementsListener(MeasurementsListener listener) {
+ ensureListeners();
+ listeners.remove(listener);
+ }
+
+ protected void fireMeasurementAdded(MeasurementModel measurement) {
+ for (MeasurementsListener listener : listeners) {
+ listener.onMeasurementAdded(this, measurement);
+ }
+ }
+
+ protected void ensureListeners() {
+ if (listeners == null) {
+ listeners = Lists.newArrayList();
+ }
+ }
+
+ protected void fireMeasurementRemoved(MeasurementModel measurement) {
+ for (MeasurementsListener listener : listeners) {
+ listener.onMeasurementRemoved(this, measurement);
+ }
+ }
+
+ public static interface MeasurementsListener {
+
+ void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement);
+
+ void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement);
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetierModel extends HierarchicalModel<VesselModel> {
-
- private static final String TAG = "Metier";
-
- public static final String TABLE_NAME = "metiers";
- public static final String COLUMN_GEAR_SPECIES = "gearSpecies";
- public static final String COLUMN_ZONE = "zone";
- public static final String COLUMN_SAMPLE_ROW_CODE = "sampleRowCode";
- public static final String COLUMN_VESSEL_ID = "vesselId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_GEAR_SPECIES,
- COLUMN_ZONE,
- COLUMN_SAMPLE_ROW_CODE,
- COLUMN_VESSEL_ID
- };
-
- protected Metier gearSpecies;
- protected String zone;
- protected String sampleRowCode;
-
- public MetierModel() {
- }
-
- public MetierModel(Context context, Cursor cursor) {
- super(cursor);
- String gearSpeciesId = cursor.getString(1);
- gearSpecies = DataCache.getMetierById(context, gearSpeciesId);
- zone = cursor.getString(2);
- sampleRowCode = cursor.getString(3);
- }
-
- public Metier getGearSpecies() {
- return gearSpecies;
- }
-
- public void setGearSpecies(Metier gearSpecies) {
- this.gearSpecies = gearSpecies;
- }
-
- public String getZone() {
- return zone;
- }
-
- public void setZone(String zone) {
- this.zone = zone;
- }
-
- public String getSampleRowCode() {
- return sampleRowCode;
- }
-
- public void setSampleRowCode(String sampleRowCode) {
- this.sampleRowCode = sampleRowCode;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(Context context) {
- return UIUtils.getStringOrUndefined(gearSpecies, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_GEAR_SPECIES, gearSpecies != null ? gearSpecies.getId() : null);
- putValue(value, COLUMN_ZONE, zone);
- putValue(value, COLUMN_SAMPLE_ROW_CODE, sampleRowCode);
- putValue(value, COLUMN_VESSEL_ID, getParentId());
- return value;
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/MetierModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,114 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetierModel extends HierarchicalModel<VesselModel> {
+
+ private static final String TAG = "Metier";
+
+ public static final String TABLE_NAME = "metiers";
+ public static final String COLUMN_GEAR_SPECIES = "gearSpecies";
+ public static final String COLUMN_ZONE = "zone";
+ public static final String COLUMN_SAMPLE_ROW_CODE = "sampleRowCode";
+ public static final String COLUMN_VESSEL_ID = "vesselId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_GEAR_SPECIES,
+ COLUMN_ZONE,
+ COLUMN_SAMPLE_ROW_CODE,
+ COLUMN_VESSEL_ID
+ };
+
+ protected Metier gearSpecies;
+ protected String zone;
+ protected String sampleRowCode;
+
+ public MetierModel() {
+ }
+
+ public MetierModel(Context context, Cursor cursor) {
+ super(cursor);
+ String gearSpeciesId = cursor.getString(1);
+ gearSpecies = DataCache.getMetierById(context, gearSpeciesId);
+ zone = cursor.getString(2);
+ sampleRowCode = cursor.getString(3);
+ }
+
+ public Metier getGearSpecies() {
+ return gearSpecies;
+ }
+
+ public void setGearSpecies(Metier gearSpecies) {
+ this.gearSpecies = gearSpecies;
+ }
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getSampleRowCode() {
+ return sampleRowCode;
+ }
+
+ public void setSampleRowCode(String sampleRowCode) {
+ this.sampleRowCode = sampleRowCode;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(Context context) {
+ return UIUtils.getStringOrUndefined(gearSpecies, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_GEAR_SPECIES, gearSpecies != null ? gearSpecies.getId() : null);
+ putValue(value, COLUMN_ZONE, zone);
+ putValue(value, COLUMN_SAMPLE_ROW_CODE, sampleRowCode);
+ putValue(value, COLUMN_VESSEL_ID, getParentId());
+ return value;
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,77 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.util.Log;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesModel extends HierarchicalModel<CommercialSpeciesModel> {
-
- private static final String TAG = "ScientificSpecies";
-
- public static final String TABLE_NAME = "scientific_species";
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_TAKING_ACTIVATION = "takingActivation";
- public static final String COLUMN_COMMERCIAL_SPECIES_ID = "commercialSpeciesId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_NAME,
- COLUMN_TAKING_ACTIVATION,
- COLUMN_COMMERCIAL_SPECIES_ID
- };
-
- protected ScientificSpecies name;
- protected boolean takingActivation;
-
- public ScientificSpeciesModel() {
- }
-
- public ScientificSpeciesModel(Context context, Cursor cursor) {
- super(cursor);
- String nameId = cursor.getString(1);
- name = DataCache.getScientificSpeciesById(context, nameId);
- takingActivation = cursor.getShort(2) > 0;
- }
-
- public ScientificSpecies getName() {
- return name;
- }
-
- public void setName(ScientificSpecies name) {
- this.name = name;
- }
-
- public boolean isTakingActivation() {
- return takingActivation;
- }
-
- public void setTakingActivation(boolean takingActivation) {
- this.takingActivation = takingActivation;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(name, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_NAME, name != null ? name.getId() : null);
- putValue(value, COLUMN_TAKING_ACTIVATION, takingActivation ? 1 : 0);
- putValue(value, COLUMN_COMMERCIAL_SPECIES_ID, getParentId());
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,101 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesModel extends HierarchicalModel<CommercialSpeciesModel> {
+
+ private static final String TAG = "ScientificSpecies";
+
+ public static final String TABLE_NAME = "scientific_species";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_TAKING_ACTIVATION = "takingActivation";
+ public static final String COLUMN_COMMERCIAL_SPECIES_ID = "commercialSpeciesId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_NAME,
+ COLUMN_TAKING_ACTIVATION,
+ COLUMN_COMMERCIAL_SPECIES_ID
+ };
+
+ protected ScientificSpecies name;
+ protected boolean takingActivation;
+
+ public ScientificSpeciesModel() {
+ }
+
+ public ScientificSpeciesModel(Context context, Cursor cursor) {
+ super(cursor);
+ String nameId = cursor.getString(1);
+ name = DataCache.getScientificSpeciesById(context, nameId);
+ takingActivation = cursor.getShort(2) > 0;
+ }
+
+ public ScientificSpecies getName() {
+ return name;
+ }
+
+ public void setName(ScientificSpecies name) {
+ this.name = name;
+ }
+
+ public boolean isTakingActivation() {
+ return takingActivation;
+ }
+
+ public void setTakingActivation(boolean takingActivation) {
+ this.takingActivation = takingActivation;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(name, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_NAME, name != null ? name.getId() : null);
+ putValue(value, COLUMN_TAKING_ACTIVATION, takingActivation ? 1 : 0);
+ putValue(value, COLUMN_COMMERCIAL_SPECIES_ID, getParentId());
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,120 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.util.Log;
-import com.google.common.collect.Sets;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Calendar;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselModel extends HierarchicalModel<LocationModel> {
-
- private static final String TAG = "Vessel";
-
- public static final String TABLE_NAME = "vessels";
- public static final String COLUMN_REGISTRATION_NUMBER = "registrationNumber";
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_LANDING_DATE = "landingDate";
- public static final String COLUMN_LANDING_LOCATION = "landingLocation";
- public static final String COLUMN_LOCATION_ID = "location_id";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_REGISTRATION_NUMBER,
- COLUMN_NAME,
- COLUMN_LANDING_DATE,
- COLUMN_LANDING_LOCATION,
- COLUMN_LOCATION_ID
- };
-
- protected String registrationNumber;
- protected String name;
- protected Calendar landingDate;
- protected Location landingLocation;
-
- public VesselModel() {
- }
-
- public VesselModel(Context context, Cursor cursor) {
- super(cursor);
- registrationNumber = cursor.getString(1);
- name = cursor.getString(2);
- landingDate = UIUtils.getCalendarFromCursor(cursor, 3);
- String landingLocationId = cursor.getString(4);
- landingLocation = DataCache.getLocationById(context, landingLocationId);
- }
-
- public String getRegistrationNumber() {
- return registrationNumber;
- }
-
- public void setRegistrationNumber(String registrationNumber) {
- Object oldValue = this.registrationNumber;
- this.registrationNumber = registrationNumber;
- changeSupport.firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- Object oldValue = this.name;
- this.name = name;
- changeSupport.firePropertyChange(COLUMN_NAME, oldValue, name);
- }
-
- public Calendar getLandingDate() {
- return landingDate;
- }
-
- public void setLandingDate(Calendar landingDate) {
- this.landingDate = landingDate;
- }
-
- public Location getLandingLocation() {
- return landingLocation;
- }
-
- public void setLandingLocation(Location landingLocation) {
- this.landingLocation = landingLocation;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(registrationNumber, context) + " - "
- + UIUtils.getStringOrUndefined(name, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_REGISTRATION_NUMBER, registrationNumber);
- putValue(value, COLUMN_NAME, name);
- putValue(value, COLUMN_LANDING_DATE, landingDate != null ? landingDate.getTimeInMillis() : null);
- putValue(value, COLUMN_LANDING_LOCATION, landingLocation != null ? landingLocation.getId() : null);
- putValue(value, COLUMN_LOCATION_ID, getParentId());
- return value;
- }
-
- @Override
- public Set<Set<String>> getOneRequiredFields() {
- Set<Set<String>> result = super.getOneRequiredFields();
- Set<String> oneRequired = Sets.newHashSet(COLUMN_REGISTRATION_NUMBER, COLUMN_NAME);
- result.add(oneRequired);
- return result;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/VesselModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,144 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import com.google.common.collect.Sets;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselModel extends HierarchicalModel<LocationModel> {
+
+ private static final String TAG = "Vessel";
+
+ public static final String TABLE_NAME = "vessels";
+ public static final String COLUMN_REGISTRATION_NUMBER = "registrationNumber";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_LANDING_DATE = "landingDate";
+ public static final String COLUMN_LANDING_LOCATION = "landingLocation";
+ public static final String COLUMN_LOCATION_ID = "location_id";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_REGISTRATION_NUMBER,
+ COLUMN_NAME,
+ COLUMN_LANDING_DATE,
+ COLUMN_LANDING_LOCATION,
+ COLUMN_LOCATION_ID
+ };
+
+ protected String registrationNumber;
+ protected String name;
+ protected Calendar landingDate;
+ protected Location landingLocation;
+
+ public VesselModel() {
+ }
+
+ public VesselModel(Context context, Cursor cursor) {
+ super(cursor);
+ registrationNumber = cursor.getString(1);
+ name = cursor.getString(2);
+ landingDate = UIUtils.getCalendarFromCursor(cursor, 3);
+ String landingLocationId = cursor.getString(4);
+ landingLocation = DataCache.getLocationById(context, landingLocationId);
+ }
+
+ public String getRegistrationNumber() {
+ return registrationNumber;
+ }
+
+ public void setRegistrationNumber(String registrationNumber) {
+ Object oldValue = this.registrationNumber;
+ this.registrationNumber = registrationNumber;
+ changeSupport.firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ Object oldValue = this.name;
+ this.name = name;
+ changeSupport.firePropertyChange(COLUMN_NAME, oldValue, name);
+ }
+
+ public Calendar getLandingDate() {
+ return landingDate;
+ }
+
+ public void setLandingDate(Calendar landingDate) {
+ this.landingDate = landingDate;
+ }
+
+ public Location getLandingLocation() {
+ return landingLocation;
+ }
+
+ public void setLandingLocation(Location landingLocation) {
+ this.landingLocation = landingLocation;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(registrationNumber, context) + " - "
+ + UIUtils.getStringOrUndefined(name, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_REGISTRATION_NUMBER, registrationNumber);
+ putValue(value, COLUMN_NAME, name);
+ putValue(value, COLUMN_LANDING_DATE, landingDate != null ? landingDate.getTimeInMillis() : null);
+ putValue(value, COLUMN_LANDING_LOCATION, landingLocation != null ? landingLocation.getId() : null);
+ putValue(value, COLUMN_LOCATION_ID, getParentId());
+ return value;
+ }
+
+ @Override
+ public Set<Set<String>> getOneRequiredFields() {
+ Set<Set<String>> result = super.getOneRequiredFields();
+ Set<String> oneRequired = Sets.newHashSet(COLUMN_REGISTRATION_NUMBER, COLUMN_NAME);
+ result.add(oneRequired);
+ return result;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Age.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,62 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Age extends BaseModel {
-
- private static final String TAG = "Age";
-
- public static final String TABLE_NAME = "ref_ages";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String label;
-
- public Age() {
- }
-
- public Age(Cursor cursor) {
- super(cursor);
- label = cursor.getString(1);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Age.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Age.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,86 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Age extends BaseModel {
+
+ private static final String TAG = "Age";
+
+ public static final String TABLE_NAME = "ref_ages";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String label;
+
+ public Age() {
+ }
+
+ public Age(Cursor cursor) {
+ super(cursor);
+ label = cursor.getString(1);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,154 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpecies extends BaseModel implements HasCode {
-
- private static final String TAG = "CommercialSpecies";
-
- public static final String TABLE_NAME = "ref_commercial_species";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_ISSCAP = "isscap";
- public static final String COLUMN_TAXON_CODE = "taxonCode";
- public static final String COLUMN_SCIENTIFIC_LABEL = "scientificLabel";
- public static final String COLUMN_FRENCH_LABEL = "frenchLabel";
- public static final String COLUMN_FAMILY = "family";
- public static final String COLUMN_SPECIES_ORDER = "speciesOrder";
- public static final String COLUMN_ACTIVE = "active";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_ISSCAP,
- COLUMN_TAXON_CODE,
- COLUMN_SCIENTIFIC_LABEL,
- COLUMN_FRENCH_LABEL,
- COLUMN_FAMILY,
- COLUMN_SPECIES_ORDER,
- COLUMN_ACTIVE
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String isscap;
- protected String taxonCode;
- protected String scientificLabel;
- protected String frenchLabel;
- protected String family;
- protected String speciesOrder;
- protected int active;
-
- public CommercialSpecies() {
- }
-
- public CommercialSpecies(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- isscap = cursor.getString(2);
- taxonCode = cursor.getString(3);
- scientificLabel = cursor.getString(4);
- frenchLabel = cursor.getString(5);
- family = cursor.getString(6);
- speciesOrder = cursor.getString(7);
- active = cursor.getInt(8);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getIsscap() {
- return isscap;
- }
-
- public void setIsscap(String isscap) {
- this.isscap = isscap;
- }
-
- public String getTaxonCode() {
- return taxonCode;
- }
-
- public void setTaxonCode(String taxonCode) {
- this.taxonCode = taxonCode;
- }
-
- public String getScientificLabel() {
- return scientificLabel;
- }
-
- public void setScientificLabel(String scientificLabel) {
- this.scientificLabel = scientificLabel;
- }
-
- public String getFrenchLabel() {
- return frenchLabel;
- }
-
- public void setFrenchLabel(String frenchLabel) {
- this.frenchLabel = frenchLabel;
- }
-
- public String getFamily() {
- return family;
- }
-
- public void setFamily(String family) {
- this.family = family;
- }
-
- public String getSpeciesOrder() {
- return speciesOrder;
- }
-
- public void setSpeciesOrder(String speciesOrder) {
- this.speciesOrder = speciesOrder;
- }
-
- public int getActive() {
- return active;
- }
-
- public void setActive(int active) {
- this.active = active;
- }
-
- @Override
- public String toString() {
- return code + " - " + frenchLabel;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(frenchLabel, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_ISSCAP, isscap);
- putValue(value, COLUMN_TAXON_CODE, taxonCode);
- putValue(value, COLUMN_SCIENTIFIC_LABEL, scientificLabel);
- putValue(value, COLUMN_FRENCH_LABEL, frenchLabel);
- putValue(value, COLUMN_FAMILY, family);
- putValue(value, COLUMN_SPECIES_ORDER, speciesOrder);
- putValue(value, COLUMN_ACTIVE, active);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,178 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpecies extends BaseModel implements HasCode {
+
+ private static final String TAG = "CommercialSpecies";
+
+ public static final String TABLE_NAME = "ref_commercial_species";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_ISSCAP = "isscap";
+ public static final String COLUMN_TAXON_CODE = "taxonCode";
+ public static final String COLUMN_SCIENTIFIC_LABEL = "scientificLabel";
+ public static final String COLUMN_FRENCH_LABEL = "frenchLabel";
+ public static final String COLUMN_FAMILY = "family";
+ public static final String COLUMN_SPECIES_ORDER = "speciesOrder";
+ public static final String COLUMN_ACTIVE = "active";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_ISSCAP,
+ COLUMN_TAXON_CODE,
+ COLUMN_SCIENTIFIC_LABEL,
+ COLUMN_FRENCH_LABEL,
+ COLUMN_FAMILY,
+ COLUMN_SPECIES_ORDER,
+ COLUMN_ACTIVE
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String isscap;
+ protected String taxonCode;
+ protected String scientificLabel;
+ protected String frenchLabel;
+ protected String family;
+ protected String speciesOrder;
+ protected int active;
+
+ public CommercialSpecies() {
+ }
+
+ public CommercialSpecies(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ isscap = cursor.getString(2);
+ taxonCode = cursor.getString(3);
+ scientificLabel = cursor.getString(4);
+ frenchLabel = cursor.getString(5);
+ family = cursor.getString(6);
+ speciesOrder = cursor.getString(7);
+ active = cursor.getInt(8);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getIsscap() {
+ return isscap;
+ }
+
+ public void setIsscap(String isscap) {
+ this.isscap = isscap;
+ }
+
+ public String getTaxonCode() {
+ return taxonCode;
+ }
+
+ public void setTaxonCode(String taxonCode) {
+ this.taxonCode = taxonCode;
+ }
+
+ public String getScientificLabel() {
+ return scientificLabel;
+ }
+
+ public void setScientificLabel(String scientificLabel) {
+ this.scientificLabel = scientificLabel;
+ }
+
+ public String getFrenchLabel() {
+ return frenchLabel;
+ }
+
+ public void setFrenchLabel(String frenchLabel) {
+ this.frenchLabel = frenchLabel;
+ }
+
+ public String getFamily() {
+ return family;
+ }
+
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ public String getSpeciesOrder() {
+ return speciesOrder;
+ }
+
+ public void setSpeciesOrder(String speciesOrder) {
+ this.speciesOrder = speciesOrder;
+ }
+
+ public int getActive() {
+ return active;
+ }
+
+ public void setActive(int active) {
+ this.active = active;
+ }
+
+ @Override
+ public String toString() {
+ return code + " - " + frenchLabel;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(frenchLabel, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_ISSCAP, isscap);
+ putValue(value, COLUMN_TAXON_CODE, taxonCode);
+ putValue(value, COLUMN_SCIENTIFIC_LABEL, scientificLabel);
+ putValue(value, COLUMN_FRENCH_LABEL, frenchLabel);
+ putValue(value, COLUMN_FAMILY, family);
+ putValue(value, COLUMN_SPECIES_ORDER, speciesOrder);
+ putValue(value, COLUMN_ACTIVE, active);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Gender.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,75 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Gender extends BaseModel implements HasCode {
-
- private static final String TAG = "Gender";
-
- public static final String TABLE_NAME = "ref_genders";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public Gender() {
- }
-
- public Gender(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Gender.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Gender.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,99 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Gender extends BaseModel implements HasCode {
+
+ private static final String TAG = "Gender";
+
+ public static final String TABLE_NAME = "ref_genders";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public Gender() {
+ }
+
+ public Gender(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/HasCode.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,29 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import com.google.common.base.Function;
-import org.apache.commons.lang3.ObjectUtils;
-
-import java.util.Comparator;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public interface HasCode {
-
- String getCode();
-
- public static final Comparator<HasCode> GET_CODE_COMPARATOR = new Comparator<HasCode>() {
- @Override
- public int compare(HasCode lhs, HasCode rhs) {
- return ObjectUtils.compare(lhs.getCode(), rhs.getCode(), true);
- }
- };
-
- public static final Function<HasCode, String> GET_CODE_FUNCTION = new Function<HasCode, String>() {
- @Override
- public String apply(HasCode input) {
- return input.getCode();
- }
- };
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/HasCode.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,53 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Function;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.util.Comparator;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public interface HasCode {
+
+ String getCode();
+
+ public static final Comparator<HasCode> GET_CODE_COMPARATOR = new Comparator<HasCode>() {
+ @Override
+ public int compare(HasCode lhs, HasCode rhs) {
+ return ObjectUtils.compare(lhs.getCode(), rhs.getCode(), true);
+ }
+ };
+
+ public static final Function<HasCode, String> GET_CODE_FUNCTION = new Function<HasCode, String>() {
+ @Override
+ public String apply(HasCode input) {
+ return input.getCode();
+ }
+ };
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Location.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Location extends BaseModel implements HasCode {
-
- private static final String TAG = "Locations";
-
- public static final String TABLE_NAME = "ref_location";
- public static final String COLUMN_TYPE_LABEL = "typeLabel";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_TYPE_LABEL,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String typeLabel;
- protected String code;
- protected String label;
-
- public Location() {
- }
-
- public Location(Cursor cursor) {
- super(cursor);
- typeLabel = cursor.getString(1);
- code = cursor.getString(2);
- label = cursor.getString(3);
- }
-
- public String getTypeLabel() {
- return typeLabel;
- }
-
- public void setTypeLabel(String typeLabel) {
- this.typeLabel = typeLabel;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return code + " - " + label + " (" + typeLabel + ")";
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(label, context) + " ("
- + UIUtils.getStringOrUndefined(typeLabel, context) + ")";
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_TYPE_LABEL, typeLabel);
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Location.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Location.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,114 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Location extends BaseModel implements HasCode {
+
+ private static final String TAG = "Locations";
+
+ public static final String TABLE_NAME = "ref_location";
+ public static final String COLUMN_TYPE_LABEL = "typeLabel";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_TYPE_LABEL,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String typeLabel;
+ protected String code;
+ protected String label;
+
+ public Location() {
+ }
+
+ public Location(Cursor cursor) {
+ super(cursor);
+ typeLabel = cursor.getString(1);
+ code = cursor.getString(2);
+ label = cursor.getString(3);
+ }
+
+ public String getTypeLabel() {
+ return typeLabel;
+ }
+
+ public void setTypeLabel(String typeLabel) {
+ this.typeLabel = typeLabel;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return code + " - " + label + " (" + typeLabel + ")";
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(label, context) + " ("
+ + UIUtils.getStringOrUndefined(typeLabel, context) + ")";
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_TYPE_LABEL, typeLabel);
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Maturity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,62 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Maturity extends BaseModel {
-
- private static final String TAG = "Maturity";
-
- public static final String TABLE_NAME = "ref_maturities";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String label;
-
- public Maturity() {
- }
-
- public Maturity(Cursor cursor) {
- super(cursor);
- label = cursor.getString(1);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Maturity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,86 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Maturity extends BaseModel {
+
+ private static final String TAG = "Maturity";
+
+ public static final String TABLE_NAME = "ref_maturities";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String label;
+
+ public Maturity() {
+ }
+
+ public Maturity(Cursor cursor) {
+ super(cursor);
+ label = cursor.getString(1);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Mensuration.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,96 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Mensuration extends BaseModel implements HasCode {
-
- private static final String TAG = "Mensuration";
-
- public enum Precision {
- CM1("1 cm"),
- MM5("0.5 cm"),
- MM1("1 mm");
-
- private String label;
-
- private Precision(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
- @Override
- public String toString() {
- return label;
- }
- }
-
- public static final String TABLE_NAME = "ref_mensurations";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public Mensuration() {
- }
-
- public Mensuration(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Mensuration.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,136 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Mensuration extends BaseModel implements HasCode {
+
+ private static final String TAG = "Mensuration";
+
+ public enum Precision {
+ CM1(10, 10, "1 cm"),
+ MM5(5, 10, "0.5 cm"),
+ MM1(1, 1, "1 mm");
+
+ private int value;
+ private int unitDivider;
+ private String label;
+
+ private Precision(int value, int unitDivider, String label) {
+ this.value = value;
+ this.unitDivider = unitDivider;
+ this.label = label;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public int getUnitDivider() {
+ return unitDivider;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ public boolean isDecimal() {
+ return value % unitDivider > 0;
+ }
+ }
+
+ public static final String TABLE_NAME = "ref_mensurations";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public Mensuration() {
+ }
+
+ public Mensuration(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Metier.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,166 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Metier extends BaseModel implements HasCode {
-
- private static final String TAG = "Metier";
-
- public static final String TABLE_NAME = "ref_metiers";
- public static final String COLUMN_ID = "metierId";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String COLUMN_GEAR_CODE = "gearCode";
- public static final String COLUMN_GEAR_LABEL = "gearLabel";
- public static final String COLUMN_SPECIES_CODE = "speciesCode";
- public static final String COLUMN_SPECIES_LABEL = "speciesLabel";
- public static final String COLUMN_FISHING = "fishing";
- public static final String COLUMN_ACTIVE = "active";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_ID,
- COLUMN_CODE,
- COLUMN_LABEL,
- COLUMN_GEAR_CODE,
- COLUMN_GEAR_LABEL,
- COLUMN_SPECIES_CODE,
- COLUMN_SPECIES_LABEL,
- COLUMN_FISHING,
- COLUMN_ACTIVE
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String metierId;
- protected String code;
- protected String label;
- protected String gearCode;
- protected String gearLabel;
- protected String speciesCode;
- protected String speciesLabel;
- protected int fishing;
- protected int active;
-
- public Metier() {
- }
-
- public Metier(Cursor cursor) {
- super(cursor);
- metierId = cursor.getString(1);
- code = cursor.getString(2);
- label = cursor.getString(3);
- gearCode = cursor.getString(4);
- gearLabel = cursor.getString(5);
- speciesCode = cursor.getString(6);
- speciesLabel = cursor.getString(7);
- fishing = cursor.getInt(8);
- active = cursor.getInt(9);
- }
-
- public String getMetierId() {
- return metierId;
- }
-
- public void setMetierId(String metierId) {
- this.metierId = metierId;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getGearCode() {
- return gearCode;
- }
-
- public void setGearCode(String gearCode) {
- this.gearCode = gearCode;
- }
-
- public String getGearLabel() {
- return gearLabel;
- }
-
- public void setGearLabel(String gearLabel) {
- this.gearLabel = gearLabel;
- }
-
- public String getSpeciesCode() {
- return speciesCode;
- }
-
- public void setSpeciesCode(String speciesCode) {
- this.speciesCode = speciesCode;
- }
-
- public String getSpeciesLabel() {
- return speciesLabel;
- }
-
- public void setSpeciesLabel(String speciesLabel) {
- this.speciesLabel = speciesLabel;
- }
-
- public int getFishing() {
- return fishing;
- }
-
- public void setFishing(int fishing) {
- this.fishing = fishing;
- }
-
- public int getActive() {
- return active;
- }
-
- public void setActive(int active) {
- this.active = active;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_ID, metierId);
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- putValue(value, COLUMN_GEAR_CODE, gearCode);
- putValue(value, COLUMN_GEAR_LABEL, gearLabel);
- putValue(value, COLUMN_SPECIES_CODE, speciesCode);
- putValue(value, COLUMN_SPECIES_LABEL, speciesLabel);
- putValue(value, COLUMN_FISHING, fishing);
- putValue(value, COLUMN_ACTIVE, active);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Metier.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Metier.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,190 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Metier extends BaseModel implements HasCode {
+
+ private static final String TAG = "Metier";
+
+ public static final String TABLE_NAME = "ref_metiers";
+ public static final String COLUMN_ID = "metierId";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String COLUMN_GEAR_CODE = "gearCode";
+ public static final String COLUMN_GEAR_LABEL = "gearLabel";
+ public static final String COLUMN_SPECIES_CODE = "speciesCode";
+ public static final String COLUMN_SPECIES_LABEL = "speciesLabel";
+ public static final String COLUMN_FISHING = "fishing";
+ public static final String COLUMN_ACTIVE = "active";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_ID,
+ COLUMN_CODE,
+ COLUMN_LABEL,
+ COLUMN_GEAR_CODE,
+ COLUMN_GEAR_LABEL,
+ COLUMN_SPECIES_CODE,
+ COLUMN_SPECIES_LABEL,
+ COLUMN_FISHING,
+ COLUMN_ACTIVE
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String metierId;
+ protected String code;
+ protected String label;
+ protected String gearCode;
+ protected String gearLabel;
+ protected String speciesCode;
+ protected String speciesLabel;
+ protected int fishing;
+ protected int active;
+
+ public Metier() {
+ }
+
+ public Metier(Cursor cursor) {
+ super(cursor);
+ metierId = cursor.getString(1);
+ code = cursor.getString(2);
+ label = cursor.getString(3);
+ gearCode = cursor.getString(4);
+ gearLabel = cursor.getString(5);
+ speciesCode = cursor.getString(6);
+ speciesLabel = cursor.getString(7);
+ fishing = cursor.getInt(8);
+ active = cursor.getInt(9);
+ }
+
+ public String getMetierId() {
+ return metierId;
+ }
+
+ public void setMetierId(String metierId) {
+ this.metierId = metierId;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getGearCode() {
+ return gearCode;
+ }
+
+ public void setGearCode(String gearCode) {
+ this.gearCode = gearCode;
+ }
+
+ public String getGearLabel() {
+ return gearLabel;
+ }
+
+ public void setGearLabel(String gearLabel) {
+ this.gearLabel = gearLabel;
+ }
+
+ public String getSpeciesCode() {
+ return speciesCode;
+ }
+
+ public void setSpeciesCode(String speciesCode) {
+ this.speciesCode = speciesCode;
+ }
+
+ public String getSpeciesLabel() {
+ return speciesLabel;
+ }
+
+ public void setSpeciesLabel(String speciesLabel) {
+ this.speciesLabel = speciesLabel;
+ }
+
+ public int getFishing() {
+ return fishing;
+ }
+
+ public void setFishing(int fishing) {
+ this.fishing = fishing;
+ }
+
+ public int getActive() {
+ return active;
+ }
+
+ public void setActive(int active) {
+ this.active = active;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_ID, metierId);
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ putValue(value, COLUMN_GEAR_CODE, gearCode);
+ putValue(value, COLUMN_GEAR_LABEL, gearLabel);
+ putValue(value, COLUMN_SPECIES_CODE, speciesCode);
+ putValue(value, COLUMN_SPECIES_LABEL, speciesLabel);
+ putValue(value, COLUMN_FISHING, fishing);
+ putValue(value, COLUMN_ACTIVE, active);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Presentation.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,75 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Presentation extends BaseModel implements HasCode {
-
- private static final String TAG = "Presentation";
-
- public static final String TABLE_NAME = "ref_presentations";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public Presentation() {
- }
-
- public Presentation(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Presentation.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,99 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Presentation extends BaseModel implements HasCode {
+
+ private static final String TAG = "Presentation";
+
+ public static final String TABLE_NAME = "ref_presentations";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public Presentation() {
+ }
+
+ public Presentation(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,89 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpecies extends BaseModel implements HasCode {
-
- private static final String TAG = "ScientificSpecies";
-
- public static final String TABLE_NAME = "ref_scientific_species";
- public static final String COLUMN_PERM_CODE = "permCode";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_PERM_CODE,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String permCode;
- protected String code;
- protected String label;
-
- public ScientificSpecies() {
- }
-
- public ScientificSpecies(Cursor cursor) {
- super(cursor);
- permCode = cursor.getString(1);
- code = cursor.getString(2);
- label = cursor.getString(3);
- }
-
- public String getPermCode() {
- return permCode;
- }
-
- public void setPermCode(String permCode) {
- this.permCode = permCode;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return code + " - " + label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_PERM_CODE, permCode);
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,113 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpecies extends BaseModel implements HasCode {
+
+ private static final String TAG = "ScientificSpecies";
+
+ public static final String TABLE_NAME = "ref_scientific_species";
+ public static final String COLUMN_PERM_CODE = "permCode";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_PERM_CODE,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String permCode;
+ protected String code;
+ protected String label;
+
+ public ScientificSpecies() {
+ }
+
+ public ScientificSpecies(Cursor cursor) {
+ super(cursor);
+ permCode = cursor.getString(1);
+ code = cursor.getString(2);
+ label = cursor.getString(3);
+ }
+
+ public String getPermCode() {
+ return permCode;
+ }
+
+ public void setPermCode(String permCode) {
+ this.permCode = permCode;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return code + " - " + label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_PERM_CODE, permCode);
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/State.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,75 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class State extends BaseModel implements HasCode {
-
- private static final String TAG = "State";
-
- public static final String TABLE_NAME = "ref_states";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public State() {
- }
-
- public State(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/State.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/State.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,99 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class State extends BaseModel implements HasCode {
+
+ private static final String TAG = "State";
+
+ public static final String TABLE_NAME = "ref_states";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public State() {
+ }
+
+ public State(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Vessel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,84 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Vessel extends BaseModel implements HasCode {
-
- private static final String TAG = "Vessel";
-
- public static final String TABLE_NAME = "ref_vessel";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_QUARTER_CODE = "quarterCode";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_NAME,
- COLUMN_QUARTER_CODE
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String name;
- protected String quarterCode;
-
- public Vessel() {
- }
-
- public Vessel(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- name = cursor.getString(2);
- quarterCode = cursor.getString(3);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getQuarterCode() {
- return quarterCode;
- }
-
- public void setQuarterCode(String quarterCode) {
- this.quarterCode = quarterCode;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(name, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_NAME, name);
- putValue(value, COLUMN_QUARTER_CODE, quarterCode);
- return value;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Vessel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,108 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Vessel extends BaseModel implements HasCode {
+
+ private static final String TAG = "Vessel";
+
+ public static final String TABLE_NAME = "ref_vessel";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_QUARTER_CODE = "quarterCode";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_NAME,
+ COLUMN_QUARTER_CODE
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String name;
+ protected String quarterCode;
+
+ public Vessel() {
+ }
+
+ public Vessel(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ name = cursor.getString(2);
+ quarterCode = cursor.getString(3);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getQuarterCode() {
+ return quarterCode;
+ }
+
+ public void setQuarterCode(String quarterCode) {
+ this.quarterCode = quarterCode;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(name, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_NAME, name);
+ putValue(value, COLUMN_QUARTER_CODE, quarterCode);
+ return value;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,28 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Age;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class AgeRowModel extends AbstractImportExportModel<Age> {
-
- public AgeRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Age", new ValueSetter<Age, String>() {
- @Override
- public void set(Age object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Age newEmptyInstance() {
- return new Age();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,52 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Age;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class AgeRowModel extends AbstractImportExportModel<Age> {
+
+ public AgeRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Age", new ValueSetter<Age, String>() {
+ @Override
+ public void set(Age object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Age newEmptyInstance() {
+ return new Age();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,77 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesRowModel extends AbstractImportExportModel<CommercialSpecies> {
-
-
- public CommercialSpeciesRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("ESPF_COD", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("ESPF_ISSCAP", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setIsscap(value);
- }
- });
- newMandatoryColumn("ESPF_TAXON_COD", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setTaxonCode(value);
- }
- });
- newMandatoryColumn("ESPF_SCI_LIB", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setScientificLabel(value);
- }
- });
- newMandatoryColumn("ESPF_FRA_LIB", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setFrenchLabel(value);
- }
- });
- newMandatoryColumn("ESPF_FAMILLE", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setFamily(value);
- }
- });
- newMandatoryColumn("ESPF_ORDRE", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setSpeciesOrder(value);
- }
- });
- newMandatoryColumn("ESPF_ACT", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- Integer iValue;
- try {
- iValue = Integer.valueOf(value);
- } catch (NumberFormatException e) {
- iValue = 0;
- }
- object.setActive(iValue);
- }
- });
- }
-
- @Override
- public CommercialSpecies newEmptyInstance() {
- return new CommercialSpecies();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,101 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesRowModel extends AbstractImportExportModel<CommercialSpecies> {
+
+
+ public CommercialSpeciesRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("ESPF_COD", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("ESPF_ISSCAP", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setIsscap(value);
+ }
+ });
+ newMandatoryColumn("ESPF_TAXON_COD", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setTaxonCode(value);
+ }
+ });
+ newMandatoryColumn("ESPF_SCI_LIB", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setScientificLabel(value);
+ }
+ });
+ newMandatoryColumn("ESPF_FRA_LIB", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setFrenchLabel(value);
+ }
+ });
+ newMandatoryColumn("ESPF_FAMILLE", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setFamily(value);
+ }
+ });
+ newMandatoryColumn("ESPF_ORDRE", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setSpeciesOrder(value);
+ }
+ });
+ newMandatoryColumn("ESPF_ACT", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ Integer iValue;
+ try {
+ iValue = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ iValue = 0;
+ }
+ object.setActive(iValue);
+ }
+ });
+ }
+
+ @Override
+ public CommercialSpecies newEmptyInstance() {
+ return new CommercialSpecies();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Gender;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class GenderRowModel extends AbstractImportExportModel<Gender> {
-
-
- public GenderRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Sexe_cod", new ValueSetter<Gender, String>() {
- @Override
- public void set(Gender object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Sexe_lib", new ValueSetter<Gender, String>() {
- @Override
- public void set(Gender object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Gender newEmptyInstance() {
- return new Gender();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Gender;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class GenderRowModel extends AbstractImportExportModel<Gender> {
+
+
+ public GenderRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Sexe_cod", new ValueSetter<Gender, String>() {
+ @Override
+ public void set(Gender object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Sexe_lib", new ValueSetter<Gender, String>() {
+ @Override
+ public void set(Gender object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Gender newEmptyInstance() {
+ return new Gender();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,254 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import android.content.Context;
-import android.util.Log;
-import android.widget.Toast;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.referentials.HasCode;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.models.BaseModel;
-import org.nuiton.csv.Import;
-import org.nuiton.csv.ImportModel;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ImportUtil {
-
- private static final String TAG = "ImportUtil";
-
- public static final char CSV_SEPARATOR = ';';
-
- public static int importAges(Context context, String path) {
- try {
- return importAges(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importAges(Context context, InputStream inputStream) {
- AgeRowModel ageRowModel = new AgeRowModel(CSV_SEPARATOR);
- int result = importData(context, ageRowModel, inputStream, DataCache.getAllAges(context));
- DataCache.invalidateAges();
- return result;
- }
-
- public static int importCommercialSpecies(Context context, String path) {
- try {
- return importCommercialSpecies(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importCommercialSpecies(Context context, InputStream inputStream) {
- CommercialSpeciesRowModel commercialSpeciesRowModel = new CommercialSpeciesRowModel(CSV_SEPARATOR);
- int result = importData(context, commercialSpeciesRowModel, inputStream, DataCache.getAllCommercialSpecies(context));
- DataCache.invalidateCommercialSpecies();
- return result;
- }
-
- public static int importGenders(Context context, String path) {
- try {
- return importGenders(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importGenders(Context context, InputStream inputStream) {
- GenderRowModel genderRowModel = new GenderRowModel(CSV_SEPARATOR);
- int result = importData(context, genderRowModel, inputStream, DataCache.getAllGenders(context));
- DataCache.invalidateGenders();
- return result;
- }
-
- public static int importLocations(Context context, String path) {
- try {
- return importLocations(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importLocations(Context context, InputStream inputStream) {
- LocationRowModel locationRowModel = new LocationRowModel(CSV_SEPARATOR);
- int result = importData(context, locationRowModel, inputStream, DataCache.getAllLocations(context));
- DataCache.invalidateLocations();
- return result;
- }
-
- public static int importMaturities(Context context, String path) {
- try {
- return importMaturities(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importMaturities(Context context, InputStream inputStream) {
- MaturityRowModel maturityRowModel = new MaturityRowModel(CSV_SEPARATOR);
- int result = importData(context, maturityRowModel, inputStream, DataCache.getAllMaturities(context));
- DataCache.invalidateMaturities();
- return result;
- }
-
- public static int importMensurations(Context context, String path) {
- try {
- return importMensurations(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importMensurations(Context context, InputStream inputStream) {
- MensurationRowModel mensurationRowModel = new MensurationRowModel(CSV_SEPARATOR);
- int result = importData(context, mensurationRowModel, inputStream, DataCache.getAllMensurations(context));
- DataCache.invalidateMensurations();
- return result;
- }
-
- public static int importMetiers(Context context, String path) {
- try {
- return importMetiers(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importMetiers(Context context, InputStream inputStream) {
- MetierRowModel metierRowModel = new MetierRowModel(CSV_SEPARATOR);
- int result = importData(context, metierRowModel, inputStream, DataCache.getAllMetiers(context));
- DataCache.invalidateMetiers();
- return result;
- }
-
- public static int importPresentations(Context context, String path) {
- try {
- return importPresentations(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importPresentations(Context context, InputStream inputStream) {
- PresentationRowModel presentationRowModel = new PresentationRowModel(CSV_SEPARATOR);
- int result = importData(context, presentationRowModel, inputStream, DataCache.getAllPresentations(context));
- DataCache.invalidatePresentations();
- return result;
- }
-
- public static int importScientificSpecies(Context context, String path) {
- try {
- return importScientificSpecies(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importScientificSpecies(Context context, InputStream inputStream) {
- ScientificSpeciesRowModel scientificSpeciesRowModel = new ScientificSpeciesRowModel(CSV_SEPARATOR);
- int result = importData(context, scientificSpeciesRowModel, inputStream, DataCache.getAllScientificSpecies(context));
- DataCache.invalidateScientificSpecies();
- return result;
- }
-
- public static int importStates(Context context, String path) {
- try {
- return importStates(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importStates(Context context, InputStream inputStream) {
- StateRowModel stateRowModel = new StateRowModel(CSV_SEPARATOR);
- int result = importData(context, stateRowModel, inputStream, DataCache.getAllStates(context));
- DataCache.invalidateStates();
- return result;
- }
-
- public static int importVessels(Context context, String path) {
- try {
- return importVessels(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importVessels(Context context, InputStream inputStream) {
- VesselRowModel vesselRowModel = new VesselRowModel(CSV_SEPARATOR);
- int result = importData(context, vesselRowModel, inputStream, DataCache.getAllVessels(context));
- DataCache.invalidateVessels();
- return result;
- }
-
- protected static <M extends BaseModel> int importData(Context context, ImportModel<M> importModel,
- InputStream inputStream, final Collection<M> actualReferential) {
- Preconditions.checkNotNull(actualReferential);
- Import<M> importer = Import.newImport(importModel, inputStream);
- Collection<M> models = Lists.newArrayList(importer.iterator());
-
- if (!models.isEmpty()) {
- Predicate<M> filter;
- //if the models have a code attribute, check
- M first = models.iterator().next();
- if (HasCode.class.isAssignableFrom(first.getClass())) {
- Collection<HasCode> hasCodes = Collections2.transform(actualReferential, new Function<M, HasCode>() {
- @Override
- public HasCode apply(M m) {
- return (HasCode) m;
- }
- });
- final Collection<String> codes = Collections2.transform(hasCodes, HasCode.GET_CODE_FUNCTION);
- filter = new Predicate<M>() {
- @Override
- public boolean apply(M model) {
- HasCode hasCode = (HasCode) model;
- return !codes.contains(hasCode.getCode());
- }
- };
- } else {
- filter = new Predicate<M>() {
- @Override
- public boolean apply(M m) {
- return !actualReferential.contains(m);
- }
- };
- }
-
- models = Collections2.filter(models, filter);
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- soh.saveData(models);
- soh.close();
- }
-
- importer.close();
- return models.size();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,278 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.util.Log;
+import android.widget.Toast;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.referentials.HasCode;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.models.BaseModel;
+import org.nuiton.csv.Import;
+import org.nuiton.csv.ImportModel;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ImportUtil {
+
+ private static final String TAG = "ImportUtil";
+
+ public static final char CSV_SEPARATOR = ';';
+
+ public static int importAges(Context context, String path) {
+ try {
+ return importAges(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importAges(Context context, InputStream inputStream) {
+ AgeRowModel ageRowModel = new AgeRowModel(CSV_SEPARATOR);
+ int result = importData(context, ageRowModel, inputStream, DataCache.getAllAges(context));
+ DataCache.invalidateAges();
+ return result;
+ }
+
+ public static int importCommercialSpecies(Context context, String path) {
+ try {
+ return importCommercialSpecies(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importCommercialSpecies(Context context, InputStream inputStream) {
+ CommercialSpeciesRowModel commercialSpeciesRowModel = new CommercialSpeciesRowModel(CSV_SEPARATOR);
+ int result = importData(context, commercialSpeciesRowModel, inputStream, DataCache.getAllCommercialSpecies(context));
+ DataCache.invalidateCommercialSpecies();
+ return result;
+ }
+
+ public static int importGenders(Context context, String path) {
+ try {
+ return importGenders(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importGenders(Context context, InputStream inputStream) {
+ GenderRowModel genderRowModel = new GenderRowModel(CSV_SEPARATOR);
+ int result = importData(context, genderRowModel, inputStream, DataCache.getAllGenders(context));
+ DataCache.invalidateGenders();
+ return result;
+ }
+
+ public static int importLocations(Context context, String path) {
+ try {
+ return importLocations(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importLocations(Context context, InputStream inputStream) {
+ LocationRowModel locationRowModel = new LocationRowModel(CSV_SEPARATOR);
+ int result = importData(context, locationRowModel, inputStream, DataCache.getAllLocations(context));
+ DataCache.invalidateLocations();
+ return result;
+ }
+
+ public static int importMaturities(Context context, String path) {
+ try {
+ return importMaturities(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importMaturities(Context context, InputStream inputStream) {
+ MaturityRowModel maturityRowModel = new MaturityRowModel(CSV_SEPARATOR);
+ int result = importData(context, maturityRowModel, inputStream, DataCache.getAllMaturities(context));
+ DataCache.invalidateMaturities();
+ return result;
+ }
+
+ public static int importMensurations(Context context, String path) {
+ try {
+ return importMensurations(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importMensurations(Context context, InputStream inputStream) {
+ MensurationRowModel mensurationRowModel = new MensurationRowModel(CSV_SEPARATOR);
+ int result = importData(context, mensurationRowModel, inputStream, DataCache.getAllMensurations(context));
+ DataCache.invalidateMensurations();
+ return result;
+ }
+
+ public static int importMetiers(Context context, String path) {
+ try {
+ return importMetiers(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importMetiers(Context context, InputStream inputStream) {
+ MetierRowModel metierRowModel = new MetierRowModel(CSV_SEPARATOR);
+ int result = importData(context, metierRowModel, inputStream, DataCache.getAllMetiers(context));
+ DataCache.invalidateMetiers();
+ return result;
+ }
+
+ public static int importPresentations(Context context, String path) {
+ try {
+ return importPresentations(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importPresentations(Context context, InputStream inputStream) {
+ PresentationRowModel presentationRowModel = new PresentationRowModel(CSV_SEPARATOR);
+ int result = importData(context, presentationRowModel, inputStream, DataCache.getAllPresentations(context));
+ DataCache.invalidatePresentations();
+ return result;
+ }
+
+ public static int importScientificSpecies(Context context, String path) {
+ try {
+ return importScientificSpecies(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importScientificSpecies(Context context, InputStream inputStream) {
+ ScientificSpeciesRowModel scientificSpeciesRowModel = new ScientificSpeciesRowModel(CSV_SEPARATOR);
+ int result = importData(context, scientificSpeciesRowModel, inputStream, DataCache.getAllScientificSpecies(context));
+ DataCache.invalidateScientificSpecies();
+ return result;
+ }
+
+ public static int importStates(Context context, String path) {
+ try {
+ return importStates(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importStates(Context context, InputStream inputStream) {
+ StateRowModel stateRowModel = new StateRowModel(CSV_SEPARATOR);
+ int result = importData(context, stateRowModel, inputStream, DataCache.getAllStates(context));
+ DataCache.invalidateStates();
+ return result;
+ }
+
+ public static int importVessels(Context context, String path) {
+ try {
+ return importVessels(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importVessels(Context context, InputStream inputStream) {
+ VesselRowModel vesselRowModel = new VesselRowModel(CSV_SEPARATOR);
+ int result = importData(context, vesselRowModel, inputStream, DataCache.getAllVessels(context));
+ DataCache.invalidateVessels();
+ return result;
+ }
+
+ protected static <M extends BaseModel> int importData(Context context, ImportModel<M> importModel,
+ InputStream inputStream, final Collection<M> actualReferential) {
+ Preconditions.checkNotNull(actualReferential);
+ Import<M> importer = Import.newImport(importModel, inputStream);
+ Collection<M> models = Lists.newArrayList(importer.iterator());
+
+ if (!models.isEmpty()) {
+ Predicate<M> filter;
+ //if the models have a code attribute, check
+ M first = models.iterator().next();
+ if (HasCode.class.isAssignableFrom(first.getClass())) {
+ Collection<HasCode> hasCodes = Collections2.transform(actualReferential, new Function<M, HasCode>() {
+ @Override
+ public HasCode apply(M m) {
+ return (HasCode) m;
+ }
+ });
+ final Collection<String> codes = Collections2.transform(hasCodes, HasCode.GET_CODE_FUNCTION);
+ filter = new Predicate<M>() {
+ @Override
+ public boolean apply(M model) {
+ HasCode hasCode = (HasCode) model;
+ return !codes.contains(hasCode.getCode());
+ }
+ };
+ } else {
+ filter = new Predicate<M>() {
+ @Override
+ public boolean apply(M m) {
+ return !actualReferential.contains(m);
+ }
+ };
+ }
+
+ models = Collections2.filter(models, filter);
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ soh.saveData(models);
+ soh.close();
+ }
+
+ importer.close();
+ return models.size();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,41 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Location;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationRowModel extends AbstractImportExportModel<Location> {
-
-
- public LocationRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("TLIEU_LIB", new ValueSetter<Location, String>() {
- @Override
- public void set(Location object, String value) throws Exception {
- object.setTypeLabel(value);
- }
- });
- newMandatoryColumn("LIEU_COD", new ValueSetter<Location, String>() {
- @Override
- public void set(Location object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("LIEU_LIB", new ValueSetter<Location, String>() {
- @Override
- public void set(Location object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Location newEmptyInstance() {
- return new Location();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,65 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Location;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationRowModel extends AbstractImportExportModel<Location> {
+
+
+ public LocationRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("TLIEU_LIB", new ValueSetter<Location, String>() {
+ @Override
+ public void set(Location object, String value) throws Exception {
+ object.setTypeLabel(value);
+ }
+ });
+ newMandatoryColumn("LIEU_COD", new ValueSetter<Location, String>() {
+ @Override
+ public void set(Location object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("LIEU_LIB", new ValueSetter<Location, String>() {
+ @Override
+ public void set(Location object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Location newEmptyInstance() {
+ return new Location();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,29 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Maturity;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MaturityRowModel extends AbstractImportExportModel<Maturity> {
-
-
- public MaturityRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Maturite", new ValueSetter<Maturity, String>() {
- @Override
- public void set(Maturity object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Maturity newEmptyInstance() {
- return new Maturity();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,53 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Maturity;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MaturityRowModel extends AbstractImportExportModel<Maturity> {
+
+
+ public MaturityRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Maturite", new ValueSetter<Maturity, String>() {
+ @Override
+ public void set(Maturity object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Maturity newEmptyInstance() {
+ return new Maturity();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MensurationRowModel extends AbstractImportExportModel<Mensuration> {
-
-
- public MensurationRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Type_Longueur_cod", new ValueSetter<Mensuration, String>() {
- @Override
- public void set(Mensuration object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Type_Longueur_lib", new ValueSetter<Mensuration, String>() {
- @Override
- public void set(Mensuration object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Mensuration newEmptyInstance() {
- return new Mensuration();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MensurationRowModel extends AbstractImportExportModel<Mensuration> {
+
+
+ public MensurationRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Type_Longueur_cod", new ValueSetter<Mensuration, String>() {
+ @Override
+ public void set(Mensuration object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Type_Longueur_lib", new ValueSetter<Mensuration, String>() {
+ @Override
+ public void set(Mensuration object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Mensuration newEmptyInstance() {
+ return new Mensuration();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,89 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Metier;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetierRowModel extends AbstractImportExportModel<Metier> {
-
-
- public MetierRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("MET_ID", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setMetierId(value);
- }
- });
- newMandatoryColumn("MET_COD", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("MET_LIB", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- newMandatoryColumn("MET_ENGIN_COD", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setGearCode(value);
- }
- });
- newMandatoryColumn("MET_ENGIN_LIB", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setGearLabel(value);
- }
- });
- newMandatoryColumn("MET_ESPECE_COD", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setSpeciesCode(value);
- }
- });
- newMandatoryColumn("MET_ESPECE_LIB", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setSpeciesLabel(value);
- }
- });
- newMandatoryColumn("MET_PECHE", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- Integer iValue;
- try {
- iValue = Integer.valueOf(value);
- } catch (NumberFormatException e) {
- iValue = 0;
- }
- object.setFishing(iValue);
- }
- });
- newMandatoryColumn("MET_ACT", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- Integer iValue;
- try {
- iValue = Integer.valueOf(value);
- } catch (NumberFormatException e) {
- iValue = 0;
- }
- object.setActive(iValue);
- }
- });
- }
-
- @Override
- public Metier newEmptyInstance() {
- return new Metier();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,113 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Metier;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetierRowModel extends AbstractImportExportModel<Metier> {
+
+
+ public MetierRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("MET_ID", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setMetierId(value);
+ }
+ });
+ newMandatoryColumn("MET_COD", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("MET_LIB", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ newMandatoryColumn("MET_ENGIN_COD", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setGearCode(value);
+ }
+ });
+ newMandatoryColumn("MET_ENGIN_LIB", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setGearLabel(value);
+ }
+ });
+ newMandatoryColumn("MET_ESPECE_COD", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setSpeciesCode(value);
+ }
+ });
+ newMandatoryColumn("MET_ESPECE_LIB", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setSpeciesLabel(value);
+ }
+ });
+ newMandatoryColumn("MET_PECHE", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ Integer iValue;
+ try {
+ iValue = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ iValue = 0;
+ }
+ object.setFishing(iValue);
+ }
+ });
+ newMandatoryColumn("MET_ACT", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ Integer iValue;
+ try {
+ iValue = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ iValue = 0;
+ }
+ object.setActive(iValue);
+ }
+ });
+ }
+
+ @Override
+ public Metier newEmptyInstance() {
+ return new Metier();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Presentation;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class PresentationRowModel extends AbstractImportExportModel<Presentation> {
-
-
- public PresentationRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Presentation_cod", new ValueSetter<Presentation, String>() {
- @Override
- public void set(Presentation object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Presentation_lib", new ValueSetter<Presentation, String>() {
- @Override
- public void set(Presentation object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Presentation newEmptyInstance() {
- return new Presentation();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Presentation;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class PresentationRowModel extends AbstractImportExportModel<Presentation> {
+
+
+ public PresentationRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Presentation_cod", new ValueSetter<Presentation, String>() {
+ @Override
+ public void set(Presentation object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Presentation_lib", new ValueSetter<Presentation, String>() {
+ @Override
+ public void set(Presentation object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Presentation newEmptyInstance() {
+ return new Presentation();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,41 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesRowModel extends AbstractImportExportModel<ScientificSpecies> {
-
-
- public ScientificSpeciesRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("C_Perm", new ValueSetter<ScientificSpecies, String>() {
- @Override
- public void set(ScientificSpecies object, String value) throws Exception {
- object.setPermCode(value);
- }
- });
- newMandatoryColumn("C_VALIDE", new ValueSetter<ScientificSpecies, String>() {
- @Override
- public void set(ScientificSpecies object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("L_VALIDE", new ValueSetter<ScientificSpecies, String>() {
- @Override
- public void set(ScientificSpecies object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public ScientificSpecies newEmptyInstance() {
- return new ScientificSpecies();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,65 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesRowModel extends AbstractImportExportModel<ScientificSpecies> {
+
+
+ public ScientificSpeciesRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("C_Perm", new ValueSetter<ScientificSpecies, String>() {
+ @Override
+ public void set(ScientificSpecies object, String value) throws Exception {
+ object.setPermCode(value);
+ }
+ });
+ newMandatoryColumn("C_VALIDE", new ValueSetter<ScientificSpecies, String>() {
+ @Override
+ public void set(ScientificSpecies object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("L_VALIDE", new ValueSetter<ScientificSpecies, String>() {
+ @Override
+ public void set(ScientificSpecies object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public ScientificSpecies newEmptyInstance() {
+ return new ScientificSpecies();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.State;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class StateRowModel extends AbstractImportExportModel<State> {
-
-
- public StateRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Etat_cod", new ValueSetter<State, String>() {
- @Override
- public void set(State object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Etat_lib", new ValueSetter<State, String>() {
- @Override
- public void set(State object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public State newEmptyInstance() {
- return new State();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.State;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class StateRowModel extends AbstractImportExportModel<State> {
+
+
+ public StateRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Etat_cod", new ValueSetter<State, String>() {
+ @Override
+ public void set(State object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Etat_lib", new ValueSetter<State, String>() {
+ @Override
+ public void set(State object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public State newEmptyInstance() {
+ return new State();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,41 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Vessel;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselRowModel extends AbstractImportExportModel<Vessel> {
-
-
- public VesselRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("NAVS_COD", new ValueSetter<Vessel, String>() {
- @Override
- public void set(Vessel object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("CARN_NOM", new ValueSetter<Vessel, String>() {
- @Override
- public void set(Vessel object, String value) throws Exception {
- object.setName(value);
- }
- });
- newMandatoryColumn("QUARTIER_COD", new ValueSetter<Vessel, String>() {
- @Override
- public void set(Vessel object, String value) throws Exception {
- object.setQuarterCode(value);
- }
- });
- }
-
- @Override
- public Vessel newEmptyInstance() {
- return new Vessel();
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,65 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Vessel;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselRowModel extends AbstractImportExportModel<Vessel> {
+
+
+ public VesselRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("NAVS_COD", new ValueSetter<Vessel, String>() {
+ @Override
+ public void set(Vessel object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("CARN_NOM", new ValueSetter<Vessel, String>() {
+ @Override
+ public void set(Vessel object, String value) throws Exception {
+ object.setName(value);
+ }
+ });
+ newMandatoryColumn("QUARTIER_COD", new ValueSetter<Vessel, String>() {
+ @Override
+ public void set(Vessel object, String value) throws Exception {
+ object.setQuarterCode(value);
+ }
+ });
+ }
+
+ @Override
+ public Vessel newEmptyInstance() {
+ return new Vessel();
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/ListItemPreference.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,62 +0,0 @@
-package fr.ifremer.wlo.preferences;
-
-import android.content.Context;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.R;
-
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public enum ListItemPreference {
-
- WEIGHT_UNIT("preferences_weight_unit", R.array.preferences_weight_unit_entries, R.array.preferences_weight_unit_values),
- DATE_FORMAT("preferences_date_format", R.array.preferences_date_format_entries, R.array.preferences_date_format_values),
- USE_PLACE("preferences_use_place", R.array.preferences_use_place_entries, R.array.preferences_use_place_values);
-
- private static final String TAG = "ListItemPreference";
-
- private String key;
- private int entriesArrayId;
- private int valuesArrayId;
-
- private ListItemPreference(String key, int entriesArrayId, int valuesArrayId) {
- this.key = key;
- this.entriesArrayId = entriesArrayId;
- this.valuesArrayId = valuesArrayId;
- }
-
- public String getKey() {
- return key;
- }
-
- public int getEntriesArrayId() {
- return entriesArrayId;
- }
-
- public int getValuesArrayId() {
- return valuesArrayId;
- }
-
- public String getEntryForValue(Context context, String value) {
- List<String> values = Lists.newArrayList(context.getResources().getStringArray(valuesArrayId));
- String[] entries = context.getResources().getStringArray(entriesArrayId);
- int index = values.indexOf(value);
- if (index < 0) {
- return null;
- }
- return entries[index];
- }
-
- public static ListItemPreference getListItemPreference(String key) {
- for (ListItemPreference pref : values()) {
- if (pref.getKey().equals(key)) {
- return pref;
- }
- }
- return null;
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java (from rev 25, trunk/src/fr/ifremer/wlo/preferences/ListItemPreference.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,86 @@
+package fr.ifremer.wlo.preferences;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.R;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public enum ListItemPreference {
+
+ WEIGHT_UNIT("preferences_weight_unit", R.array.preferences_weight_unit_entries, R.array.preferences_weight_unit_values),
+ DATE_FORMAT("preferences_date_format", R.array.preferences_date_format_entries, R.array.preferences_date_format_values),
+ USE_PLACE("preferences_use_place", R.array.preferences_use_place_entries, R.array.preferences_use_place_values);
+
+ private static final String TAG = "ListItemPreference";
+
+ private String key;
+ private int entriesArrayId;
+ private int valuesArrayId;
+
+ private ListItemPreference(String key, int entriesArrayId, int valuesArrayId) {
+ this.key = key;
+ this.entriesArrayId = entriesArrayId;
+ this.valuesArrayId = valuesArrayId;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public int getEntriesArrayId() {
+ return entriesArrayId;
+ }
+
+ public int getValuesArrayId() {
+ return valuesArrayId;
+ }
+
+ public String getEntryForValue(Context context, String value) {
+ List<String> values = Lists.newArrayList(context.getResources().getStringArray(valuesArrayId));
+ String[] entries = context.getResources().getStringArray(entriesArrayId);
+ int index = values.indexOf(value);
+ if (index < 0) {
+ return null;
+ }
+ return entries[index];
+ }
+
+ public static ListItemPreference getListItemPreference(String key) {
+ for (ListItemPreference pref : values()) {
+ if (pref.getKey().equals(key)) {
+ return pref;
+ }
+ }
+ return null;
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,308 +0,0 @@
-package fr.ifremer.wlo.preferences;
-
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.Environment;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.text.format.DateFormat;
-import android.util.Log;
-import android.widget.Toast;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.MainActivity;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.WloBaseActivity;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.StorageUtils;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
-import fr.ifremer.wlo.utils.UIUtils;
-import fr.ifremer.wlo.utils.filechooser.FileDialog;
-import fr.ifremer.wlo.utils.filechooser.SelectionMode;
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class SettingsActivity extends WloBaseActivity {
-
- private static final String TAG = "SettingsActivity";
-
- protected static final int REQUEST_IMPORT_AGES = 0;
- protected static final int REQUEST_IMPORT_COMMERCIAL_SPECIES = 1;
- protected static final int REQUEST_IMPORT_GENDERS = 2;
- protected static final int REQUEST_IMPORT_LOCATIONS = 3;
- protected static final int REQUEST_IMPORT_MATURITIES = 4;
- protected static final int REQUEST_IMPORT_MENSURATIONS = 5;
- protected static final int REQUEST_IMPORT_METIERS = 6;
- protected static final int REQUEST_IMPORT_PRESENTATIONS = 7;
- protected static final int REQUEST_IMPORT_SCIENTIFIC_SPECIES = 8;
- protected static final int REQUEST_IMPORT_STATES = 9;
- protected static final int REQUEST_IMPORT_VESSELS = 10;
- @Override
- protected Integer getContentView() {
- return null;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MainActivity.class;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Display the fragment as the main content.
- getFragmentManager().beginTransaction()
- .replace(android.R.id.content, new SettingsFragment())
- .commit();
-
- }
-
- public static class SettingsFragment extends PreferenceFragment
- implements SharedPreferences.OnSharedPreferenceChangeListener {
-
- // map pref_key / request code
- protected BiMap<String, Integer> requestCodeByPrefKey = HashBiMap.create();
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.preferences);
-
- // create map pref_key / request code
- requestCodeByPrefKey.put("import_ages", REQUEST_IMPORT_AGES);
- requestCodeByPrefKey.put("import_commercial_species", REQUEST_IMPORT_COMMERCIAL_SPECIES);
- requestCodeByPrefKey.put("import_genders", REQUEST_IMPORT_GENDERS);
- requestCodeByPrefKey.put("import_locations", REQUEST_IMPORT_LOCATIONS);
- requestCodeByPrefKey.put("import_maturities", REQUEST_IMPORT_MATURITIES);
- requestCodeByPrefKey.put("import_mensurations", REQUEST_IMPORT_MENSURATIONS);
- requestCodeByPrefKey.put("import_metiers", REQUEST_IMPORT_METIERS);
- requestCodeByPrefKey.put("import_presentations", REQUEST_IMPORT_PRESENTATIONS);
- requestCodeByPrefKey.put("import_scientific_species", REQUEST_IMPORT_SCIENTIFIC_SPECIES);
- requestCodeByPrefKey.put("import_states", REQUEST_IMPORT_STATES);
- requestCodeByPrefKey.put("import_vessels", REQUEST_IMPORT_VESSELS);
-
- Map<String, Integer> nbElementsByPrefKey = Maps.newHashMap();
- Context context = getActivity();
- nbElementsByPrefKey.put("import_ages", DataCache.getAllAges(context).size());
- nbElementsByPrefKey.put("import_commercial_species", DataCache.getAllCommercialSpecies(context).size());
- nbElementsByPrefKey.put("import_genders", DataCache.getAllGenders(context).size());
- nbElementsByPrefKey.put("import_locations", DataCache.getAllLocations(context).size());
- nbElementsByPrefKey.put("import_maturities", DataCache.getAllMaturities(context).size());
- nbElementsByPrefKey.put("import_mensurations", DataCache.getAllMensurations(context).size());
- nbElementsByPrefKey.put("import_metiers", DataCache.getAllMetiers(context).size());
- nbElementsByPrefKey.put("import_presentations", DataCache.getAllPresentations(context).size());
- nbElementsByPrefKey.put("import_scientific_species", DataCache.getAllScientificSpecies(context).size());
- nbElementsByPrefKey.put("import_states", DataCache.getAllStates(context).size());
- nbElementsByPrefKey.put("import_vessels", DataCache.getAllVessels(context).size());
-
- for (String key : requestCodeByPrefKey.keySet()) {
- final Integer requestCode = requestCodeByPrefKey.get(key);
- Preference filePicker = findPreference(key);
- filePicker.setSummary(getString(R.string.preferences_import_summary, nbElementsByPrefKey.get(key)));
- filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- Intent intent = new Intent(getActivity(), FileDialog.class); //Intent to start openIntents File Manager
- intent.putExtra(FileDialog.START_PATH, "/sdcard");
- intent.putExtra(FileDialog.CAN_SELECT_DIR, false);
- intent.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
-
- //alternatively you can set file filter
- intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "csv" });
-
- startActivityForResult(intent, requestCode);
- return true;
- }
- });
- }
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
-
- Preference connectionPref = findPreference(key);
- String summary = null;
-
- ListItemPreference pref = ListItemPreference.getListItemPreference(key);
- if (pref != null) {
- String entry = sharedPreferences.getString(key, "");
- summary = pref.getEntryForValue(getActivity(), entry);
-
- } else {
- summary = sharedPreferences.getString(key, "");
- }
- // Set summary to be the user-description for the selected value
- connectionPref.setSummary(summary);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
-
- for (StringPreference pref : StringPreference.values()) {
- String key = pref.getKey();
- Preference connectionPref = findPreference(key);
- connectionPref.setSummary(sharedPreferences.getString(key, ""));
- }
-
- for (ListItemPreference pref : ListItemPreference.values()) {
- String key = pref.getKey();
- Preference connectionPref = findPreference(key);
- String entry = sharedPreferences.getString(key, "");
- String summary = pref.getEntryForValue(getActivity(), entry);
- connectionPref.setSummary(summary);
- }
-
- sharedPreferences.registerOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- getPreferenceScreen().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
- if (resultCode == RESULT_OK
- && requestCode >= REQUEST_IMPORT_AGES && requestCode <= REQUEST_IMPORT_VESSELS) {
-
- Context context = getActivity();
- if (!StorageUtils.isExternalStorageWritable()) {
- AlertDialog dialog = new AlertDialog.Builder(context)
- .setTitle(R.string.preferences_import_no_external_storage_title)
- .setMessage(R.string.preferences_import_no_external_storage_message)
- .setCancelable(false)
- .setNegativeButton(R.string.no, UIUtils.getCancelClickListener())
- .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- importData(requestCode, data, false);
- }
- }).create();
- dialog.show();
-
- } else {
- importData(requestCode, data, true);
- }
-
- } else {
- super.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- protected void importData(final int requestCode, final Intent data, final boolean backupFile) {
- final Context context = getActivity();
-
- final ProgressDialog dialog = new ProgressDialog(context);
- dialog.setCancelable(false);
- dialog.setMessage(getString(R.string.preferences_importing_referential));
- dialog.show();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- String path = data.getStringExtra(FileDialog.RESULT_PATH);
- Log.d(TAG, path);
- final int updatedNb;
- final int newNb;
- switch (requestCode) {
- case REQUEST_IMPORT_AGES:
- newNb = ImportUtil.importAges(context, path);
- updatedNb = DataCache.getAllAges(context).size();
- break;
- case REQUEST_IMPORT_COMMERCIAL_SPECIES:
- newNb = ImportUtil.importCommercialSpecies(context, path);
- updatedNb = DataCache.getAllCommercialSpecies(context).size();
- break;
- case REQUEST_IMPORT_GENDERS:
- newNb = ImportUtil.importGenders(context, path);
- updatedNb = DataCache.getAllGenders(context).size();
- break;
- case REQUEST_IMPORT_LOCATIONS:
- newNb = ImportUtil.importLocations(context, path);
- updatedNb = DataCache.getAllLocations(context).size();
- break;
- case REQUEST_IMPORT_MATURITIES:
- newNb = ImportUtil.importMaturities(context, path);
- updatedNb = DataCache.getAllMaturities(context).size();
- break;
- case REQUEST_IMPORT_MENSURATIONS:
- newNb = ImportUtil.importMensurations(context, path);
- updatedNb = DataCache.getAllMensurations(context).size();
- break;
- case REQUEST_IMPORT_METIERS:
- newNb = ImportUtil.importMetiers(context, path);
- updatedNb = DataCache.getAllMetiers(context).size();
- break;
- case REQUEST_IMPORT_PRESENTATIONS:
- newNb = ImportUtil.importPresentations(context, path);
- updatedNb = DataCache.getAllPresentations(context).size();
- break;
- case REQUEST_IMPORT_SCIENTIFIC_SPECIES:
- newNb = ImportUtil.importScientificSpecies(context, path);
- updatedNb = DataCache.getAllScientificSpecies(context).size();
- break;
- case REQUEST_IMPORT_STATES:
- newNb = ImportUtil.importStates(context, path);
- updatedNb = DataCache.getAllStates(context).size();
- break;
- case REQUEST_IMPORT_VESSELS:
- newNb = ImportUtil.importVessels(context, path);
- updatedNb = DataCache.getAllVessels(context).size();
- break;
- default:
- newNb = 0;
- updatedNb = 0;
- }
-
- dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- String key = requestCodeByPrefKey.inverse().get(requestCode);
- Preference filePicker = findPreference(key);
- filePicker.setSummary(getString(R.string.preferences_import_summary, updatedNb));
-
- Toast.makeText(context, context.getString(R.string.import_new_element_number, newNb), Toast.LENGTH_SHORT).show();
- }
- });
-
- if (backupFile) {
- File importedFile = new File(path);
- String copyFileName = String.format("%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS-", new Date()) + importedFile.getName();
- File dir = Environment.getExternalStoragePublicDirectory(".wlo");
- File file = new File(dir, copyFileName);
- try {
- FileUtils.copyInputStreamToFile(new FileInputStream(path), file);
- } catch (IOException e) {
- Log.e(TAG, "Error while copying the file", e);
- }
- }
-
- dialog.dismiss();
- }
- }).start();
- }
- }
-
-}
\ No newline at end of file
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,332 @@
+package fr.ifremer.wlo.preferences;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.Environment;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.text.format.DateFormat;
+import android.util.Log;
+import android.widget.Toast;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.MainActivity;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.WloBaseActivity;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.StorageUtils;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
+import fr.ifremer.wlo.utils.UIUtils;
+import fr.ifremer.wlo.utils.filechooser.FileDialog;
+import fr.ifremer.wlo.utils.filechooser.SelectionMode;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class SettingsActivity extends WloBaseActivity {
+
+ private static final String TAG = "SettingsActivity";
+
+ protected static final int REQUEST_IMPORT_AGES = 0;
+ protected static final int REQUEST_IMPORT_COMMERCIAL_SPECIES = 1;
+ protected static final int REQUEST_IMPORT_GENDERS = 2;
+ protected static final int REQUEST_IMPORT_LOCATIONS = 3;
+ protected static final int REQUEST_IMPORT_MATURITIES = 4;
+ protected static final int REQUEST_IMPORT_MENSURATIONS = 5;
+ protected static final int REQUEST_IMPORT_METIERS = 6;
+ protected static final int REQUEST_IMPORT_PRESENTATIONS = 7;
+ protected static final int REQUEST_IMPORT_SCIENTIFIC_SPECIES = 8;
+ protected static final int REQUEST_IMPORT_STATES = 9;
+ protected static final int REQUEST_IMPORT_VESSELS = 10;
+ @Override
+ protected Integer getContentView() {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MainActivity.class;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Display the fragment as the main content.
+ getFragmentManager().beginTransaction()
+ .replace(android.R.id.content, new SettingsFragment())
+ .commit();
+
+ }
+
+ public static class SettingsFragment extends PreferenceFragment
+ implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+ // map pref_key / request code
+ protected BiMap<String, Integer> requestCodeByPrefKey = HashBiMap.create();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.preferences);
+
+ // create map pref_key / request code
+ requestCodeByPrefKey.put("import_ages", REQUEST_IMPORT_AGES);
+ requestCodeByPrefKey.put("import_commercial_species", REQUEST_IMPORT_COMMERCIAL_SPECIES);
+ requestCodeByPrefKey.put("import_genders", REQUEST_IMPORT_GENDERS);
+ requestCodeByPrefKey.put("import_locations", REQUEST_IMPORT_LOCATIONS);
+ requestCodeByPrefKey.put("import_maturities", REQUEST_IMPORT_MATURITIES);
+ requestCodeByPrefKey.put("import_mensurations", REQUEST_IMPORT_MENSURATIONS);
+ requestCodeByPrefKey.put("import_metiers", REQUEST_IMPORT_METIERS);
+ requestCodeByPrefKey.put("import_presentations", REQUEST_IMPORT_PRESENTATIONS);
+ requestCodeByPrefKey.put("import_scientific_species", REQUEST_IMPORT_SCIENTIFIC_SPECIES);
+ requestCodeByPrefKey.put("import_states", REQUEST_IMPORT_STATES);
+ requestCodeByPrefKey.put("import_vessels", REQUEST_IMPORT_VESSELS);
+
+ Map<String, Integer> nbElementsByPrefKey = Maps.newHashMap();
+ Context context = getActivity();
+ nbElementsByPrefKey.put("import_ages", DataCache.getAllAges(context).size());
+ nbElementsByPrefKey.put("import_commercial_species", DataCache.getAllCommercialSpecies(context).size());
+ nbElementsByPrefKey.put("import_genders", DataCache.getAllGenders(context).size());
+ nbElementsByPrefKey.put("import_locations", DataCache.getAllLocations(context).size());
+ nbElementsByPrefKey.put("import_maturities", DataCache.getAllMaturities(context).size());
+ nbElementsByPrefKey.put("import_mensurations", DataCache.getAllMensurations(context).size());
+ nbElementsByPrefKey.put("import_metiers", DataCache.getAllMetiers(context).size());
+ nbElementsByPrefKey.put("import_presentations", DataCache.getAllPresentations(context).size());
+ nbElementsByPrefKey.put("import_scientific_species", DataCache.getAllScientificSpecies(context).size());
+ nbElementsByPrefKey.put("import_states", DataCache.getAllStates(context).size());
+ nbElementsByPrefKey.put("import_vessels", DataCache.getAllVessels(context).size());
+
+ for (String key : requestCodeByPrefKey.keySet()) {
+ final Integer requestCode = requestCodeByPrefKey.get(key);
+ Preference filePicker = findPreference(key);
+ filePicker.setSummary(getString(R.string.preferences_import_summary, nbElementsByPrefKey.get(key)));
+ filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent intent = new Intent(getActivity(), FileDialog.class); //Intent to start openIntents File Manager
+ intent.putExtra(FileDialog.START_PATH, "/sdcard");
+ intent.putExtra(FileDialog.CAN_SELECT_DIR, false);
+ intent.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
+
+ //alternatively you can set file filter
+ intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "csv" });
+
+ startActivityForResult(intent, requestCode);
+ return true;
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+
+ Preference connectionPref = findPreference(key);
+ String summary = null;
+
+ ListItemPreference pref = ListItemPreference.getListItemPreference(key);
+ if (pref != null) {
+ String entry = sharedPreferences.getString(key, "");
+ summary = pref.getEntryForValue(getActivity(), entry);
+
+ } else {
+ summary = sharedPreferences.getString(key, "");
+ }
+ // Set summary to be the user-description for the selected value
+ connectionPref.setSummary(summary);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+
+ for (StringPreference pref : StringPreference.values()) {
+ String key = pref.getKey();
+ Preference connectionPref = findPreference(key);
+ connectionPref.setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ for (ListItemPreference pref : ListItemPreference.values()) {
+ String key = pref.getKey();
+ Preference connectionPref = findPreference(key);
+ String entry = sharedPreferences.getString(key, "");
+ String summary = pref.getEntryForValue(getActivity(), entry);
+ connectionPref.setSummary(summary);
+ }
+
+ sharedPreferences.registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ getPreferenceScreen().getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
+ if (resultCode == RESULT_OK
+ && requestCode >= REQUEST_IMPORT_AGES && requestCode <= REQUEST_IMPORT_VESSELS) {
+
+ Context context = getActivity();
+ if (!StorageUtils.isExternalStorageWritable()) {
+ AlertDialog dialog = new AlertDialog.Builder(context)
+ .setTitle(R.string.preferences_import_no_external_storage_title)
+ .setMessage(R.string.preferences_import_no_external_storage_message)
+ .setCancelable(false)
+ .setNegativeButton(R.string.no, UIUtils.getCancelClickListener())
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ importData(requestCode, data, false);
+ }
+ }).create();
+ dialog.show();
+
+ } else {
+ importData(requestCode, data, true);
+ }
+
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+ }
+
+ protected void importData(final int requestCode, final Intent data, final boolean backupFile) {
+ final Context context = getActivity();
+
+ final ProgressDialog dialog = new ProgressDialog(context);
+ dialog.setCancelable(false);
+ dialog.setMessage(getString(R.string.preferences_importing_referential));
+ dialog.show();
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ String path = data.getStringExtra(FileDialog.RESULT_PATH);
+ Log.d(TAG, path);
+ final int updatedNb;
+ final int newNb;
+ switch (requestCode) {
+ case REQUEST_IMPORT_AGES:
+ newNb = ImportUtil.importAges(context, path);
+ updatedNb = DataCache.getAllAges(context).size();
+ break;
+ case REQUEST_IMPORT_COMMERCIAL_SPECIES:
+ newNb = ImportUtil.importCommercialSpecies(context, path);
+ updatedNb = DataCache.getAllCommercialSpecies(context).size();
+ break;
+ case REQUEST_IMPORT_GENDERS:
+ newNb = ImportUtil.importGenders(context, path);
+ updatedNb = DataCache.getAllGenders(context).size();
+ break;
+ case REQUEST_IMPORT_LOCATIONS:
+ newNb = ImportUtil.importLocations(context, path);
+ updatedNb = DataCache.getAllLocations(context).size();
+ break;
+ case REQUEST_IMPORT_MATURITIES:
+ newNb = ImportUtil.importMaturities(context, path);
+ updatedNb = DataCache.getAllMaturities(context).size();
+ break;
+ case REQUEST_IMPORT_MENSURATIONS:
+ newNb = ImportUtil.importMensurations(context, path);
+ updatedNb = DataCache.getAllMensurations(context).size();
+ break;
+ case REQUEST_IMPORT_METIERS:
+ newNb = ImportUtil.importMetiers(context, path);
+ updatedNb = DataCache.getAllMetiers(context).size();
+ break;
+ case REQUEST_IMPORT_PRESENTATIONS:
+ newNb = ImportUtil.importPresentations(context, path);
+ updatedNb = DataCache.getAllPresentations(context).size();
+ break;
+ case REQUEST_IMPORT_SCIENTIFIC_SPECIES:
+ newNb = ImportUtil.importScientificSpecies(context, path);
+ updatedNb = DataCache.getAllScientificSpecies(context).size();
+ break;
+ case REQUEST_IMPORT_STATES:
+ newNb = ImportUtil.importStates(context, path);
+ updatedNb = DataCache.getAllStates(context).size();
+ break;
+ case REQUEST_IMPORT_VESSELS:
+ newNb = ImportUtil.importVessels(context, path);
+ updatedNb = DataCache.getAllVessels(context).size();
+ break;
+ default:
+ newNb = 0;
+ updatedNb = 0;
+ }
+
+ dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ String key = requestCodeByPrefKey.inverse().get(requestCode);
+ Preference filePicker = findPreference(key);
+ filePicker.setSummary(getString(R.string.preferences_import_summary, updatedNb));
+
+ Toast.makeText(context, context.getString(R.string.import_new_element_number, newNb), Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ if (backupFile) {
+ File importedFile = new File(path);
+ String copyFileName = String.format("%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS-", new Date()) + importedFile.getName();
+ File dir = Environment.getExternalStoragePublicDirectory(".wlo");
+ File file = new File(dir, copyFileName);
+ try {
+ FileUtils.copyInputStreamToFile(new FileInputStream(path), file);
+ } catch (IOException e) {
+ Log.e(TAG, "Error while copying the file", e);
+ }
+ }
+
+ dialog.dismiss();
+ }
+ }).start();
+ }
+ }
+
+}
\ No newline at end of file
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/StringPreference.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,22 +0,0 @@
-package fr.ifremer.wlo.preferences;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public enum StringPreference {
-
- COMPANY("preferences_company"),
- DEFAULT_OPERATOR("preferences_default_operator");
-
- private String key;
-
- private StringPreference(String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java (from rev 25, trunk/src/fr/ifremer/wlo/preferences/StringPreference.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/preferences/StringPreference.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,46 @@
+package fr.ifremer.wlo.preferences;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public enum StringPreference {
+
+ COMPANY("preferences_company"),
+ DEFAULT_OPERATOR("preferences_default_operator");
+
+ private String key;
+
+ private StringPreference(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/DataCache.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,441 +0,0 @@
-package fr.ifremer.wlo.storage;
-
-import android.content.Context;
-import android.database.Cursor;
-import com.google.common.base.Function;
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Table;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Gender;
-import fr.ifremer.wlo.models.referentials.HasCode;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Maturity;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.models.referentials.Vessel;
-import org.apache.commons.lang3.ObjectUtils;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class DataCache {
-
- public static final String DEFAULT_MENSURATION_CODE = "LT";
-
- protected static Map<String, Age> ages;
- protected static Map<String, CommercialSpecies> commercialSpecies;
- protected static Map<String, Gender> genders;
- protected static Map<String, Location> locations;
- protected static Map<String, Maturity> maturities;
- protected static Map<String, Mensuration> mensurations;
- protected static Mensuration defaultMensuration;
- protected static Map<String, Metier> metiers;
- protected static Map<String, Presentation> presentations;
- protected static Map<String, ScientificSpecies> scientificSpecies;
- protected static Map<String, State> states;
- protected static Map<String, Vessel> vessels;
- protected static Set<String> sortCategories;
-
- public static Collection<Age> getAllAges(Context context) {
- initAges(context);
- return ages.values();
- }
-
- public static Age getAgeById(Context context, String id) {
- initAges(context);
- return ages.get(id);
- }
-
- public static void invalidateAges() {
- ages = null;
- }
-
- public static Collection<CommercialSpecies> getAllCommercialSpecies(Context context) {
- initCommercialSpecies(context);
- return commercialSpecies.values();
- }
-
- public static CommercialSpecies getCommercialSpeciesById(Context context, String id) {
- initCommercialSpecies(context);
- return commercialSpecies.get(id);
- }
-
- public static void invalidateCommercialSpecies() {
- commercialSpecies = null;
- }
-
- public static Collection<Gender> getAllGenders(Context context) {
- initGenders(context);
- return genders.values();
- }
-
- public static Gender getGenderById(Context context, String id) {
- initGenders(context);
- return genders.get(id);
- }
-
- public static void invalidateGenders() {
- genders = null;
- }
-
- public static Collection<Location> getAllLocations(Context context) {
- initLocations(context);
- List<Location> result = Lists.newArrayList(locations.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Location getLocationById(Context context, String id) {
- initLocations(context);
- return locations.get(id);
- }
-
- public static void invalidateLocations() {
- locations = null;
- }
-
- public static Collection<Maturity> getAllMaturities(Context context) {
- initMaturities(context);
- return maturities.values();
- }
-
- public static Maturity getMaturityById(Context context, String id) {
- initMaturities(context);
- return maturities.get(id);
- }
-
- public static void invalidateMaturities() {
- maturities = null;
- }
-
- public static Collection<Mensuration> getAllMensurations(Context context) {
- initMensurations(context);
- List<Mensuration> result = Lists.newArrayList(mensurations.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Mensuration getMensurationById(Context context, String id) {
- initMensurations(context);
- return mensurations.get(id);
- }
-
- public static Mensuration getDefaultMensuration(Context context) {
- if (defaultMensuration == null) {
- initMensurations(context);
- Map<String, Mensuration> mensurationsByCode = Maps.uniqueIndex(mensurations.values(), HasCode.GET_CODE_FUNCTION);
- defaultMensuration = mensurationsByCode.get(DEFAULT_MENSURATION_CODE);
- }
- return defaultMensuration;
- }
-
- public static void invalidateMensurations() {
- mensurations = null;
- }
-
- public static Collection<Metier> getAllMetiers(Context context) {
- initMetiers(context);
- List<Metier> result = Lists.newArrayList(metiers.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Metier getMetierById(Context context, String id) {
- initMetiers(context);
- return metiers.get(id);
- }
-
- public static void invalidateMetiers() {
- metiers = null;
- }
-
- public static Collection<Presentation> getAllPresentations(Context context) {
- initPresentations(context);
- List<Presentation> result = Lists.newArrayList(presentations.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Presentation getPresentationById(Context context, String id) {
- initPresentations(context);
- return presentations.get(id);
- }
-
- public static void invalidatePresentations() {
- presentations = null;
- }
-
- public static Collection<ScientificSpecies> getAllScientificSpecies(Context context) {
- initScientificSpecies(context);
- List<ScientificSpecies> result = Lists.newArrayList(scientificSpecies.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static ScientificSpecies getScientificSpeciesById(Context context, String id) {
- initScientificSpecies(context);
- return scientificSpecies.get(id);
- }
-
- public static void invalidateScientificSpecies() {
- scientificSpecies = null;
- }
-
- public static Set<String> getAllSortCategories(Context context) {
- initSortCategories(context);
- return sortCategories;
- }
-
- public static void invalidateSortCategories() {
- sortCategories = null;
- }
-
- public static Collection<State> getAllStates(Context context) {
- initStates(context);
- List<State> result = Lists.newArrayList(states.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static State getStateById(Context context, String id) {
- initStates(context);
- return states.get(id);
- }
-
- public static void invalidateStates() {
- states = null;
- }
-
- public static Collection<Vessel> getAllVessels(Context context) {
- initVessels(context);
- List<Vessel> result = Lists.newArrayList(vessels.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Vessel getVesselById(Context context, String id) {
- initVessels(context);
- return vessels.get(id);
- }
-
- public static void invalidateVessels() {
- vessels = null;
- }
-
- protected static void initAges(Context context) {
- if (ages == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefAges();
- List<Age> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Age>() {
- @Override
- public Age apply(Cursor input) {
- return new Age(input);
- }
- });
- ages = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initCommercialSpecies(Context context) {
- if (commercialSpecies == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefCommercialSpecies();
- List<CommercialSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, CommercialSpecies>() {
- @Override
- public CommercialSpecies apply(Cursor input) {
- return new CommercialSpecies(input);
- }
- });
-
- commercialSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initGenders(Context context) {
- if (genders == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefGenders();
- List<Gender> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Gender>() {
- @Override
- public Gender apply(Cursor input) {
- return new Gender(input);
- }
- });
-
- genders = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initLocations(Context context) {
- if (locations == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefLocations();
- List<Location> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Location>() {
- @Override
- public Location apply(Cursor input) {
- return new Location(input);
- }
- });
- locations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initMaturities(Context context) {
- if (maturities == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefMaturities();
- List<Maturity> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Maturity>() {
- @Override
- public Maturity apply(Cursor input) {
- return new Maturity(input);
- }
- });
- maturities = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initMensurations(Context context) {
- if (mensurations == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefMensurations();
- List<Mensuration> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Mensuration>() {
- @Override
- public Mensuration apply(Cursor input) {
- return new Mensuration(input);
- }
- });
-
- mensurations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initMetiers(Context context) {
- if (metiers == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefMetiers();
- List<Metier> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Metier>() {
- @Override
- public Metier apply(Cursor input) {
- return new Metier(input);
- }
- });
-
- metiers = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initPresentations(Context context) {
- if (presentations == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefPresentations();
- List<Presentation> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Presentation>() {
- @Override
- public Presentation apply(Cursor input) {
- return new Presentation(input);
- }
- });
-
- presentations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initScientificSpecies(Context context) {
- if (scientificSpecies == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefScientificSpecies();
- List<ScientificSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, ScientificSpecies>() {
- @Override
- public ScientificSpecies apply(Cursor input) {
- return new ScientificSpecies(input);
- }
- });
-
- scientificSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initStates(Context context) {
- if (states == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefStates();
- List<State> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, State>() {
- @Override
- public State apply(Cursor input) {
- return new State(input);
- }
- });
-
- states = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initVessels(Context context) {
- if (vessels == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefVessels();
- List<Vessel> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Vessel>() {
- @Override
- public Vessel apply(Cursor input) {
- return new Vessel(input);
- }
- });
-
- vessels = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initSortCategories(Context context) {
- if (sortCategories == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllSortCategories();
- List<String> sc = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, String>() {
- @Override
- public String apply(Cursor cursor) {
- return cursor.getString(0);
- }
- });
- sortCategories = Sets.newHashSet(sc);
- soh.close();
- }
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java (from rev 25, trunk/src/fr/ifremer/wlo/storage/DataCache.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/storage/DataCache.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,465 @@
+package fr.ifremer.wlo.storage;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.database.Cursor;
+import com.google.common.base.Function;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.collect.Table;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.models.referentials.HasCode;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.models.referentials.Vessel;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class DataCache {
+
+ public static final String DEFAULT_MENSURATION_CODE = "LT";
+
+ protected static Map<String, Age> ages;
+ protected static Map<String, CommercialSpecies> commercialSpecies;
+ protected static Map<String, Gender> genders;
+ protected static Map<String, Location> locations;
+ protected static Map<String, Maturity> maturities;
+ protected static Map<String, Mensuration> mensurations;
+ protected static Mensuration defaultMensuration;
+ protected static Map<String, Metier> metiers;
+ protected static Map<String, Presentation> presentations;
+ protected static Map<String, ScientificSpecies> scientificSpecies;
+ protected static Map<String, State> states;
+ protected static Map<String, Vessel> vessels;
+ protected static Set<String> sortCategories;
+
+ public static Collection<Age> getAllAges(Context context) {
+ initAges(context);
+ return ages.values();
+ }
+
+ public static Age getAgeById(Context context, String id) {
+ initAges(context);
+ return ages.get(id);
+ }
+
+ public static void invalidateAges() {
+ ages = null;
+ }
+
+ public static Collection<CommercialSpecies> getAllCommercialSpecies(Context context) {
+ initCommercialSpecies(context);
+ return commercialSpecies.values();
+ }
+
+ public static CommercialSpecies getCommercialSpeciesById(Context context, String id) {
+ initCommercialSpecies(context);
+ return commercialSpecies.get(id);
+ }
+
+ public static void invalidateCommercialSpecies() {
+ commercialSpecies = null;
+ }
+
+ public static Collection<Gender> getAllGenders(Context context) {
+ initGenders(context);
+ return genders.values();
+ }
+
+ public static Gender getGenderById(Context context, String id) {
+ initGenders(context);
+ return genders.get(id);
+ }
+
+ public static void invalidateGenders() {
+ genders = null;
+ }
+
+ public static Collection<Location> getAllLocations(Context context) {
+ initLocations(context);
+ List<Location> result = Lists.newArrayList(locations.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Location getLocationById(Context context, String id) {
+ initLocations(context);
+ return locations.get(id);
+ }
+
+ public static void invalidateLocations() {
+ locations = null;
+ }
+
+ public static Collection<Maturity> getAllMaturities(Context context) {
+ initMaturities(context);
+ return maturities.values();
+ }
+
+ public static Maturity getMaturityById(Context context, String id) {
+ initMaturities(context);
+ return maturities.get(id);
+ }
+
+ public static void invalidateMaturities() {
+ maturities = null;
+ }
+
+ public static Collection<Mensuration> getAllMensurations(Context context) {
+ initMensurations(context);
+ List<Mensuration> result = Lists.newArrayList(mensurations.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Mensuration getMensurationById(Context context, String id) {
+ initMensurations(context);
+ return mensurations.get(id);
+ }
+
+ public static Mensuration getDefaultMensuration(Context context) {
+ if (defaultMensuration == null) {
+ initMensurations(context);
+ Map<String, Mensuration> mensurationsByCode = Maps.uniqueIndex(mensurations.values(), HasCode.GET_CODE_FUNCTION);
+ defaultMensuration = mensurationsByCode.get(DEFAULT_MENSURATION_CODE);
+ }
+ return defaultMensuration;
+ }
+
+ public static void invalidateMensurations() {
+ mensurations = null;
+ }
+
+ public static Collection<Metier> getAllMetiers(Context context) {
+ initMetiers(context);
+ List<Metier> result = Lists.newArrayList(metiers.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Metier getMetierById(Context context, String id) {
+ initMetiers(context);
+ return metiers.get(id);
+ }
+
+ public static void invalidateMetiers() {
+ metiers = null;
+ }
+
+ public static Collection<Presentation> getAllPresentations(Context context) {
+ initPresentations(context);
+ List<Presentation> result = Lists.newArrayList(presentations.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Presentation getPresentationById(Context context, String id) {
+ initPresentations(context);
+ return presentations.get(id);
+ }
+
+ public static void invalidatePresentations() {
+ presentations = null;
+ }
+
+ public static Collection<ScientificSpecies> getAllScientificSpecies(Context context) {
+ initScientificSpecies(context);
+ List<ScientificSpecies> result = Lists.newArrayList(scientificSpecies.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static ScientificSpecies getScientificSpeciesById(Context context, String id) {
+ initScientificSpecies(context);
+ return scientificSpecies.get(id);
+ }
+
+ public static void invalidateScientificSpecies() {
+ scientificSpecies = null;
+ }
+
+ public static Set<String> getAllSortCategories(Context context) {
+ initSortCategories(context);
+ return sortCategories;
+ }
+
+ public static void invalidateSortCategories() {
+ sortCategories = null;
+ }
+
+ public static Collection<State> getAllStates(Context context) {
+ initStates(context);
+ List<State> result = Lists.newArrayList(states.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static State getStateById(Context context, String id) {
+ initStates(context);
+ return states.get(id);
+ }
+
+ public static void invalidateStates() {
+ states = null;
+ }
+
+ public static Collection<Vessel> getAllVessels(Context context) {
+ initVessels(context);
+ List<Vessel> result = Lists.newArrayList(vessels.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Vessel getVesselById(Context context, String id) {
+ initVessels(context);
+ return vessels.get(id);
+ }
+
+ public static void invalidateVessels() {
+ vessels = null;
+ }
+
+ protected static void initAges(Context context) {
+ if (ages == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefAges();
+ List<Age> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Age>() {
+ @Override
+ public Age apply(Cursor input) {
+ return new Age(input);
+ }
+ });
+ ages = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initCommercialSpecies(Context context) {
+ if (commercialSpecies == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefCommercialSpecies();
+ List<CommercialSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, CommercialSpecies>() {
+ @Override
+ public CommercialSpecies apply(Cursor input) {
+ return new CommercialSpecies(input);
+ }
+ });
+
+ commercialSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initGenders(Context context) {
+ if (genders == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefGenders();
+ List<Gender> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Gender>() {
+ @Override
+ public Gender apply(Cursor input) {
+ return new Gender(input);
+ }
+ });
+
+ genders = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initLocations(Context context) {
+ if (locations == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefLocations();
+ List<Location> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Location>() {
+ @Override
+ public Location apply(Cursor input) {
+ return new Location(input);
+ }
+ });
+ locations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initMaturities(Context context) {
+ if (maturities == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefMaturities();
+ List<Maturity> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Maturity>() {
+ @Override
+ public Maturity apply(Cursor input) {
+ return new Maturity(input);
+ }
+ });
+ maturities = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initMensurations(Context context) {
+ if (mensurations == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefMensurations();
+ List<Mensuration> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Mensuration>() {
+ @Override
+ public Mensuration apply(Cursor input) {
+ return new Mensuration(input);
+ }
+ });
+
+ mensurations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initMetiers(Context context) {
+ if (metiers == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefMetiers();
+ List<Metier> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Metier>() {
+ @Override
+ public Metier apply(Cursor input) {
+ return new Metier(input);
+ }
+ });
+
+ metiers = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initPresentations(Context context) {
+ if (presentations == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefPresentations();
+ List<Presentation> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Presentation>() {
+ @Override
+ public Presentation apply(Cursor input) {
+ return new Presentation(input);
+ }
+ });
+
+ presentations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initScientificSpecies(Context context) {
+ if (scientificSpecies == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefScientificSpecies();
+ List<ScientificSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, ScientificSpecies>() {
+ @Override
+ public ScientificSpecies apply(Cursor input) {
+ return new ScientificSpecies(input);
+ }
+ });
+
+ scientificSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initStates(Context context) {
+ if (states == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefStates();
+ List<State> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, State>() {
+ @Override
+ public State apply(Cursor input) {
+ return new State(input);
+ }
+ });
+
+ states = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initVessels(Context context) {
+ if (vessels == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefVessels();
+ List<Vessel> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Vessel>() {
+ @Override
+ public Vessel apply(Cursor input) {
+ return new Vessel(input);
+ }
+ });
+
+ vessels = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initSortCategories(Context context) {
+ if (sortCategories == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllSortCategories();
+ List<String> sc = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, String>() {
+ @Override
+ public String apply(Cursor cursor) {
+ return cursor.getString(0);
+ }
+ });
+ sortCategories = Sets.newHashSet(sc);
+ soh.close();
+ }
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/StorageUtils.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,18 +0,0 @@
-package fr.ifremer.wlo.storage;
-
-import android.os.Environment;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class StorageUtils {
-
- public static boolean isExternalStorageWritable() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- return true;
- }
- return false;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java (from rev 25, trunk/src/fr/ifremer/wlo/storage/StorageUtils.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/storage/StorageUtils.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,42 @@
+package fr.ifremer.wlo.storage;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Environment;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class StorageUtils {
+
+ public static boolean isExternalStorageWritable() {
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
+ return true;
+ }
+ return false;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,571 +0,0 @@
-package fr.ifremer.wlo.storage;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.ContextModel;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Gender;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Maturity;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.models.referentials.Vessel;
-
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class WloSqlOpenHelper extends SQLiteOpenHelper {
-
- private static final String TAG = "WloOpenHelper";
-
- public static final String DATABASE_NAME = "wlo.db";
- public static final int DATABASE_VERSION = 9;
-
- public static final String TEXT_TYPE = " TEXT";
- public static final String BIGINT_TYPE = " BIGINT";
- public static final String BYTE_TYPE = " BYTE";
- public static final String COMMA_SEP = ",";
- public static final String NOT_NULL = " NOT NULL";
-
- //CONTEXT
- protected static final String SQL_CREATE_CONTEXTS =
- "CREATE TABLE " + ContextModel.TABLE_NAME + " (" +
- ContextModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- ContextModel.COLUMN_NAME + TEXT_TYPE + NOT_NULL +
- " )";
-
- protected static final String SQL_DELETE_CONTEXTS =
- "DROP TABLE IF EXISTS " + ContextModel.TABLE_NAME;
-
-
- //LOCATION
- protected static final String SQL_CREATE_LOCATIONS =
- "CREATE TABLE " + LocationModel.TABLE_NAME + " (" +
- LocationModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- LocationModel.COLUMN_OPERATOR + TEXT_TYPE + COMMA_SEP +
- LocationModel.COLUMN_START_DATE + BIGINT_TYPE + COMMA_SEP +
- LocationModel.COLUMN_END_DATE + BIGINT_TYPE + COMMA_SEP +
- LocationModel.COLUMN_LOCATION + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- LocationModel.COLUMN_CONTEXT_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + LocationModel.COLUMN_CONTEXT_ID + ") REFERENCES " +
- ContextModel.TABLE_NAME + "(" + ContextModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + LocationModel.COLUMN_LOCATION + ") REFERENCES " +
- Location.TABLE_NAME + "(" + Location._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_LOCATIONS =
- "DROP TABLE IF EXISTS " + LocationModel.TABLE_NAME;
-
- // VESSEL
- protected static final String SQL_CREATE_VESSELS =
- "CREATE TABLE " + VesselModel.TABLE_NAME + " (" +
- VesselModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- VesselModel.COLUMN_REGISTRATION_NUMBER + TEXT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_LANDING_DATE + BIGINT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_LANDING_LOCATION + TEXT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_LOCATION_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + VesselModel.COLUMN_LOCATION_ID + ") REFERENCES " +
- LocationModel.TABLE_NAME + "(" + LocationModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + VesselModel.COLUMN_LANDING_LOCATION + ") REFERENCES " +
- Location.TABLE_NAME + "(" + Location._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_VESSELS =
- "DROP TABLE IF EXISTS " + VesselModel.TABLE_NAME;
-
- // METIER
- protected static final String SQL_CREATE_METIERS =
- "CREATE TABLE " + MetierModel.TABLE_NAME + " (" +
- MetierModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- MetierModel.COLUMN_GEAR_SPECIES + TEXT_TYPE + COMMA_SEP +
- MetierModel.COLUMN_ZONE + TEXT_TYPE + COMMA_SEP +
- MetierModel.COLUMN_SAMPLE_ROW_CODE + TEXT_TYPE + COMMA_SEP +
- MetierModel.COLUMN_VESSEL_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + MetierModel.COLUMN_VESSEL_ID + ") REFERENCES " +
- VesselModel.TABLE_NAME + "(" + VesselModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + MetierModel.COLUMN_GEAR_SPECIES + ") REFERENCES " +
- Metier.TABLE_NAME + "(" + Metier._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_METIERS =
- "DROP TABLE IF EXISTS " + MetierModel.TABLE_NAME;
-
- // COMMERCIAL SPECIES
- protected static final String SQL_CREATE_COMMERCIAL_SPECIES =
- "CREATE TABLE " + CommercialSpeciesModel.TABLE_NAME + " (" +
- CommercialSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_FAO_CODE + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_PRECISION + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_SPECIES_MIX + BYTE_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_SORT_CATEGORY + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_STATE + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_PRESENTATION + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_METIER_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_METIER_ID + ") REFERENCES " +
- MetierModel.TABLE_NAME + "(" + MetierModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_FAO_CODE + ") REFERENCES " +
- CommercialSpecies.TABLE_NAME + "(" + CommercialSpecies._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + ") REFERENCES " +
- Mensuration.TABLE_NAME + "(" + Mensuration._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_STATE + ") REFERENCES " +
- State.TABLE_NAME + "(" + State._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_PRESENTATION + ") REFERENCES " +
- Presentation.TABLE_NAME + "(" + Presentation._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_COMMERCIAL_SPECIES =
- "DROP TABLE IF EXISTS " + CommercialSpeciesModel.TABLE_NAME;
-
- // SCIENTIFIC SPECIES
- protected static final String SQL_CREATE_SCIENTIFIC_SPECIES =
- "CREATE TABLE " + ScientificSpeciesModel.TABLE_NAME + " (" +
- ScientificSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
- ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP +
- ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + ") REFERENCES " +
- CommercialSpeciesModel.TABLE_NAME + "(" + CommercialSpeciesModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_NAME + ") REFERENCES " +
- ScientificSpecies.TABLE_NAME + "(" + ScientificSpecies._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_SCIENTIFIC_SPECIES =
- "DROP TABLE IF EXISTS " + ScientificSpeciesModel.TABLE_NAME;
-
-
- // Referentials
-
- // Ages
- protected static final String SQL_CREATE_REF_AGES =
- "CREATE TABLE " + Age.TABLE_NAME + " (" +
- Age._ID + TEXT_TYPE + " PRIMARY KEY," +
- Age.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
- " )";
-
- protected static final String SQL_DELETE_REF_AGES =
- "DROP TABLE IF EXISTS " + Age.TABLE_NAME;
-
- // Commercial Species
- protected static final String SQL_CREATE_REF_COMMERCIAL_SPECIES =
- "CREATE TABLE " + CommercialSpecies.TABLE_NAME + " (" +
- CommercialSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- CommercialSpecies.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- CommercialSpecies.COLUMN_ISSCAP + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_TAXON_CODE + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_SCIENTIFIC_LABEL + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_FRENCH_LABEL + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_FAMILY + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_SPECIES_ORDER + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_ACTIVE + BYTE_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_COMMERCIAL_SPECIES =
- "DROP TABLE IF EXISTS " + CommercialSpecies.TABLE_NAME;
-
- // Genders
- protected static final String SQL_CREATE_REF_GENDERS =
- "CREATE TABLE " + Gender.TABLE_NAME + " (" +
- Gender._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Gender.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Gender.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_GENDERS =
- "DROP TABLE IF EXISTS " + Gender.TABLE_NAME;
-
- // Locations
- protected static final String SQL_CREATE_REF_LOCATIONS =
- "CREATE TABLE " + Location.TABLE_NAME + " (" +
- Location._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Location.COLUMN_TYPE_LABEL + TEXT_TYPE + COMMA_SEP +
- Location.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Location.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_LOCATIONS =
- "DROP TABLE IF EXISTS " + Location.TABLE_NAME;
-
- // Maturities
- protected static final String SQL_CREATE_REF_MATURITIES =
- "CREATE TABLE " + Maturity.TABLE_NAME + " (" +
- Maturity._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Maturity.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
- " )";
-
- protected static final String SQL_DELETE_REF_MATURITIES =
- "DROP TABLE IF EXISTS " + Maturity.TABLE_NAME;
-
- // Mensurations
- protected static final String SQL_CREATE_REF_MENSURATIONS =
- "CREATE TABLE " + Mensuration.TABLE_NAME + " (" +
- Mensuration._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Mensuration.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Mensuration.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_MENSURATIONS =
- "DROP TABLE IF EXISTS " + Mensuration.TABLE_NAME;
-
- // Metiers
- protected static final String SQL_CREATE_REF_METIERS =
- "CREATE TABLE " + Metier.TABLE_NAME + " (" +
- Metier._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Metier.COLUMN_ID + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Metier.COLUMN_LABEL + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_GEAR_CODE + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_GEAR_LABEL + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_SPECIES_CODE + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_SPECIES_LABEL + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_FISHING + BYTE_TYPE + COMMA_SEP +
- Metier.COLUMN_ACTIVE + BYTE_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_METIERS =
- "DROP TABLE IF EXISTS " + Metier.TABLE_NAME;
-
- // Presentations
- protected static final String SQL_CREATE_REF_PRESENTATIONS =
- "CREATE TABLE " + Presentation.TABLE_NAME + " (" +
- Presentation._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Presentation.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Presentation.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_PRESENTATIONS =
- "DROP TABLE IF EXISTS " + Presentation.TABLE_NAME;
-
- // Scientific species
- protected static final String SQL_CREATE_REF_SCIENTIFIC_SPECIES =
- "CREATE TABLE " + ScientificSpecies.TABLE_NAME + " (" +
- ScientificSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- ScientificSpecies.COLUMN_PERM_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- ScientificSpecies.COLUMN_CODE + TEXT_TYPE + COMMA_SEP +
- ScientificSpecies.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_SCIENTIFIC_SPECIES =
- "DROP TABLE IF EXISTS " + ScientificSpecies.TABLE_NAME;
-
- // States
- protected static final String SQL_CREATE_REF_STATES =
- "CREATE TABLE " + State.TABLE_NAME + " (" +
- State._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- State.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- State.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_STATES =
- "DROP TABLE IF EXISTS " + State.TABLE_NAME;
-
- // Vessels
- protected static final String SQL_CREATE_REF_VESSELS =
- "CREATE TABLE " + Vessel.TABLE_NAME + " (" +
- Vessel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Vessel.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Vessel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
- Vessel.COLUMN_QUARTER_CODE + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_VESSELS =
- "DROP TABLE IF EXISTS " + Vessel.TABLE_NAME;
-
-
- public WloSqlOpenHelper(android.content.Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- // referentials
- db.execSQL(SQL_CREATE_REF_AGES);
- db.execSQL(SQL_CREATE_REF_COMMERCIAL_SPECIES);
- db.execSQL(SQL_CREATE_REF_GENDERS);
- db.execSQL(SQL_CREATE_REF_LOCATIONS);
- db.execSQL(SQL_CREATE_REF_MATURITIES);
- db.execSQL(SQL_CREATE_REF_MENSURATIONS);
- db.execSQL(SQL_CREATE_REF_METIERS);
- db.execSQL(SQL_CREATE_REF_PRESENTATIONS);
- db.execSQL(SQL_CREATE_REF_SCIENTIFIC_SPECIES);
- db.execSQL(SQL_CREATE_REF_STATES);
- db.execSQL(SQL_CREATE_REF_VESSELS);
-
- // models
- db.execSQL(SQL_CREATE_CONTEXTS);
- db.execSQL(SQL_CREATE_LOCATIONS);
- db.execSQL(SQL_CREATE_VESSELS);
- db.execSQL(SQL_CREATE_METIERS);
- db.execSQL(SQL_CREATE_COMMERCIAL_SPECIES);
- db.execSQL(SQL_CREATE_SCIENTIFIC_SPECIES);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- //TODO kmorin 20131129 migrate data before droping the table
- // models
- db.execSQL(SQL_DELETE_SCIENTIFIC_SPECIES);
- db.execSQL(SQL_DELETE_COMMERCIAL_SPECIES);
- db.execSQL(SQL_DELETE_METIERS);
- db.execSQL(SQL_DELETE_VESSELS);
- db.execSQL(SQL_DELETE_LOCATIONS);
- db.execSQL(SQL_DELETE_CONTEXTS);
-
- // referentials
- db.execSQL(SQL_DELETE_REF_AGES);
- db.execSQL(SQL_DELETE_REF_COMMERCIAL_SPECIES);
- db.execSQL(SQL_DELETE_REF_GENDERS);
- db.execSQL(SQL_DELETE_REF_LOCATIONS);
- db.execSQL(SQL_DELETE_REF_MATURITIES);
- db.execSQL(SQL_DELETE_REF_MENSURATIONS);
- db.execSQL(SQL_DELETE_REF_METIERS);
- db.execSQL(SQL_DELETE_REF_PRESENTATIONS);
- db.execSQL(SQL_DELETE_REF_SCIENTIFIC_SPECIES);
- db.execSQL(SQL_DELETE_REF_STATES);
- db.execSQL(SQL_DELETE_REF_VESSELS);
- onCreate(db);
- }
-
- @Override
- public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- onUpgrade(db, oldVersion, newVersion);
- }
-
- @Override
- public synchronized void close() {
- super.close();
- getReadableDatabase().close();
- getWritableDatabase().close();
- }
-
- // CONTEXTS
-
- public Cursor getAllContexts() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(ContextModel.TABLE_NAME, ContextModel.ALL_COLUMNS, null, null, null, null, null);
- return cursor;
- }
-
- //LOCATION
-
- public Cursor getAllLocations(String contextId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(LocationModel.TABLE_NAME, LocationModel.ALL_COLUMNS,
- LocationModel.COLUMN_CONTEXT_ID + " = ?", new String[]{ contextId },
- null, null, null);
- return cursor;
- }
-
- //VESSEL
-
- public Cursor getAllVessels(String locationId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(VesselModel.TABLE_NAME, VesselModel.ALL_COLUMNS,
- VesselModel.COLUMN_LOCATION_ID + " = ?", new String[]{ locationId },
- null, null, null);
- return cursor;
- }
-
- //METIERS
-
- public Cursor getAllMetiers(String vesselId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(MetierModel.TABLE_NAME, MetierModel.ALL_COLUMNS,
- MetierModel.COLUMN_VESSEL_ID + " = ?", new String[]{ vesselId },
- null, null, null);
- return cursor;
- }
-
- //COMMERCIAL SPECIES
-
- public Cursor getAllCommercialSpecies(String metierId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, CommercialSpeciesModel.ALL_COLUMNS,
- CommercialSpeciesModel.COLUMN_METIER_ID + " = ?", new String[]{ metierId },
- null, null, null);
- return cursor;
- }
-
- public Cursor getAllSortCategories() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, new String[]{ CommercialSpeciesModel.COLUMN_SORT_CATEGORY },
- null, null, null, null, null);
- return cursor;
- }
-
- //SCIENTIFIC SPECIES
-
- public Cursor getAllScientificSpecies(String commercialSpeciesId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(ScientificSpeciesModel.TABLE_NAME, ScientificSpeciesModel.ALL_COLUMNS,
- ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + " = ?", new String[]{ commercialSpeciesId },
- null, null, null);
- return cursor;
- }
-
- // Referentials
-
- public Cursor getAllRefAges() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Age.TABLE_NAME, Age.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefCommercialSpecies() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(CommercialSpecies.TABLE_NAME, CommercialSpecies.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefGenders() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Gender.TABLE_NAME, Gender.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefLocations() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Location.TABLE_NAME, Location.ALL_COLUMNS,
- null, null, null, null, Location.COLUMN_CODE);
- return cursor;
- }
-
- public Cursor getAllRefMaturities() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Maturity.TABLE_NAME, Maturity.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefMensurations() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Mensuration.TABLE_NAME, Mensuration.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefMetiers() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Metier.TABLE_NAME, Metier.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefPresentations() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Presentation.TABLE_NAME, Presentation.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefScientificSpecies() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(ScientificSpecies.TABLE_NAME, ScientificSpecies.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefStates() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(State.TABLE_NAME, State.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefVessels() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Vessel.TABLE_NAME, Vessel.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- //TODO remove when tests are over
- public void clearReferentials() {
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
- db.delete(Age.TABLE_NAME, null, null);
- db.delete(CommercialSpecies.TABLE_NAME, null, null);
- db.delete(Gender.TABLE_NAME, null, null);
- db.delete(Location.TABLE_NAME, null, null);
- db.delete(Maturity.TABLE_NAME, null, null);
- db.delete(Mensuration.TABLE_NAME, null, null);
- db.delete(Metier.TABLE_NAME, null, null);
- db.delete(Presentation.TABLE_NAME, null, null);
- db.delete(ScientificSpecies.TABLE_NAME, null, null);
- db.delete(State.TABLE_NAME, null, null);
- db.delete(Vessel.TABLE_NAME, null, null);
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- public <M extends BaseModel> void saveData(M model) {
- saveData(Lists.newArrayList(model));
- }
-
- public <M extends BaseModel> void saveData(List<M> models) {
- Preconditions.checkNotNull(models);
-
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
-
- for (BaseModel model : models) {
- String tableName = model.getTableName();
-// Log.d(TAG, "saving data in " + tableName);
-
- boolean newSession = model.isNew();
- if (newSession) {
- String id = UUID.randomUUID().toString();
- model.setId(id);
- }
- ContentValues values = model.convertIntoContentValues();
-
- if (newSession) {
- db.insert(tableName, null, values);
-
- } else {
- db.update(tableName, values, BaseModel._ID + " = ?", new String[]{ model.getId() });
- }
- }
-
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- public static <E> List<E> transformCursorIntoCollection(Cursor cursor,
- Function<Cursor, E> function) {
-
- List<E> result = Lists.newArrayList();
- boolean cont = cursor.moveToFirst();
- while (cont) {
- E e = function.apply(cursor);
- result.add(e);
- cont = cursor.moveToNext();
- }
- return result;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java (from rev 25, trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,633 @@
+package fr.ifremer.wlo.storage;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.ContextModel;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.models.referentials.Vessel;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class WloSqlOpenHelper extends SQLiteOpenHelper {
+
+ private static final String TAG = "WloOpenHelper";
+
+ public static final String DATABASE_NAME = "wlo.db";
+ public static final int DATABASE_VERSION = 10;
+
+ public static final String TEXT_TYPE = " TEXT";
+ public static final String BIGINT_TYPE = " BIGINT";
+ public static final String BYTE_TYPE = " BYTE";
+ public static final String COMMA_SEP = ",";
+ public static final String NOT_NULL = " NOT NULL";
+
+ //CONTEXT
+ protected static final String SQL_CREATE_CONTEXTS =
+ "CREATE TABLE " + ContextModel.TABLE_NAME + " (" +
+ ContextModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ ContextModel.COLUMN_NAME + TEXT_TYPE + NOT_NULL +
+ " )";
+
+ protected static final String SQL_DELETE_CONTEXTS =
+ "DROP TABLE IF EXISTS " + ContextModel.TABLE_NAME;
+
+
+ //LOCATION
+ protected static final String SQL_CREATE_LOCATIONS =
+ "CREATE TABLE " + LocationModel.TABLE_NAME + " (" +
+ LocationModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ LocationModel.COLUMN_OPERATOR + TEXT_TYPE + COMMA_SEP +
+ LocationModel.COLUMN_START_DATE + BIGINT_TYPE + COMMA_SEP +
+ LocationModel.COLUMN_END_DATE + BIGINT_TYPE + COMMA_SEP +
+ LocationModel.COLUMN_LOCATION + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ LocationModel.COLUMN_CONTEXT_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + LocationModel.COLUMN_CONTEXT_ID + ") REFERENCES " +
+ ContextModel.TABLE_NAME + "(" + ContextModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + LocationModel.COLUMN_LOCATION + ") REFERENCES " +
+ Location.TABLE_NAME + "(" + Location._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_LOCATIONS =
+ "DROP TABLE IF EXISTS " + LocationModel.TABLE_NAME;
+
+ // VESSEL
+ protected static final String SQL_CREATE_VESSELS =
+ "CREATE TABLE " + VesselModel.TABLE_NAME + " (" +
+ VesselModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ VesselModel.COLUMN_REGISTRATION_NUMBER + TEXT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_LANDING_DATE + BIGINT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_LANDING_LOCATION + TEXT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_LOCATION_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + VesselModel.COLUMN_LOCATION_ID + ") REFERENCES " +
+ LocationModel.TABLE_NAME + "(" + LocationModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + VesselModel.COLUMN_LANDING_LOCATION + ") REFERENCES " +
+ Location.TABLE_NAME + "(" + Location._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_VESSELS =
+ "DROP TABLE IF EXISTS " + VesselModel.TABLE_NAME;
+
+ // METIER
+ protected static final String SQL_CREATE_METIERS =
+ "CREATE TABLE " + MetierModel.TABLE_NAME + " (" +
+ MetierModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ MetierModel.COLUMN_GEAR_SPECIES + TEXT_TYPE + COMMA_SEP +
+ MetierModel.COLUMN_ZONE + TEXT_TYPE + COMMA_SEP +
+ MetierModel.COLUMN_SAMPLE_ROW_CODE + TEXT_TYPE + COMMA_SEP +
+ MetierModel.COLUMN_VESSEL_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + MetierModel.COLUMN_VESSEL_ID + ") REFERENCES " +
+ VesselModel.TABLE_NAME + "(" + VesselModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + MetierModel.COLUMN_GEAR_SPECIES + ") REFERENCES " +
+ Metier.TABLE_NAME + "(" + Metier._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_METIERS =
+ "DROP TABLE IF EXISTS " + MetierModel.TABLE_NAME;
+
+ // COMMERCIAL SPECIES
+ protected static final String SQL_CREATE_COMMERCIAL_SPECIES =
+ "CREATE TABLE " + CommercialSpeciesModel.TABLE_NAME + " (" +
+ CommercialSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_FAO_CODE + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_PRECISION + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_SPECIES_MIX + BYTE_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_SORT_CATEGORY + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_STATE + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_PRESENTATION + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_METIER_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_METIER_ID + ") REFERENCES " +
+ MetierModel.TABLE_NAME + "(" + MetierModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_FAO_CODE + ") REFERENCES " +
+ CommercialSpecies.TABLE_NAME + "(" + CommercialSpecies._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + ") REFERENCES " +
+ Mensuration.TABLE_NAME + "(" + Mensuration._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_STATE + ") REFERENCES " +
+ State.TABLE_NAME + "(" + State._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_PRESENTATION + ") REFERENCES " +
+ Presentation.TABLE_NAME + "(" + Presentation._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_COMMERCIAL_SPECIES =
+ "DROP TABLE IF EXISTS " + CommercialSpeciesModel.TABLE_NAME;
+
+ // SCIENTIFIC SPECIES
+ protected static final String SQL_CREATE_SCIENTIFIC_SPECIES =
+ "CREATE TABLE " + ScientificSpeciesModel.TABLE_NAME + " (" +
+ ScientificSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
+ ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP +
+ ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + ") REFERENCES " +
+ CommercialSpeciesModel.TABLE_NAME + "(" + CommercialSpeciesModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_NAME + ") REFERENCES " +
+ ScientificSpecies.TABLE_NAME + "(" + ScientificSpecies._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_SCIENTIFIC_SPECIES =
+ "DROP TABLE IF EXISTS " + ScientificSpeciesModel.TABLE_NAME;
+
+ // MEASUREMENTS
+ protected static final String SQL_CREATE_MEASUREMENTS =
+ "CREATE TABLE " + MeasurementModel.TABLE_NAME + " (" +
+ MeasurementModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ MeasurementModel.COLUMN_SIZE + BIGINT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_DATE + BIGINT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_CATEGORY_1 + TEXT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_CATEGORY_2 + TEXT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_CATEGORY_3 + TEXT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + ") REFERENCES " +
+ ScientificSpeciesModel.TABLE_NAME + "(" + ScientificSpeciesModel._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_MEASUREMENTS =
+ "DROP TABLE IF EXISTS " + MeasurementModel.TABLE_NAME;
+
+
+ // Referentials
+
+ // Ages
+ protected static final String SQL_CREATE_REF_AGES =
+ "CREATE TABLE " + Age.TABLE_NAME + " (" +
+ Age._ID + TEXT_TYPE + " PRIMARY KEY," +
+ Age.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
+ " )";
+
+ protected static final String SQL_DELETE_REF_AGES =
+ "DROP TABLE IF EXISTS " + Age.TABLE_NAME;
+
+ // Commercial Species
+ protected static final String SQL_CREATE_REF_COMMERCIAL_SPECIES =
+ "CREATE TABLE " + CommercialSpecies.TABLE_NAME + " (" +
+ CommercialSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ CommercialSpecies.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ CommercialSpecies.COLUMN_ISSCAP + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_TAXON_CODE + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_SCIENTIFIC_LABEL + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_FRENCH_LABEL + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_FAMILY + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_SPECIES_ORDER + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_ACTIVE + BYTE_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_COMMERCIAL_SPECIES =
+ "DROP TABLE IF EXISTS " + CommercialSpecies.TABLE_NAME;
+
+ // Genders
+ protected static final String SQL_CREATE_REF_GENDERS =
+ "CREATE TABLE " + Gender.TABLE_NAME + " (" +
+ Gender._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Gender.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Gender.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_GENDERS =
+ "DROP TABLE IF EXISTS " + Gender.TABLE_NAME;
+
+ // Locations
+ protected static final String SQL_CREATE_REF_LOCATIONS =
+ "CREATE TABLE " + Location.TABLE_NAME + " (" +
+ Location._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Location.COLUMN_TYPE_LABEL + TEXT_TYPE + COMMA_SEP +
+ Location.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Location.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_LOCATIONS =
+ "DROP TABLE IF EXISTS " + Location.TABLE_NAME;
+
+ // Maturities
+ protected static final String SQL_CREATE_REF_MATURITIES =
+ "CREATE TABLE " + Maturity.TABLE_NAME + " (" +
+ Maturity._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Maturity.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
+ " )";
+
+ protected static final String SQL_DELETE_REF_MATURITIES =
+ "DROP TABLE IF EXISTS " + Maturity.TABLE_NAME;
+
+ // Mensurations
+ protected static final String SQL_CREATE_REF_MENSURATIONS =
+ "CREATE TABLE " + Mensuration.TABLE_NAME + " (" +
+ Mensuration._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Mensuration.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Mensuration.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_MENSURATIONS =
+ "DROP TABLE IF EXISTS " + Mensuration.TABLE_NAME;
+
+ // Metiers
+ protected static final String SQL_CREATE_REF_METIERS =
+ "CREATE TABLE " + Metier.TABLE_NAME + " (" +
+ Metier._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Metier.COLUMN_ID + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Metier.COLUMN_LABEL + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_GEAR_CODE + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_GEAR_LABEL + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_SPECIES_CODE + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_SPECIES_LABEL + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_FISHING + BYTE_TYPE + COMMA_SEP +
+ Metier.COLUMN_ACTIVE + BYTE_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_METIERS =
+ "DROP TABLE IF EXISTS " + Metier.TABLE_NAME;
+
+ // Presentations
+ protected static final String SQL_CREATE_REF_PRESENTATIONS =
+ "CREATE TABLE " + Presentation.TABLE_NAME + " (" +
+ Presentation._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Presentation.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Presentation.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_PRESENTATIONS =
+ "DROP TABLE IF EXISTS " + Presentation.TABLE_NAME;
+
+ // Scientific species
+ protected static final String SQL_CREATE_REF_SCIENTIFIC_SPECIES =
+ "CREATE TABLE " + ScientificSpecies.TABLE_NAME + " (" +
+ ScientificSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ ScientificSpecies.COLUMN_PERM_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ ScientificSpecies.COLUMN_CODE + TEXT_TYPE + COMMA_SEP +
+ ScientificSpecies.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_SCIENTIFIC_SPECIES =
+ "DROP TABLE IF EXISTS " + ScientificSpecies.TABLE_NAME;
+
+ // States
+ protected static final String SQL_CREATE_REF_STATES =
+ "CREATE TABLE " + State.TABLE_NAME + " (" +
+ State._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ State.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ State.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_STATES =
+ "DROP TABLE IF EXISTS " + State.TABLE_NAME;
+
+ // Vessels
+ protected static final String SQL_CREATE_REF_VESSELS =
+ "CREATE TABLE " + Vessel.TABLE_NAME + " (" +
+ Vessel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Vessel.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Vessel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
+ Vessel.COLUMN_QUARTER_CODE + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_VESSELS =
+ "DROP TABLE IF EXISTS " + Vessel.TABLE_NAME;
+
+
+ public WloSqlOpenHelper(android.content.Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ // referentials
+ db.execSQL(SQL_CREATE_REF_AGES);
+ db.execSQL(SQL_CREATE_REF_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_CREATE_REF_GENDERS);
+ db.execSQL(SQL_CREATE_REF_LOCATIONS);
+ db.execSQL(SQL_CREATE_REF_MATURITIES);
+ db.execSQL(SQL_CREATE_REF_MENSURATIONS);
+ db.execSQL(SQL_CREATE_REF_METIERS);
+ db.execSQL(SQL_CREATE_REF_PRESENTATIONS);
+ db.execSQL(SQL_CREATE_REF_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_CREATE_REF_STATES);
+ db.execSQL(SQL_CREATE_REF_VESSELS);
+
+ // models
+ db.execSQL(SQL_CREATE_CONTEXTS);
+ db.execSQL(SQL_CREATE_LOCATIONS);
+ db.execSQL(SQL_CREATE_VESSELS);
+ db.execSQL(SQL_CREATE_METIERS);
+ db.execSQL(SQL_CREATE_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_CREATE_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_CREATE_MEASUREMENTS);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ //TODO kmorin 20131129 migrate data before droping the table
+ // models
+ db.execSQL(SQL_DELETE_MEASUREMENTS);
+ db.execSQL(SQL_DELETE_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_DELETE_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_DELETE_METIERS);
+ db.execSQL(SQL_DELETE_VESSELS);
+ db.execSQL(SQL_DELETE_LOCATIONS);
+ db.execSQL(SQL_DELETE_CONTEXTS);
+
+ // referentials
+ db.execSQL(SQL_DELETE_REF_AGES);
+ db.execSQL(SQL_DELETE_REF_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_DELETE_REF_GENDERS);
+ db.execSQL(SQL_DELETE_REF_LOCATIONS);
+ db.execSQL(SQL_DELETE_REF_MATURITIES);
+ db.execSQL(SQL_DELETE_REF_MENSURATIONS);
+ db.execSQL(SQL_DELETE_REF_METIERS);
+ db.execSQL(SQL_DELETE_REF_PRESENTATIONS);
+ db.execSQL(SQL_DELETE_REF_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_DELETE_REF_STATES);
+ db.execSQL(SQL_DELETE_REF_VESSELS);
+ onCreate(db);
+ }
+
+ @Override
+ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ onUpgrade(db, oldVersion, newVersion);
+ }
+
+ @Override
+ public synchronized void close() {
+ super.close();
+ getReadableDatabase().close();
+ getWritableDatabase().close();
+ }
+
+ // CONTEXTS
+
+ public Cursor getAllContexts() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(ContextModel.TABLE_NAME, ContextModel.ALL_COLUMNS, null, null, null, null, null);
+ return cursor;
+ }
+
+ //LOCATION
+
+ public Cursor getAllLocations(String contextId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(LocationModel.TABLE_NAME, LocationModel.ALL_COLUMNS,
+ LocationModel.COLUMN_CONTEXT_ID + " = ?", new String[]{ contextId },
+ null, null, null);
+ return cursor;
+ }
+
+ //VESSEL
+
+ public Cursor getAllVessels(String locationId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(VesselModel.TABLE_NAME, VesselModel.ALL_COLUMNS,
+ VesselModel.COLUMN_LOCATION_ID + " = ?", new String[]{ locationId },
+ null, null, null);
+ return cursor;
+ }
+
+ //METIERS
+
+ public Cursor getAllMetiers(String vesselId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(MetierModel.TABLE_NAME, MetierModel.ALL_COLUMNS,
+ MetierModel.COLUMN_VESSEL_ID + " = ?", new String[]{ vesselId },
+ null, null, null);
+ return cursor;
+ }
+
+ //COMMERCIAL SPECIES
+
+ public Cursor getAllCommercialSpecies(String metierId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, CommercialSpeciesModel.ALL_COLUMNS,
+ CommercialSpeciesModel.COLUMN_METIER_ID + " = ?", new String[]{ metierId },
+ null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllSortCategories() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, new String[]{ CommercialSpeciesModel.COLUMN_SORT_CATEGORY },
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ //SCIENTIFIC SPECIES
+
+ public Cursor getAllScientificSpecies(String commercialSpeciesId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(ScientificSpeciesModel.TABLE_NAME, ScientificSpeciesModel.ALL_COLUMNS,
+ ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + " = ?", new String[]{ commercialSpeciesId },
+ null, null, null);
+ return cursor;
+ }
+
+ //MEASUREMENTS
+
+ public Cursor getAllMeasurements(String scientificSpeciesId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(MeasurementModel.TABLE_NAME, MeasurementModel.ALL_COLUMNS,
+ MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + " = ?", new String[]{ scientificSpeciesId },
+ null, null, MeasurementModel.COLUMN_DATE + " ASC");
+ return cursor;
+ }
+
+ public void deleteMeasurement(MeasurementModel measurement) {
+ if (!measurement.isNew()) {
+ SQLiteDatabase db = getWritableDatabase();
+ db.delete(MeasurementModel.TABLE_NAME, MeasurementModel._ID + " = ?", new String[]{ measurement.getId() });
+ }
+ }
+
+ // Referentials
+
+ public Cursor getAllRefAges() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Age.TABLE_NAME, Age.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefCommercialSpecies() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(CommercialSpecies.TABLE_NAME, CommercialSpecies.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefGenders() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Gender.TABLE_NAME, Gender.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefLocations() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Location.TABLE_NAME, Location.ALL_COLUMNS,
+ null, null, null, null, Location.COLUMN_CODE);
+ return cursor;
+ }
+
+ public Cursor getAllRefMaturities() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Maturity.TABLE_NAME, Maturity.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefMensurations() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Mensuration.TABLE_NAME, Mensuration.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefMetiers() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Metier.TABLE_NAME, Metier.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefPresentations() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Presentation.TABLE_NAME, Presentation.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefScientificSpecies() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(ScientificSpecies.TABLE_NAME, ScientificSpecies.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefStates() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(State.TABLE_NAME, State.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefVessels() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Vessel.TABLE_NAME, Vessel.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ //TODO remove when tests are over
+ public void clearReferentials() {
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+ db.delete(Age.TABLE_NAME, null, null);
+ db.delete(CommercialSpecies.TABLE_NAME, null, null);
+ db.delete(Gender.TABLE_NAME, null, null);
+ db.delete(Location.TABLE_NAME, null, null);
+ db.delete(Maturity.TABLE_NAME, null, null);
+ db.delete(Mensuration.TABLE_NAME, null, null);
+ db.delete(Metier.TABLE_NAME, null, null);
+ db.delete(Presentation.TABLE_NAME, null, null);
+ db.delete(ScientificSpecies.TABLE_NAME, null, null);
+ db.delete(State.TABLE_NAME, null, null);
+ db.delete(Vessel.TABLE_NAME, null, null);
+ db.setTransactionSuccessful();
+ db.endTransaction();
+ }
+
+ public <M extends BaseModel> void saveData(M model) {
+ saveData(Lists.newArrayList(model));
+ }
+
+ public <M extends BaseModel> void saveData(Collection<M> models) {
+ Preconditions.checkNotNull(models);
+
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+
+ for (BaseModel model : models) {
+ String tableName = model.getTableName();
+// Log.d(TAG, "saving data in " + tableName);
+
+ boolean newSession = model.isNew();
+ if (newSession) {
+ String id = UUID.randomUUID().toString();
+ model.setId(id);
+ }
+ ContentValues values = model.convertIntoContentValues();
+
+ if (newSession) {
+ db.insert(tableName, null, values);
+
+ } else {
+ db.update(tableName, values, BaseModel._ID + " = ?", new String[]{ model.getId() });
+ }
+ }
+
+ db.setTransactionSuccessful();
+ db.endTransaction();
+ }
+
+ public static <E> List<E> transformCursorIntoCollection(Cursor cursor,
+ Function<Cursor, E> function) {
+
+ List<E> result = Lists.newArrayList();
+ boolean cont = cursor.moveToFirst();
+ while (cont) {
+ E e = function.apply(cursor);
+ result.add(e);
+ cont = cursor.moveToNext();
+ }
+ return result;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,55 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.widget.TextView;
-import com.google.common.base.Preconditions;
-import fr.ifremer.wlo.models.BaseModel;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class AbstractDateTimePickerFragment extends DialogFragment {
-
- private static final String TAG = "AbstractDateTimePickerFragment";
-
- protected Calendar date;
- protected TextView view;
- protected BaseModel model;
- protected String attribute;
-
- public AbstractDateTimePickerFragment(BaseModel model, String attribute, TextView view) {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(attribute);
- this.view = view;
- this.model = model;
- this.attribute = attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
-
- Class clazz = model.getClass();
- try {
- date = (Calendar) clazz.getMethod("get" + this.attribute).invoke(model);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on get" + this.attribute + " for class " + clazz, e);
- }
-
- if (date == null) {
- date = Calendar.getInstance();
- }
- }
-
- protected void setDateInModel() {
- Class clazz = model.getClass();
- try {
- clazz.getMethod("set" + attribute, Calendar.class).invoke(model, date);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on set" + attribute + " for class " + clazz, e);
- }
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,79 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.widget.TextView;
+import com.google.common.base.Preconditions;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class AbstractDateTimePickerFragment extends DialogFragment {
+
+ private static final String TAG = "AbstractDateTimePickerFragment";
+
+ protected Calendar date;
+ protected TextView view;
+ protected BaseModel model;
+ protected String attribute;
+
+ public AbstractDateTimePickerFragment(BaseModel model, String attribute, TextView view) {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(attribute);
+ this.view = view;
+ this.model = model;
+ this.attribute = attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
+
+ Class clazz = model.getClass();
+ try {
+ date = (Calendar) clazz.getMethod("get" + this.attribute).invoke(model);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on get" + this.attribute + " for class " + clazz, e);
+ }
+
+ if (date == null) {
+ date = Calendar.getInstance();
+ }
+ }
+
+ protected void setDateInModel() {
+ Class clazz = model.getClass();
+ try {
+ clazz.getMethod("set" + attribute, Calendar.class).invoke(model, date);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on set" + attribute + " for class " + clazz, e);
+ }
+ }
+
+}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,188 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+import com.google.common.base.Function;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class BaseModelArrayAdapter<M extends BaseModel> extends ArrayAdapter<M> {
+
+ /**
+ * The resource indicating what views to inflate to display the content of this
+ * array adapter.
+ */
+ protected int mResource;
+
+ /**
+ * If the inflated resource is not a TextView, {@link #mFieldId} is used to find
+ * a TextView inside the inflated views hierarchy. This field must contain the
+ * identifier that matches the one defined in the resource file.
+ */
+ protected int mFieldId = 0;
+
+ protected LayoutInflater mInflater;
+
+ /**
+ * Function to transform object into String
+ */
+ protected Function<M, String> toStringFunction;
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, Function<M, String> toStringFunction) {
+ super(context, textViewResourceId);
+ init(textViewResourceId, 0, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId) {
+ super(context, textViewResourceId);
+ init(textViewResourceId, 0, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, Function<M, String> toStringFunction) {
+ super(context, resource, textViewResourceId);
+ init(resource, textViewResourceId, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId) {
+ super(context, resource, textViewResourceId);
+ init(resource, textViewResourceId, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, M[] objects, Function<M, String> toStringFunction) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, M[] objects) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, M[] objects, Function<M, String> toStringFunction) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, M[] objects) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, List<M> objects, Function<M, String> toStringFunction) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, List<M> objects) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, List<M> objects, Function<M, String> toStringFunction) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, List<M> objects) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, null);
+ }
+
+ protected void init(int resource, int textViewResourceId, Function<M, String> toStringFunction) {
+ mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mResource = resource;
+ mFieldId = textViewResourceId;
+ this.toStringFunction = toStringFunction;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ return createViewFromResource(position, convertView, parent, mResource);
+ }
+
+ private View createViewFromResource(int position, View convertView, ViewGroup parent,
+ int resource) {
+ View view;
+ TextView text;
+
+ if (convertView == null) {
+ view = mInflater.inflate(resource, parent, false);
+ } else {
+ view = convertView;
+ }
+
+ try {
+ if (mFieldId == 0) {
+ // If no custom field is assigned, assume the whole resource is a TextView
+ text = (TextView) view;
+ } else {
+ // Otherwise, find the TextView field within the layout
+ text = (TextView) view.findViewById(mFieldId);
+ }
+ } catch (ClassCastException e) {
+ Log.e("BaseModelArrayAdapter", "You must supply a resource ID for a TextView");
+ throw new IllegalStateException(
+ "BaseModelArrayAdapter requires the resource ID to be a TextView", e);
+ }
+
+ M item = getItem(position);
+ String s;
+ if (toStringFunction != null) {
+ s = toStringFunction.apply(item);
+ } else {
+ s = item.toString(getContext());
+ }
+ text.setText(s);
+
+ return view;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/BaseTextWatcher.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,23 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.text.Editable;
-import android.text.TextWatcher;
-
-/**
- * TextWatcher which does nothing. It is only to avoid redefining unuseful methods all the time
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class BaseTextWatcher implements TextWatcher {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/BaseTextWatcher.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,47 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.text.Editable;
+import android.text.TextWatcher;
+
+/**
+ * TextWatcher which does nothing. It is only to avoid redefining unuseful methods all the time
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class BaseTextWatcher implements TextWatcher {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/DatePickerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,45 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.app.DatePickerDialog;
-import android.app.Dialog;
-import android.os.Bundle;
-import android.widget.DatePicker;
-import android.widget.TextView;
-import fr.ifremer.wlo.models.BaseModel;
-
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class DatePickerFragment extends AbstractDateTimePickerFragment
- implements DatePickerDialog.OnDateSetListener {
-
- private static final String TAG = "DatePickerFragment";
-
- public DatePickerFragment(BaseModel model, String attribute, TextView view) {
- super(model, attribute, view);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- int year = date.get(Calendar.YEAR);
- int month = date.get(Calendar.MONTH);
- int day = date.get(Calendar.DAY_OF_MONTH);
-
- // Create a new instance of DatePickerDialog and return it
- return new DatePickerDialog(getActivity(), this, year, month, day);
- }
-
- public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- date.set(Calendar.YEAR, year);
- date.set(Calendar.MONTH, monthOfYear);
- date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- setDateInModel();
-
- String formattedDate = UIUtils.getDateOrUndefined(date, getActivity());
- this.view.setText(formattedDate);
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/DatePickerFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,69 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.widget.DatePicker;
+import android.widget.TextView;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class DatePickerFragment extends AbstractDateTimePickerFragment
+ implements DatePickerDialog.OnDateSetListener {
+
+ private static final String TAG = "DatePickerFragment";
+
+ public DatePickerFragment(BaseModel model, String attribute, TextView view) {
+ super(model, attribute, view);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ int year = date.get(Calendar.YEAR);
+ int month = date.get(Calendar.MONTH);
+ int day = date.get(Calendar.DAY_OF_MONTH);
+
+ // Create a new instance of DatePickerDialog and return it
+ return new DatePickerDialog(getActivity(), this, year, month, day);
+ }
+
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ date.set(Calendar.YEAR, year);
+ date.set(Calendar.MONTH, monthOfYear);
+ date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ setDateInModel();
+
+ String formattedDate = UIUtils.getDateOrUndefined(date, getActivity());
+ this.view.setText(formattedDate);
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/TimePickerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,44 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.app.Dialog;
-import android.app.TimePickerDialog;
-import android.os.Bundle;
-import android.text.format.DateFormat;
-import android.widget.TextView;
-import android.widget.TimePicker;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.BaseModel;
-
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class TimePickerFragment extends AbstractDateTimePickerFragment
- implements TimePickerDialog.OnTimeSetListener {
-
- private static final String TAG = "TimePickerFragment";
-
- public TimePickerFragment(BaseModel model, String attribute, TextView view) {
- super(model, attribute, view);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- int hour = date.get(Calendar.HOUR_OF_DAY);
- int minute = date.get(Calendar.MINUTE);
-
- // Create a new instance of TimePickerDialog and return it
- return new TimePickerDialog(getActivity(), this, hour, minute,
- DateFormat.is24HourFormat(getActivity()));
- }
-
- public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
- date.set(Calendar.HOUR_OF_DAY, hourOfDay);
- date.set(Calendar.MINUTE, minute);
- setDateInModel();
- this.view.setText(getString(R.string.time_format, date.getTime()));
- }
-
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/TimePickerFragment.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,68 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Dialog;
+import android.app.TimePickerDialog;
+import android.os.Bundle;
+import android.text.format.DateFormat;
+import android.widget.TextView;
+import android.widget.TimePicker;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class TimePickerFragment extends AbstractDateTimePickerFragment
+ implements TimePickerDialog.OnTimeSetListener {
+
+ private static final String TAG = "TimePickerFragment";
+
+ public TimePickerFragment(BaseModel model, String attribute, TextView view) {
+ super(model, attribute, view);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ int hour = date.get(Calendar.HOUR_OF_DAY);
+ int minute = date.get(Calendar.MINUTE);
+
+ // Create a new instance of TimePickerDialog and return it
+ return new TimePickerDialog(getActivity(), this, hour, minute,
+ DateFormat.is24HourFormat(getActivity()));
+ }
+
+ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+ date.set(Calendar.HOUR_OF_DAY, hourOfDay);
+ date.set(Calendar.MINUTE, minute);
+ setDateInModel();
+ this.view.setText(getString(R.string.time_format, date.getTime()));
+ }
+
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/UIUtils.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,100 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.database.Cursor;
-import android.preference.PreferenceManager;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.preferences.ListItemPreference;
-
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class UIUtils {
-
- private static final String TAG = "UIUtils";
-
- /**
- * @return A dialog click listener which cancel the dialog
- */
- public static DialogInterface.OnClickListener getCancelClickListener() {
- return new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- };
- }
-
- /**
- * Method to get a default string if the one given is null
- * @param s the string to check
- * @param defaultId the id of the string to return if s is null
- * @param context the location
- * @return s or the string with id defaultId
- */
- public static String getStringOrDefault(String s, int defaultId, Context context) {
- if (s != null) {
- return s;
- }
- return context.getString(defaultId);
- }
-
- /**
- * Method to get "undefined" if the one given is null
- * @param model the model to check
- * @param context the location
- * @return s or "undefined"
- */
- public static String getStringOrUndefined(BaseModel model, Context context) {
- String s = model != null ? model.toString(context) : null;
- return getStringOrDefault(s, R.string.undefined, context);
- }
-
- /**
- * Method to get "undefined" if the one given is null
- * @param s the string to check
- * @param context the location
- * @return s or "undefined"
- */
- public static String getStringOrUndefined(String s, Context context) {
- return getStringOrDefault(s, R.string.undefined, context);
- }
-
- /**
- * Method to get "undefined" if the one given is null
- * @param cal the calender to check
- * @param context the location
- * @return the formatted date or "undefined"
- */
- public static String getDateOrUndefined(Calendar cal, Context context) {
- if (cal == null) {
- return context.getString(R.string.undefined);
- }
- String dateFormat = getDateFormat(context);
- return String.format(dateFormat, cal);
- }
-
- public static String getDateFormat(Context context) {
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
- String dateFormat = sharedPref.getString(ListItemPreference.DATE_FORMAT.getKey(), "");
- return dateFormat;
- }
-
-
- public static Calendar getCalendarFromCursor(Cursor cursor, int columnIndex) {
- Calendar cal;
- if (cursor.getType(columnIndex) == Cursor.FIELD_TYPE_NULL) {
- cal = null;
- } else {
- long time = cursor.getLong(columnIndex);
- cal = Calendar.getInstance();
- cal.setTimeInMillis(time);
- }
- return cal;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/UIUtils.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/UIUtils.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,144 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.preference.PreferenceManager;
+import com.google.common.base.Preconditions;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.preferences.ListItemPreference;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class UIUtils {
+
+ private static final String TAG = "UIUtils";
+
+ /**
+ * @return A dialog click listener which cancel the dialog
+ */
+ public static DialogInterface.OnClickListener getCancelClickListener() {
+ return new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ };
+ }
+
+ /**
+ * Method to get a default string if the one given is null
+ * @param s the string to check
+ * @param defaultId the id of the string to return if s is null
+ * @param context the location
+ * @return s or the string with id defaultId
+ */
+ public static String getStringOrDefault(String s, int defaultId, Context context) {
+ if (s != null) {
+ return s;
+ }
+ return context.getString(defaultId);
+ }
+
+ /**
+ * Method to get "undefined" if the one given is null
+ * @param model the model to check
+ * @param context the location
+ * @return s or "undefined"
+ */
+ public static String getStringOrUndefined(BaseModel model, Context context) {
+ String s = model != null ? model.toString(context) : null;
+ return getStringOrDefault(s, R.string.undefined, context);
+ }
+
+ /**
+ * Method to get "undefined" if the one given is null
+ * @param s the string to check
+ * @param context the location
+ * @return s or "undefined"
+ */
+ public static String getStringOrUndefined(String s, Context context) {
+ return getStringOrDefault(s, R.string.undefined, context);
+ }
+
+ /**
+ * Method to get "undefined" if the one given is null
+ * @param cal the calender to check
+ * @param context the location
+ * @return the formatted date or "undefined"
+ */
+ public static String getDateOrUndefined(Calendar cal, Context context) {
+ if (cal == null) {
+ return context.getString(R.string.undefined);
+ }
+ String dateFormat = getDateFormat(context);
+ return String.format(dateFormat, cal);
+ }
+
+ public static String getDateFormat(Context context) {
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
+ String dateFormat = sharedPref.getString(ListItemPreference.DATE_FORMAT.getKey(), "");
+ return dateFormat;
+ }
+
+ public static Calendar getCalendarFromCursor(Cursor cursor, int columnIndex) {
+ Calendar cal;
+ if (cursor.getType(columnIndex) == Cursor.FIELD_TYPE_NULL) {
+ cal = null;
+ } else {
+ long time = cursor.getLong(columnIndex);
+ cal = Calendar.getInstance();
+ cal.setTimeInMillis(time);
+ }
+ return cal;
+ }
+
+ public static String getSizeFormat(Mensuration.Precision precision) {
+ String sizeFormat;
+ if (precision == Mensuration.Precision.MM5) {
+ sizeFormat = "%.1f";
+ } else {
+ sizeFormat = "%.0f";
+ }
+ return sizeFormat;
+ }
+
+ public static String getFormattedSize(int size, Mensuration.Precision precision) {
+ Preconditions.checkNotNull(precision);
+ String format = getSizeFormat(precision);
+ int divider = precision.getUnitDivider();
+ double dSize = (double) size / divider;
+ return String.format(Locale.US, format, dSize);
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,67 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.AutoCompleteTextView;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class WloAutoCompleteTextView extends AutoCompleteTextView {
-
- private int myThreshold;
-
- public WloAutoCompleteTextView(Context context) {
- super(context);
- init();
- }
-
- public WloAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init();
- }
-
- public WloAutoCompleteTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init();
- }
-
- protected void init() {
- setOnFocusChangeListener(new OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- showDropDown();
- } else {
- dismissDropDown();
- }
- }
- });
- setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- showDropDown();
- }
- });
- }
-
- @Override
- public void setThreshold(int threshold) {
- if (threshold < 0) {
- threshold = 0;
- }
- myThreshold = threshold;
- }
-
- @Override
- public boolean enoughToFilter() {
- return getText().length() >= myThreshold;
- }
-
- @Override
- public int getThreshold() {
- return myThreshold;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,91 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.AutoCompleteTextView;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class WloAutoCompleteTextView extends AutoCompleteTextView {
+
+ private int myThreshold;
+
+ public WloAutoCompleteTextView(Context context) {
+ super(context);
+ init();
+ }
+
+ public WloAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ public WloAutoCompleteTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ protected void init() {
+ setOnFocusChangeListener(new OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus) {
+ showDropDown();
+ } else {
+ dismissDropDown();
+ }
+ }
+ });
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showDropDown();
+ }
+ });
+ }
+
+ @Override
+ public void setThreshold(int threshold) {
+ if (threshold < 0) {
+ threshold = 0;
+ }
+ myThreshold = threshold;
+ }
+
+ @Override
+ public boolean enoughToFilter() {
+ return getText().length() >= myThreshold;
+ }
+
+ @Override
+ public int getThreshold() {
+ return myThreshold;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,113 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.storage.DataCache;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class WloItemListViewBinder implements SimpleCursorAdapter.ViewBinder {
-
- private static final String TAG = "WloItemListViewBinder";
-
- public enum DataType {
- DATE, DATETIME, LOCATION, METIER,
- MENSURATION, STATE, PRESENTATION,
- COMMERCIAL_SPECIES, SCIENTIFIC_SPECIES
- }
-
- protected Map<Integer, DataType> dataTypes = Maps.newHashMap();
- protected String dateFormat;
- protected String dateTimeFormat;
- protected Context context;
-
- public WloItemListViewBinder(Context context) {
- this(context, null);
- }
-
- public WloItemListViewBinder(Context context, Map<Integer, DataType> dataTypes) {
- this.context = context;
- dateFormat = UIUtils.getDateFormat(context);
- dateTimeFormat = dateFormat + " " + context.getString(R.string.time_format);
- if (dataTypes != null) {
- this.dataTypes = dataTypes;
- }
- }
-
- @Override
- public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
- DataType dataType = dataTypes.get(columnIndex);
- Log.d(TAG, "dataType for " + columnIndex + " : " + dataType);
-
- if (DataType.DATE.equals(dataType) || DataType.DATETIME.equals(dataType)) {
- if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
- long time = cursor.getLong(columnIndex);
- Date date = new Date(time);
- String format = DataType.DATE.equals(dataType) ? dateFormat : dateTimeFormat;
- String formattedDate = String.format(format, date);
- TextView textView = (TextView) view;
- textView.setText(formattedDate);
- return true;
- }
- }
-
- if (dataType != null) {
- if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
- Context context = view.getContext();
- String id = cursor.getString(columnIndex);
- BaseModel ref = null;
- switch (dataType) {
- case LOCATION:
- ref = DataCache.getLocationById(context, id);
- break;
- case METIER:
- ref = DataCache.getMetierById(context, id);
- break;
- case COMMERCIAL_SPECIES:
- ref = DataCache.getCommercialSpeciesById(context, id);
- break;
- case MENSURATION:
- ref = DataCache.getMensurationById(context, id);
- break;
- case STATE:
- ref = DataCache.getStateById(context, id);
- break;
- case PRESENTATION:
- ref = DataCache.getPresentationById(context, id);
- break;
- case SCIENTIFIC_SPECIES:
- ref = DataCache.getScientificSpeciesById(context, id);
- break;
- }
- TextView textView = (TextView) view;
- textView.setText(UIUtils.getStringOrUndefined(ref, context));
- return true;
- }
- }
-
- String value = cursor.getString(columnIndex);
- if (value == null) {
- TextView textView = (TextView) view;
- textView.setText(R.string.undefined);
- return true;
- }
-
- return false;
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,137 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.storage.DataCache;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class WloItemListViewBinder implements SimpleCursorAdapter.ViewBinder {
+
+ private static final String TAG = "WloItemListViewBinder";
+
+ public enum DataType {
+ DATE, DATETIME, LOCATION, METIER,
+ MENSURATION, STATE, PRESENTATION,
+ COMMERCIAL_SPECIES, SCIENTIFIC_SPECIES
+ }
+
+ protected Map<Integer, DataType> dataTypes = Maps.newHashMap();
+ protected String dateFormat;
+ protected String dateTimeFormat;
+ protected Context context;
+
+ public WloItemListViewBinder(Context context) {
+ this(context, null);
+ }
+
+ public WloItemListViewBinder(Context context, Map<Integer, DataType> dataTypes) {
+ this.context = context;
+ dateFormat = UIUtils.getDateFormat(context);
+ dateTimeFormat = dateFormat + " " + context.getString(R.string.time_format);
+ if (dataTypes != null) {
+ this.dataTypes = dataTypes;
+ }
+ }
+
+ @Override
+ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
+ DataType dataType = dataTypes.get(columnIndex);
+ Log.d(TAG, "dataType for " + columnIndex + " : " + dataType);
+
+ if (DataType.DATE.equals(dataType) || DataType.DATETIME.equals(dataType)) {
+ if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
+ long time = cursor.getLong(columnIndex);
+ Date date = new Date(time);
+ String format = DataType.DATE.equals(dataType) ? dateFormat : dateTimeFormat;
+ String formattedDate = String.format(format, date);
+ TextView textView = (TextView) view;
+ textView.setText(formattedDate);
+ return true;
+ }
+ }
+
+ if (dataType != null) {
+ if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
+ Context context = view.getContext();
+ String id = cursor.getString(columnIndex);
+ BaseModel ref = null;
+ switch (dataType) {
+ case LOCATION:
+ ref = DataCache.getLocationById(context, id);
+ break;
+ case METIER:
+ ref = DataCache.getMetierById(context, id);
+ break;
+ case COMMERCIAL_SPECIES:
+ ref = DataCache.getCommercialSpeciesById(context, id);
+ break;
+ case MENSURATION:
+ ref = DataCache.getMensurationById(context, id);
+ break;
+ case STATE:
+ ref = DataCache.getStateById(context, id);
+ break;
+ case PRESENTATION:
+ ref = DataCache.getPresentationById(context, id);
+ break;
+ case SCIENTIFIC_SPECIES:
+ ref = DataCache.getScientificSpeciesById(context, id);
+ break;
+ }
+ TextView textView = (TextView) view;
+ textView.setText(UIUtils.getStringOrUndefined(ref, context));
+ return true;
+ }
+ }
+
+ String value = cursor.getString(columnIndex);
+ if (value == null) {
+ TextView textView = (TextView) view;
+ textView.setText(R.string.undefined);
+ return true;
+ }
+
+ return false;
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,387 +0,0 @@
-package fr.ifremer.wlo.utils.filechooser;
-
-import android.app.AlertDialog;
-import android.app.ListActivity;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.widget.TextView;
-import fr.ifremer.wlo.R;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- * Activity para escolha de arquivos/diretorios.
- *
- * @author android
- *
- */
-public class FileDialog extends ListActivity {
-
- /**
- * Chave de um item da lista de paths.
- */
- private static final String ITEM_KEY = "key";
-
- /**
- * Imagem de um item da lista de paths (diretorio ou arquivo).
- */
- private static final String ITEM_IMAGE = "image";
-
- /**
- * Diretorio raiz.
- */
- private static final String ROOT = "/";
-
- /**
- * Parametro de entrada da Activity: path inicial. Padrao: ROOT.
- */
- public static final String START_PATH = "START_PATH";
-
- /**
- * Parametro de entrada da Activity: filtro de formatos de arquivos. Padrao:
- * null.
- */
- public static final String FORMAT_FILTER = "FORMAT_FILTER";
-
- /**
- * Parametro de saida da Activity: path escolhido. Padrao: null.
- */
- public static final String RESULT_PATH = "RESULT_PATH";
-
- /**
- * Parametro de entrada da Activity: tipo de selecao: pode criar novos paths
- * ou nao. Padrao: nao permite.
- *
- * @see {@link SelectionMode}
- */
- public static final String SELECTION_MODE = "SELECTION_MODE";
-
- /**
- * Parametro de entrada da Activity: se e permitido escolher diretorios.
- * Padrao: falso.
- */
- public static final String CAN_SELECT_DIR = "CAN_SELECT_DIR";
-
- private List<String> path = null;
- private TextView myPath;
- private EditText mFileName;
- private ArrayList<HashMap<String, Object>> mList;
-
- private Button selectButton;
-
- private LinearLayout layoutSelect;
- private LinearLayout layoutCreate;
- private InputMethodManager inputManager;
- private String parentPath;
- private String currentPath = ROOT;
-
- private int selectionMode = SelectionMode.MODE_CREATE;
-
- private String[] formatFilter = null;
-
- private boolean canSelectDir = false;
-
- private File selectedFile;
- private HashMap<String, Integer> lastPositions = new HashMap<String, Integer>();
-
- /**
- * Called when the activity is first created. Configura todos os parametros
- * de entrada e das VIEWS..
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setResult(RESULT_CANCELED, getIntent());
-
- setContentView(R.layout.file_dialog_main);
- myPath = (TextView) findViewById(R.id.path);
- mFileName = (EditText) findViewById(R.id.fdEditTextFile);
-
- inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
-
- selectButton = (Button) findViewById(R.id.fdButtonSelect);
- selectButton.setEnabled(false);
- selectButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (selectedFile != null) {
- getIntent().putExtra(RESULT_PATH, selectedFile.getPath());
- setResult(RESULT_OK, getIntent());
- finish();
- }
- }
- });
-
- final Button newButton = (Button) findViewById(R.id.fdButtonNew);
- newButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- setCreateVisible(v);
-
- mFileName.setText("");
- mFileName.requestFocus();
- }
- });
-
- selectionMode = getIntent().getIntExtra(SELECTION_MODE, SelectionMode.MODE_CREATE);
-
- formatFilter = getIntent().getStringArrayExtra(FORMAT_FILTER);
-
- canSelectDir = getIntent().getBooleanExtra(CAN_SELECT_DIR, false);
-
- if (selectionMode == SelectionMode.MODE_OPEN) {
- newButton.setVisibility(View.GONE);
- }
-
- layoutSelect = (LinearLayout) findViewById(R.id.fdLinearLayoutSelect);
- layoutCreate = (LinearLayout) findViewById(R.id.fdLinearLayoutCreate);
- layoutCreate.setVisibility(View.GONE);
-
- final Button cancelButton = (Button) findViewById(R.id.fdButtonCancel);
- cancelButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- setSelectVisible(v);
- }
-
- });
- final Button createButton = (Button) findViewById(R.id.fdButtonCreate);
- createButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (mFileName.getText().length() > 0) {
- getIntent().putExtra(RESULT_PATH, currentPath + "/" + mFileName.getText());
- setResult(RESULT_OK, getIntent());
- finish();
- }
- }
- });
-
- String startPath = getIntent().getStringExtra(START_PATH);
- startPath = startPath != null ? startPath : ROOT;
- if (canSelectDir) {
- File file = new File(startPath);
- selectedFile = file;
- selectButton.setEnabled(true);
- }
- getDir(startPath);
- }
-
- private void getDir(String dirPath) {
-
- boolean useAutoSelection = dirPath.length() < currentPath.length();
-
- Integer position = lastPositions.get(parentPath);
-
- getDirImpl(dirPath);
-
- if (position != null && useAutoSelection) {
- getListView().setSelection(position);
- }
-
- }
-
- /**
- * Monta a estrutura de arquivos e diretorios filhos do diretorio fornecido.
- *
- * @param dirPath
- * Diretorio pai.
- */
- private void getDirImpl(final String dirPath) {
-
- currentPath = dirPath;
-
- final List<String> item = new ArrayList<String>();
- path = new ArrayList<String>();
- mList = new ArrayList<HashMap<String, Object>>();
-
- File f = new File(currentPath);
- File[] files = f.listFiles();
- if (files == null) {
- currentPath = ROOT;
- f = new File(currentPath);
- files = f.listFiles();
- }
- myPath.setText(getText(R.string.file_chooser_location) + ": " + currentPath);
-
- if (!currentPath.equals(ROOT)) {
-
- item.add(ROOT);
- addItem(ROOT, R.drawable.folder);
- path.add(ROOT);
-
- item.add("../");
- addItem("../", R.drawable.folder);
- path.add(f.getParent());
- parentPath = f.getParent();
-
- }
-
- TreeMap<String, String> dirsMap = new TreeMap<String, String>();
- TreeMap<String, String> dirsPathMap = new TreeMap<String, String>();
- TreeMap<String, String> filesMap = new TreeMap<String, String>();
- TreeMap<String, String> filesPathMap = new TreeMap<String, String>();
- for (File file : files) {
- if (file.isDirectory()) {
- String dirName = file.getName();
- dirsMap.put(dirName, dirName);
- dirsPathMap.put(dirName, file.getPath());
- } else {
- final String fileName = file.getName();
- final String fileNameLwr = fileName.toLowerCase();
- // se ha um filtro de formatos, utiliza-o
- if (formatFilter != null) {
- boolean contains = false;
- for (int i = 0; i < formatFilter.length; i++) {
- final String formatLwr = formatFilter[i].toLowerCase();
- if (fileNameLwr.endsWith(formatLwr)) {
- contains = true;
- break;
- }
- }
- if (contains) {
- filesMap.put(fileName, fileName);
- filesPathMap.put(fileName, file.getPath());
- }
- // senao, adiciona todos os arquivos
- } else {
- filesMap.put(fileName, fileName);
- filesPathMap.put(fileName, file.getPath());
- }
- }
- }
- item.addAll(dirsMap.tailMap("").values());
- item.addAll(filesMap.tailMap("").values());
- path.addAll(dirsPathMap.tailMap("").values());
- path.addAll(filesPathMap.tailMap("").values());
-
- SimpleAdapter fileList = new SimpleAdapter(this, mList, R.layout.file_dialog_row, new String[] {
- ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage });
-
- for (String dir : dirsMap.tailMap("").values()) {
- addItem(dir, R.drawable.folder);
- }
-
- for (String file : filesMap.tailMap("").values()) {
- addItem(file, R.drawable.file);
- }
-
- fileList.notifyDataSetChanged();
-
- setListAdapter(fileList);
-
- }
-
- private void addItem(String fileName, int imageId) {
- HashMap<String, Object> item = new HashMap<String, Object>();
- item.put(ITEM_KEY, fileName);
- item.put(ITEM_IMAGE, imageId);
- mList.add(item);
- }
-
- /**
- * Quando clica no item da lista, deve-se: 1) Se for diretorio, abre seus
- * arquivos filhos; 2) Se puder escolher diretorio, define-o como sendo o
- * path escolhido. 3) Se for arquivo, define-o como path escolhido. 4) Ativa
- * botao de selecao.
- */
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
-
- File file = new File(path.get(position));
-
- setSelectVisible(v);
-
- if (file.isDirectory()) {
- selectButton.setEnabled(false);
- if (file.canRead()) {
- lastPositions.put(currentPath, position);
- getDir(path.get(position));
- if (canSelectDir) {
- selectedFile = file;
- v.setSelected(true);
- selectButton.setEnabled(true);
- }
- } else {
- new AlertDialog.Builder(this).setIcon(R.drawable.icon)
- .setTitle("[" + file.getName() + "] " + getText(R.string.file_chooser_cant_read_folder))
- .setPositiveButton("OK", new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
-
- }
- }).show();
- }
- } else {
- selectedFile = file;
- v.setSelected(true);
- selectButton.setEnabled(true);
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if ((keyCode == KeyEvent.KEYCODE_BACK)) {
- selectButton.setEnabled(false);
-
- if (layoutCreate.getVisibility() == View.VISIBLE) {
- layoutCreate.setVisibility(View.GONE);
- layoutSelect.setVisibility(View.VISIBLE);
- } else {
-// if (!currentPath.equals(ROOT)) {
-// getDir(parentPath);
-// } else {
- return super.onKeyDown(keyCode, event);
-// }
- }
-
- return true;
- } else {
- return super.onKeyDown(keyCode, event);
- }
- }
-
- /**
- * Define se o botao de CREATE e visivel.
- *
- * @param v
- */
- private void setCreateVisible(View v) {
- layoutCreate.setVisibility(View.VISIBLE);
- layoutSelect.setVisibility(View.GONE);
-
- inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
- selectButton.setEnabled(false);
- }
-
- /**
- * Define se o botao de SELECT e visivel.
- *
- * @param v
- */
- private void setSelectVisible(View v) {
- layoutCreate.setVisibility(View.GONE);
- layoutSelect.setVisibility(View.VISIBLE);
-
- inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
- selectButton.setEnabled(false);
- }
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,411 @@
+package fr.ifremer.wlo.utils.filechooser;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.AlertDialog;
+import android.app.ListActivity;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+import fr.ifremer.wlo.R;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.TreeMap;
+
+/**
+ * Activity para escolha de arquivos/diretorios.
+ *
+ * @author android
+ *
+ */
+public class FileDialog extends ListActivity {
+
+ /**
+ * Chave de um item da lista de paths.
+ */
+ private static final String ITEM_KEY = "key";
+
+ /**
+ * Imagem de um item da lista de paths (diretorio ou arquivo).
+ */
+ private static final String ITEM_IMAGE = "image";
+
+ /**
+ * Diretorio raiz.
+ */
+ private static final String ROOT = "/";
+
+ /**
+ * Parametro de entrada da Activity: path inicial. Padrao: ROOT.
+ */
+ public static final String START_PATH = "START_PATH";
+
+ /**
+ * Parametro de entrada da Activity: filtro de formatos de arquivos. Padrao:
+ * null.
+ */
+ public static final String FORMAT_FILTER = "FORMAT_FILTER";
+
+ /**
+ * Parametro de saida da Activity: path escolhido. Padrao: null.
+ */
+ public static final String RESULT_PATH = "RESULT_PATH";
+
+ /**
+ * Parametro de entrada da Activity: tipo de selecao: pode criar novos paths
+ * ou nao. Padrao: nao permite.
+ *
+ * @see {@link SelectionMode}
+ */
+ public static final String SELECTION_MODE = "SELECTION_MODE";
+
+ /**
+ * Parametro de entrada da Activity: se e permitido escolher diretorios.
+ * Padrao: falso.
+ */
+ public static final String CAN_SELECT_DIR = "CAN_SELECT_DIR";
+
+ private List<String> path = null;
+ private TextView myPath;
+ private EditText mFileName;
+ private ArrayList<HashMap<String, Object>> mList;
+
+ private Button selectButton;
+
+ private LinearLayout layoutSelect;
+ private LinearLayout layoutCreate;
+ private InputMethodManager inputManager;
+ private String parentPath;
+ private String currentPath = ROOT;
+
+ private int selectionMode = SelectionMode.MODE_CREATE;
+
+ private String[] formatFilter = null;
+
+ private boolean canSelectDir = false;
+
+ private File selectedFile;
+ private HashMap<String, Integer> lastPositions = new HashMap<String, Integer>();
+
+ /**
+ * Called when the activity is first created. Configura todos os parametros
+ * de entrada e das VIEWS..
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setResult(RESULT_CANCELED, getIntent());
+
+ setContentView(R.layout.file_dialog_main);
+ myPath = (TextView) findViewById(R.id.path);
+ mFileName = (EditText) findViewById(R.id.fdEditTextFile);
+
+ inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
+
+ selectButton = (Button) findViewById(R.id.fdButtonSelect);
+ selectButton.setEnabled(false);
+ selectButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (selectedFile != null) {
+ getIntent().putExtra(RESULT_PATH, selectedFile.getPath());
+ setResult(RESULT_OK, getIntent());
+ finish();
+ }
+ }
+ });
+
+ final Button newButton = (Button) findViewById(R.id.fdButtonNew);
+ newButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ setCreateVisible(v);
+
+ mFileName.setText("");
+ mFileName.requestFocus();
+ }
+ });
+
+ selectionMode = getIntent().getIntExtra(SELECTION_MODE, SelectionMode.MODE_CREATE);
+
+ formatFilter = getIntent().getStringArrayExtra(FORMAT_FILTER);
+
+ canSelectDir = getIntent().getBooleanExtra(CAN_SELECT_DIR, false);
+
+ if (selectionMode == SelectionMode.MODE_OPEN) {
+ newButton.setVisibility(View.GONE);
+ }
+
+ layoutSelect = (LinearLayout) findViewById(R.id.fdLinearLayoutSelect);
+ layoutCreate = (LinearLayout) findViewById(R.id.fdLinearLayoutCreate);
+ layoutCreate.setVisibility(View.GONE);
+
+ final Button cancelButton = (Button) findViewById(R.id.fdButtonCancel);
+ cancelButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ setSelectVisible(v);
+ }
+
+ });
+ final Button createButton = (Button) findViewById(R.id.fdButtonCreate);
+ createButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (mFileName.getText().length() > 0) {
+ getIntent().putExtra(RESULT_PATH, currentPath + "/" + mFileName.getText());
+ setResult(RESULT_OK, getIntent());
+ finish();
+ }
+ }
+ });
+
+ String startPath = getIntent().getStringExtra(START_PATH);
+ startPath = startPath != null ? startPath : ROOT;
+ if (canSelectDir) {
+ File file = new File(startPath);
+ selectedFile = file;
+ selectButton.setEnabled(true);
+ }
+ getDir(startPath);
+ }
+
+ private void getDir(String dirPath) {
+
+ boolean useAutoSelection = dirPath.length() < currentPath.length();
+
+ Integer position = lastPositions.get(parentPath);
+
+ getDirImpl(dirPath);
+
+ if (position != null && useAutoSelection) {
+ getListView().setSelection(position);
+ }
+
+ }
+
+ /**
+ * Monta a estrutura de arquivos e diretorios filhos do diretorio fornecido.
+ *
+ * @param dirPath
+ * Diretorio pai.
+ */
+ private void getDirImpl(final String dirPath) {
+
+ currentPath = dirPath;
+
+ final List<String> item = new ArrayList<String>();
+ path = new ArrayList<String>();
+ mList = new ArrayList<HashMap<String, Object>>();
+
+ File f = new File(currentPath);
+ File[] files = f.listFiles();
+ if (files == null) {
+ currentPath = ROOT;
+ f = new File(currentPath);
+ files = f.listFiles();
+ }
+ myPath.setText(getText(R.string.file_chooser_location) + ": " + currentPath);
+
+ if (!currentPath.equals(ROOT)) {
+
+ item.add(ROOT);
+ addItem(ROOT, R.drawable.folder);
+ path.add(ROOT);
+
+ item.add("../");
+ addItem("../", R.drawable.folder);
+ path.add(f.getParent());
+ parentPath = f.getParent();
+
+ }
+
+ TreeMap<String, String> dirsMap = new TreeMap<String, String>();
+ TreeMap<String, String> dirsPathMap = new TreeMap<String, String>();
+ TreeMap<String, String> filesMap = new TreeMap<String, String>();
+ TreeMap<String, String> filesPathMap = new TreeMap<String, String>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ String dirName = file.getName();
+ dirsMap.put(dirName, dirName);
+ dirsPathMap.put(dirName, file.getPath());
+ } else {
+ final String fileName = file.getName();
+ final String fileNameLwr = fileName.toLowerCase();
+ // se ha um filtro de formatos, utiliza-o
+ if (formatFilter != null) {
+ boolean contains = false;
+ for (int i = 0; i < formatFilter.length; i++) {
+ final String formatLwr = formatFilter[i].toLowerCase();
+ if (fileNameLwr.endsWith(formatLwr)) {
+ contains = true;
+ break;
+ }
+ }
+ if (contains) {
+ filesMap.put(fileName, fileName);
+ filesPathMap.put(fileName, file.getPath());
+ }
+ // senao, adiciona todos os arquivos
+ } else {
+ filesMap.put(fileName, fileName);
+ filesPathMap.put(fileName, file.getPath());
+ }
+ }
+ }
+ item.addAll(dirsMap.tailMap("").values());
+ item.addAll(filesMap.tailMap("").values());
+ path.addAll(dirsPathMap.tailMap("").values());
+ path.addAll(filesPathMap.tailMap("").values());
+
+ SimpleAdapter fileList = new SimpleAdapter(this, mList, R.layout.file_dialog_row, new String[] {
+ ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage });
+
+ for (String dir : dirsMap.tailMap("").values()) {
+ addItem(dir, R.drawable.folder);
+ }
+
+ for (String file : filesMap.tailMap("").values()) {
+ addItem(file, R.drawable.file);
+ }
+
+ fileList.notifyDataSetChanged();
+
+ setListAdapter(fileList);
+
+ }
+
+ private void addItem(String fileName, int imageId) {
+ HashMap<String, Object> item = new HashMap<String, Object>();
+ item.put(ITEM_KEY, fileName);
+ item.put(ITEM_IMAGE, imageId);
+ mList.add(item);
+ }
+
+ /**
+ * Quando clica no item da lista, deve-se: 1) Se for diretorio, abre seus
+ * arquivos filhos; 2) Se puder escolher diretorio, define-o como sendo o
+ * path escolhido. 3) Se for arquivo, define-o como path escolhido. 4) Ativa
+ * botao de selecao.
+ */
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+
+ File file = new File(path.get(position));
+
+ setSelectVisible(v);
+
+ if (file.isDirectory()) {
+ selectButton.setEnabled(false);
+ if (file.canRead()) {
+ lastPositions.put(currentPath, position);
+ getDir(path.get(position));
+ if (canSelectDir) {
+ selectedFile = file;
+ v.setSelected(true);
+ selectButton.setEnabled(true);
+ }
+ } else {
+ new AlertDialog.Builder(this).setIcon(R.drawable.icon)
+ .setTitle("[" + file.getName() + "] " + getText(R.string.file_chooser_cant_read_folder))
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+
+ }
+ }).show();
+ }
+ } else {
+ selectedFile = file;
+ v.setSelected(true);
+ selectButton.setEnabled(true);
+ }
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if ((keyCode == KeyEvent.KEYCODE_BACK)) {
+ selectButton.setEnabled(false);
+
+ if (layoutCreate.getVisibility() == View.VISIBLE) {
+ layoutCreate.setVisibility(View.GONE);
+ layoutSelect.setVisibility(View.VISIBLE);
+ } else {
+// if (!currentPath.equals(ROOT)) {
+// getDir(parentPath);
+// } else {
+ return super.onKeyDown(keyCode, event);
+// }
+ }
+
+ return true;
+ } else {
+ return super.onKeyDown(keyCode, event);
+ }
+ }
+
+ /**
+ * Define se o botao de CREATE e visivel.
+ *
+ * @param v
+ */
+ private void setCreateVisible(View v) {
+ layoutCreate.setVisibility(View.VISIBLE);
+ layoutSelect.setVisibility(View.GONE);
+
+ inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ selectButton.setEnabled(false);
+ }
+
+ /**
+ * Define se o botao de SELECT e visivel.
+ *
+ * @param v
+ */
+ private void setSelectVisible(View v) {
+ layoutCreate.setVisibility(View.GONE);
+ layoutSelect.setVisibility(View.VISIBLE);
+
+ inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ selectButton.setEnabled(false);
+ }
+}
Deleted: tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -1,7 +0,0 @@
-package fr.ifremer.wlo.utils.filechooser;
-
-public class SelectionMode {
- public static final int MODE_CREATE = 0;
-
- public static final int MODE_OPEN = 1;
-}
Copied: tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java)
===================================================================
--- tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java (rev 0)
+++ tags/wlo-0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java 2014-01-27 09:03:16 UTC (rev 29)
@@ -0,0 +1,31 @@
+package fr.ifremer.wlo.utils.filechooser;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+public class SelectionMode {
+ public static final int MODE_CREATE = 0;
+
+ public static final int MODE_OPEN = 1;
+}
1
0
r28 - in tags: . 0.1 0.1/res/layout 0.1/src 0.1/src/fr/ifremer/wlo 0.1/src/fr/ifremer/wlo/measurement 0.1/src/fr/ifremer/wlo/models 0.1/src/fr/ifremer/wlo/models/referentials 0.1/src/fr/ifremer/wlo/models/referentials/imports 0.1/src/fr/ifremer/wlo/preferences 0.1/src/fr/ifremer/wlo/storage 0.1/src/fr/ifremer/wlo/utils 0.1/src/fr/ifremer/wlo/utils/filechooser
by kmorin@users.forge.codelutin.com 27 Jan '14
by kmorin@users.forge.codelutin.com 27 Jan '14
27 Jan '14
Author: kmorin
Date: 2014-01-27 10:00:23 +0100 (Mon, 27 Jan 2014)
New Revision: 28
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/28
Log:
tag 0.1 (not done with a maven release due to android plugin conflicts)
Added:
tags/0.1/
tags/0.1/LICENSE.txt
tags/0.1/default.properties
tags/0.1/pom.xml
tags/0.1/res/layout/measurement.xml
tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java
tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java
tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java
tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java
tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java
tags/0.1/src/fr/ifremer/wlo/Home.java
tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java
tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java
tags/0.1/src/fr/ifremer/wlo/MainActivity.java
tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java
tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java
tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java
tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java
tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java
tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java
tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java
tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java
tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java
tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java
tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java
tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java
tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java
tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java
tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java
tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java
tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java
tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java
tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java
tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java
tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java
tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java
tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java
tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java
tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java
tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java
tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java
tags/0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java
tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java
tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java
tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java
tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java
tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java
tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java
tags/0.1/src/license/
Removed:
tags/0.1/LICENSE.txt
tags/0.1/default.properties
tags/0.1/pom.xml
tags/0.1/res/layout/measurement.xml
tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java
tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java
tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java
tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java
tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java
tags/0.1/src/fr/ifremer/wlo/Home.java
tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java
tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java
tags/0.1/src/fr/ifremer/wlo/MainActivity.java
tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java
tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java
tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java
tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java
tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java
tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java
tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java
tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java
tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java
tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java
tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java
tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java
tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java
tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java
tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java
tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java
tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java
tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java
tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java
tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java
tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java
tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java
tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java
tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java
tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java
tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java
tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java
tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java
tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java
tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java
tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java
tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java
tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java
tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java
Deleted: tags/0.1/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/LICENSE.txt 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program 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 3 of the License, or
- (at your option) any later version.
-
- This program 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, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Copied: tags/0.1/LICENSE.txt (from rev 26, trunk/LICENSE.txt)
===================================================================
--- tags/0.1/LICENSE.txt (rev 0)
+++ tags/0.1/LICENSE.txt 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Deleted: tags/0.1/default.properties
===================================================================
--- trunk/default.properties 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/default.properties 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,13 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Indicates whether an apk should be generated for each density.
-split.density=false
-# Project target.
-target=android-4
Copied: tags/0.1/default.properties (from rev 26, trunk/default.properties)
===================================================================
--- tags/0.1/default.properties (rev 0)
+++ tags/0.1/default.properties 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,13 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Indicates whether an apk should be generated for each density.
+split.density=false
+# Project target.
+target=android-15
Deleted: tags/0.1/pom.xml
===================================================================
--- trunk/pom.xml 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/pom.xml 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,578 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.nuiton</groupId>
- <artifactId>mavenpom4redmine</artifactId>
- <version>4.5</version>
- </parent>
-
- <groupId>fr.ifremer</groupId>
- <artifactId>wlo</artifactId>
- <version>0.1-SNAPSHOT</version>
-
- <name>WLO</name>
- <description>
- Application pour les missions de recueil d'information sur les stockes pour l'observation en criée et en mer.
- </description>
- <inceptionYear>2013</inceptionYear>
- <url>http://forge.codelutin.com/projects/wlo</url>
-
- <licenses>
- <license>
- <name>General Public License (GPL)</name>
- <url>http://www.gnu.org/licenses/gpl.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
-
- <developers>
- <developer>
- <id>chemit</id>
- <name>Tony Chemit</name>
- <email>chemit at codelutin dot com</email>
- <organization>CodeLutin</organization>
- <organizationUrl>http://www.codelutin.com</organizationUrl>
- <roles>
- <role>developer</role>
- </roles>
- <timezone>Europe/Paris</timezone>
- </developer>
- <developer>
- <id>morin</id>
- <name>Kevin Morin</name>
- <email>morin at codelutin dot com</email>
- <organization>CodeLutin</organization>
- <organizationUrl>http://www.codelutin.com</organizationUrl>
- <roles>
- <role>developer</role>
- </roles>
- <timezone>Europe/Paris</timezone>
- </developer>
- </developers>
-
- <scm>
- <url>https://forge.codelutin.com/svn/wlo/trunk</url>
- <connection>
- scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
- </connection>
- <developerConnection>
- scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
- </developerConnection>
- </scm>
- <distributionManagement>
- <site>
- <id>${platform}</id>
- <url>${our.site.repository}/${projectId}</url>
- </site>
- </distributionManagement>
-
- <packaging>apk</packaging>
-
- <properties>
-
- <!-- Java version -->
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- <signatureArtifactId>java17</signatureArtifactId>
- <signatureVersion>1.0</signatureVersion>
-
- <platform>forge.codelutin.com</platform>
- <projectId>wlo</projectId>
- <maven.test.skip>true</maven.test.skip>
- <!-- locales for the site generation, by default only french -->
- <locales>fr</locales>
-
- <!-- do not relatize links in generated site -->
- <relativizeDecorationLinks>false</relativizeDecorationLinks>
-
- <!-- license header configuration -->
- <license.organizationName>Ifremer</license.organizationName>
- <license.licenseName>gpl_v3</license.licenseName>
-
- <!-- Post Release configuration -->
- <skipPostRelease>false</skipPostRelease>
-
- <gsonVersion>2.2.4</gsonVersion>
- <sdkVersion>19.0.1</sdkVersion>
-
- </properties>
-
-
- <dependencies>
-
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android</artifactId>
- <version>4.1.1.4</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android-test</artifactId>
- <version>4.1.1.4</version>
- <scope>test</scope>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>support-v4</artifactId>-->
- <!--<version>19.0.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>/opt/android/extras/android/m2repository/com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar</systemPath>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>appcompat-v7</artifactId>-->
- <!--<version>19.0.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>/opt/android/extras/android/m2repository/com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.aar</systemPath>-->
- <!--</dependency>-->
-
- <dependency>
- <groupId>android.support</groupId>
- <artifactId>compatibility-v7-appcompat</artifactId>
- <version>${sdkVersion}</version>
- <type>apklib</type>
- </dependency>
-
- <dependency>
- <groupId>android.support</groupId>
- <artifactId>compatibility-v7-appcompat</artifactId>
- <version>${sdkVersion}</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>android.support</groupId>
- <artifactId>compatibility-v4</artifactId>
- <version>${sdkVersion}</version>
- </dependency>
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>support-v4</artifactId>-->
- <!--<version>18.0.0</version>-->
- <!--<scope>compile</scope>-->
- <!--</dependency>-->
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guavaVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>${gsonVersion}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.achartengine</groupId>
- <artifactId>achartengine</artifactId>
- <version>1.1.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-csv</artifactId>
- <version>3.0-alpha-1</version>
- <exclusions>
- <exclusion>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- </dependencies>
-
- <repositories>
- <repository>
- <id>wlo-group</id>
- <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- </repository>
-
- <!--<repository>-->
- <!--<id>android.support-mvn-repo</id>-->
- <!--<url>https://raw.github.com/kmchugh/android.support/mvn-repo</url>-->
- <!--<snapshots>-->
- <!--<enabled>true</enabled>-->
- <!--<updatePolicy>daily</updatePolicy>-->
- <!--</snapshots>-->
- <!--</repository>-->
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>wlo-group</id>
- <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- </pluginRepository>
- </pluginRepositories>
-
- <build>
- <sourceDirectory>src</sourceDirectory>
- <resources>
- <resource>
- <directory>res</directory>
- <filtering>false</filtering>
- </resource>
- </resources>
-
- <plugins>
-
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>android-maven-plugin</artifactId>
- <version>3.8.2</version>
- <executions>
- <execution>
- <id>alignApk</id>
- <phase>install</phase>
- <goals>
- <goal>zipalign</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <sdk>
- <path>/opt/android</path>
- <platform>15</platform>
- </sdk>
- <!--<deleteConflictingFiles>true</deleteConflictingFiles>-->
- <!--<device>emulator</device>-->
- <device>usb</device>
- <zipalign>
- <verbose>true</verbose>
- <skip>false</skip>
- <inputApk>
- ${project.build.directory}/${project.artifactId}-${project.version}.apk
- </inputApk>
- <outputApk>
- ${project.build.directory}/${project.artifactId}-${project.version}-aligned.apk
- </outputApk>
- </zipalign>
- <extractDuplicates>true</extractDuplicates>
- </configuration>
- <extensions>true</extensions>
- </plugin>
-
- <!-- plugin site -->
- <!--<plugin>-->
- <!--<artifactId>maven-site-plugin</artifactId>-->
- <!--<dependencies>-->
- <!--<dependency>-->
- <!--<groupId>org.nuiton.jrst</groupId>-->
- <!--<artifactId>doxia-module-jrst</artifactId>-->
- <!--<version>${jrstPluginVersion}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>hsqldb</groupId>-->
- <!--<artifactId>hsqldb</artifactId>-->
- <!--<version>${jdbc.hsqldb.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.hibernate</groupId>-->
- <!--<artifactId>hibernate-core</artifactId>-->
- <!--<version>${hibernateVersion}</version>-->
- <!--</dependency>-->
- <!--</dependencies>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<groupId>org.codehaus.mojo</groupId>-->
- <!--<artifactId>animal-sniffer-maven-plugin</artifactId>-->
- <!--<version>${animalSnifferPluginVersion}</version>-->
- <!--<configuration>-->
- <!--<signature>-->
- <!--<groupId>org.codehaus.mojo.signature</groupId>-->
- <!--<artifactId>java16-sun</artifactId>-->
- <!--<version>1.10</version>-->
- <!--</signature>-->
- <!--</configuration>-->
- <!--</plugin>-->
-
- </plugins>
-
- </build>
-
- <reporting>
- <excludeDefaults>true</excludeDefaults>
- </reporting>
-
- <profiles>
-
- <profile>
- <id>check-release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>check-release-properties</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <phase>initialize</phase>
- <configuration>
- <rules>
- <requireProperty>
- <property>dbVersion</property>
- <message>You must set a dbVersion property!</message>
- </requireProperty>
- </rules>
- <ignoreCache>true</ignoreCache>
- <failFast>true</failFast>
- <fail>true</fail>
-
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- </profile>
- <profile>
- <id>license-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <defaultGoal>generate-resources</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>update-file-header-on-pom</id>
- <goals>
- <goal>update-file-header</goal>
- </goals>
- <phase>generate-resources</phase>
- <configuration>
- <roots>
- <root>${project.basedir}</root>
- </roots>
- <includes>
- <include>pom.xml</include>
- </includes>
- <addSvnKeyWords>false</addSvnKeyWords>
- <verbose>false</verbose>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile>
- <id>deploy-update</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <build>
- <plugins>
- <!--<plugin>-->
- <!--<artifactId>maven-antrun-plugin</artifactId>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<id>copy update-properties to site</id>-->
- <!--<phase>package</phase>-->
- <!--<inherited>false</inherited>-->
- <!--<configuration>-->
- <!--<tasks>-->
- <!--<echo message="Copy model to site" />-->
- <!--<copy verbose="true" failonerror="false" overwrite="true" filtering="true" todir="${project.build.directory}/update">-->
- <!--<filterset>-->
- <!--<filter value="${project.version}" token="projectVersion" />-->
- <!--<filter value="${jreVersion}" token="jreVersion" />-->
- <!--<filter value="${dbVersion}" token="dbVersion" />-->
- <!--</filterset>-->
- <!--<fileset dir="${basedir}/src/update/">-->
- <!--<include name="update-tutti.properties" />-->
- <!--</fileset>-->
- <!--</copy>-->
- <!--</tasks>-->
- <!--</configuration>-->
- <!--<goals>-->
- <!--<goal>run</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<groupId>org.codehaus.mojo</groupId>-->
- <!--<artifactId>wagon-maven-plugin</artifactId>-->
- <!--<version>1.0-beta-4</version>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<phase>deploy</phase>-->
- <!--<inherited>false</inherited>-->
- <!--<goals>-->
- <!--<goal>upload-single</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<serverId>forge.codelutin.com</serverId>-->
- <!--<fromFile>-->
- <!--${project.build.directory}/update/update-tutti.properties-->
- <!--</fromFile>-->
- <!--<url>-->
- <!--scpexe://forge.codelutin.com/var/www/ApplicationUpdate/http/tutti-->
- <!--</url>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--</executions>-->
-
- <!--</plugin>-->
- </plugins>
- </build>
-
- </profile>
-
- <profile>
- <id>reporting</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <reporting>
- <plugins>
-
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <version>${projectInfoReportsPluginVersion}</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>project-team</report>
- <report>mailing-list</report>
- <report>cim</report>
- <report>issue-tracking</report>
- <report>license</report>
- <report>scm</report>
- <report>dependencies</report>
- <report>dependency-convergence</report>
- <report>dependency-info</report>
- <report>plugin-management</report>
- <report>plugins</report>
- <report>dependency-management</report>
- <report>summary</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
-
- <!--<plugin>-->
- <!--<groupId>org.nuiton</groupId>-->
- <!--<artifactId>nuiton-maven-report-plugin</artifactId>-->
- <!--<version>3.0-alpha-1</version>-->
- <!--<inherited>false</inherited>-->
- <!--<reportSets>-->
- <!--<reportSet>-->
- <!--<reports>-->
- <!--<report>aggregate-config-report</report>-->
- <!--</reports>-->
- <!--</reportSet>-->
- <!--</reportSets>-->
- <!--<configuration>-->
- <!--<i18nBundleName>tutti-i18n</i18nBundleName>-->
- <!--</configuration>-->
- <!--</plugin>-->
-
- </plugins>
- </reporting>
-
- </profile>
-
- <!-- This profile update license stuff with new goal update-file-header -->
- <profile>
- <id>update-file-header</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
-
- <properties>
- <license.descriptor>src/license/project.xml</license.descriptor>
- </properties>
- <build>
- <defaultGoal>process-resources</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>license-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>update-file-header</id>
- <goals>
- <goal>update-file-header</goal>
- </goals>
- <configuration>
- <addSvnKeyWords>true</addSvnKeyWords>
- <excludes>
- <exclude>**/i18n/*.properties</exclude>
- <exclude>**/THIRD-PARTY.properties</exclude>
- <!-- since sh scripts must begins by the line #!/bin/sh,
- can not use the mojo for the mojo -->
- <exclude>**/*.sh</exclude>
- </excludes>
- </configuration>
- <phase>process-resources</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- </profiles>
-
-</project>
Copied: tags/0.1/pom.xml (from rev 26, trunk/pom.xml)
===================================================================
--- tags/0.1/pom.xml (rev 0)
+++ tags/0.1/pom.xml 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,539 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ WLO
+ %%
+ Copyright (C) 2013 - 2014 Ifremer
+ %%
+ This program 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 3 of the
+ License, or (at your option) any later version.
+
+ This program 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, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>mavenpom4redmine</artifactId>
+ <version>4.5</version>
+ </parent>
+
+ <groupId>fr.ifremer</groupId>
+ <artifactId>wlo</artifactId>
+ <version>0.1</version>
+
+ <name>WLO</name>
+ <description>
+ Application pour les missions de recueil d'information sur les stockes pour l'observation en criée et en mer.
+ </description>
+ <inceptionYear>2013</inceptionYear>
+ <url>http://forge.codelutin.com/projects/wlo</url>
+
+ <licenses>
+ <license>
+ <name>General Public License (GPL)</name>
+ <url>http://www.gnu.org/licenses/gpl.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <developers>
+ <developer>
+ <id>chemit</id>
+ <name>Tony Chemit</name>
+ <email>chemit at codelutin dot com</email>
+ <organization>CodeLutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <roles>
+ <role>developer</role>
+ </roles>
+ <timezone>Europe/Paris</timezone>
+ </developer>
+ <developer>
+ <id>morin</id>
+ <name>Kevin Morin</name>
+ <email>morin at codelutin dot com</email>
+ <organization>CodeLutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <roles>
+ <role>developer</role>
+ </roles>
+ <timezone>Europe/Paris</timezone>
+ </developer>
+ </developers>
+
+ <scm>
+ <url>https://forge.codelutin.com/svn/wlo/trunk</url>
+ <connection>
+ scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.forge.codelutin.com/svn/wlo/trunk
+ </developerConnection>
+ </scm>
+ <distributionManagement>
+ <site>
+ <id>${platform}</id>
+ <url>${our.site.repository}/${projectId}</url>
+ </site>
+ </distributionManagement>
+
+ <packaging>apk</packaging>
+
+ <properties>
+
+ <!-- Java version -->
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
+ <signatureArtifactId>java17</signatureArtifactId>
+ <signatureVersion>1.0</signatureVersion>
+
+ <platform>forge.codelutin.com</platform>
+ <projectId>wlo</projectId>
+ <maven.test.skip>true</maven.test.skip>
+ <!-- locales for the site generation, by default only french -->
+ <locales>fr</locales>
+
+ <!-- do not relatize links in generated site -->
+ <relativizeDecorationLinks>false</relativizeDecorationLinks>
+
+ <!-- license header configuration -->
+ <license.organizationName>Ifremer</license.organizationName>
+ <license.licenseName>gpl_v3</license.licenseName>
+
+ <!-- Post Release configuration -->
+ <skipPostRelease>false</skipPostRelease>
+
+ <gsonVersion>2.2.4</gsonVersion>
+ <sdkVersion>19.0.1</sdkVersion>
+
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android</artifactId>
+ <version>4.1.1.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android-test</artifactId>
+ <version>4.1.1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>android.support</groupId>
+ <artifactId>compatibility-v7-appcompat</artifactId>
+ <version>${sdkVersion}</version>
+ <type>apklib</type>
+ </dependency>
+
+ <dependency>
+ <groupId>android.support</groupId>
+ <artifactId>compatibility-v7-appcompat</artifactId>
+ <version>${sdkVersion}</version>
+ <type>jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>android.support</groupId>
+ <artifactId>compatibility-v4</artifactId>
+ <version>${sdkVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guavaVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gsonVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.achartengine</groupId>
+ <artifactId>achartengine</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ <version>3.0-alpha-1</version>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>wlo-group</id>
+ <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ </repository>
+
+ <!--<repository>-->
+ <!--<id>android.support-mvn-repo</id>-->
+ <!--<url>https://raw.github.com/kmchugh/android.support/mvn-repo</url>-->
+ <!--<snapshots>-->
+ <!--<enabled>true</enabled>-->
+ <!--<updatePolicy>daily</updatePolicy>-->
+ <!--</snapshots>-->
+ <!--</repository>-->
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>wlo-group</id>
+ <url>http://nexus.nuiton.org/nexus/content/groups/wlo-group/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>res</directory>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
+ <artifactId>android-maven-plugin</artifactId>
+ <version>3.8.2</version>
+ <executions>
+ <execution>
+ <id>alignApk</id>
+ <phase>install</phase>
+ <goals>
+ <goal>zipalign</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <sdk>
+ <path>${env.ANDROID_HOME}</path>
+ <platform>15</platform>
+ </sdk>
+ <!--<device>emulator</device>-->
+ <device>usb</device>
+ <zipalign>
+ <verbose>true</verbose>
+ <skip>false</skip>
+ <inputApk>
+ ${project.build.directory}/${project.artifactId}-${project.version}.apk
+ </inputApk>
+ <outputApk>
+ ${project.build.directory}/${project.artifactId}-${project.version}-aligned.apk
+ </outputApk>
+ </zipalign>
+ <extractDuplicates>true</extractDuplicates>
+ </configuration>
+ <extensions>true</extensions>
+ </plugin>
+
+ <!-- plugin site -->
+ <!--<plugin>-->
+ <!--<artifactId>maven-site-plugin</artifactId>-->
+ <!--<dependencies>-->
+ <!--<dependency>-->
+ <!--<groupId>org.nuiton.jrst</groupId>-->
+ <!--<artifactId>doxia-module-jrst</artifactId>-->
+ <!--<version>${jrstPluginVersion}</version>-->
+ <!--</dependency>-->
+ <!--<dependency>-->
+ <!--<groupId>hsqldb</groupId>-->
+ <!--<artifactId>hsqldb</artifactId>-->
+ <!--<version>${jdbc.hsqldb.version}</version>-->
+ <!--</dependency>-->
+ <!--<dependency>-->
+ <!--<groupId>org.hibernate</groupId>-->
+ <!--<artifactId>hibernate-core</artifactId>-->
+ <!--<version>${hibernateVersion}</version>-->
+ <!--</dependency>-->
+ <!--</dependencies>-->
+ <!--</plugin>-->
+
+ <!--<plugin>-->
+ <!--<groupId>org.codehaus.mojo</groupId>-->
+ <!--<artifactId>animal-sniffer-maven-plugin</artifactId>-->
+ <!--<version>${animalSnifferPluginVersion}</version>-->
+ <!--<configuration>-->
+ <!--<signature>-->
+ <!--<groupId>org.codehaus.mojo.signature</groupId>-->
+ <!--<artifactId>java16-sun</artifactId>-->
+ <!--<version>1.10</version>-->
+ <!--</signature>-->
+ <!--</configuration>-->
+ <!--</plugin>-->
+
+ </plugins>
+
+ </build>
+
+ <reporting>
+ <excludeDefaults>true</excludeDefaults>
+ </reporting>
+
+ <profiles>
+
+ <profile>
+ <id>check-release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ </profile>
+ <profile>
+ <id>license-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <defaultGoal>generate-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-file-header-on-pom</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <roots>
+ <root>${project.basedir}</root>
+ </roots>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ <addSvnKeyWords>false</addSvnKeyWords>
+ <verbose>false</verbose>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>deploy-update</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+ <!--<plugin>-->
+ <!--<artifactId>maven-antrun-plugin</artifactId>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<id>copy update-properties to site</id>-->
+ <!--<phase>package</phase>-->
+ <!--<inherited>false</inherited>-->
+ <!--<configuration>-->
+ <!--<tasks>-->
+ <!--<echo message="Copy model to site" />-->
+ <!--<copy verbose="true" failonerror="false" overwrite="true" filtering="true" todir="${project.build.directory}/update">-->
+ <!--<filterset>-->
+ <!--<filter value="${project.version}" token="projectVersion" />-->
+ <!--<filter value="${jreVersion}" token="jreVersion" />-->
+ <!--<filter value="${dbVersion}" token="dbVersion" />-->
+ <!--</filterset>-->
+ <!--<fileset dir="${basedir}/src/update/">-->
+ <!--<include name="update-tutti.properties" />-->
+ <!--</fileset>-->
+ <!--</copy>-->
+ <!--</tasks>-->
+ <!--</configuration>-->
+ <!--<goals>-->
+ <!--<goal>run</goal>-->
+ <!--</goals>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--</plugin>-->
+
+ <!--<plugin>-->
+ <!--<groupId>org.codehaus.mojo</groupId>-->
+ <!--<artifactId>wagon-maven-plugin</artifactId>-->
+ <!--<version>1.0-beta-4</version>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<phase>deploy</phase>-->
+ <!--<inherited>false</inherited>-->
+ <!--<goals>-->
+ <!--<goal>upload-single</goal>-->
+ <!--</goals>-->
+ <!--<configuration>-->
+ <!--<serverId>forge.codelutin.com</serverId>-->
+ <!--<fromFile>-->
+ <!--${project.build.directory}/update/update-tutti.properties-->
+ <!--</fromFile>-->
+ <!--<url>-->
+ <!--scpexe://forge.codelutin.com/var/www/ApplicationUpdate/http/tutti-->
+ <!--</url>-->
+ <!--</configuration>-->
+ <!--</execution>-->
+ <!--</executions>-->
+
+ <!--</plugin>-->
+ </plugins>
+ </build>
+
+ </profile>
+
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>${projectInfoReportsPluginVersion}</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>project-team</report>
+ <report>mailing-list</report>
+ <report>cim</report>
+ <report>issue-tracking</report>
+ <report>license</report>
+ <report>scm</report>
+ <report>dependencies</report>
+ <report>dependency-convergence</report>
+ <report>dependency-info</report>
+ <report>plugin-management</report>
+ <report>plugins</report>
+ <report>dependency-management</report>
+ <report>summary</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <!--<plugin>-->
+ <!--<groupId>org.nuiton</groupId>-->
+ <!--<artifactId>nuiton-maven-report-plugin</artifactId>-->
+ <!--<version>3.0-alpha-1</version>-->
+ <!--<inherited>false</inherited>-->
+ <!--<reportSets>-->
+ <!--<reportSet>-->
+ <!--<reports>-->
+ <!--<report>aggregate-config-report</report>-->
+ <!--</reports>-->
+ <!--</reportSet>-->
+ <!--</reportSets>-->
+ <!--<configuration>-->
+ <!--<i18nBundleName>tutti-i18n</i18nBundleName>-->
+ <!--</configuration>-->
+ <!--</plugin>-->
+
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ <!-- This profile update license stuff with new goal update-file-header -->
+ <profile>
+ <id>update-file-header</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <properties>
+ <license.descriptor>src/license/project.xml</license.descriptor>
+ </properties>
+ <build>
+ <defaultGoal>process-resources</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-file-header</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <configuration>
+ <addSvnKeyWords>true</addSvnKeyWords>
+ <excludes>
+ <exclude>**/i18n/*.properties</exclude>
+ <exclude>**/THIRD-PARTY.properties</exclude>
+ <!-- since sh scripts must begins by the line #!/bin/sh,
+ can not use the mojo for the mojo -->
+ <exclude>**/*.sh</exclude>
+ </excludes>
+ </configuration>
+ <phase>process-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Deleted: tags/0.1/res/layout/measurement.xml
===================================================================
--- trunk/res/layout/measurement.xml 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/res/layout/measurement.xml 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,143 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<android.support.v4.widget.DrawerLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/drawer_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout android:id="@+id/form"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <TextView android:text="@string/gender"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:paddingLeft="10dp"
- android:paddingRight="5dp"/>
-
- <Spinner android:id="@+id/gender_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
- <TextView android:text="@string/maturity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:paddingLeft="10dp"
- android:paddingRight="5dp"/>
-
- <Spinner android:id="@+id/maturity_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
- <TextView android:text="@string/age"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingTop="10dp"
- android:paddingLeft="10dp"
- android:paddingRight="5dp"/>
-
- <Spinner android:id="@+id/age_spinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"/>
-
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button android:text="-"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="decSize"/>
-
- <EditText android:id="@+id/size"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:inputType="number"/>
-
- <Button android:text="+"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="incSize"/>
-
- </LinearLayout>
-
- <Button android:text="@android:string/ok"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:onClick="addMeasurement"/>
-
- </LinearLayout>
-
- <View android:layout_width="1px"
- android:layout_height="match_parent"
- android:background="@android:color/holo_blue_light"/>
-
- <TabHost android:id="@android:id/tabhost"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:layout_height="match_parent">
-
- <LinearLayout android:id="@+id/fragment_placeholder"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <TabWidget android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-
- <View android:layout_width="match_parent"
- android:layout_height="2px"
- android:background="@android:color/holo_blue_light"/>
-
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <fragment android:name="fr.ifremer.wlo.measurement.GraphFragment"
- android:id="@+id/graph"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <fragment android:name="fr.ifremer.wlo.measurement.TableFragment"
- android:id="@+id/table"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <fragment android:name="fr.ifremer.wlo.measurement.LogsFragment"
- android:id="@+id/logs"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-
- </FrameLayout>
-
- </LinearLayout>
-
- </TabHost>
-
- </LinearLayout>
-
- <ListView android:id="@+id/left_drawer"
- android:layout_width="240dp"
- android:layout_height="match_parent"
- android:layout_gravity="start"
- android:choiceMode="singleChoice"
- android:background="@android:color/holo_blue_dark"/>
-
-</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
Copied: tags/0.1/res/layout/measurement.xml (from rev 24, trunk/res/layout/measurement.xml)
===================================================================
--- tags/0.1/res/layout/measurement.xml (rev 0)
+++ tags/0.1/res/layout/measurement.xml 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<android.support.v4.widget.DrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout android:id="@+id/form"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView android:text="@string/gender"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp"/>
+
+ <Spinner android:id="@+id/gender_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <TextView android:text="@string/maturity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp"/>
+
+ <Spinner android:id="@+id/maturity_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <TextView android:text="@string/age"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp"/>
+
+ <Spinner android:id="@+id/age_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button android:text="-"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="decSize"/>
+
+ <EditText android:id="@+id/size"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <Button android:text="+"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:onClick="incSize"/>
+
+ </LinearLayout>
+
+ <Button android:text="@android:string/ok"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="addMeasurement"/>
+
+ </LinearLayout>
+
+ <View android:layout_width="1px"
+ android:layout_height="match_parent"
+ android:background="@android:color/holo_blue_light"/>
+
+ <TabHost android:id="@android:id/tabhost"
+ android:layout_weight="1"
+ android:layout_width="0dp"
+ android:layout_height="match_parent">
+
+ <LinearLayout android:id="@+id/fragment_placeholder"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TabWidget android:id="@android:id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <View android:layout_width="match_parent"
+ android:layout_height="2px"
+ android:background="@android:color/holo_blue_light"/>
+
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_weight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <fragment android:name="fr.ifremer.wlo.measurement.GraphFragment"
+ android:id="@+id/graph"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <fragment android:name="fr.ifremer.wlo.measurement.TableFragment"
+ android:id="@+id/table"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <fragment android:name="fr.ifremer.wlo.measurement.LogsFragment"
+ android:id="@+id/logs"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+ </FrameLayout>
+
+ </LinearLayout>
+
+ </TabHost>
+
+ </LinearLayout>
+
+ <ListView android:id="@+id/left_drawer"
+ android:layout_width="240dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:choiceMode="singleChoice"
+ android:background="@android:color/holo_blue_dark"/>
+
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java
===================================================================
--- trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,606 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package fr.ifremer.wlo;
-
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothServerSocket;
-import android.bluetooth.BluetoothSocket;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.TaskStackBuilder;
-import android.util.Log;
-import com.google.common.collect.Lists;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * This class does all the work for setting up and managing Bluetooth
- * connections with other devices. It has a thread that listens for
- * incoming connections, a thread for connecting with a device, and a
- * thread for performing data transmissions when connected.
- */
-public class BigFinCommunicationService extends Service {
-
- private static final String TAG = "BigFinCommunicationService";
-
- // Unique UUID for this application
- private static final UUID MY_UUID =
- UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
- private static final int NOIFICATION_ID = 42;
-
- // Constants that indicate the current connection state
- public static final int STATE_NONE = 0; // we're doing nothing
- public static final int STATE_LISTEN = 1; // now listening for incoming connections
- public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
- public static final int STATE_CONNECTED = 3; // now connected to a remote device
-
- // OUTGOING MESSAGE
- public static final int MESSAGE_STATE_CHANGE = 1;
- public static final int MESSAGE_READ = 2;
- public static final int MESSAGE_WRITE = 3;
- public static final int MESSAGE_DEVICE_NAME = 4;
- public static final int MESSAGE_CONNECTION_LOST = 5;
- public static final int MESSAGE_CONNECTION_FAILED = 6;
-
- // INCOMING MESSAGE
- public static final int MESSAGE_REGISTER_CLIENT = 1;
- public static final int MESSAGE_UNREGISTER_CLIENT = 2;
- public static final int MESSAGE_CONNECT_DEVICE = 3;
- public static final int MESSAGE_SEND_DATA = 4;
- public static final int MESSAGE_DISCONNECT_DEVICE = 5;
-
- public static final String DEVICE_NAME = "device_name";
- public static final String TOAST = "toast";
- public static final String DEVICE_ADDRESS = "device_address";
- public static final String DATA_TO_SEND = "dataToSend";
-
- // Member fields
- protected BluetoothAdapter mAdapter;
- protected AcceptThread mAcceptThread;
- protected ConnectThread mConnectThread;
- protected ConnectedThread mConnectedThread;
- protected int mState;
-
- // Keeps track of all current registered clients.
- protected List<Messenger> mClients = Lists.newArrayList();
- // Target we publish for clients to send messages to IncomingHandler.
- protected final Messenger mMessenger = new Messenger(new IncomingHandler());
-
- protected NotificationCompat.Builder notificationBuilder;
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- mAdapter = BluetoothAdapter.getDefaultAdapter();
-
- setState(STATE_NONE);
-
- notificationBuilder = new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.wlo_ico);
-
- updateNotification(false);
-
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify(NOIFICATION_ID, notificationBuilder.build());
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- stop();
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.cancel(NOIFICATION_ID);
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- return mMessenger.getBinder();
- }
-
- protected void updateNotification(boolean connected) {
- int title;
- int text;
-
-// TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
-// // Adds the Intent to the top of the stack
-// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
-
- if (connected) {
- title = R.string.bigfin_ichtyometer_connected_title;
- text = R.string.bigfin_ichtyometer_connected_text;
-
- } else {
- title = R.string.bigfin_no_ichtyometer_connected_title;
- text = R.string.bigfin_no_ichtyometer_connected_text;
-// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
- }
-
- // Gets a PendingIntent containing the entire back stack
-// PendingIntent pendingIntent =
-// stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
-
-// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
-
- notificationBuilder.setContentTitle(getText(title))
- .setContentText(getText(text));
-// .setContentIntent(pendingIntent);
-
- if (connected) {
- startForeground(NOIFICATION_ID, notificationBuilder.build());
- } else {
- stopForeground(false);
- }
- }
-
- protected void sendMessage(int what, int arg1) {
- sendMessage(what, arg1, -1, null);
- }
-
- protected void sendMessage(int what, int arg1, int arg2) {
- sendMessage(what, arg1, arg2, null);
- }
-
- protected void sendMessage(int what, int arg1, int arg2, Object obj) {
- for (Messenger messenger : mClients) {
- try {
- Message message = Message.obtain(null, what, arg1, arg2, obj);
- messenger.send(message);
-
- } catch (RemoteException e) {
- mClients.remove(messenger);
- }
- }
- }
-
- protected void sendMessage(int what, String key, String value) {
- for (Messenger messenger : mClients) {
- try {
- Message message = Message.obtain(null, what);
- Bundle bundle = new Bundle();
- bundle.putString(key, value);
- message.setData(bundle);
- messenger.send(message);
-
- } catch (RemoteException e) {
- mClients.remove(messenger);
- }
- }
- }
-
- /**
- * Set the current state of the chat connection
- * @param state An integer defining the current connection state
- */
- protected synchronized void setState(int state) {
- Log.d(TAG, "setState() " + mState + " -> " + state);
- mState = state;
- sendMessage(MESSAGE_STATE_CHANGE, state);
- }
-
- /**
- * Stop all threads
- */
- protected synchronized void stop() {
- Log.d(TAG, "stop");
-
- if (mConnectThread != null) {
- mConnectThread.cancel();
- mConnectThread = null;
- }
-
- if (mConnectedThread != null) {
- mConnectedThread.cancel();
- mConnectedThread = null;
- }
-
- if (mAcceptThread != null) {
- mAcceptThread.cancel();
- mAcceptThread = null;
- }
-
- setState(STATE_NONE);
-
- notificationBuilder.setContentTitle(getText(R.string.bigfin_no_ichtyometer_connected_title))
- .setContentText(getText(R.string.bigfin_no_ichtyometer_connected_text));
- NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- manager.notify(NOIFICATION_ID, notificationBuilder.build());
-
- }
-
- protected synchronized void reset() {
- Log.d(TAG, "reset");
-
- stop();
-
- setState(STATE_LISTEN);
-
- // Start the thread to listen on a BluetoothServerSocket
- mAcceptThread = new AcceptThread();
- mAcceptThread.start();
- }
-
- /**
- * Start the ConnectThread to initiate a connection to a remote device.
- * @param device The BluetoothDevice to connect
- */
- protected synchronized void connect(BluetoothDevice device) {
- Log.d(TAG, "connect to: " + device);
-
- // Cancel any thread attempting to make a connection
- if (mState == STATE_CONNECTING) {
- if (mConnectThread != null) {
- mConnectThread.cancel();
- mConnectThread = null;
- }
- }
-
- // Cancel any thread currently running a connection
- if (mConnectedThread != null) {
- mConnectedThread.cancel();
- mConnectedThread = null;
- }
-
- // Start the thread to connect with the given device
- mConnectThread = new ConnectThread(device);
- mConnectThread.start();
- setState(STATE_CONNECTING);
- }
-
- /**
- * Start the ConnectedThread to begin managing a Bluetooth connection
- * @param socket The BluetoothSocket on which the connection was made
- * @param device The BluetoothDevice that has been connected
- */
- protected synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
- Log.d(TAG, "connected");
-
- // Cancel the thread that completed the connection
- if (mConnectThread != null) {
- mConnectThread.cancel();
- mConnectThread = null;
- }
-
- // Cancel any thread currently running a connection
- if (mConnectedThread != null) {
- mConnectedThread.cancel();
- mConnectedThread = null;
- }
-
- // Cancel the accept thread because we only want to connect to one device
- if (mAcceptThread != null) {
- mAcceptThread.cancel();
- mAcceptThread = null;
- }
-
- // Start the thread to manage the connection and perform transmissions
- mConnectedThread = new ConnectedThread(socket);
- mConnectedThread.start();
-
- // Send the name of the connected device back to the UI Activity
- sendMessage(MESSAGE_DEVICE_NAME, DEVICE_NAME, device.getName());
-
- setState(STATE_CONNECTED);
-
- updateNotification(true);
-
- }
-
- /**
- * Write to the ConnectedThread in an unsynchronized manner
- * @param out The bytes to write
- * @see ConnectedThread#write(byte[])
- */
- protected void write(byte[] out) {
- // Create temporary object
- ConnectedThread r;
- // Synchronize a copy of the ConnectedThread
- synchronized (this) {
- if (mState != STATE_CONNECTED) return;
- r = mConnectedThread;
- }
- // Perform the write unsynchronized
- r.write(out);
- }
-
- /**
- * Indicate that the connection attempt failed and notify the UI Activity.
- */
- protected void connectionFailed() {
- // Send a failure message back to the Activity
- sendMessage(MESSAGE_CONNECTION_FAILED, TOAST, "Unable to connect device");
-
- // Start the service over to restart listening mode
- reset();
- }
-
- /**
- * Indicate that the connection was lost and notify the UI Activity.
- */
- protected void connectionLost() {
- // Send a failure message back to the Activity
- sendMessage(MESSAGE_CONNECTION_LOST, TOAST, "Device connection was lost");
-
- // Start the service over to restart listening mode
- reset();
- }
-
- /**
- * This thread runs while listening for incoming connections. It behaves
- * like a server-side client. It runs until a connection is accepted
- * (or until cancelled).
- */
- protected class AcceptThread extends Thread {
- // The local server socket
- private final BluetoothServerSocket mmServerSocket;
-
- public AcceptThread() {
- BluetoothServerSocket tmp = null;
-
- // Create a new listening server socket
- try {
- tmp = mAdapter.listenUsingRfcommWithServiceRecord("BigFinBtSocket", MY_UUID);
-
- } catch (IOException e) {
- Log.e(TAG, "Socket listen() failed", e);
- }
- mmServerSocket = tmp;
- }
-
- public void run() {
- Log.d(TAG, "BEGIN mAcceptThread" + this);
- setName("AcceptThread");
-
- BluetoothSocket socket = null;
-
- // Listen to the server socket if we're not connected
- while (mState != STATE_CONNECTED) {
- try {
- // This is a blocking call and will only return on a
- // successful connection or an exception
- socket = mmServerSocket.accept();
- } catch (IOException e) {
- Log.e(TAG, "Socket accept() failed", e);
- break;
- }
-
- // If a connection was accepted
- if (socket != null) {
- synchronized (BigFinCommunicationService.this) {
- switch (mState) {
- case STATE_LISTEN:
- case STATE_CONNECTING:
- // Situation normal. Start the connected thread.
- connected(socket, socket.getRemoteDevice());
- break;
- case STATE_NONE:
- case STATE_CONNECTED:
- // Either not ready or already connected. Terminate new socket.
- try {
- socket.close();
- } catch (IOException e) {
- Log.e(TAG, "Could not close unwanted socket", e);
- }
- break;
- }
- }
- }
- }
- Log.i(TAG, "END mAcceptThread");
-
- }
-
- public void cancel() {
- Log.d(TAG, "Socket cancel " + this);
- try {
- mmServerSocket.close();
- } catch (IOException e) {
- Log.e(TAG, "Socket close() of server failed", e);
- }
- }
- }
-
-
- /**
- * This thread runs while attempting to make an outgoing connection
- * with a device. It runs straight through; the connection either
- * succeeds or fails.
- */
- protected class ConnectThread extends Thread {
- protected final BluetoothSocket mmSocket;
- protected final BluetoothDevice mmDevice;
-
- public ConnectThread(BluetoothDevice device) {
- mmDevice = device;
- BluetoothSocket tmp = null;
-
- // Get a BluetoothSocket for a connection with the
- // given BluetoothDevice
- try {
- tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
- } catch (IOException e) {
- Log.e(TAG, "Socket create() failed", e);
- }
- mmSocket = tmp;
- }
-
- public void run() {
- Log.i(TAG, "BEGIN mConnectThread");
- setName("ConnectThread");
-
- // Make a connection to the BluetoothSocket
- try {
- // This is a blocking call and will only return on a
- // successful connection or an exception
- mmSocket.connect();
-
- } catch (IOException e) {
- Log.e(TAG, "Error while connecting", e);
- // Close the socket
- try {
- mmSocket.close();
- } catch (IOException e2) {
- Log.e(TAG, "unable to close() socket during connection failure", e2);
- }
- connectionFailed();
- return;
- }
-
- // Reset the ConnectThread because we're done
- synchronized (BigFinCommunicationService.this) {
- mConnectThread = null;
- }
-
- // Start the connected thread
- connected(mmSocket, mmDevice);
- }
-
- public void cancel() {
- try {
- mmSocket.close();
- } catch (IOException e) {
- Log.e(TAG, "close() of connect socket failed", e);
- }
- }
- }
-
- /**
- * This thread runs during a connection with a remote device.
- * It handles all incoming and outgoing transmissions.
- */
- protected class ConnectedThread extends Thread {
- protected final BluetoothSocket mmSocket;
- protected final InputStream mmInStream;
- protected final OutputStream mmOutStream;
-
- public ConnectedThread(BluetoothSocket socket) {
- Log.d(TAG, "create ConnectedThread");
- mmSocket = socket;
- InputStream tmpIn = null;
- OutputStream tmpOut = null;
-
- // Get the BluetoothSocket input and output streams
- try {
- tmpIn = socket.getInputStream();
- tmpOut = socket.getOutputStream();
- } catch (IOException e) {
- Log.e(TAG, "temp sockets not created", e);
- }
-
- mmInStream = tmpIn;
- mmOutStream = tmpOut;
- }
-
- public void run() {
- Log.i(TAG, "BEGIN mConnectedThread");
- byte[] buffer = new byte[1024];
- int bytes;
-
- // Keep listening to the InputStream while connected
- while (true) {
- try {
- // Read from the InputStream
- bytes = mmInStream.read(buffer);
-
- // Send the obtained bytes to the UI Activity
- sendMessage(MESSAGE_READ, bytes, -1, buffer);
-
- } catch (IOException e) {
- Log.e(TAG, "disconnected", e);
- connectionLost();
- break;
- }
- }
- }
-
- /**
- * Write to the connected OutStream.
- * @param buffer The bytes to write
- */
- public void write(byte[] buffer) {
- try {
- mmOutStream.write(buffer);
-
- // Share the sent message back to the UI Activity
- sendMessage(MESSAGE_WRITE, -1, -1, buffer);
-
- } catch (IOException e) {
- Log.e(TAG, "Exception during write", e);
- }
- }
-
- public void cancel() {
- try {
- mmSocket.close();
- } catch (IOException e) {
- Log.e(TAG, "close() of connect socket failed", e);
- }
- }
- }
-
- // Handler of incoming messages from clients.
- protected class IncomingHandler extends Handler {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MESSAGE_REGISTER_CLIENT:
- mClients.add(msg.replyTo);
- break;
-
- case MESSAGE_UNREGISTER_CLIENT:
- mClients.remove(msg.replyTo);
- break;
-
- case MESSAGE_CONNECT_DEVICE:
- reset();
-
- String deviceAddress = msg.getData().getString(DEVICE_ADDRESS);
- Log.d(TAG, "connect device " + deviceAddress);
- // Get the BluetoothDevice object
- BluetoothDevice device = mAdapter.getRemoteDevice(deviceAddress);
- connect(device);
- break;
-
- case MESSAGE_SEND_DATA:
- String dataToSend = msg.getData().getString(DATA_TO_SEND);
- write(dataToSend.getBytes());
- break;
-
- case MESSAGE_DISCONNECT_DEVICE:
- stop();
- break;
-
- default:
- super.handleMessage(msg);
- }
- }
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java (from rev 25, trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,630 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothServerSocket;
+import android.bluetooth.BluetoothSocket;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.support.v4.app.NotificationCompat;
+import android.support.v4.app.TaskStackBuilder;
+import android.util.Log;
+import com.google.common.collect.Lists;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * This class does all the work for setting up and managing Bluetooth
+ * connections with other devices. It has a thread that listens for
+ * incoming connections, a thread for connecting with a device, and a
+ * thread for performing data transmissions when connected.
+ */
+public class BigFinCommunicationService extends Service {
+
+ private static final String TAG = "BigFinCommunicationService";
+
+ // Unique UUID for this application
+ private static final UUID MY_UUID =
+ UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
+ private static final int NOIFICATION_ID = 42;
+
+ // Constants that indicate the current connection state
+ public static final int STATE_NONE = 0; // we're doing nothing
+ public static final int STATE_LISTEN = 1; // now listening for incoming connections
+ public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
+ public static final int STATE_CONNECTED = 3; // now connected to a remote device
+
+ // OUTGOING MESSAGE
+ public static final int MESSAGE_STATE_CHANGE = 1;
+ public static final int MESSAGE_READ = 2;
+ public static final int MESSAGE_WRITE = 3;
+ public static final int MESSAGE_DEVICE_NAME = 4;
+ public static final int MESSAGE_CONNECTION_LOST = 5;
+ public static final int MESSAGE_CONNECTION_FAILED = 6;
+
+ // INCOMING MESSAGE
+ public static final int MESSAGE_REGISTER_CLIENT = 1;
+ public static final int MESSAGE_UNREGISTER_CLIENT = 2;
+ public static final int MESSAGE_CONNECT_DEVICE = 3;
+ public static final int MESSAGE_SEND_DATA = 4;
+ public static final int MESSAGE_DISCONNECT_DEVICE = 5;
+
+ public static final String DEVICE_NAME = "device_name";
+ public static final String TOAST = "toast";
+ public static final String DEVICE_ADDRESS = "device_address";
+ public static final String DATA_TO_SEND = "dataToSend";
+
+ // Member fields
+ protected BluetoothAdapter mAdapter;
+ protected AcceptThread mAcceptThread;
+ protected ConnectThread mConnectThread;
+ protected ConnectedThread mConnectedThread;
+ protected int mState;
+
+ // Keeps track of all current registered clients.
+ protected List<Messenger> mClients = Lists.newArrayList();
+ // Target we publish for clients to send messages to IncomingHandler.
+ protected final Messenger mMessenger = new Messenger(new IncomingHandler());
+
+ protected NotificationCompat.Builder notificationBuilder;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ mAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ setState(STATE_NONE);
+
+ notificationBuilder = new NotificationCompat.Builder(this)
+ .setSmallIcon(R.drawable.wlo_ico);
+
+ updateNotification(false);
+
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ manager.notify(NOIFICATION_ID, notificationBuilder.build());
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ stop();
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ manager.cancel(NOIFICATION_ID);
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mMessenger.getBinder();
+ }
+
+ protected void updateNotification(boolean connected) {
+ int title;
+ int text;
+
+// TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
+// // Adds the Intent to the top of the stack
+// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
+
+ if (connected) {
+ title = R.string.bigfin_ichtyometer_connected_title;
+ text = R.string.bigfin_ichtyometer_connected_text;
+
+ } else {
+ title = R.string.bigfin_no_ichtyometer_connected_title;
+ text = R.string.bigfin_no_ichtyometer_connected_text;
+// stackBuilder.addNextIntent(new Intent(this, MainActivity.class));
+ }
+
+ // Gets a PendingIntent containing the entire back stack
+// PendingIntent pendingIntent =
+// stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
+
+// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ notificationBuilder.setContentTitle(getText(title))
+ .setContentText(getText(text));
+// .setContentIntent(pendingIntent);
+
+ if (connected) {
+ startForeground(NOIFICATION_ID, notificationBuilder.build());
+ } else {
+ stopForeground(false);
+ }
+ }
+
+ protected void sendMessage(int what, int arg1) {
+ sendMessage(what, arg1, -1, null);
+ }
+
+ protected void sendMessage(int what, int arg1, int arg2) {
+ sendMessage(what, arg1, arg2, null);
+ }
+
+ protected void sendMessage(int what, int arg1, int arg2, Object obj) {
+ for (Messenger messenger : mClients) {
+ try {
+ Message message = Message.obtain(null, what, arg1, arg2, obj);
+ messenger.send(message);
+
+ } catch (RemoteException e) {
+ mClients.remove(messenger);
+ }
+ }
+ }
+
+ protected void sendMessage(int what, String key, String value) {
+ for (Messenger messenger : mClients) {
+ try {
+ Message message = Message.obtain(null, what);
+ Bundle bundle = new Bundle();
+ bundle.putString(key, value);
+ message.setData(bundle);
+ messenger.send(message);
+
+ } catch (RemoteException e) {
+ mClients.remove(messenger);
+ }
+ }
+ }
+
+ /**
+ * Set the current state of the chat connection
+ * @param state An integer defining the current connection state
+ */
+ protected synchronized void setState(int state) {
+ Log.d(TAG, "setState() " + mState + " -> " + state);
+ mState = state;
+ sendMessage(MESSAGE_STATE_CHANGE, state);
+ }
+
+ /**
+ * Stop all threads
+ */
+ protected synchronized void stop() {
+ Log.d(TAG, "stop");
+
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
+ }
+
+ if (mConnectedThread != null) {
+ mConnectedThread.cancel();
+ mConnectedThread = null;
+ }
+
+ if (mAcceptThread != null) {
+ mAcceptThread.cancel();
+ mAcceptThread = null;
+ }
+
+ setState(STATE_NONE);
+
+ notificationBuilder.setContentTitle(getText(R.string.bigfin_no_ichtyometer_connected_title))
+ .setContentText(getText(R.string.bigfin_no_ichtyometer_connected_text));
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ manager.notify(NOIFICATION_ID, notificationBuilder.build());
+
+ }
+
+ protected synchronized void reset() {
+ Log.d(TAG, "reset");
+
+ stop();
+
+ setState(STATE_LISTEN);
+
+ // Start the thread to listen on a BluetoothServerSocket
+ mAcceptThread = new AcceptThread();
+ mAcceptThread.start();
+ }
+
+ /**
+ * Start the ConnectThread to initiate a connection to a remote device.
+ * @param device The BluetoothDevice to connect
+ */
+ protected synchronized void connect(BluetoothDevice device) {
+ Log.d(TAG, "connect to: " + device);
+
+ // Cancel any thread attempting to make a connection
+ if (mState == STATE_CONNECTING) {
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
+ }
+ }
+
+ // Cancel any thread currently running a connection
+ if (mConnectedThread != null) {
+ mConnectedThread.cancel();
+ mConnectedThread = null;
+ }
+
+ // Start the thread to connect with the given device
+ mConnectThread = new ConnectThread(device);
+ mConnectThread.start();
+ setState(STATE_CONNECTING);
+ }
+
+ /**
+ * Start the ConnectedThread to begin managing a Bluetooth connection
+ * @param socket The BluetoothSocket on which the connection was made
+ * @param device The BluetoothDevice that has been connected
+ */
+ protected synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
+ Log.d(TAG, "connected");
+
+ // Cancel the thread that completed the connection
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
+ }
+
+ // Cancel any thread currently running a connection
+ if (mConnectedThread != null) {
+ mConnectedThread.cancel();
+ mConnectedThread = null;
+ }
+
+ // Cancel the accept thread because we only want to connect to one device
+ if (mAcceptThread != null) {
+ mAcceptThread.cancel();
+ mAcceptThread = null;
+ }
+
+ // Start the thread to manage the connection and perform transmissions
+ mConnectedThread = new ConnectedThread(socket);
+ mConnectedThread.start();
+
+ // Send the name of the connected device back to the UI Activity
+ sendMessage(MESSAGE_DEVICE_NAME, DEVICE_NAME, device.getName());
+
+ setState(STATE_CONNECTED);
+
+ updateNotification(true);
+
+ }
+
+ /**
+ * Write to the ConnectedThread in an unsynchronized manner
+ * @param out The bytes to write
+ * @see ConnectedThread#write(byte[])
+ */
+ protected void write(byte[] out) {
+ // Create temporary object
+ ConnectedThread r;
+ // Synchronize a copy of the ConnectedThread
+ synchronized (this) {
+ if (mState != STATE_CONNECTED) return;
+ r = mConnectedThread;
+ }
+ // Perform the write unsynchronized
+ r.write(out);
+ }
+
+ /**
+ * Indicate that the connection attempt failed and notify the UI Activity.
+ */
+ protected void connectionFailed() {
+ // Send a failure message back to the Activity
+ sendMessage(MESSAGE_CONNECTION_FAILED, TOAST, "Unable to connect device");
+
+ // Start the service over to restart listening mode
+ reset();
+ }
+
+ /**
+ * Indicate that the connection was lost and notify the UI Activity.
+ */
+ protected void connectionLost() {
+ // Send a failure message back to the Activity
+ sendMessage(MESSAGE_CONNECTION_LOST, TOAST, "Device connection was lost");
+
+ // Start the service over to restart listening mode
+ reset();
+ }
+
+ /**
+ * This thread runs while listening for incoming connections. It behaves
+ * like a server-side client. It runs until a connection is accepted
+ * (or until cancelled).
+ */
+ protected class AcceptThread extends Thread {
+ // The local server socket
+ private final BluetoothServerSocket mmServerSocket;
+
+ public AcceptThread() {
+ BluetoothServerSocket tmp = null;
+
+ // Create a new listening server socket
+ try {
+ tmp = mAdapter.listenUsingRfcommWithServiceRecord("BigFinBtSocket", MY_UUID);
+
+ } catch (IOException e) {
+ Log.e(TAG, "Socket listen() failed", e);
+ }
+ mmServerSocket = tmp;
+ }
+
+ public void run() {
+ Log.d(TAG, "BEGIN mAcceptThread" + this);
+ setName("AcceptThread");
+
+ BluetoothSocket socket = null;
+
+ // Listen to the server socket if we're not connected
+ while (mState != STATE_CONNECTED) {
+ try {
+ // This is a blocking call and will only return on a
+ // successful connection or an exception
+ socket = mmServerSocket.accept();
+ } catch (IOException e) {
+ Log.e(TAG, "Socket accept() failed", e);
+ break;
+ }
+
+ // If a connection was accepted
+ if (socket != null) {
+ synchronized (BigFinCommunicationService.this) {
+ switch (mState) {
+ case STATE_LISTEN:
+ case STATE_CONNECTING:
+ // Situation normal. Start the connected thread.
+ connected(socket, socket.getRemoteDevice());
+ break;
+ case STATE_NONE:
+ case STATE_CONNECTED:
+ // Either not ready or already connected. Terminate new socket.
+ try {
+ socket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Could not close unwanted socket", e);
+ }
+ break;
+ }
+ }
+ }
+ }
+ Log.i(TAG, "END mAcceptThread");
+
+ }
+
+ public void cancel() {
+ Log.d(TAG, "Socket cancel " + this);
+ try {
+ mmServerSocket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Socket close() of server failed", e);
+ }
+ }
+ }
+
+
+ /**
+ * This thread runs while attempting to make an outgoing connection
+ * with a device. It runs straight through; the connection either
+ * succeeds or fails.
+ */
+ protected class ConnectThread extends Thread {
+ protected final BluetoothSocket mmSocket;
+ protected final BluetoothDevice mmDevice;
+
+ public ConnectThread(BluetoothDevice device) {
+ mmDevice = device;
+ BluetoothSocket tmp = null;
+
+ // Get a BluetoothSocket for a connection with the
+ // given BluetoothDevice
+ try {
+ tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
+ } catch (IOException e) {
+ Log.e(TAG, "Socket create() failed", e);
+ }
+ mmSocket = tmp;
+ }
+
+ public void run() {
+ Log.i(TAG, "BEGIN mConnectThread");
+ setName("ConnectThread");
+
+ // Make a connection to the BluetoothSocket
+ try {
+ // This is a blocking call and will only return on a
+ // successful connection or an exception
+ mmSocket.connect();
+
+ } catch (IOException e) {
+ Log.e(TAG, "Error while connecting", e);
+ // Close the socket
+ try {
+ mmSocket.close();
+ } catch (IOException e2) {
+ Log.e(TAG, "unable to close() socket during connection failure", e2);
+ }
+ connectionFailed();
+ return;
+ }
+
+ // Reset the ConnectThread because we're done
+ synchronized (BigFinCommunicationService.this) {
+ mConnectThread = null;
+ }
+
+ // Start the connected thread
+ connected(mmSocket, mmDevice);
+ }
+
+ public void cancel() {
+ try {
+ mmSocket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "close() of connect socket failed", e);
+ }
+ }
+ }
+
+ /**
+ * This thread runs during a connection with a remote device.
+ * It handles all incoming and outgoing transmissions.
+ */
+ protected class ConnectedThread extends Thread {
+ protected final BluetoothSocket mmSocket;
+ protected final InputStream mmInStream;
+ protected final OutputStream mmOutStream;
+
+ public ConnectedThread(BluetoothSocket socket) {
+ Log.d(TAG, "create ConnectedThread");
+ mmSocket = socket;
+ InputStream tmpIn = null;
+ OutputStream tmpOut = null;
+
+ // Get the BluetoothSocket input and output streams
+ try {
+ tmpIn = socket.getInputStream();
+ tmpOut = socket.getOutputStream();
+ } catch (IOException e) {
+ Log.e(TAG, "temp sockets not created", e);
+ }
+
+ mmInStream = tmpIn;
+ mmOutStream = tmpOut;
+ }
+
+ public void run() {
+ Log.i(TAG, "BEGIN mConnectedThread");
+ byte[] buffer = new byte[1024];
+ int bytes;
+
+ // Keep listening to the InputStream while connected
+ while (true) {
+ try {
+ // Read from the InputStream
+ bytes = mmInStream.read(buffer);
+
+ // Send the obtained bytes to the UI Activity
+ sendMessage(MESSAGE_READ, bytes, -1, buffer);
+
+ } catch (IOException e) {
+ Log.e(TAG, "disconnected", e);
+ connectionLost();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Write to the connected OutStream.
+ * @param buffer The bytes to write
+ */
+ public void write(byte[] buffer) {
+ try {
+ mmOutStream.write(buffer);
+
+ // Share the sent message back to the UI Activity
+ sendMessage(MESSAGE_WRITE, -1, -1, buffer);
+
+ } catch (IOException e) {
+ Log.e(TAG, "Exception during write", e);
+ }
+ }
+
+ public void cancel() {
+ try {
+ mmSocket.close();
+ } catch (IOException e) {
+ Log.e(TAG, "close() of connect socket failed", e);
+ }
+ }
+ }
+
+ // Handler of incoming messages from clients.
+ protected class IncomingHandler extends Handler {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MESSAGE_REGISTER_CLIENT:
+ mClients.add(msg.replyTo);
+ break;
+
+ case MESSAGE_UNREGISTER_CLIENT:
+ mClients.remove(msg.replyTo);
+ break;
+
+ case MESSAGE_CONNECT_DEVICE:
+ reset();
+
+ String deviceAddress = msg.getData().getString(DEVICE_ADDRESS);
+ Log.d(TAG, "connect device " + deviceAddress);
+ // Get the BluetoothDevice object
+ BluetoothDevice device = mAdapter.getRemoteDevice(deviceAddress);
+ connect(device);
+ break;
+
+ case MESSAGE_SEND_DATA:
+ String dataToSend = msg.getData().getString(DATA_TO_SEND);
+ write(dataToSend.getBytes());
+ break;
+
+ case MESSAGE_DISCONNECT_DEVICE:
+ stop();
+ break;
+
+ default:
+ super.handleMessage(msg);
+ }
+ }
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/CommercialSpeciesActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,68 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesActivity extends WloBaseListActivity<CommercialSpeciesModel> {
-
- private static final String TAG = "CommercialSpeciesActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { CommercialSpeciesModel.COLUMN_FAO_CODE },
- new int[] { android.R.id.text1 }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllCommercialSpecies(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected CommercialSpeciesModel createNewModel(Cursor cursor) {
- return new CommercialSpeciesModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return ScientificSpeciesActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return CommercialSpeciesFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.commercial_species_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MetiersActivity.class;
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(1, WloItemListViewBinder.DataType.COMMERCIAL_SPECIES);
- types.put(2, WloItemListViewBinder.DataType.MENSURATION);
- types.put(3, WloItemListViewBinder.DataType.STATE);
- types.put(4, WloItemListViewBinder.DataType.PRESENTATION);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/CommercialSpeciesActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,92 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesActivity extends WloBaseListActivity<CommercialSpeciesModel> {
+
+ private static final String TAG = "CommercialSpeciesActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { CommercialSpeciesModel.COLUMN_FAO_CODE },
+ new int[] { android.R.id.text1 }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllCommercialSpecies(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected CommercialSpeciesModel createNewModel(Cursor cursor) {
+ return new CommercialSpeciesModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return ScientificSpeciesActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return CommercialSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.commercial_species_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MetiersActivity.class;
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(1, WloItemListViewBinder.DataType.COMMERCIAL_SPECIES);
+ types.put(2, WloItemListViewBinder.DataType.MENSURATION);
+ types.put(3, WloItemListViewBinder.DataType.STATE);
+ types.put(4, WloItemListViewBinder.DataType.PRESENTATION);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,111 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.Spinner;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesFormActivity extends WloModelEditionActivity<CommercialSpeciesModel> {
-
- private static final String TAG = "CommercialSpeciesFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.commercial_species_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return CommercialSpeciesActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return ScientificSpeciesFormActivity.class;
- }
-
- @Override
- protected CommercialSpeciesModel createNewModel() {
- return new CommercialSpeciesModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // editors
-
- // init editors
- List<CommercialSpecies> commercialSpecies = Lists.newArrayList(DataCache.getAllCommercialSpecies(this));
- initAutoCompleteTextView(R.id.commercial_species_form_fao_code, CommercialSpeciesModel.COLUMN_FAO_CODE, commercialSpecies);
-
- if (model.getMeasurementMethod() == null) {
- Mensuration defaultMensuration = DataCache.getDefaultMensuration(this);
- model.setMeasurementMethod(defaultMensuration);
- }
- List<Mensuration> mensurations = Lists.newArrayList(DataCache.getAllMensurations(this));
- initAutoCompleteTextView(R.id.commercial_species_form_measurement_method, CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD, mensurations);
-
- Spinner precisionSpinner = (Spinner) findViewById(R.id.commercial_species_form_precision);
- ArrayAdapter<Mensuration.Precision> precisions = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
- Mensuration.Precision.values());
- precisionSpinner.setAdapter(precisions);
- precisionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
- @Override
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
- model.setPrecision((Mensuration.Precision) adapterView.getItemAtPosition(i));
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> adapterView) {
- model.setPrecision(null);
- }
- });
-
- Set<String> sortCategories = DataCache.getAllSortCategories(this);
- initAutoCompleteTextView(R.id.commercial_species_form_sortCategory, CommercialSpeciesModel.COLUMN_SORT_CATEGORY, sortCategories);
-
- List<State> states = Lists.newArrayList(DataCache.getAllStates(this));
- initAutoCompleteTextView(R.id.commercial_species_form_state, CommercialSpeciesModel.COLUMN_STATE, states);
-
- List<Presentation> presentations = Lists.newArrayList(DataCache.getAllPresentations(this));
- initAutoCompleteTextView(R.id.commercial_species_form_presentation, CommercialSpeciesModel.COLUMN_PRESENTATION, presentations);
-
- CheckBox speciesMixEditor = (CheckBox) findViewById(R.id.commercial_species_form_species_mix);
- speciesMixEditor.setChecked(model.isSpeciesMix());
- speciesMixEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- model.setSpeciesMix(b);
- }
- });
-
- }
-
- @Override
- protected void saveModel() {
- super.saveModel();
- DataCache.invalidateSortCategories();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/CommercialSpeciesFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,136 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.Spinner;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesFormActivity extends WloModelEditionActivity<CommercialSpeciesModel> {
+
+ private static final String TAG = "CommercialSpeciesFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.commercial_species_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return CommercialSpeciesActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return ScientificSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected CommercialSpeciesModel createNewModel() {
+ return new CommercialSpeciesModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // editors
+
+ // init editors
+ List<CommercialSpecies> commercialSpecies = Lists.newArrayList(DataCache.getAllCommercialSpecies(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_fao_code, CommercialSpeciesModel.COLUMN_FAO_CODE, commercialSpecies);
+
+ if (model.getMeasurementMethod() == null) {
+ Mensuration defaultMensuration = DataCache.getDefaultMensuration(this);
+ model.setMeasurementMethod(defaultMensuration);
+ }
+ List<Mensuration> mensurations = Lists.newArrayList(DataCache.getAllMensurations(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_measurement_method, CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD, mensurations);
+
+ Spinner precisionSpinner = (Spinner) findViewById(R.id.commercial_species_form_precision);
+ ArrayAdapter<Mensuration.Precision> precisions = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
+ Mensuration.Precision.values());
+ precisionSpinner.setAdapter(precisions);
+ precisionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
+ model.setPrecision((Mensuration.Precision) adapterView.getItemAtPosition(i));
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> adapterView) {
+ model.setPrecision(null);
+ }
+ });
+ precisionSpinner.setSelection(model.getPrecision().ordinal());
+
+ Set<String> sortCategories = DataCache.getAllSortCategories(this);
+ initAutoCompleteTextView(R.id.commercial_species_form_sortCategory, CommercialSpeciesModel.COLUMN_SORT_CATEGORY, sortCategories);
+
+ List<State> states = Lists.newArrayList(DataCache.getAllStates(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_state, CommercialSpeciesModel.COLUMN_STATE, states);
+
+ List<Presentation> presentations = Lists.newArrayList(DataCache.getAllPresentations(this));
+ initAutoCompleteTextView(R.id.commercial_species_form_presentation, CommercialSpeciesModel.COLUMN_PRESENTATION, presentations);
+
+ CheckBox speciesMixEditor = (CheckBox) findViewById(R.id.commercial_species_form_species_mix);
+ speciesMixEditor.setChecked(model.isSpeciesMix());
+ speciesMixEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ model.setSpeciesMix(b);
+ }
+ });
+
+ }
+
+ @Override
+ protected void saveModel() {
+ super.saveModel();
+ DataCache.invalidateSortCategories();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ContextFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,44 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.util.Log;
-import fr.ifremer.wlo.models.ContextModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ContextFormActivity extends WloModelEditionActivity<ContextModel> {
-
- private static final String TAG = "ContextFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.context_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ContextsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return LocationFormActivity.class;
- }
-
- @Override
- protected ContextModel createNewModel() {
- return new ContextModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- initEditText(R.id.context_form_name, ContextModel.COLUMN_NAME);
-
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ContextFormActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/ContextFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,68 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.util.Log;
+import fr.ifremer.wlo.models.ContextModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ContextFormActivity extends WloModelEditionActivity<ContextModel> {
+
+ private static final String TAG = "ContextFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.context_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ContextsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return LocationFormActivity.class;
+ }
+
+ @Override
+ protected ContextModel createNewModel() {
+ return new ContextModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ initEditText(R.id.context_form_name, ContextModel.COLUMN_NAME);
+
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ContextsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,65 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import fr.ifremer.wlo.models.ContextModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ContextsActivity extends WloBaseListActivity<ContextModel> {
-
- private static final String TAG = "ContextsActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { ContextModel.COLUMN_NAME },
- new int[] { android.R.id.text1 }, 0
- );
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllContexts();
- return cursor;
- }
-
- @Override
- protected ContextModel createNewModel(Cursor cursor) {
- return new ContextModel(cursor);
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return ContextFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return null;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return LocationsActivity.class;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MainActivity.class;
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- Cursor cursor = getAllData();
- Log.d(TAG, "cursor size : " + cursor.getCount());
- adapter.swapCursor(cursor);
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ContextsActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/ContextsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,89 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import fr.ifremer.wlo.models.ContextModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ContextsActivity extends WloBaseListActivity<ContextModel> {
+
+ private static final String TAG = "ContextsActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { ContextModel.COLUMN_NAME },
+ new int[] { android.R.id.text1 }, 0
+ );
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllContexts();
+ return cursor;
+ }
+
+ @Override
+ protected ContextModel createNewModel(Cursor cursor) {
+ return new ContextModel(cursor);
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return ContextFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return LocationsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MainActivity.class;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ Cursor cursor = getAllData();
+ Log.d(TAG, "cursor size : " + cursor.getCount());
+ adapter.swapCursor(cursor);
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/DeviceListActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,328 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package fr.ifremer.wlo;
-
-import android.app.ListActivity;
-import android.app.ProgressDialog;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.util.Set;
-
-/**
- * This Activity appears as a dialog. It lists any paired devices and
- * devices detected in the area after discovery. When a device is chosen
- * by the user, the MAC address of the device is sent back to the parent
- * Activity in the result Intent.
- */
-public class DeviceListActivity extends ListActivity implements ServiceConnection {
- // Debugging
- private static final String TAG = "DeviceListActivity";
-
- // Return Intent extra
- public static final String EXTRA_DEVICE_ADDRESS = "device_address";
-
- // Member fields
- protected BluetoothAdapter mBtAdapter;
- protected ArrayAdapter<String> mPairedDevicesArrayAdapter;
-// private ArrayAdapter<String> mNewDevicesArrayAdapter;
-
- protected Messenger mServiceMessenger = null;
- protected Messenger mMessenger = new Messenger(new IncomingHandler());
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Initialize the button to perform device discovery
-// Button scanButton = (Button) findViewById(R.id.button_scan);
-// scanButton.setOnClickListener(new OnClickListener() {
-// public void onClick(View v) {
-// doDiscovery();
-// v.setVisibility(View.GONE);
-// }
-// });
-
- // Initialize array adapters. One for already paired devices and
- // one for newly discovered devices
- mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
-// mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
-
- // Find and set up the ListView for paired devices
-// ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
- ListView pairedListView = getListView();
- pairedListView.setAdapter(mPairedDevicesArrayAdapter);
- pairedListView.setOnItemClickListener(mDeviceClickListener);
-
- // Find and set up the ListView for newly discovered devices
-// ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
-// newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
-// newDevicesListView.setOnItemClickListener(mDeviceClickListener);
-
- // Register for broadcasts when a device is discovered
-// IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
-// this.registerReceiver(mReceiver, filter);
-
- // Register for broadcasts when discovery has finished
-// filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
-// this.registerReceiver(mReceiver, filter);
-
- // Get the local Bluetooth adapter
- mBtAdapter = BluetoothAdapter.getDefaultAdapter();
-
- // Get a set of currently paired devices
- Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
-
- // If there are paired devices, add each one to the ArrayAdapter
- if (pairedDevices.size() > 0) {
-// findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
- for (BluetoothDevice device : pairedDevices) {
- mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
- }
- } else {
- String noDevices = getResources().getText(R.string.devices_none_paired).toString();
- mPairedDevicesArrayAdapter.add(noDevices);
- }
-
- bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
-
- // Make sure we're not doing discovery anymore
- if (mBtAdapter != null) {
- mBtAdapter.cancelDiscovery();
- }
-
- // Unregister broadcast listeners
-// this.unregisterReceiver(mReceiver);
- doUnbindService();
- }
-
- /**
- * Start device discover with the BluetoothAdapter
- */
-// private void doDiscovery() {
-// Log.d(TAG, "doDiscovery()");
-//
-// // Indicate scanning in the title
-// setProgressBarIndeterminateVisibility(true);
-// setTitle(R.string.scanning);
-//
-// // Turn on sub-title for new devices
-// findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
-//
-// // If we're already discovering, stop it
-// if (mBtAdapter.isDiscovering()) {
-// mBtAdapter.cancelDiscovery();
-// }
-//
-// // Request discover from BluetoothAdapter
-// mBtAdapter.startDiscovery();
-// }
-
- /**
- * Un-bind this Activity to MyService
- */
- protected void doUnbindService() {
- // If we have received the service, and hence registered with it, then now is the time to unregister.
- if (mServiceMessenger != null) {
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
- // Detach our existing connection.
- unbindService(this);
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mServiceMessenger = new Messenger(service);
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
- }
- catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mServiceMessenger = null;
- }
-
- // The on-click listener for all devices in the ListViews
- protected OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
- public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
- // Cancel discovery because it's costly and we're about to connect
- mBtAdapter.cancelDiscovery();
-
- // Get the device MAC address, which is the last 17 chars in the View
- String info = ((TextView) v).getText().toString();
- String address = info.substring(info.length() - 17);
-
- // Create the result Intent and include the MAC address
-// Intent intent = new Intent();
-// intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
-
- // Attempt to connect to the device
- Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_CONNECT_DEVICE);
- Bundle bundle = new Bundle();
- bundle.putString(BigFinCommunicationService.DEVICE_ADDRESS, address);
- message.setData(bundle);
- try {
- mServiceMessenger.send(message);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
-
- // Set result and finish this Activity
-// setResult(Activity.RESULT_OK, intent);
-// finish();
- }
- };
-
- // The BroadcastReceiver that listens for discovered devices and
- // changes the title when discovery is finished
-// private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
-// @Override
-// public void onReceive(Context context, Intent intent) {
-// String action = intent.getAction();
-//
-// // When discovery finds a device
-// if (BluetoothDevice.ACTION_FOUND.equals(action)) {
-// // Get the BluetoothDevice object from the Intent
-// BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
-// // If it's already paired, skip it, because it's been listed already
-// if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
-// mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
-// }
-// // When discovery is finished, change the Activity title
-// } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
-// setProgressBarIndeterminateVisibility(false);
-// setTitle(R.string.select_device);
-// if (mNewDevicesArrayAdapter.getCount() == 0) {
-// String noDevices = getResources().getText(R.string.none_found).toString();
-// mNewDevicesArrayAdapter.add(noDevices);
-// }
-// }
-// }
-// };
-
- protected void sendDataToDevice(String data) {
- Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_SEND_DATA);
- Bundle bundle = new Bundle();
- bundle.putString(BigFinCommunicationService.DATA_TO_SEND, data);
- message.setData(bundle);
- try {
- mServiceMessenger.send(message);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
-
- // The Handler that gets information back from the BluetoothChatService
- class IncomingHandler extends Handler {
-
- ProgressDialog dialog;
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
- switch (msg.arg1) {
- case BigFinCommunicationService.STATE_CONNECTED:
- sendDataToDevice("a");
- sendDataToDevice("b");
-
- dialog.dismiss();
- finish();
-
- break;
-
- case BigFinCommunicationService.STATE_CONNECTING:
- dialog = ProgressDialog.show(DeviceListActivity.this, "",
- "Connecting. Please wait...", true);
- break;
-
- }
- break;
-
- case BigFinCommunicationService.MESSAGE_WRITE:
- byte[] writeBuf = (byte[]) msg.obj;
- // construct a string from the buffer
- String writeMessage = new String(writeBuf);
- Log.d(TAG, "write " + writeMessage);
- break;
-
- case BigFinCommunicationService.MESSAGE_READ:
- byte[] readBuf = (byte[]) msg.obj;
- // construct a string from the valid bytes in the buffer
- String readMessage = new String(readBuf, 0, msg.arg1);
- Log.d(TAG, "read " + readMessage);
- break;
-
- case BigFinCommunicationService.MESSAGE_DEVICE_NAME:
- // save the connected device's name
- String mConnectedDeviceName = msg.getData().getString(BigFinCommunicationService.DEVICE_NAME);
- Toast.makeText(getApplicationContext(), "Connected to "
- + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
- break;
-
- case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
- case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
- if (dialog != null) {
- dialog.dismiss();
- }
- Toast.makeText(getApplicationContext(), msg.getData().getString(BigFinCommunicationService.TOAST),
- Toast.LENGTH_SHORT).show();
- break;
- }
- }
-
- };
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/DeviceListActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/DeviceListActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,352 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.ListActivity;
+import android.app.ProgressDialog;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.Set;
+
+/**
+ * This Activity appears as a dialog. It lists any paired devices and
+ * devices detected in the area after discovery. When a device is chosen
+ * by the user, the MAC address of the device is sent back to the parent
+ * Activity in the result Intent.
+ */
+public class DeviceListActivity extends ListActivity implements ServiceConnection {
+ // Debugging
+ private static final String TAG = "DeviceListActivity";
+
+ // Return Intent extra
+ public static final String EXTRA_DEVICE_ADDRESS = "device_address";
+
+ // Member fields
+ protected BluetoothAdapter mBtAdapter;
+ protected ArrayAdapter<String> mPairedDevicesArrayAdapter;
+// private ArrayAdapter<String> mNewDevicesArrayAdapter;
+
+ protected Messenger mServiceMessenger = null;
+ protected Messenger mMessenger = new Messenger(new IncomingHandler());
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Initialize the button to perform device discovery
+// Button scanButton = (Button) findViewById(R.id.button_scan);
+// scanButton.setOnClickListener(new OnClickListener() {
+// public void onClick(View v) {
+// doDiscovery();
+// v.setVisibility(View.GONE);
+// }
+// });
+
+ // Initialize array adapters. One for already paired devices and
+ // one for newly discovered devices
+ mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
+// mNewDevicesArrayAdapter = new ArrayAdapter<String>(this, R.layout.device_name);
+
+ // Find and set up the ListView for paired devices
+// ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
+ ListView pairedListView = getListView();
+ pairedListView.setAdapter(mPairedDevicesArrayAdapter);
+ pairedListView.setOnItemClickListener(mDeviceClickListener);
+
+ // Find and set up the ListView for newly discovered devices
+// ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
+// newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
+// newDevicesListView.setOnItemClickListener(mDeviceClickListener);
+
+ // Register for broadcasts when a device is discovered
+// IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
+// this.registerReceiver(mReceiver, filter);
+
+ // Register for broadcasts when discovery has finished
+// filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
+// this.registerReceiver(mReceiver, filter);
+
+ // Get the local Bluetooth adapter
+ mBtAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // Get a set of currently paired devices
+ Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
+
+ // If there are paired devices, add each one to the ArrayAdapter
+ if (pairedDevices.size() > 0) {
+// findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
+ for (BluetoothDevice device : pairedDevices) {
+ mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
+ }
+ } else {
+ String noDevices = getResources().getText(R.string.devices_none_paired).toString();
+ mPairedDevicesArrayAdapter.add(noDevices);
+ }
+
+ bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+
+ // Make sure we're not doing discovery anymore
+ if (mBtAdapter != null) {
+ mBtAdapter.cancelDiscovery();
+ }
+
+ // Unregister broadcast listeners
+// this.unregisterReceiver(mReceiver);
+ doUnbindService();
+ }
+
+ /**
+ * Start device discover with the BluetoothAdapter
+ */
+// private void doDiscovery() {
+// Log.d(TAG, "doDiscovery()");
+//
+// // Indicate scanning in the title
+// setProgressBarIndeterminateVisibility(true);
+// setTitle(R.string.scanning);
+//
+// // Turn on sub-title for new devices
+// findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);
+//
+// // If we're already discovering, stop it
+// if (mBtAdapter.isDiscovering()) {
+// mBtAdapter.cancelDiscovery();
+// }
+//
+// // Request discover from BluetoothAdapter
+// mBtAdapter.startDiscovery();
+// }
+
+ /**
+ * Un-bind this Activity to MyService
+ */
+ protected void doUnbindService() {
+ // If we have received the service, and hence registered with it, then now is the time to unregister.
+ if (mServiceMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ // Detach our existing connection.
+ unbindService(this);
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mServiceMessenger = new Messenger(service);
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+ }
+ catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mServiceMessenger = null;
+ }
+
+ // The on-click listener for all devices in the ListViews
+ protected OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
+ public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
+ // Cancel discovery because it's costly and we're about to connect
+ mBtAdapter.cancelDiscovery();
+
+ // Get the device MAC address, which is the last 17 chars in the View
+ String info = ((TextView) v).getText().toString();
+ String address = info.substring(info.length() - 17);
+
+ // Create the result Intent and include the MAC address
+// Intent intent = new Intent();
+// intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
+
+ // Attempt to connect to the device
+ Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_CONNECT_DEVICE);
+ Bundle bundle = new Bundle();
+ bundle.putString(BigFinCommunicationService.DEVICE_ADDRESS, address);
+ message.setData(bundle);
+ try {
+ mServiceMessenger.send(message);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+
+ // Set result and finish this Activity
+// setResult(Activity.RESULT_OK, intent);
+// finish();
+ }
+ };
+
+ // The BroadcastReceiver that listens for discovered devices and
+ // changes the title when discovery is finished
+// private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+// @Override
+// public void onReceive(Context context, Intent intent) {
+// String action = intent.getAction();
+//
+// // When discovery finds a device
+// if (BluetoothDevice.ACTION_FOUND.equals(action)) {
+// // Get the BluetoothDevice object from the Intent
+// BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+// // If it's already paired, skip it, because it's been listed already
+// if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
+// mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
+// }
+// // When discovery is finished, change the Activity title
+// } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
+// setProgressBarIndeterminateVisibility(false);
+// setTitle(R.string.select_device);
+// if (mNewDevicesArrayAdapter.getCount() == 0) {
+// String noDevices = getResources().getText(R.string.none_found).toString();
+// mNewDevicesArrayAdapter.add(noDevices);
+// }
+// }
+// }
+// };
+
+ protected void sendDataToDevice(String data) {
+ Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_SEND_DATA);
+ Bundle bundle = new Bundle();
+ bundle.putString(BigFinCommunicationService.DATA_TO_SEND, data);
+ message.setData(bundle);
+ try {
+ mServiceMessenger.send(message);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+
+ // The Handler that gets information back from the BluetoothChatService
+ class IncomingHandler extends Handler {
+
+ ProgressDialog dialog;
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
+ switch (msg.arg1) {
+ case BigFinCommunicationService.STATE_CONNECTED:
+ sendDataToDevice("a");
+ sendDataToDevice("b");
+
+ dialog.dismiss();
+ finish();
+
+ break;
+
+ case BigFinCommunicationService.STATE_CONNECTING:
+ dialog = ProgressDialog.show(DeviceListActivity.this, "",
+ "Connecting. Please wait...", true);
+ break;
+
+ }
+ break;
+
+ case BigFinCommunicationService.MESSAGE_WRITE:
+ byte[] writeBuf = (byte[]) msg.obj;
+ // construct a string from the buffer
+ String writeMessage = new String(writeBuf);
+ Log.d(TAG, "write " + writeMessage);
+ break;
+
+ case BigFinCommunicationService.MESSAGE_READ:
+ byte[] readBuf = (byte[]) msg.obj;
+ // construct a string from the valid bytes in the buffer
+ String readMessage = new String(readBuf, 0, msg.arg1);
+ Log.d(TAG, "read " + readMessage);
+ break;
+
+ case BigFinCommunicationService.MESSAGE_DEVICE_NAME:
+ // save the connected device's name
+ String mConnectedDeviceName = msg.getData().getString(BigFinCommunicationService.DEVICE_NAME);
+ Toast.makeText(getApplicationContext(), "Connected to "
+ + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
+ break;
+
+ case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
+ case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
+ if (dialog != null) {
+ dialog.dismiss();
+ }
+ Toast.makeText(getApplicationContext(), msg.getData().getString(BigFinCommunicationService.TOAST),
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+
+ };
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/Home.java
===================================================================
--- trunk/src/fr/ifremer/wlo/Home.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/Home.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package fr.ifremer.wlo;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.speech.tts.TextToSpeech;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.Toast;
-import fr.ifremer.wlo.measurement.MeasurementActivity;
-
-/**
- * This is the main Activity that displays the current chat location.
- */
-public class Home extends Activity implements TextToSpeech.OnInitListener {
-
- // Debugging
- private static final String TAG = "Home";
-
- // Message types sent from the BluetoothChatService Handler
- public static final int MESSAGE_STATE_CHANGE = 1;
- public static final int MESSAGE_READ = 2;
- public static final int MESSAGE_WRITE = 3;
- public static final int MESSAGE_DEVICE_NAME = 4;
- public static final int MESSAGE_TOAST = 5;
-
- // Key names received from the BluetoothChatService Handler
- public static final String DEVICE_NAME = "device_name";
- public static final String TOAST = "toast";
-
- // Intent request codes
- protected static final int REQUEST_CONNECT_DEVICE = 1;
- protected static final int REQUEST_ENABLE_BT = 2;
- protected static final int REQUEST_CHECK_TTS = 3;
-
- // Layout Views
- protected ListView mConversationView;
-
- // Name of the connected device
- protected String mConnectedDeviceName = null;
- // Array adapter for the conversation thread
- protected ArrayAdapter<String> mConversationArrayAdapter;
- // Local Bluetooth adapter
- protected BluetoothAdapter mBluetoothAdapter = null;
- // Member object for the chat services
- protected BigFinCommunicationService mBFCommunicationService = null;
-
-// protected TextToSpeech mTts;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Set up the window layout
-// setContentView(R.layout.home);
-
- // Get local Bluetooth adapter
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-
- // If the adapter is null, then Bluetooth is not supported
- if (mBluetoothAdapter == null) {
- Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
- finish();
- return;
- }
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- // If BT is not on, request that it be enabled.
- // setupChat() will then be called during onActivityResult
- if (!mBluetoothAdapter.isEnabled()) {
- Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
-
- // Otherwise, setup the chat location
- } else {
-// Intent checkIntent = new Intent();
-// checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
-// startActivityForResult(checkIntent, REQUEST_CHECK_TTS);
- setupChat();
- }
- }
-
- @Override
- public synchronized void onResume() {
- super.onResume();
-
- // Performing this check in onResume() covers the case in which BT was
- // not enabled during onStart(), so we were paused to enable it...
- // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
- if (mBFCommunicationService != null) {
- // Only if the state is STATE_NONE, do we know that we haven't started already
-// if (mBFCommunicationService.getState() == BigFinCommunicationService.STATE_NONE) {
- // Start the Bluetooth chat services
-// mBFCommunicationService.start();
- selectDevice();
-// }
- }
- }
-
- protected void selectDevice() {
- // Launch the DeviceListActivity to see devices and do scan
- Intent serverIntent = new Intent(this, DeviceListActivity.class);
- startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
- }
-
- private void setupChat() {
- Log.d(TAG, "setupChat()");
-
- // Initialize the array adapter for the conversation thread
- mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
-// mConversationView = (ListView) findViewById(R.id.in);
- mConversationView.setAdapter(mConversationArrayAdapter);
-
- // Initialize the BluetoothChatService to perform bluetooth connections
-// mBFCommunicationService = new BigFinCommunicationService(this, mHandler);
-
- }
-
- @Override
- public void onStop() {
- super.onStop();
-// mTts.shutdown();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- // Stop the Bluetooth chat services
-// if (mBFCommunicationService != null) mBFCommunicationService.stop();
- }
-
- protected final void setStatus(int resId) {
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setSubtitle(resId);
- }
- }
-
- protected final void setStatus(CharSequence subTitle) {
- final ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setSubtitle(subTitle);
- }
- }
-
- // The Handler that gets information back from the BluetoothChatService
- protected final Handler mHandler = new Handler() {
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MESSAGE_STATE_CHANGE:
- Log.d(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
- switch (msg.arg1) {
- case BigFinCommunicationService.STATE_CONNECTED:
-// setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
- mConversationArrayAdapter.clear();
- mBFCommunicationService.write("a".getBytes());
- mBFCommunicationService.write("b".getBytes());
-
- Intent intent = new Intent(Home.this, MeasurementActivity.class);
- startActivity(intent);
-
- break;
-
- case BigFinCommunicationService.STATE_CONNECTING:
-// setStatus(R.string.title_connecting);
-
- break;
-
- case BigFinCommunicationService.STATE_LISTEN:
- case BigFinCommunicationService.STATE_NONE:
-// setStatus(R.string.title_not_connected);
- break;
- }
- break;
-
- case MESSAGE_WRITE:
- byte[] writeBuf = (byte[]) msg.obj;
- // construct a string from the buffer
- String writeMessage = new String(writeBuf);
-// mConversationArrayAdapter.add("Me: " + writeMessage);
- break;
-
- case MESSAGE_READ:
- byte[] readBuf = (byte[]) msg.obj;
- // construct a string from the valid bytes in the buffer
- String readMessage = new String(readBuf, 0, msg.arg1);
- mConversationArrayAdapter.add(readMessage);
-// mTts.speak(readMessage, TextToSpeech.QUEUE_ADD, null);
- break;
-
- case MESSAGE_DEVICE_NAME:
- // save the connected device's name
- mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
- Toast.makeText(getApplicationContext(), "Connected to "
- + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
- break;
-
- case MESSAGE_TOAST:
- Toast.makeText(getApplicationContext(), msg.getData().getString(TOAST),
- Toast.LENGTH_SHORT).show();
- break;
- }
- }
- };
-
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- switch (requestCode) {
- case REQUEST_CONNECT_DEVICE:
- // When DeviceListActivity returns with a device to connect
- if (resultCode == Activity.RESULT_OK) {
- connectDevice(data);
- }
- break;
-
- case REQUEST_ENABLE_BT:
- // When the request to enable Bluetooth returns
- if (resultCode == Activity.RESULT_OK) {
- // Bluetooth is now enabled, so set up a chat location
- setupChat();
-
- } else {
- // User did not enable Bluetooth or an error occurred
- Log.d(TAG, "BT not enabled");
-// Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
- finish();
- }
- break;
-
- case REQUEST_CHECK_TTS:
- if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
- // Succès, au moins un moteur de TTS à été trouvé, on l'instancie
-// mTts = new TextToSpeech(this, this);
-
- } else {
- // Echec, aucun moteur n'a été trouvé, on propose à l'utilisateur d'en installer un depuis le Market
- Intent installIntent = new Intent();
- installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
- startActivity(installIntent);
- }
- break;
- }
-
- }
-
- protected void connectDevice(Intent data) {
- // Get the device MAC address
- String address = data.getExtras()
- .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
- // Get the BluetoothDevice object
- BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
- // Attempt to connect to the device
- mBFCommunicationService.connect(device);
-
- Intent intent = new Intent(this, MeasurementActivity.class);
- startActivity(intent);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
-// inflater.inflate(R.menu.option_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-// switch (item.getItemId()) {
-// case R.id.connect_scan:
-// selectDevice();
-// return true;
-// case R.id.disconnect:
-//// mBFCommunicationService.start();
-// return true;
-// }
- return false;
- }
-
- @Override
- public void onInit(int status) {
- if (status == TextToSpeech.SUCCESS) {
-// if (mTts.isLanguageAvailable(Locale.FRANCE) == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
-// mTts.setLanguage(Locale.FRANCE);
-// }
- }
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/Home.java (from rev 25, trunk/src/fr/ifremer/wlo/Home.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/Home.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/Home.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.speech.tts.TextToSpeech;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+import fr.ifremer.wlo.measurement.MeasurementActivity;
+
+/**
+ * This is the main Activity that displays the current chat location.
+ */
+public class Home extends Activity implements TextToSpeech.OnInitListener {
+
+ // Debugging
+ private static final String TAG = "Home";
+
+ // Message types sent from the BluetoothChatService Handler
+ public static final int MESSAGE_STATE_CHANGE = 1;
+ public static final int MESSAGE_READ = 2;
+ public static final int MESSAGE_WRITE = 3;
+ public static final int MESSAGE_DEVICE_NAME = 4;
+ public static final int MESSAGE_TOAST = 5;
+
+ // Key names received from the BluetoothChatService Handler
+ public static final String DEVICE_NAME = "device_name";
+ public static final String TOAST = "toast";
+
+ // Intent request codes
+ protected static final int REQUEST_CONNECT_DEVICE = 1;
+ protected static final int REQUEST_ENABLE_BT = 2;
+ protected static final int REQUEST_CHECK_TTS = 3;
+
+ // Layout Views
+ protected ListView mConversationView;
+
+ // Name of the connected device
+ protected String mConnectedDeviceName = null;
+ // Array adapter for the conversation thread
+ protected ArrayAdapter<String> mConversationArrayAdapter;
+ // Local Bluetooth adapter
+ protected BluetoothAdapter mBluetoothAdapter = null;
+ // Member object for the chat services
+ protected BigFinCommunicationService mBFCommunicationService = null;
+
+// protected TextToSpeech mTts;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Set up the window layout
+// setContentView(R.layout.home);
+
+ // Get local Bluetooth adapter
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // If the adapter is null, then Bluetooth is not supported
+ if (mBluetoothAdapter == null) {
+ Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
+ finish();
+ return;
+ }
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ // If BT is not on, request that it be enabled.
+ // setupChat() will then be called during onActivityResult
+ if (!mBluetoothAdapter.isEnabled()) {
+ Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
+
+ // Otherwise, setup the chat location
+ } else {
+// Intent checkIntent = new Intent();
+// checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
+// startActivityForResult(checkIntent, REQUEST_CHECK_TTS);
+ setupChat();
+ }
+ }
+
+ @Override
+ public synchronized void onResume() {
+ super.onResume();
+
+ // Performing this check in onResume() covers the case in which BT was
+ // not enabled during onStart(), so we were paused to enable it...
+ // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
+ if (mBFCommunicationService != null) {
+ // Only if the state is STATE_NONE, do we know that we haven't started already
+// if (mBFCommunicationService.getState() == BigFinCommunicationService.STATE_NONE) {
+ // Start the Bluetooth chat services
+// mBFCommunicationService.start();
+ selectDevice();
+// }
+ }
+ }
+
+ protected void selectDevice() {
+ // Launch the DeviceListActivity to see devices and do scan
+ Intent serverIntent = new Intent(this, DeviceListActivity.class);
+ startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
+ }
+
+ private void setupChat() {
+ Log.d(TAG, "setupChat()");
+
+ // Initialize the array adapter for the conversation thread
+ mConversationArrayAdapter = new ArrayAdapter<String>(this, R.layout.message);
+// mConversationView = (ListView) findViewById(R.id.in);
+ mConversationView.setAdapter(mConversationArrayAdapter);
+
+ // Initialize the BluetoothChatService to perform bluetooth connections
+// mBFCommunicationService = new BigFinCommunicationService(this, mHandler);
+
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+// mTts.shutdown();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ // Stop the Bluetooth chat services
+// if (mBFCommunicationService != null) mBFCommunicationService.stop();
+ }
+
+ protected final void setStatus(int resId) {
+ final ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(resId);
+ }
+ }
+
+ protected final void setStatus(CharSequence subTitle) {
+ final ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setSubtitle(subTitle);
+ }
+ }
+
+ // The Handler that gets information back from the BluetoothChatService
+ protected final Handler mHandler = new Handler() {
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MESSAGE_STATE_CHANGE:
+ Log.d(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
+ switch (msg.arg1) {
+ case BigFinCommunicationService.STATE_CONNECTED:
+// setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
+ mConversationArrayAdapter.clear();
+ mBFCommunicationService.write("a".getBytes());
+ mBFCommunicationService.write("b".getBytes());
+
+ Intent intent = new Intent(Home.this, MeasurementActivity.class);
+ startActivity(intent);
+
+ break;
+
+ case BigFinCommunicationService.STATE_CONNECTING:
+// setStatus(R.string.title_connecting);
+
+ break;
+
+ case BigFinCommunicationService.STATE_LISTEN:
+ case BigFinCommunicationService.STATE_NONE:
+// setStatus(R.string.title_not_connected);
+ break;
+ }
+ break;
+
+ case MESSAGE_WRITE:
+ byte[] writeBuf = (byte[]) msg.obj;
+ // construct a string from the buffer
+ String writeMessage = new String(writeBuf);
+// mConversationArrayAdapter.add("Me: " + writeMessage);
+ break;
+
+ case MESSAGE_READ:
+ byte[] readBuf = (byte[]) msg.obj;
+ // construct a string from the valid bytes in the buffer
+ String readMessage = new String(readBuf, 0, msg.arg1);
+ mConversationArrayAdapter.add(readMessage);
+// mTts.speak(readMessage, TextToSpeech.QUEUE_ADD, null);
+ break;
+
+ case MESSAGE_DEVICE_NAME:
+ // save the connected device's name
+ mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
+ Toast.makeText(getApplicationContext(), "Connected to "
+ + mConnectedDeviceName, Toast.LENGTH_SHORT).show();
+ break;
+
+ case MESSAGE_TOAST:
+ Toast.makeText(getApplicationContext(), msg.getData().getString(TOAST),
+ Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+ };
+
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ switch (requestCode) {
+ case REQUEST_CONNECT_DEVICE:
+ // When DeviceListActivity returns with a device to connect
+ if (resultCode == Activity.RESULT_OK) {
+ connectDevice(data);
+ }
+ break;
+
+ case REQUEST_ENABLE_BT:
+ // When the request to enable Bluetooth returns
+ if (resultCode == Activity.RESULT_OK) {
+ // Bluetooth is now enabled, so set up a chat location
+ setupChat();
+
+ } else {
+ // User did not enable Bluetooth or an error occurred
+ Log.d(TAG, "BT not enabled");
+// Toast.makeText(this, R.string.bt_not_enabled_leaving, Toast.LENGTH_SHORT).show();
+ finish();
+ }
+ break;
+
+ case REQUEST_CHECK_TTS:
+ if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
+ // Succès, au moins un moteur de TTS à été trouvé, on l'instancie
+// mTts = new TextToSpeech(this, this);
+
+ } else {
+ // Echec, aucun moteur n'a été trouvé, on propose à l'utilisateur d'en installer un depuis le Market
+ Intent installIntent = new Intent();
+ installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
+ startActivity(installIntent);
+ }
+ break;
+ }
+
+ }
+
+ protected void connectDevice(Intent data) {
+ // Get the device MAC address
+ String address = data.getExtras()
+ .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
+ // Get the BluetoothDevice object
+ BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
+ // Attempt to connect to the device
+ mBFCommunicationService.connect(device);
+
+ Intent intent = new Intent(this, MeasurementActivity.class);
+ startActivity(intent);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+// inflater.inflate(R.menu.option_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+// switch (item.getItemId()) {
+// case R.id.connect_scan:
+// selectDevice();
+// return true;
+// case R.id.disconnect:
+//// mBFCommunicationService.start();
+// return true;
+// }
+ return false;
+ }
+
+ @Override
+ public void onInit(int status) {
+ if (status == TextToSpeech.SUCCESS) {
+// if (mTts.isLanguageAvailable(Locale.FRANCE) == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
+// mTts.setLanguage(Locale.FRANCE);
+// }
+ }
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/LocationFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,124 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.preferences.StringPreference;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.DatePickerFragment;
-import fr.ifremer.wlo.utils.TimePickerFragment;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Calendar;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationFormActivity extends WloModelEditionActivity<LocationModel> {
-
- private static final String TAG = "LocationFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.location_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return LocationsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return VesselFormActivity.class;
- }
-
- @Override
- protected LocationModel createNewModel() {
- return new LocationModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // init editors
- String defaultOperator = null;
- if (model.isNew()) {
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
- defaultOperator = sharedPref.getString(StringPreference.DEFAULT_OPERATOR.getKey(), null);
- }
- initEditText(R.id.location_form_operator, LocationModel.COLUMN_OPERATOR, defaultOperator);
-
- List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
- initAutoCompleteTextView(R.id.location_form_location, LocationModel.COLUMN_LOCATION, locations);
-
- TextView startDateTextView = (TextView) findViewById(R.id.location_form_start_date);
- TextView startTimeTextView = (TextView) findViewById(R.id.location_form_start_time);
- TextView endDateTextView = (TextView) findViewById(R.id.location_form_end_date);
- TextView endTimeTextView = (TextView) findViewById(R.id.location_form_end_time);
-
- String dateFormat = UIUtils.getDateFormat(this);
- // start date
- Calendar startDate = model.getStartDate();
- if (startDate != null) {
- startDateTextView.setText(String.format(dateFormat, startDate.getTime()));
- startTimeTextView.setText(getString(R.string.time_format, startDate.getTime()));
- }
-
- // end date
- Calendar endDate = model.getEndDate();
- if (endDate != null) {
- endDateTextView.setText(String.format(dateFormat, endDate.getTime()));
- endTimeTextView.setText(getString(R.string.time_format, endDate.getTime()));
- }
-
- }
-
- public void pickDate(View v) {
- String attribute;
- switch (v.getId()) {
- case R.id.location_form_start_date:
- attribute = LocationModel.COLUMN_START_DATE;
- break;
-
- case R.id.location_form_end_date:
- attribute = LocationModel.COLUMN_END_DATE;
- break;
-
- default:
- return;
- }
- DialogFragment newFragment = new DatePickerFragment(model, attribute, (TextView) v);
- newFragment.show(getSupportFragmentManager(), "datePicker");
- }
-
- public void pickTime(View v) {
- String attribute;
- switch (v.getId()) {
- case R.id.location_form_start_time:
- attribute = LocationModel.COLUMN_START_DATE;
- break;
-
- case R.id.location_form_end_time:
- attribute = LocationModel.COLUMN_END_DATE;
- break;
-
- default:
- return;
- }
- DialogFragment newFragment = new TimePickerFragment(model, attribute, (TextView) v);
- newFragment.show(getSupportFragmentManager(), "timePicker");
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/LocationFormActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/LocationFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,148 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.preferences.StringPreference;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.DatePickerFragment;
+import fr.ifremer.wlo.utils.TimePickerFragment;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationFormActivity extends WloModelEditionActivity<LocationModel> {
+
+ private static final String TAG = "LocationFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.location_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return LocationsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return VesselFormActivity.class;
+ }
+
+ @Override
+ protected LocationModel createNewModel() {
+ return new LocationModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // init editors
+ String defaultOperator = null;
+ if (model.isNew()) {
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+ defaultOperator = sharedPref.getString(StringPreference.DEFAULT_OPERATOR.getKey(), null);
+ }
+ initEditText(R.id.location_form_operator, LocationModel.COLUMN_OPERATOR, defaultOperator);
+
+ List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
+ initAutoCompleteTextView(R.id.location_form_location, LocationModel.COLUMN_LOCATION, locations);
+
+ TextView startDateTextView = (TextView) findViewById(R.id.location_form_start_date);
+ TextView startTimeTextView = (TextView) findViewById(R.id.location_form_start_time);
+ TextView endDateTextView = (TextView) findViewById(R.id.location_form_end_date);
+ TextView endTimeTextView = (TextView) findViewById(R.id.location_form_end_time);
+
+ String dateFormat = UIUtils.getDateFormat(this);
+ // start date
+ Calendar startDate = model.getStartDate();
+ if (startDate != null) {
+ startDateTextView.setText(String.format(dateFormat, startDate.getTime()));
+ startTimeTextView.setText(getString(R.string.time_format, startDate.getTime()));
+ }
+
+ // end date
+ Calendar endDate = model.getEndDate();
+ if (endDate != null) {
+ endDateTextView.setText(String.format(dateFormat, endDate.getTime()));
+ endTimeTextView.setText(getString(R.string.time_format, endDate.getTime()));
+ }
+
+ }
+
+ public void pickDate(View v) {
+ String attribute;
+ switch (v.getId()) {
+ case R.id.location_form_start_date:
+ attribute = LocationModel.COLUMN_START_DATE;
+ break;
+
+ case R.id.location_form_end_date:
+ attribute = LocationModel.COLUMN_END_DATE;
+ break;
+
+ default:
+ return;
+ }
+ DialogFragment newFragment = new DatePickerFragment(model, attribute, (TextView) v);
+ newFragment.show(getSupportFragmentManager(), "datePicker");
+ }
+
+ public void pickTime(View v) {
+ String attribute;
+ switch (v.getId()) {
+ case R.id.location_form_start_time:
+ attribute = LocationModel.COLUMN_START_DATE;
+ break;
+
+ case R.id.location_form_end_time:
+ attribute = LocationModel.COLUMN_END_DATE;
+ break;
+
+ default:
+ return;
+ }
+ DialogFragment newFragment = new TimePickerFragment(model, attribute, (TextView) v);
+ newFragment.show(getSupportFragmentManager(), "timePicker");
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/LocationsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,67 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationsActivity extends WloBaseListActivity<LocationModel> {
-
- private static final String TAG = "LocationsActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, R.layout.location_list_item, null,
- new String[] { LocationModel.COLUMN_LOCATION, LocationModel.COLUMN_START_DATE, LocationModel.COLUMN_END_DATE },
- new int[] { R.id.location_location, R.id.location_start_date, R.id.location_end_date }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllLocations(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected LocationModel createNewModel(Cursor cursor) {
- return new LocationModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return VesselsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return LocationFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.locations_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ContextsActivity.class;
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(2, WloItemListViewBinder.DataType.DATETIME);
- types.put(3, WloItemListViewBinder.DataType.DATETIME);
- types.put(4, WloItemListViewBinder.DataType.LOCATION);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/LocationsActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/LocationsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,91 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationsActivity extends WloBaseListActivity<LocationModel> {
+
+ private static final String TAG = "LocationsActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, R.layout.location_list_item, null,
+ new String[] { LocationModel.COLUMN_LOCATION, LocationModel.COLUMN_START_DATE, LocationModel.COLUMN_END_DATE },
+ new int[] { R.id.location_location, R.id.location_start_date, R.id.location_end_date }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllLocations(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected LocationModel createNewModel(Cursor cursor) {
+ return new LocationModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return VesselsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return LocationFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.locations_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ContextsActivity.class;
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(2, WloItemListViewBinder.DataType.DATETIME);
+ types.put(3, WloItemListViewBinder.DataType.DATETIME);
+ types.put(4, WloItemListViewBinder.DataType.LOCATION);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/MainActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MainActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/MainActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,251 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.app.Activity;
-import android.app.ProgressDialog;
-import android.bluetooth.BluetoothAdapter;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.Toast;
-import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
-import fr.ifremer.wlo.preferences.SettingsActivity;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-
-import java.io.IOException;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MainActivity extends WloBaseActivity {
-
- private static final String TAG = "MainActivity";
-
- protected static final int REQUEST_ENABLE_BT = 1;
- protected static final int REQUEST_CONNECT_ICHTYOMETER = 2;
-
- // Local Bluetooth adapter
- protected BluetoothAdapter mBluetoothAdapter = null;
-
- protected Button connectButton;
- protected Button disconnectButton;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "create");
-
- mMessenger = new Messenger(new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
- switch (msg.arg1) {
- case BigFinCommunicationService.STATE_CONNECTED:
- bigfinConnected();
- break;
-
- case BigFinCommunicationService.STATE_LISTEN:
- case BigFinCommunicationService.STATE_NONE:
- bigfinDisconnected();
- break;
- }
- break;
-
- case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
- case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
- bigfinDisconnected();
- break;
- }
- }
- });
-
- super.onCreate(savedInstanceState);
-
- // Get local Bluetooth adapter
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
-
- // If the adapter is null, then Bluetooth is not supported
- if (mBluetoothAdapter == null) {
- findViewById(R.id.main_connect_ichtyometer_button).setEnabled(false);
- }
-
- connectButton = (Button) findViewById(R.id.main_connect_ichtyometer_button);
- disconnectButton = (Button) findViewById(R.id.main_disconnect_ichtyometer_button);
- bigfinDisconnected();
-
- final ProgressDialog dialog = new ProgressDialog(this);
- dialog.setIndeterminate(false);
- dialog.setCancelable(false);
- dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- dialog.setMax(11);
- dialog.setMessage(getString(R.string.main_loading_referential));
- dialog.show();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- if (DataCache.getAllAges(MainActivity.this).isEmpty()) {
- ImportUtil.importAges(MainActivity.this, getAssets().open("ref_import_ages.csv"));
- }
- dialog.setProgress(1);
- if (DataCache.getAllCommercialSpecies(MainActivity.this).isEmpty()) {
- ImportUtil.importCommercialSpecies(MainActivity.this, getAssets().open("ref_import_commercial_species.csv"));
- }
- dialog.setProgress(2);
- if (DataCache.getAllGenders(MainActivity.this).isEmpty()) {
- ImportUtil.importGenders(MainActivity.this, getAssets().open("ref_import_genders.csv"));
- }
- dialog.setProgress(3);
- if (DataCache.getAllLocations(MainActivity.this).isEmpty()) {
- ImportUtil.importLocations(MainActivity.this, getAssets().open("ref_import_locations.csv"));
- }
- dialog.setProgress(4);
- if (DataCache.getAllMaturities(MainActivity.this).isEmpty()) {
- ImportUtil.importMaturities(MainActivity.this, getAssets().open("ref_import_maturities.csv"));
- }
- dialog.setProgress(5);
- if (DataCache.getAllMensurations(MainActivity.this).isEmpty()) {
- ImportUtil.importMensurations(MainActivity.this, getAssets().open("ref_import_mensurations.csv"));
- }
- dialog.setProgress(6);
- if (DataCache.getAllMetiers(MainActivity.this).isEmpty()) {
- ImportUtil.importMetiers(MainActivity.this, getAssets().open("ref_import_metiers.csv"));
- }
- dialog.setProgress(7);
- if (DataCache.getAllPresentations(MainActivity.this).isEmpty()) {
- ImportUtil.importPresentations(MainActivity.this, getAssets().open("ref_import_presentations.csv"));
- }
- dialog.setProgress(8);
- if (DataCache.getAllScientificSpecies(MainActivity.this).isEmpty()) {
- ImportUtil.importScientificSpecies(MainActivity.this, getAssets().open("ref_import_scientific_species.csv"));
- }
- dialog.setProgress(9);
- if (DataCache.getAllStates(MainActivity.this).isEmpty()) {
- ImportUtil.importStates(MainActivity.this, getAssets().open("ref_import_states.csv"));
- }
- dialog.setProgress(10);
- if (DataCache.getAllVessels(MainActivity.this).isEmpty()) {
- ImportUtil.importVessels(MainActivity.this, getAssets().open("ref_import_vessels.csv"));
- }
- dialog.setProgress(11);
-
- } catch (IOException e) {
- Log.e(TAG, "error on initial import", e);
-
- } finally {
- dialog.dismiss();
- }
- }
- }).start();
-
- }
-
- protected void bigfinConnected() {
- disconnectButton.setVisibility(View.VISIBLE);
- connectButton.setVisibility(View.GONE);
- }
-
- protected void bigfinDisconnected() {
- connectButton.setVisibility(View.VISIBLE);
- disconnectButton.setVisibility(View.GONE);
- }
-
-// @Override
-// public synchronized void onResume() {
-// super.onResume();
-//
-// // Performing this check in onResume() covers the case in which BT was
-// // not enabled during onStart(), so we were paused to enable it...
-// // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
-// if (mBFCommunicationService != null) {
-// // Only if the state is STATE_NONE, do we know that we haven't started already
-// if (mBFCommunicationService.getState() == BigFinCommunicationService.STATE_NONE) {
-// // Start the Bluetooth chat services
-// mBFCommunicationService.start();
-// selectDevice();
-// }
-// }
-// }
-
- @Override
- protected Integer getContentView() {
- return R.layout.main;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return null;
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- switch (requestCode) {
- case REQUEST_CONNECT_ICHTYOMETER:
- // When DeviceListActivity returns with a device to connect
-// if (resultCode == Activity.RESULT_OK) {
-// connectDevice(data);
-// }
- break;
-
- case REQUEST_ENABLE_BT:
- // When the request to enable Bluetooth returns
- if (resultCode == Activity.RESULT_OK) {
- // Bluetooth is now enabled, so open the device list
- selectDevice();
-
- } else {
- // User did not enable Bluetooth or an error occurred
- Log.d(TAG, "BT not enabled");
- Toast.makeText(this, R.string.bt_not_enabled, Toast.LENGTH_SHORT).show();
- }
- break;
-
- }
-
- }
-
- public void openContexts(View source) {
- startActivity(new Intent(this, ContextsActivity.class));
- }
-
- public void connectIchtyometer(View source) {
- // If BT is not on, request that it be enabled.
- if (!mBluetoothAdapter.isEnabled()) {
- Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
-
- } else {
- selectDevice();
- }
- }
-
- public void disconnectIchtyometer(View source) {
- Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_DISCONNECT_DEVICE);
- try {
- mServiceMessenger.send(message);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
-
- public void openSettings(View source) {
- startActivity(new Intent(this, SettingsActivity.class));
- }
-
- protected void selectDevice() {
- // Launch the DeviceListActivity to see devices and do scan
- Intent serverIntent = new Intent(this, DeviceListActivity.class);
- startActivityForResult(serverIntent, REQUEST_CONNECT_ICHTYOMETER);
- }
-
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/MainActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/MainActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/MainActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/MainActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,259 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.bluetooth.BluetoothAdapter;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
+import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
+import fr.ifremer.wlo.preferences.SettingsActivity;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+
+import java.io.IOException;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MainActivity extends WloBaseActivity {
+
+ private static final String TAG = "MainActivity";
+
+ protected static final int REQUEST_ENABLE_BT = 1;
+ protected static final int REQUEST_CONNECT_ICHTYOMETER = 2;
+
+ // Local Bluetooth adapter
+ protected BluetoothAdapter mBluetoothAdapter = null;
+
+ protected Button connectButton;
+ protected Button disconnectButton;
+ protected ProgressDialog dialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "create");
+
+ mMessenger = new Messenger(new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case BigFinCommunicationService.MESSAGE_STATE_CHANGE:
+ switch (msg.arg1) {
+ case BigFinCommunicationService.STATE_CONNECTED:
+ bigfinConnected();
+ break;
+
+ case BigFinCommunicationService.STATE_LISTEN:
+ case BigFinCommunicationService.STATE_NONE:
+ bigfinDisconnected();
+ break;
+ }
+ break;
+
+ case BigFinCommunicationService.MESSAGE_CONNECTION_FAILED:
+ case BigFinCommunicationService.MESSAGE_CONNECTION_LOST:
+ bigfinDisconnected();
+ break;
+ }
+ }
+ });
+
+ super.onCreate(savedInstanceState);
+
+ // Get local Bluetooth adapter
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // If the adapter is null, then Bluetooth is not supported
+ if (mBluetoothAdapter == null) {
+ findViewById(R.id.main_connect_ichtyometer_button).setEnabled(false);
+ }
+
+ connectButton = (Button) findViewById(R.id.main_connect_ichtyometer_button);
+ disconnectButton = (Button) findViewById(R.id.main_disconnect_ichtyometer_button);
+ bigfinDisconnected();
+
+ dialog = new ProgressDialog(this);
+ dialog.setIndeterminate(false);
+ dialog.setCancelable(false);
+ dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ dialog.setMax(11);
+ dialog.setMessage(getString(R.string.main_loading_referential));
+ dialog.show();
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (DataCache.getAllAges(MainActivity.this).isEmpty()) {
+ ImportUtil.importAges(MainActivity.this, getAssets().open("ref_import_ages.csv"));
+ }
+ dialog.setProgress(1);
+ if (DataCache.getAllCommercialSpecies(MainActivity.this).isEmpty()) {
+ ImportUtil.importCommercialSpecies(MainActivity.this, getAssets().open("ref_import_commercial_species.csv"));
+ }
+ dialog.setProgress(2);
+ if (DataCache.getAllGenders(MainActivity.this).isEmpty()) {
+ ImportUtil.importGenders(MainActivity.this, getAssets().open("ref_import_genders.csv"));
+ }
+ dialog.setProgress(3);
+ if (DataCache.getAllLocations(MainActivity.this).isEmpty()) {
+ ImportUtil.importLocations(MainActivity.this, getAssets().open("ref_import_locations.csv"));
+ }
+ dialog.setProgress(4);
+ if (DataCache.getAllMaturities(MainActivity.this).isEmpty()) {
+ ImportUtil.importMaturities(MainActivity.this, getAssets().open("ref_import_maturities.csv"));
+ }
+ dialog.setProgress(5);
+ if (DataCache.getAllMensurations(MainActivity.this).isEmpty()) {
+ ImportUtil.importMensurations(MainActivity.this, getAssets().open("ref_import_mensurations.csv"));
+ }
+ dialog.setProgress(6);
+ if (DataCache.getAllMetiers(MainActivity.this).isEmpty()) {
+ ImportUtil.importMetiers(MainActivity.this, getAssets().open("ref_import_metiers.csv"));
+ }
+ dialog.setProgress(7);
+ if (DataCache.getAllPresentations(MainActivity.this).isEmpty()) {
+ ImportUtil.importPresentations(MainActivity.this, getAssets().open("ref_import_presentations.csv"));
+ }
+ dialog.setProgress(8);
+ if (DataCache.getAllScientificSpecies(MainActivity.this).isEmpty()) {
+ ImportUtil.importScientificSpecies(MainActivity.this, getAssets().open("ref_import_scientific_species.csv"));
+ }
+ dialog.setProgress(9);
+ if (DataCache.getAllStates(MainActivity.this).isEmpty()) {
+ ImportUtil.importStates(MainActivity.this, getAssets().open("ref_import_states.csv"));
+ }
+ dialog.setProgress(10);
+ if (DataCache.getAllVessels(MainActivity.this).isEmpty()) {
+ ImportUtil.importVessels(MainActivity.this, getAssets().open("ref_import_vessels.csv"));
+ }
+ dialog.setProgress(11);
+
+ } catch (IOException e) {
+ Log.e(TAG, "error on initial import", e);
+
+ } finally {
+ dialog.dismiss();
+ }
+ }
+ }).start();
+
+ }
+
+ protected void bigfinConnected() {
+ disconnectButton.setVisibility(View.VISIBLE);
+ connectButton.setVisibility(View.GONE);
+ }
+
+ protected void bigfinDisconnected() {
+ connectButton.setVisibility(View.VISIBLE);
+ disconnectButton.setVisibility(View.GONE);
+ }
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.main;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return null;
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ switch (requestCode) {
+ case REQUEST_CONNECT_ICHTYOMETER:
+ // When DeviceListActivity returns with a device to connect
+// if (resultCode == Activity.RESULT_OK) {
+// connectDevice(data);
+// }
+ break;
+
+ case REQUEST_ENABLE_BT:
+ // When the request to enable Bluetooth returns
+ if (resultCode == Activity.RESULT_OK) {
+ // Bluetooth is now enabled, so open the device list
+ selectDevice();
+
+ } else {
+ // User did not enable Bluetooth or an error occurred
+ Log.d(TAG, "BT not enabled");
+ Toast.makeText(this, R.string.bt_not_enabled, Toast.LENGTH_SHORT).show();
+ }
+ break;
+
+ }
+
+ }
+
+ public void openContexts(View source) {
+ startActivity(new Intent(this, ContextsActivity.class));
+ }
+
+ public void connectIchtyometer(View source) {
+ // If BT is not on, request that it be enabled.
+ if (!mBluetoothAdapter.isEnabled()) {
+ Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
+
+ } else {
+ selectDevice();
+ }
+ }
+
+ public void disconnectIchtyometer(View source) {
+ Message message = Message.obtain(null, BigFinCommunicationService.MESSAGE_DISCONNECT_DEVICE);
+ try {
+ mServiceMessenger.send(message);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+
+ public void openSettings(View source) {
+ startActivity(new Intent(this, SettingsActivity.class));
+ }
+
+ protected void selectDevice() {
+ // Launch the DeviceListActivity to see devices and do scan
+ Intent serverIntent = new Intent(this, DeviceListActivity.class);
+ startActivityForResult(serverIntent, REQUEST_CONNECT_ICHTYOMETER);
+ }
+
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MetierFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,56 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.util.Log;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.storage.DataCache;
-
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetierFormActivity extends WloModelEditionActivity<MetierModel> {
-
- private static final String TAG = "MetierFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.metier_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MetiersActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return CommercialSpeciesFormActivity.class;
- }
-
- @Override
- protected MetierModel createNewModel() {
- return new MetierModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // init editors
- List<Metier> metiers = Lists.newArrayList(DataCache.getAllMetiers(this));
- initAutoCompleteTextView(R.id.metier_form_gear_species, MetierModel.COLUMN_GEAR_SPECIES, metiers);
-
- initEditText(R.id.metier_form_zone, MetierModel.COLUMN_ZONE);
- initEditText(R.id.metier_form_sample_row_code, MetierModel.COLUMN_SAMPLE_ROW_CODE);
-
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/MetierFormActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/MetierFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,80 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.util.Log;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.storage.DataCache;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetierFormActivity extends WloModelEditionActivity<MetierModel> {
+
+ private static final String TAG = "MetierFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.metier_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MetiersActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return CommercialSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected MetierModel createNewModel() {
+ return new MetierModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // init editors
+ List<Metier> metiers = Lists.newArrayList(DataCache.getAllMetiers(this));
+ initAutoCompleteTextView(R.id.metier_form_gear_species, MetierModel.COLUMN_GEAR_SPECIES, metiers);
+
+ initEditText(R.id.metier_form_zone, MetierModel.COLUMN_ZONE);
+ initEditText(R.id.metier_form_sample_row_code, MetierModel.COLUMN_SAMPLE_ROW_CODE);
+
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/MetiersActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,65 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetiersActivity extends WloBaseListActivity<MetierModel> {
-
- private static final String TAG = "MetierActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { MetierModel.COLUMN_GEAR_SPECIES },
- new int[] { android.R.id.text1 }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllMetiers(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected MetierModel createNewModel(Cursor cursor) {
- return new MetierModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return MetierFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.metiers_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return VesselsActivity.class;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return CommercialSpeciesActivity.class;
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(1, WloItemListViewBinder.DataType.METIER);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/MetiersActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/MetiersActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,89 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetiersActivity extends WloBaseListActivity<MetierModel> {
+
+ private static final String TAG = "MetierActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { MetierModel.COLUMN_GEAR_SPECIES },
+ new int[] { android.R.id.text1 }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllMetiers(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected MetierModel createNewModel(Cursor cursor) {
+ return new MetierModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return MetierFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.metiers_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return VesselsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return CommercialSpeciesActivity.class;
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(1, WloItemListViewBinder.DataType.METIER);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,93 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.Intent;
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.View;
-import android.widget.ListView;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.measurement.MeasurementActivity;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesActivity extends WloBaseListActivity<ScientificSpeciesModel> {
-
- private static final String TAG = "ScientificSpeciesActivity";
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
- new String[] { ScientificSpeciesModel.COLUMN_NAME },
- new int[] { android.R.id.text1 }, 0);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- CommercialSpeciesModel parent = (CommercialSpeciesModel) parentModel;
- //TODO handle npe
- if (parent == null || parent.isSpeciesMix() || adapter.getCount() == 0) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.model_list_menu, menu);
- }
- return true;
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllScientificSpecies(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected ScientificSpeciesModel createNewModel(Cursor cursor) {
- return new ScientificSpeciesModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return ScientificSpeciesFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.scientific_species_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getNextActivity() {
- return MeasurementActivity.class;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return CommercialSpeciesActivity.class;
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- ScientificSpeciesModel model = createNewModel(l, position);
-
- Log.d(TAG, model.toString(this) + " clicked");
-
- Intent intent = new Intent(this, getNextActivity());
- intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
- startActivity(intent);
- }
-
- @Override
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
- types.put(1, WloItemListViewBinder.DataType.SCIENTIFIC_SPECIES);
- return new WloItemListViewBinder(this, types);
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ScientificSpeciesActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,117 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.View;
+import android.widget.ListView;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.measurement.MeasurementActivity;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesActivity extends WloBaseListActivity<ScientificSpeciesModel> {
+
+ private static final String TAG = "ScientificSpeciesActivity";
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null,
+ new String[] { ScientificSpeciesModel.COLUMN_NAME },
+ new int[] { android.R.id.text1 }, 0);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ CommercialSpeciesModel parent = (CommercialSpeciesModel) parentModel;
+ //TODO handle npe
+ if (parent == null || parent.isSpeciesMix() || adapter.getCount() == 0) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.model_list_menu, menu);
+ }
+ return true;
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllScientificSpecies(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected ScientificSpeciesModel createNewModel(Cursor cursor) {
+ return new ScientificSpeciesModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return ScientificSpeciesFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.scientific_species_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getNextActivity() {
+ return MeasurementActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return CommercialSpeciesActivity.class;
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ ScientificSpeciesModel model = createNewModel(l, position);
+
+ Log.d(TAG, model.toString(this) + " clicked");
+
+ Intent intent = new Intent(this, getNextActivity());
+ intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
+ startActivity(intent);
+ }
+
+ @Override
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ Map<Integer, WloItemListViewBinder.DataType> types = Maps.newHashMap();
+ types.put(1, WloItemListViewBinder.DataType.SCIENTIFIC_SPECIES);
+ return new WloItemListViewBinder(this, types);
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,85 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.measurement.MeasurementActivity;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesFormActivity extends WloModelEditionActivity<ScientificSpeciesModel> {
-
- private static final String TAG = "ScientificSpeciesFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.scientific_species_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ScientificSpeciesActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return null;
- }
-
- @Override
- protected ScientificSpeciesModel createNewModel() {
- return new ScientificSpeciesModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // editors
-
- // init editors
- List<ScientificSpecies> scientificSpecies = Lists.newArrayList(DataCache.getAllScientificSpecies(this));
- initAutoCompleteTextView(R.id.scientific_species_form_name, ScientificSpeciesModel.COLUMN_NAME, scientificSpecies);
-
- CheckBox takingActivationEditor = (CheckBox) findViewById(R.id.scientific_species_form_takingActivation);
- takingActivationEditor.setChecked(model.isTakingActivation());
- takingActivationEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- model.setTakingActivation(b);
- }
- });
- }
-
- @Override
- public void validate(View view) {
- boolean newModel = model.isNew();
-
- WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
- woh.saveData(model);
- woh.close();
-
- if (newModel) {
- Intent intent = new Intent(this, MeasurementActivity.class);
- intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
- startActivity(intent);
-
- } else {
- finish();
- }
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/ScientificSpeciesFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,109 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.measurement.MeasurementActivity;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesFormActivity extends WloModelEditionActivity<ScientificSpeciesModel> {
+
+ private static final String TAG = "ScientificSpeciesFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.scientific_species_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ScientificSpeciesActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return null;
+ }
+
+ @Override
+ protected ScientificSpeciesModel createNewModel() {
+ return new ScientificSpeciesModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // editors
+
+ // init editors
+ List<ScientificSpecies> scientificSpecies = Lists.newArrayList(DataCache.getAllScientificSpecies(this));
+ initAutoCompleteTextView(R.id.scientific_species_form_name, ScientificSpeciesModel.COLUMN_NAME, scientificSpecies);
+
+ CheckBox takingActivationEditor = (CheckBox) findViewById(R.id.scientific_species_form_takingActivation);
+ takingActivationEditor.setChecked(model.isTakingActivation());
+ takingActivationEditor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ model.setTakingActivation(b);
+ }
+ });
+ }
+
+ @Override
+ public void validate(View view) {
+ boolean newModel = model.isNew();
+
+ WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
+ woh.saveData(model);
+ woh.close();
+
+ if (newModel) {
+ Intent intent = new Intent(this, MeasurementActivity.class);
+ intent.putExtra(MeasurementActivity.INTENT_EXTRA_SCIENTIFIC_SPECIES, model);
+ startActivity(intent);
+
+ } else {
+ finish();
+ }
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/VesselFormActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,103 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.TextView;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.HasCode;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Vessel;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.DatePickerFragment;
-import fr.ifremer.wlo.utils.UIUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselFormActivity extends WloModelEditionActivity<VesselModel> {
-
- private static final String TAG = "VesselFormActivity";
-
- @Override
- protected Integer getContentView() {
- return R.layout.vessel_form;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return VesselsActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
- return MetierFormActivity.class;
- }
-
- @Override
- protected VesselModel createNewModel() {
- return new VesselModel();
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // init editors
- Collection<Vessel> vessels = DataCache.getAllVessels(this);
- List<String> vesselCodes = Lists.newArrayList(Collections2.transform(vessels, HasCode.GET_CODE_FUNCTION));
- final Map<String, Vessel> vesselsByCode = Maps.uniqueIndex(vessels, HasCode.GET_CODE_FUNCTION);
- initAutoCompleteTextView(R.id.vessel_form_registration_number, VesselModel.COLUMN_REGISTRATION_NUMBER, vesselCodes);
-
- initEditText(R.id.vessel_form_name, VesselModel.COLUMN_NAME);
-
- List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
- initAutoCompleteTextView(R.id.vessel_form_landing_location, VesselModel.COLUMN_LANDING_LOCATION, locations);
-
- EditText landingDateEditor = (EditText) findViewById(R.id.vessel_form_landing_date);
- // landing date
- Calendar landingDate = model.getLandingDate();
- if (landingDate != null) {
- String dateFormat = UIUtils.getDateFormat(this);
- landingDateEditor.setText(String.format(dateFormat, landingDate.getTime()));
- }
-
- model.addPropertyChangeListener(VesselModel.COLUMN_REGISTRATION_NUMBER, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- Log.d(TAG, "registration number changed ! " + event.getNewValue());
- VesselModel vesselModel = (VesselModel) event.getSource();
- Log.d(TAG, "name " + vesselModel.getName());
- if (StringUtils.isEmpty(vesselModel.getName())) {
- String newCode = (String) event.getNewValue();
- Vessel vessel = vesselsByCode.get(newCode);
- vesselModel.setName(vessel != null ? vessel.getName() : getString(R.string.undefined));
- }
- }
- });
-
- }
-
- /* Method called by the view */
-
- public void pickLandingDate(View v) {
- DialogFragment newFragment = new DatePickerFragment(model, VesselModel.COLUMN_LANDING_DATE, (TextView) v);
- newFragment.show(getSupportFragmentManager(), "datePicker");
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/VesselFormActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/VesselFormActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,127 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.referentials.HasCode;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Vessel;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.DatePickerFragment;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselFormActivity extends WloModelEditionActivity<VesselModel> {
+
+ private static final String TAG = "VesselFormActivity";
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.vessel_form;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return VesselsActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getNextEditionActivity() {
+ return MetierFormActivity.class;
+ }
+
+ @Override
+ protected VesselModel createNewModel() {
+ return new VesselModel();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // init editors
+ Collection<Vessel> vessels = DataCache.getAllVessels(this);
+ List<String> vesselCodes = Lists.newArrayList(Collections2.transform(vessels, HasCode.GET_CODE_FUNCTION));
+ final Map<String, Vessel> vesselsByCode = Maps.uniqueIndex(vessels, HasCode.GET_CODE_FUNCTION);
+ initAutoCompleteTextView(R.id.vessel_form_registration_number, VesselModel.COLUMN_REGISTRATION_NUMBER, vesselCodes);
+
+ initEditText(R.id.vessel_form_name, VesselModel.COLUMN_NAME);
+
+ List<Location> locations = Lists.newArrayList(DataCache.getAllLocations(this));
+ initAutoCompleteTextView(R.id.vessel_form_landing_location, VesselModel.COLUMN_LANDING_LOCATION, locations);
+
+ EditText landingDateEditor = (EditText) findViewById(R.id.vessel_form_landing_date);
+ // landing date
+ Calendar landingDate = model.getLandingDate();
+ if (landingDate != null) {
+ String dateFormat = UIUtils.getDateFormat(this);
+ landingDateEditor.setText(String.format(dateFormat, landingDate.getTime()));
+ }
+
+ model.addPropertyChangeListener(VesselModel.COLUMN_REGISTRATION_NUMBER, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ Log.d(TAG, "registration number changed ! " + event.getNewValue());
+ VesselModel vesselModel = (VesselModel) event.getSource();
+ Log.d(TAG, "name " + vesselModel.getName());
+ if (StringUtils.isEmpty(vesselModel.getName())) {
+ String newCode = (String) event.getNewValue();
+ Vessel vessel = vesselsByCode.get(newCode);
+ vesselModel.setName(vessel != null ? vessel.getName() : getString(R.string.undefined));
+ }
+ }
+ });
+
+ }
+
+ /* Method called by the view */
+
+ public void pickLandingDate(View v) {
+ DialogFragment newFragment = new DatePickerFragment(model, VesselModel.COLUMN_LANDING_DATE, (TextView) v);
+ newFragment.show(getSupportFragmentManager(), "datePicker");
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/VesselsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,54 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import fr.ifremer.wlo.models.VesselModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselsActivity extends WloBaseListActivity<VesselModel> {
-
- private static final String TAG = "VesselsActivity";
-
- /* Activity methods */
-
- @Override
- protected SimpleCursorAdapter createAdapter() {
- return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, null,
- new String[] { VesselModel.COLUMN_REGISTRATION_NUMBER, VesselModel.COLUMN_NAME },
- new int[] { android.R.id.text1, android.R.id.text2 }, 0);
- }
-
- @Override
- protected Cursor getAllData() {
- Cursor cursor = woh.getAllVessels(parentModel.getId());
- return cursor;
- }
-
- @Override
- protected VesselModel createNewModel(Cursor cursor) {
- return new VesselModel(this, cursor);
- }
-
- @Override
- protected Class<? extends WloBaseListActivity> getNextActivity() {
- return MetiersActivity.class;
- }
-
- @Override
- protected Class<? extends WloModelEditionActivity> getEditionActivity() {
- return VesselFormActivity.class;
- }
-
- @Override
- protected Integer getSubtitle() {
- return R.string.vessels_subtitle;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return LocationsActivity.class;
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/VesselsActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/VesselsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,78 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import fr.ifremer.wlo.models.VesselModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselsActivity extends WloBaseListActivity<VesselModel> {
+
+ private static final String TAG = "VesselsActivity";
+
+ /* Activity methods */
+
+ @Override
+ protected SimpleCursorAdapter createAdapter() {
+ return new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, null,
+ new String[] { VesselModel.COLUMN_REGISTRATION_NUMBER, VesselModel.COLUMN_NAME },
+ new int[] { android.R.id.text1, android.R.id.text2 }, 0);
+ }
+
+ @Override
+ protected Cursor getAllData() {
+ Cursor cursor = woh.getAllVessels(parentModel.getId());
+ return cursor;
+ }
+
+ @Override
+ protected VesselModel createNewModel(Cursor cursor) {
+ return new VesselModel(this, cursor);
+ }
+
+ @Override
+ protected Class<? extends WloBaseListActivity> getNextActivity() {
+ return MetiersActivity.class;
+ }
+
+ @Override
+ protected Class<? extends WloModelEditionActivity> getEditionActivity() {
+ return VesselFormActivity.class;
+ }
+
+ @Override
+ protected Integer getSubtitle() {
+ return R.string.vessels_subtitle;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return LocationsActivity.class;
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloBaseActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,107 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
-import android.util.Log;
-import android.view.View;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class WloBaseActivity extends ActionBarActivity implements ServiceConnection {
-
- private static final String TAG = "WloBaseActivity";
-
- protected Messenger mServiceMessenger = null;
- protected Messenger mMessenger = null;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Integer viewId = getContentView();
- if (viewId != null) {
- setContentView(viewId);
- }
-
- ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
-
- bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
- }
-
- @Override
- protected void onDestroy() {
- Log.d(TAG, "destroy");
- super.onDestroy();
- doUnbindService();
- }
-
- protected void doUnbindService() {
- Log.d(TAG, "doUnbindService");
- // If we have received the service, and hence registered with it, then now is the time to unregister.
- if (mServiceMessenger != null && mMessenger != null) {
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
-
- } catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
- // Detach our existing connection.
- unbindService(this);
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mServiceMessenger = new Messenger(service);
- Log.d(TAG, "mMessenger " + mMessenger);
- if (mMessenger != null) {
- try {
- Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
- msg.replyTo = mMessenger;
- mServiceMessenger.send(msg);
- }
- catch (RemoteException e) {
- Log.e(TAG, "Error while sending data to the service");
- }
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- Log.d(TAG, "onServiceDisconnected");
- mServiceMessenger = null;
- }
-
- public void cancel(View view) {
- setResult(RESULT_CANCELED);
- finish();
- }
-
- protected abstract Integer getContentView();
-
- protected abstract Class<? extends WloBaseActivity> getUpActivity();
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Class upClass = getUpActivity();
- if (upClass == null) {
- return null;
- }
- Intent intent = new Intent(this, upClass);
- return intent;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/WloBaseActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/WloBaseActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,131 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
+import android.util.Log;
+import android.view.View;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class WloBaseActivity extends ActionBarActivity implements ServiceConnection {
+
+ private static final String TAG = "WloBaseActivity";
+
+ protected Messenger mServiceMessenger = null;
+ protected Messenger mMessenger = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Integer viewId = getContentView();
+ if (viewId != null) {
+ setContentView(viewId);
+ }
+
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ bindService(new Intent(this, BigFinCommunicationService.class), this, Context.BIND_AUTO_CREATE);
+ }
+
+ @Override
+ protected void onDestroy() {
+ Log.d(TAG, "destroy");
+ super.onDestroy();
+ doUnbindService();
+ }
+
+ protected void doUnbindService() {
+ Log.d(TAG, "doUnbindService");
+ // If we have received the service, and hence registered with it, then now is the time to unregister.
+ if (mServiceMessenger != null && mMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_UNREGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ // Detach our existing connection.
+ unbindService(this);
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mServiceMessenger = new Messenger(service);
+ Log.d(TAG, "mMessenger " + mMessenger);
+ if (mMessenger != null) {
+ try {
+ Message msg = Message.obtain(null, BigFinCommunicationService.MESSAGE_REGISTER_CLIENT);
+ msg.replyTo = mMessenger;
+ mServiceMessenger.send(msg);
+ }
+ catch (RemoteException e) {
+ Log.e(TAG, "Error while sending data to the service");
+ }
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.d(TAG, "onServiceDisconnected");
+ mServiceMessenger = null;
+ }
+
+ public void cancel(View view) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
+ protected abstract Integer getContentView();
+
+ protected abstract Class<? extends WloBaseActivity> getUpActivity();
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Class upClass = getUpActivity();
+ if (upClass == null) {
+ return null;
+ }
+ Intent intent = new Intent(this, upClass);
+ return intent;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,445 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package fr.ifremer.wlo;
-
-import android.content.Intent;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.os.Handler;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.HierarchicalModel;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.utils.WloItemListViewBinder;
-
-/**
- * An activity that displays a list of items by binding to a data source such as
- * an array or Cursor, and exposes event handlers when the user selects an item.
- * <p>
- * ListActivity hosts a {@link android.widget.ListView ListView} object that can
- * be bound to different data sources, typically either an array or a Cursor
- * holding query results. Binding, screen layout, and row layout are discussed
- * in the following sections.
- * <p>
- * <strong>Screen Layout</strong>
- * </p>
- * <p>
- * ListActivity has a default layout that consists of a single, full-screen list
- * in the center of the screen. However, if you desire, you can customize the
- * screen layout by setting your own view layout with setContentView() in
- * onCreate(). To do this, your own view MUST contain a ListView object with the
- * id "@android:id/list" (or {@link android.R.id#list} if it's in code)
- * <p>
- * Optionally, your custom view can contain another view object of any type to
- * display when the list view is empty. This "empty list" notifier must have an
- * id "android:empty". Note that when an empty view is present, the list view
- * will be hidden when there is no data to display.
- * <p>
- * The following code demonstrates an (ugly) custom screen layout. It has a list
- * with a green background, and an alternate red "no data" message.
- * </p>
- *
- * <pre>
- * <?xml version="1.0" encoding="utf-8"?>
- * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- * android:orientation="vertical"
- * android:layout_width="fill_parent"
- * android:layout_height="fill_parent"
- * android:paddingLeft="8dp"
- * android:paddingRight="8dp">
- *
- * <ListView android:id="@id/android:list"
- * android:layout_width="fill_parent"
- * android:layout_height="fill_parent"
- * android:background="#00FF00"
- * android:layout_weight="1"
- * android:drawSelectorOnTop="false"/>
- *
- * <TextView id="@id/android:empty"
- * android:layout_width="fill_parent"
- * android:layout_height="fill_parent"
- * android:background="#FF0000"
- * android:text="No data"/>
- * </LinearLayout>
- * </pre>
- *
- * <p>
- * <strong>Row Layout</strong>
- * </p>
- * <p>
- * You can specify the layout of individual rows in the list. You do this by
- * specifying a layout resource in the ListAdapter object hosted by the activity
- * (the ListAdapter binds the ListView to the data; more on this later).
- * <p>
- * A ListAdapter constructor takes a parameter that specifies a layout resource
- * for each row. It also has two additional parameters that let you specify
- * which data field to associate with which object in the row layout resource.
- * These two parameters are typically parallel arrays.
- * </p>
- * <p>
- * Android provides some standard row layout resources. These are in the
- * {@link android.R.layout} class, and have names such as simple_list_item_1,
- * simple_list_item_2, and two_line_list_item. The following layout XML is the
- * source for the resource two_line_list_item, which displays two data
- * fields,one above the other, for each list row.
- * </p>
- *
- * <pre>
- * <?xml version="1.0" encoding="utf-8"?>
- * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- * android:layout_width="fill_parent"
- * android:layout_height="wrap_content"
- * android:orientation="vertical">
- *
- * <TextView android:id="@+id/text1"
- * android:textSize="16sp"
- * android:textStyle="bold"
- * android:layout_width="fill_parent"
- * android:layout_height="wrap_content"/>
- *
- * <TextView android:id="@+id/text2"
- * android:textSize="16sp"
- * android:layout_width="fill_parent"
- * android:layout_height="wrap_content"/>
- * </LinearLayout>
- * </pre>
- *
- * <p>
- * You must identify the data bound to each TextView object in this layout. The
- * syntax for this is discussed in the next section.
- * </p>
- * <p>
- * <strong>Binding to Data</strong>
- * </p>
- * <p>
- * You bind the ListActivity's ListView object to data using a class that
- * implements the {@link android.widget.ListAdapter ListAdapter} interface.
- * Android provides two standard list adapters:
- * {@link android.widget.SimpleAdapter SimpleAdapter} for static data (Maps),
- * and {@link android.widget.SimpleCursorAdapter SimpleCursorAdapter} for Cursor
- * query results.
- * </p>
- * <p>
- * The following code from a custom ListActivity demonstrates querying the
- * Contacts provider for all contacts, then binding the Name and Company fields
- * to a two line row layout in the activity's ListView.
- * </p>
- *
- * <pre>
- * public class MyListAdapter extends ListActivity {
- *
- * @Override
- * protected void onCreate(Bundle savedInstanceState){
- * super.onCreate(savedInstanceState);
- *
- * // We'll define a custom screen layout here (the one shown above), but
- * // typically, you could just use the standard ListActivity layout.
- * setContentView(R.layout.custom_list_activity_view);
- *
- * // Query for all people contacts using the {@link android.provider.Contacts.People} convenience class.
- * // Put a managed wrapper around the retrieved cursor so we don't have to worry about
- * // requerying or closing it as the activity changes state.
- * mCursor = People.query(this.getContentResolver(), null);
- * startManagingCursor(mCursor);
- *
- * // Now create a new list adapter bound to the cursor.
- * // SimpleListAdapter is designed for binding to a Cursor.
- * ListAdapter adapter = new SimpleCursorAdapter(
- * this, // Context.
- * android.R.layout.two_line_list_item, // Specify the row template to use (here, two columns bound to the two retrieved cursor
- * rows).
- * mCursor, // Pass in the cursor to bind to.
- * new String[] {People.NAME, People.COMPANY}, // Array of cursor columns to bind to.
- * new int[]); // Parallel array of which template objects to bind to those columns.
- *
- * // Bind to our new adapter.
- * setListAdapter(adapter);
- * }
- * }
- * </pre>
- *
- * @see #setListAdapter
- * @see android.widget.ListView
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class WloBaseListActivity<M extends BaseModel> extends WloBaseActivity implements AdapterView.OnItemLongClickListener {
-
- private static final String TAG = "WloBaseListActivity";
-
- public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
-
- protected BaseModel parentModel;
-
- protected WloSqlOpenHelper woh;
- protected SimpleCursorAdapter adapter;
-
- /**
- * This field should be made private, so it is hidden from the SDK.
- * {@hide}
- */
- protected ListView mList;
-
- private Handler mHandler = new Handler();
- private boolean mFinishedStart = false;
-
- private Runnable mRequestFocus = new Runnable() {
- public void run() {
- mList.focusableViewAvailable(mList);
- }
- };
-
- protected abstract SimpleCursorAdapter createAdapter();
-
- protected abstract Cursor getAllData();
-
- protected abstract M createNewModel(Cursor cursor);
-
- protected M createNewModel(AdapterView l, int position) {
- Cursor cursor = (Cursor) l.getItemAtPosition(position);
- M model = createNewModel(cursor);
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- hModel.setParent(parentModel);
- }
- return model;
- }
-
- protected abstract Class<? extends WloBaseActivity> getNextActivity();
-
- protected abstract Class<? extends WloModelEditionActivity> getEditionActivity();
-
- protected abstract Integer getSubtitle();
-
- @Override
- protected Integer getContentView() {
- return android.R.layout.list_content;
- }
-
- protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
- return new WloItemListViewBinder(this);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- woh = new WloSqlOpenHelper(this);
- adapter = createAdapter();
-
- adapter.setViewBinder(getAdapterBinder());
-
- setListAdapter(adapter);
- getListView().setOnItemLongClickListener(this);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- parentModel = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
- if (parentModel != null) {
- Cursor cursor = getAllData();
- Log.d(TAG, "cursor size : " + cursor.getCount());
- adapter.swapCursor(cursor);
-
- Integer subtitleId = getSubtitle();
- if (subtitleId != null) {
- String subtitle = getString(subtitleId, parentModel.toString(this));
- getSupportActionBar().setSubtitle(subtitle);
- }
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- woh.close();
- }
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Intent intent = super.getSupportParentActivityIntent();
- if (intent != null && parentModel != null && HierarchicalModel.class.isAssignableFrom(parentModel.getClass())) {
- HierarchicalModel hParentModel = (HierarchicalModel) parentModel;
- intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hParentModel.getParent());
- }
- return intent;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.model_list_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.add_item:
- Intent intent = new Intent(this, getEditionActivity());
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
- startActivity(intent);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- /**
- * This method will be called when an item in the list is selected.
- * Subclasses should override. Subclasses can call
- * getListView().getItemAtPosition(position) if they need to access the
- * data associated with the selected item.
- *
- * @param l The ListView where the click happened
- * @param v The view that was clicked within the ListView
- * @param position The position of the view in the list
- * @param id The row id of the item that was clicked
- */
- protected void onListItemClick(ListView l, View v, int position, long id) {
- M model = createNewModel(l, position);
-
- Log.d(TAG, model.toString(this) + " clicked");
-
- Intent intent = new Intent(this, getNextActivity());
- intent.putExtra(INTENT_EXTRA_PARENT_MODEL, model);
- startActivity(intent);
- }
-
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
- M model = createNewModel(parent, position);
-
- Log.d(TAG, model.toString(this) + " long clicked");
- Intent intent = new Intent(this, getEditionActivity());
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
- startActivity(intent);
- return true;
- }
-
- /**
- * Ensures the list view has been created before Activity restores all
- * of the view states.
- *
- */
- @Override
- protected void onRestoreInstanceState(Bundle state) {
- ensureList();
- super.onRestoreInstanceState(state);
- }
-
- /**
- * Updates the screen state (current list and other views) when the
- * content changes.
- *
- */
- @Override
- public void onSupportContentChanged() {
- super.onSupportContentChanged();
- View emptyView = findViewById(android.R.id.empty);
- mList = (ListView)findViewById(android.R.id.list);
- if (mList == null) {
- throw new RuntimeException(
- "Your content must have a ListView whose id attribute is " +
- "'android.R.id.list'");
- }
- if (emptyView != null) {
- mList.setEmptyView(emptyView);
- }
- mList.setOnItemClickListener(mOnClickListener);
- if (mFinishedStart) {
- setListAdapter(adapter);
- }
- mHandler.post(mRequestFocus);
- mFinishedStart = true;
- }
-
- /**
- * Provide the cursor for the list view.
- */
- public void setListAdapter(SimpleCursorAdapter adapter) {
- synchronized (this) {
- ensureList();
- this.adapter = adapter;
- mList.setAdapter(adapter);
- }
- }
-
- /**
- * Set the currently selected list item to the specified
- * position with the adapter's data
- *
- * @param position
- */
- public void setSelection(int position) {
- mList.setSelection(position);
- }
-
- /**
- * Get the position of the currently selected list item.
- */
- public int getSelectedItemPosition() {
- return mList.getSelectedItemPosition();
- }
-
- /**
- * Get the cursor row ID of the currently selected list item.
- */
- public long getSelectedItemId() {
- return mList.getSelectedItemId();
- }
-
- /**
- * Get the activity's list view widget.
- */
- public ListView getListView() {
- ensureList();
- return mList;
- }
-
- /**
- * Get the ListAdapter associated with this activity's ListView.
- */
- public ListAdapter getListAdapter() {
- return adapter;
- }
-
- private void ensureList() {
- if (mList != null) {
- return;
- }
- setContentView(android.R.layout.list_content);
-
- }
-
- private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView parent, View v, int position, long id)
- {
- onListItemClick((ListView)parent, v, position, id);
- }
- };
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/WloBaseListActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/WloBaseListActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,469 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.HierarchicalModel;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.WloItemListViewBinder;
+
+/**
+ * An activity that displays a list of items by binding to a data source such as
+ * an array or Cursor, and exposes event handlers when the user selects an item.
+ * <p>
+ * ListActivity hosts a {@link android.widget.ListView ListView} object that can
+ * be bound to different data sources, typically either an array or a Cursor
+ * holding query results. Binding, screen layout, and row layout are discussed
+ * in the following sections.
+ * <p>
+ * <strong>Screen Layout</strong>
+ * </p>
+ * <p>
+ * ListActivity has a default layout that consists of a single, full-screen list
+ * in the center of the screen. However, if you desire, you can customize the
+ * screen layout by setting your own view layout with setContentView() in
+ * onCreate(). To do this, your own view MUST contain a ListView object with the
+ * id "@android:id/list" (or {@link android.R.id#list} if it's in code)
+ * <p>
+ * Optionally, your custom view can contain another view object of any type to
+ * display when the list view is empty. This "empty list" notifier must have an
+ * id "android:empty". Note that when an empty view is present, the list view
+ * will be hidden when there is no data to display.
+ * <p>
+ * The following code demonstrates an (ugly) custom screen layout. It has a list
+ * with a green background, and an alternate red "no data" message.
+ * </p>
+ *
+ * <pre>
+ * <?xml version="1.0" encoding="utf-8"?>
+ * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ * android:orientation="vertical"
+ * android:layout_width="fill_parent"
+ * android:layout_height="fill_parent"
+ * android:paddingLeft="8dp"
+ * android:paddingRight="8dp">
+ *
+ * <ListView android:id="@id/android:list"
+ * android:layout_width="fill_parent"
+ * android:layout_height="fill_parent"
+ * android:background="#00FF00"
+ * android:layout_weight="1"
+ * android:drawSelectorOnTop="false"/>
+ *
+ * <TextView id="@id/android:empty"
+ * android:layout_width="fill_parent"
+ * android:layout_height="fill_parent"
+ * android:background="#FF0000"
+ * android:text="No data"/>
+ * </LinearLayout>
+ * </pre>
+ *
+ * <p>
+ * <strong>Row Layout</strong>
+ * </p>
+ * <p>
+ * You can specify the layout of individual rows in the list. You do this by
+ * specifying a layout resource in the ListAdapter object hosted by the activity
+ * (the ListAdapter binds the ListView to the data; more on this later).
+ * <p>
+ * A ListAdapter constructor takes a parameter that specifies a layout resource
+ * for each row. It also has two additional parameters that let you specify
+ * which data field to associate with which object in the row layout resource.
+ * These two parameters are typically parallel arrays.
+ * </p>
+ * <p>
+ * Android provides some standard row layout resources. These are in the
+ * {@link android.R.layout} class, and have names such as simple_list_item_1,
+ * simple_list_item_2, and two_line_list_item. The following layout XML is the
+ * source for the resource two_line_list_item, which displays two data
+ * fields,one above the other, for each list row.
+ * </p>
+ *
+ * <pre>
+ * <?xml version="1.0" encoding="utf-8"?>
+ * <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ * android:layout_width="fill_parent"
+ * android:layout_height="wrap_content"
+ * android:orientation="vertical">
+ *
+ * <TextView android:id="@+id/text1"
+ * android:textSize="16sp"
+ * android:textStyle="bold"
+ * android:layout_width="fill_parent"
+ * android:layout_height="wrap_content"/>
+ *
+ * <TextView android:id="@+id/text2"
+ * android:textSize="16sp"
+ * android:layout_width="fill_parent"
+ * android:layout_height="wrap_content"/>
+ * </LinearLayout>
+ * </pre>
+ *
+ * <p>
+ * You must identify the data bound to each TextView object in this layout. The
+ * syntax for this is discussed in the next section.
+ * </p>
+ * <p>
+ * <strong>Binding to Data</strong>
+ * </p>
+ * <p>
+ * You bind the ListActivity's ListView object to data using a class that
+ * implements the {@link android.widget.ListAdapter ListAdapter} interface.
+ * Android provides two standard list adapters:
+ * {@link android.widget.SimpleAdapter SimpleAdapter} for static data (Maps),
+ * and {@link android.widget.SimpleCursorAdapter SimpleCursorAdapter} for Cursor
+ * query results.
+ * </p>
+ * <p>
+ * The following code from a custom ListActivity demonstrates querying the
+ * Contacts provider for all contacts, then binding the Name and Company fields
+ * to a two line row layout in the activity's ListView.
+ * </p>
+ *
+ * <pre>
+ * public class MyListAdapter extends ListActivity {
+ *
+ * @Override
+ * protected void onCreate(Bundle savedInstanceState){
+ * super.onCreate(savedInstanceState);
+ *
+ * // We'll define a custom screen layout here (the one shown above), but
+ * // typically, you could just use the standard ListActivity layout.
+ * setContentView(R.layout.custom_list_activity_view);
+ *
+ * // Query for all people contacts using the {@link android.provider.Contacts.People} convenience class.
+ * // Put a managed wrapper around the retrieved cursor so we don't have to worry about
+ * // requerying or closing it as the activity changes state.
+ * mCursor = People.query(this.getContentResolver(), null);
+ * startManagingCursor(mCursor);
+ *
+ * // Now create a new list adapter bound to the cursor.
+ * // SimpleListAdapter is designed for binding to a Cursor.
+ * ListAdapter adapter = new SimpleCursorAdapter(
+ * this, // Context.
+ * android.R.layout.two_line_list_item, // Specify the row template to use (here, two columns bound to the two retrieved cursor
+ * rows).
+ * mCursor, // Pass in the cursor to bind to.
+ * new String[] {People.NAME, People.COMPANY}, // Array of cursor columns to bind to.
+ * new int[]); // Parallel array of which template objects to bind to those columns.
+ *
+ * // Bind to our new adapter.
+ * setListAdapter(adapter);
+ * }
+ * }
+ * </pre>
+ *
+ * @see #setListAdapter
+ * @see android.widget.ListView
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class WloBaseListActivity<M extends BaseModel> extends WloBaseActivity implements AdapterView.OnItemLongClickListener {
+
+ private static final String TAG = "WloBaseListActivity";
+
+ public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
+
+ protected BaseModel parentModel;
+
+ protected WloSqlOpenHelper woh;
+ protected SimpleCursorAdapter adapter;
+
+ /**
+ * This field should be made private, so it is hidden from the SDK.
+ * {@hide}
+ */
+ protected ListView mList;
+
+ private Handler mHandler = new Handler();
+ private boolean mFinishedStart = false;
+
+ private Runnable mRequestFocus = new Runnable() {
+ public void run() {
+ mList.focusableViewAvailable(mList);
+ }
+ };
+
+ protected abstract SimpleCursorAdapter createAdapter();
+
+ protected abstract Cursor getAllData();
+
+ protected abstract M createNewModel(Cursor cursor);
+
+ protected M createNewModel(AdapterView l, int position) {
+ Cursor cursor = (Cursor) l.getItemAtPosition(position);
+ M model = createNewModel(cursor);
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ hModel.setParent(parentModel);
+ }
+ return model;
+ }
+
+ protected abstract Class<? extends WloBaseActivity> getNextActivity();
+
+ protected abstract Class<? extends WloModelEditionActivity> getEditionActivity();
+
+ protected abstract Integer getSubtitle();
+
+ @Override
+ protected Integer getContentView() {
+ return android.R.layout.list_content;
+ }
+
+ protected SimpleCursorAdapter.ViewBinder getAdapterBinder() {
+ return new WloItemListViewBinder(this);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ woh = new WloSqlOpenHelper(this);
+ adapter = createAdapter();
+
+ adapter.setViewBinder(getAdapterBinder());
+
+ setListAdapter(adapter);
+ getListView().setOnItemLongClickListener(this);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ parentModel = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
+ if (parentModel != null) {
+ Cursor cursor = getAllData();
+ Log.d(TAG, "cursor size : " + cursor.getCount());
+ adapter.swapCursor(cursor);
+
+ Integer subtitleId = getSubtitle();
+ if (subtitleId != null) {
+ String subtitle = getString(subtitleId, parentModel.toString(this));
+ getSupportActionBar().setSubtitle(subtitle);
+ }
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ woh.close();
+ }
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Intent intent = super.getSupportParentActivityIntent();
+ if (intent != null && parentModel != null && HierarchicalModel.class.isAssignableFrom(parentModel.getClass())) {
+ HierarchicalModel hParentModel = (HierarchicalModel) parentModel;
+ intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hParentModel.getParent());
+ }
+ return intent;
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.model_list_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.add_item:
+ Intent intent = new Intent(this, getEditionActivity());
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
+ startActivity(intent);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * This method will be called when an item in the list is selected.
+ * Subclasses should override. Subclasses can call
+ * getListView().getItemAtPosition(position) if they need to access the
+ * data associated with the selected item.
+ *
+ * @param l The ListView where the click happened
+ * @param v The view that was clicked within the ListView
+ * @param position The position of the view in the list
+ * @param id The row id of the item that was clicked
+ */
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ M model = createNewModel(l, position);
+
+ Log.d(TAG, model.toString(this) + " clicked");
+
+ Intent intent = new Intent(this, getNextActivity());
+ intent.putExtra(INTENT_EXTRA_PARENT_MODEL, model);
+ startActivity(intent);
+ }
+
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ M model = createNewModel(parent, position);
+
+ Log.d(TAG, model.toString(this) + " long clicked");
+ Intent intent = new Intent(this, getEditionActivity());
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
+ startActivity(intent);
+ return true;
+ }
+
+ /**
+ * Ensures the list view has been created before Activity restores all
+ * of the view states.
+ *
+ */
+ @Override
+ protected void onRestoreInstanceState(Bundle state) {
+ ensureList();
+ super.onRestoreInstanceState(state);
+ }
+
+ /**
+ * Updates the screen state (current list and other views) when the
+ * content changes.
+ *
+ */
+ @Override
+ public void onSupportContentChanged() {
+ super.onSupportContentChanged();
+ View emptyView = findViewById(android.R.id.empty);
+ mList = (ListView)findViewById(android.R.id.list);
+ if (mList == null) {
+ throw new RuntimeException(
+ "Your content must have a ListView whose id attribute is " +
+ "'android.R.id.list'");
+ }
+ if (emptyView != null) {
+ mList.setEmptyView(emptyView);
+ }
+ mList.setOnItemClickListener(mOnClickListener);
+ if (mFinishedStart) {
+ setListAdapter(adapter);
+ }
+ mHandler.post(mRequestFocus);
+ mFinishedStart = true;
+ }
+
+ /**
+ * Provide the cursor for the list view.
+ */
+ public void setListAdapter(SimpleCursorAdapter adapter) {
+ synchronized (this) {
+ ensureList();
+ this.adapter = adapter;
+ mList.setAdapter(adapter);
+ }
+ }
+
+ /**
+ * Set the currently selected list item to the specified
+ * position with the adapter's data
+ *
+ * @param position
+ */
+ public void setSelection(int position) {
+ mList.setSelection(position);
+ }
+
+ /**
+ * Get the position of the currently selected list item.
+ */
+ public int getSelectedItemPosition() {
+ return mList.getSelectedItemPosition();
+ }
+
+ /**
+ * Get the cursor row ID of the currently selected list item.
+ */
+ public long getSelectedItemId() {
+ return mList.getSelectedItemId();
+ }
+
+ /**
+ * Get the activity's list view widget.
+ */
+ public ListView getListView() {
+ ensureList();
+ return mList;
+ }
+
+ /**
+ * Get the ListAdapter associated with this activity's ListView.
+ */
+ public ListAdapter getListAdapter() {
+ return adapter;
+ }
+
+ private void ensureList() {
+ if (mList != null) {
+ return;
+ }
+ setContentView(android.R.layout.list_content);
+
+ }
+
+ private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView parent, View v, int position, long id)
+ {
+ onListItemClick((ListView)parent, v, position, id);
+ }
+ };
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,262 +0,0 @@
-package fr.ifremer.wlo;
-
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.EditText;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.HierarchicalModel;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.utils.BaseTextWatcher;
-import fr.ifremer.wlo.utils.UIUtils;
-import org.apache.commons.lang3.ObjectUtils;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class WloModelEditionActivity<M extends BaseModel> extends WloBaseActivity {
-
- private static final String TAG = "WloModelEditionActivity";
-
- public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
- public static final String INTENT_EXTRA_MODEL = "model";
-
- protected M model;
-
- protected abstract Class<? extends WloModelEditionActivity> getNextEditionActivity();
-
- protected abstract M createNewModel();
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- Log.d(TAG, "on create");
- super.onCreate(savedInstanceState);
-
- // model
- model = (M) getIntent().getSerializableExtra(INTENT_EXTRA_MODEL);
- if (model == null) {
- model = createNewModel();
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- BaseModel parent = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
- HierarchicalModel hModel = (HierarchicalModel) model;
- hModel.setParent(parent);
- }
-
- } else {
- setTitle(model.toString(this));
- }
- }
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Intent intent = super.getSupportParentActivityIntent();
- if (intent != null && HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hModel.getParent());
- }
- return intent;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.form_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.new_item:
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == AlertDialog.BUTTON_POSITIVE) {
- saveModel();
- }
- Intent intent = new Intent(WloModelEditionActivity.this, WloModelEditionActivity.this.getClass());
- if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
- HierarchicalModel hModel = (HierarchicalModel) model;
- BaseModel parentModel = hModel.getParent();
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
- }
- startActivity(intent);
- }
- };
- builder.setMessage(R.string.exit_form_confirmation)
- .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener())
- .setNeutralButton(R.string.no, listener)
- .setPositiveButton(R.string.yes, listener)
- .create()
- .show();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
-
- /* Method called by the view */
-
- public void validate(View view) {
- boolean newModel = model.isNew();
-
- Multimap<BaseModel.ErrorType, String> errors = model.checkValidity();
-
- if (errors.isEmpty()) {
- saveModel();
-
- if (newModel) {
- Intent intent = new Intent(this, getNextEditionActivity());
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, model);
- startActivity(intent);
-
- } else {
- Intent intent = new Intent();
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
- setResult(RESULT_OK, intent);
- finish();
- }
-
- } else {
- View root = findViewById(android.R.id.content);
-
- Collection<String> requiredFields = errors.get(BaseModel.ErrorType.REQUIRED);
- String errorMessage = getString(R.string.required_field_error_message);
- for (String field : requiredFields) {
- View v = root.findViewWithTag(field);
- if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
- ((EditText) v).setError(errorMessage);
- }
- }
-
- Collection<String> oneRequiredFields = errors.get(BaseModel.ErrorType.ONE_REQUIRED);
- errorMessage = getString(R.string.one_required_field_error_message);
- for (String field : oneRequiredFields) {
- View v = root.findViewWithTag(field);
- if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
- ((EditText) v).setError(errorMessage);
- }
- }
- }
- }
-
- /* Protected methods */
-
- protected void saveModel() {
- WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
- woh.saveData(model);
- woh.close();
- }
-
- protected void initEditText(int editorId, final String attribute) {
- initEditText(editorId, attribute, null);
- }
-
- protected void initEditText(int editorId, final String attribute, String defaultValue) {
- EditText editText = (EditText) findViewById(editorId);
- initEditText(editText, attribute, defaultValue);
- }
-
- protected void initEditText(final EditText editText, final String attribute, String defaultValue) {
- final Class clazz = model.getClass();
- final String firtsLetterUpperCaseAttribute =
- attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
-
- editText.setTag(attribute);
-
- try {
- Object value = clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
- editText.setText(value != null ? value.toString() : defaultValue);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
-
- editText.addTextChangedListener(new BaseTextWatcher() {
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- try {
- clazz.getMethod("set" + firtsLetterUpperCaseAttribute, String.class).invoke(model, s.toString());
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
- editText.setError(null);
- }
- });
-
- model.addPropertyChangeListener(attribute, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- Object newValue = event.getNewValue();
- if (!editText.isFocused()) {
- editText.setText(newValue != null ? newValue.toString() : getString(R.string.undefined));
- editText.setError(null);
- }
- }
- });
- }
-
- protected <R> AutoCompleteTextView initAutoCompleteTextView(int autoCompleteTextViewId, final String attribute, Collection<R> data) {
- AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(autoCompleteTextViewId);
- initAutoCompleteTextView(autoCompleteTextView, attribute, data);
- return autoCompleteTextView;
- }
-
- protected <R> void initAutoCompleteTextView(AutoCompleteTextView autoCompleteTextView, final String attribute, Collection<R> data) {
- final Class clazz = model.getClass();
- final String firtsLetterUpperCaseAttribute =
- attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
-
- ArrayAdapter<R> adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, Lists.newArrayList(data));
- autoCompleteTextView.setAdapter(adapter);
-
- autoCompleteTextView.setThreshold(0);
- autoCompleteTextView.setTag(attribute);
-
- try {
- R value = (R) clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
- if (value != null) {
- autoCompleteTextView.setText(value.toString());
- autoCompleteTextView.setError(null);
- }
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
-
- autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- R selectedData = (R) parent.getItemAtPosition(position);
- try {
- clazz.getMethod("set" + firtsLetterUpperCaseAttribute, selectedData.getClass()).invoke(model, selectedData);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
- }
- }
- });
-
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/WloModelEditionActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/WloModelEditionActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,286 @@
+package fr.ifremer.wlo;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.EditText;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.HierarchicalModel;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.BaseTextWatcher;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class WloModelEditionActivity<M extends BaseModel> extends WloBaseActivity {
+
+ private static final String TAG = "WloModelEditionActivity";
+
+ public static final String INTENT_EXTRA_PARENT_MODEL = "parentModel";
+ public static final String INTENT_EXTRA_MODEL = "model";
+
+ protected M model;
+
+ protected abstract Class<? extends WloModelEditionActivity> getNextEditionActivity();
+
+ protected abstract M createNewModel();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "on create");
+ super.onCreate(savedInstanceState);
+
+ // model
+ model = (M) getIntent().getSerializableExtra(INTENT_EXTRA_MODEL);
+ if (model == null) {
+ model = createNewModel();
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ BaseModel parent = (BaseModel) getIntent().getSerializableExtra(INTENT_EXTRA_PARENT_MODEL);
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ hModel.setParent(parent);
+ }
+
+ } else {
+ setTitle(model.toString(this));
+ }
+ }
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Intent intent = super.getSupportParentActivityIntent();
+ if (intent != null && HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ intent.putExtra(WloBaseListActivity.INTENT_EXTRA_PARENT_MODEL, hModel.getParent());
+ }
+ return intent;
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.form_menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.new_item:
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == AlertDialog.BUTTON_POSITIVE) {
+ saveModel();
+ }
+ Intent intent = new Intent(WloModelEditionActivity.this, WloModelEditionActivity.this.getClass());
+ if (HierarchicalModel.class.isAssignableFrom(model.getClass())) {
+ HierarchicalModel hModel = (HierarchicalModel) model;
+ BaseModel parentModel = hModel.getParent();
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, parentModel);
+ }
+ startActivity(intent);
+ }
+ };
+ builder.setMessage(R.string.exit_form_confirmation)
+ .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener())
+ .setNeutralButton(R.string.no, listener)
+ .setPositiveButton(R.string.yes, listener)
+ .create()
+ .show();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ /* Method called by the view */
+
+ public void validate(View view) {
+ boolean newModel = model.isNew();
+
+ Multimap<BaseModel.ErrorType, String> errors = model.checkValidity();
+
+ if (errors.isEmpty()) {
+ saveModel();
+
+ if (newModel) {
+ Intent intent = new Intent(this, getNextEditionActivity());
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_PARENT_MODEL, model);
+ startActivity(intent);
+
+ } else {
+ Intent intent = new Intent();
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, model);
+ setResult(RESULT_OK, intent);
+ finish();
+ }
+
+ } else {
+ View root = findViewById(android.R.id.content);
+
+ Collection<String> requiredFields = errors.get(BaseModel.ErrorType.REQUIRED);
+ String errorMessage = getString(R.string.required_field_error_message);
+ for (String field : requiredFields) {
+ View v = root.findViewWithTag(field);
+ if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
+ ((EditText) v).setError(errorMessage);
+ }
+ }
+
+ Collection<String> oneRequiredFields = errors.get(BaseModel.ErrorType.ONE_REQUIRED);
+ errorMessage = getString(R.string.one_required_field_error_message);
+ for (String field : oneRequiredFields) {
+ View v = root.findViewWithTag(field);
+ if (v != null && EditText.class.isAssignableFrom(v.getClass())) {
+ ((EditText) v).setError(errorMessage);
+ }
+ }
+ }
+ }
+
+ /* Protected methods */
+
+ protected void saveModel() {
+ WloSqlOpenHelper woh = new WloSqlOpenHelper(this);
+ woh.saveData(model);
+ woh.close();
+ }
+
+ protected void initEditText(int editorId, final String attribute) {
+ initEditText(editorId, attribute, null);
+ }
+
+ protected void initEditText(int editorId, final String attribute, String defaultValue) {
+ EditText editText = (EditText) findViewById(editorId);
+ initEditText(editText, attribute, defaultValue);
+ }
+
+ protected void initEditText(final EditText editText, final String attribute, String defaultValue) {
+ final Class clazz = model.getClass();
+ final String firtsLetterUpperCaseAttribute =
+ attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
+
+ editText.setTag(attribute);
+
+ try {
+ Object value = clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
+ editText.setText(value != null ? value.toString() : defaultValue);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+
+ editText.addTextChangedListener(new BaseTextWatcher() {
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ try {
+ clazz.getMethod("set" + firtsLetterUpperCaseAttribute, String.class).invoke(model, s.toString());
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+ editText.setError(null);
+ }
+ });
+
+ model.addPropertyChangeListener(attribute, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ Object newValue = event.getNewValue();
+ if (!editText.isFocused()) {
+ editText.setText(newValue != null ? newValue.toString() : getString(R.string.undefined));
+ editText.setError(null);
+ }
+ }
+ });
+ }
+
+ protected <R> AutoCompleteTextView initAutoCompleteTextView(int autoCompleteTextViewId, final String attribute, Collection<R> data) {
+ AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(autoCompleteTextViewId);
+ initAutoCompleteTextView(autoCompleteTextView, attribute, data);
+ return autoCompleteTextView;
+ }
+
+ protected <R> void initAutoCompleteTextView(AutoCompleteTextView autoCompleteTextView, final String attribute, Collection<R> data) {
+ final Class clazz = model.getClass();
+ final String firtsLetterUpperCaseAttribute =
+ attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
+
+ ArrayAdapter<R> adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, Lists.newArrayList(data));
+ autoCompleteTextView.setAdapter(adapter);
+
+ autoCompleteTextView.setThreshold(0);
+ autoCompleteTextView.setTag(attribute);
+
+ try {
+ R value = (R) clazz.getMethod("get" + firtsLetterUpperCaseAttribute).invoke(model);
+ if (value != null) {
+ autoCompleteTextView.setText(value.toString());
+ autoCompleteTextView.setError(null);
+ }
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on get" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+
+ autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ R selectedData = (R) parent.getItemAtPosition(position);
+ try {
+ clazz.getMethod("set" + firtsLetterUpperCaseAttribute, selectedData.getClass()).invoke(model, selectedData);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on set" + firtsLetterUpperCaseAttribute + " for class " + clazz, e);
+ }
+ }
+ });
+
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/GraphActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.widget.LinearLayout;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.WloBaseActivity;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import org.achartengine.ChartFactory;
-import org.achartengine.GraphicalView;
-import org.achartengine.chart.BarChart;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import java.text.NumberFormat;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class GraphActivity extends WloBaseActivity {
-
- private static final String TAG = "GraphActivity";
-
- public static final String INTENT_EXTRA_DATA = "data";
- public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
-
- protected MeasurementsModel measurements;
- protected GraphicalView mChartView;
- protected XYMultipleSeriesDataset mDataset;
- protected XYMultipleSeriesRenderer mRenderer;
-
- @Override
- protected Integer getContentView() {
- return R.layout.measurement_graph;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MeasurementActivity.class;
- }
-
- /* Activity methods */
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- LinearLayout root = (LinearLayout) findViewById(R.id.graphContainer);
-
- mDataset = new XYMultipleSeriesDataset();
- mRenderer = new XYMultipleSeriesRenderer();
-
- mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, BarChart.Type.DEFAULT);
- root.addView(mChartView);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
- XYSeries mCurrentSeries = (XYSeries) getIntent().getSerializableExtra(INTENT_EXTRA_DATA);
-
- XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
- mCurrentRenderer.setDisplayBoundingPoints(true);
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setDisplayChartValues(true);
-
- mRenderer.removeAllRenderers();
- mDataset.clear();
-
- mRenderer.addSeriesRenderer(mCurrentRenderer);
- mDataset.addSeries(mCurrentSeries);
-
- mChartView.repaint();
- }
-
- @Override
- public Intent getSupportParentActivityIntent() {
- Intent intent = super.getSupportParentActivityIntent();
- if (intent != null) {
- intent.putExtra(MeasurementActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
- }
- return intent;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/GraphActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/GraphActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,114 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.LinearLayout;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.WloBaseActivity;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import org.achartengine.ChartFactory;
+import org.achartengine.GraphicalView;
+import org.achartengine.chart.BarChart;
+import org.achartengine.model.XYMultipleSeriesDataset;
+import org.achartengine.model.XYSeries;
+import org.achartengine.renderer.XYMultipleSeriesRenderer;
+import org.achartengine.renderer.XYSeriesRenderer;
+
+import java.text.NumberFormat;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class GraphActivity extends WloBaseActivity {
+
+ private static final String TAG = "GraphActivity";
+
+ public static final String INTENT_EXTRA_DATA = "data";
+ public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
+
+ protected MeasurementsModel measurements;
+ protected GraphicalView mChartView;
+ protected XYMultipleSeriesDataset mDataset;
+ protected XYMultipleSeriesRenderer mRenderer;
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.measurement_graph;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MeasurementActivity.class;
+ }
+
+ /* Activity methods */
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ LinearLayout root = (LinearLayout) findViewById(R.id.graphContainer);
+
+ mDataset = new XYMultipleSeriesDataset();
+ mRenderer = new XYMultipleSeriesRenderer();
+
+ mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, BarChart.Type.DEFAULT);
+ root.addView(mChartView);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
+ XYSeries mCurrentSeries = (XYSeries) getIntent().getSerializableExtra(INTENT_EXTRA_DATA);
+
+ XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
+ mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
+ mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
+ mCurrentRenderer.setDisplayBoundingPoints(true);
+ mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
+ mCurrentRenderer.setDisplayChartValues(true);
+
+ mRenderer.removeAllRenderers();
+ mDataset.clear();
+
+ mRenderer.addSeriesRenderer(mCurrentRenderer);
+ mDataset.addSeries(mCurrentSeries);
+
+ mChartView.repaint();
+ }
+
+ @Override
+ public Intent getSupportParentActivityIntent() {
+ Intent intent = super.getSupportParentActivityIntent();
+ if (intent != null) {
+ intent.putExtra(MeasurementActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
+ }
+ return intent;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/GraphFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,136 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import org.achartengine.ChartFactory;
-import org.achartengine.GraphicalView;
-import org.achartengine.chart.BarChart;
-import org.achartengine.model.XYMultipleSeriesDataset;
-import org.achartengine.model.XYSeries;
-import org.achartengine.renderer.XYMultipleSeriesRenderer;
-import org.achartengine.renderer.XYSeriesRenderer;
-
-import java.text.NumberFormat;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since x.x
- */
-public class GraphFragment extends MeasurementsDisplayerFragment {
-
- private static final String TAG = "GraphFragment";
-
- protected GraphicalView mChartView;
- protected XYSeries mCurrentSeries;
- protected XYMultipleSeriesRenderer mRenderer;
-
- /* Fragment methods */
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View v = inflater.inflate(R.layout.measurement_graph_fragment, container, false);
- return v;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- LinearLayout root = (LinearLayout) getView();
-
- mCurrentSeries = new XYSeries(getString(R.string.measurement_graph_title));
- final XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();
- mDataset.addSeries(mCurrentSeries);
-
- XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
- mCurrentRenderer.setDisplayBoundingPoints(true);
- mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
- mCurrentRenderer.setDisplayChartValues(true);
-
- mRenderer = new XYMultipleSeriesRenderer();
- mRenderer.addSeriesRenderer(mCurrentRenderer);
- mRenderer.setZoomEnabled(false, false);
- mRenderer.setPanEnabled(false, false);
- mRenderer.setYAxisMin(0);
-
- mChartView = ChartFactory.getBarChartView(getActivity(), mDataset, mRenderer, BarChart.Type.DEFAULT);
- mChartView.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- Intent i = new Intent(getActivity(), GraphActivity.class);
- i.putExtra(GraphActivity.INTENT_EXTRA_DATA, mCurrentSeries);
- i.putExtra(GraphActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
- startActivity(i);
- return true;
- }
- });
-
- for (MeasurementModel measurement : measurements.getMeasurements().values()) {
- addMeasurement(measurement);
- }
-
- root.addView(mChartView);
-
- }
-
- /* MeasurementsListener methods */
-
- @Override
- public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
- addMeasurement(measurement);
- mChartView.repaint();
- }
-
- @Override
- public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
- int size = measurement.getSize();
-
- int nb = measurements.getMeasurementNb(size);
-
- int index = mCurrentSeries.getIndexForKey(size);
-
- mCurrentSeries.remove(index);
- mCurrentSeries.add(index, size, nb);
-
- mChartView.repaint();
- }
-
- /* Protected methods */
-
- protected void addMeasurement(MeasurementModel measurement) {
- int size = measurement.getSize();
- int nb = measurements.getMeasurementNb(size);
-
- int count = mCurrentSeries.getItemCount();
- if (size >= count) {
- for (int i = count ; i < size ; i++) {
- mCurrentSeries.add(i, 0);
- }
- mCurrentSeries.add(size, nb);
-
- } else {
- int index = mCurrentSeries.getIndexForKey(size);
- mCurrentSeries.remove(index);
- mCurrentSeries.add(index, size, nb);
- }
-
- updateAxis(size, nb);
- }
-
- protected void updateAxis(int size, int nb) {
- mRenderer.setXAxisMin(Math.min(mRenderer.getXAxisMin(), size - 1));
- mRenderer.setXAxisMax(Math.max(mRenderer.getXAxisMax(), size + 1));
- mRenderer.setYAxisMax(Math.max(mRenderer.getYAxisMax(), nb + 1));
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/GraphFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/GraphFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,171 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import org.achartengine.ChartFactory;
+import org.achartengine.GraphicalView;
+import org.achartengine.chart.BarChart;
+import org.achartengine.model.XYMultipleSeriesDataset;
+import org.achartengine.model.XYSeries;
+import org.achartengine.renderer.XYMultipleSeriesRenderer;
+import org.achartengine.renderer.XYSeriesRenderer;
+
+import java.text.NumberFormat;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since x.x
+ */
+public class GraphFragment extends MeasurementsDisplayerFragment {
+
+ private static final String TAG = "GraphFragment";
+
+ protected GraphicalView mChartView;
+ protected XYSeries mCurrentSeries;
+ protected XYMultipleSeriesRenderer mRenderer;
+
+ /* Fragment methods */
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ View v = inflater.inflate(R.layout.measurement_graph_fragment, container, false);
+ return v;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ LinearLayout root = (LinearLayout) getView();
+
+ mCurrentSeries = new XYSeries(getString(R.string.measurement_graph_title));
+ final XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();
+ mDataset.addSeries(mCurrentSeries);
+
+ XYSeriesRenderer mCurrentRenderer = new XYSeriesRenderer();
+ mCurrentRenderer.setChartValuesFormat(NumberFormat.getIntegerInstance());
+ mCurrentRenderer.setColor(getResources().getColor(android.R.color.holo_blue_light));
+ mCurrentRenderer.setDisplayBoundingPoints(true);
+ mCurrentRenderer.setDisplayChartValues(true);
+
+ mRenderer = new XYMultipleSeriesRenderer();
+ mRenderer.addSeriesRenderer(mCurrentRenderer);
+ mRenderer.setZoomEnabled(false, false);
+ mRenderer.setPanEnabled(false, false);
+ mRenderer.setYAxisMin(0);
+
+ mChartView = ChartFactory.getBarChartView(getActivity(), mDataset, mRenderer, BarChart.Type.DEFAULT);
+ mChartView.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Intent i = new Intent(getActivity(), GraphActivity.class);
+ i.putExtra(GraphActivity.INTENT_EXTRA_DATA, mCurrentSeries);
+ i.putExtra(GraphActivity.INTENT_EXTRA_MEASUREMENTS, measurements);
+ startActivity(i);
+ return true;
+ }
+ });
+
+ for (MeasurementModel measurement : measurements.getMeasurements().values()) {
+ addMeasurement(measurement);
+ }
+
+ root.addView(mChartView);
+
+ }
+
+ /* MeasurementsListener methods */
+
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ addMeasurement(measurement);
+ mChartView.repaint();
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ int size = measurement.getSize();
+
+ int nb = measurements.getMeasurementNb(size);
+
+ Mensuration.Precision precision = measurements.getPrecision();
+ double dSize = (double) size / precision.getUnitDivider();
+ int index = mCurrentSeries.getIndexForKey(dSize);
+
+ mCurrentSeries.remove(index);
+ mCurrentSeries.add(index, dSize, nb);
+
+ mChartView.repaint();
+ }
+
+ /* Protected methods */
+
+ protected void addMeasurement(MeasurementModel measurement) {
+ int size = measurement.getSize();
+ int nb = measurements.getMeasurementNb(size);
+
+ Mensuration.Precision precision = measurements.getPrecision();
+ double dSize = (double) size / precision.getUnitDivider();
+ double step = (double) precision.getValue() / precision.getUnitDivider();
+ double count = mCurrentSeries.getItemCount();
+
+ if (precision.isDecimal()) {
+ count = count * precision.getValue() / precision.getUnitDivider();
+ }
+
+ if (dSize >= count) {
+ for (double i = count ; i < dSize ; i = i + step) {
+ mCurrentSeries.add(i, 0);
+ }
+ mCurrentSeries.add(dSize, nb);
+
+ } else {
+ int index = mCurrentSeries.getIndexForKey(dSize);
+ mCurrentSeries.remove(index);
+ mCurrentSeries.add(index, dSize, nb);
+ }
+
+ updateAxis(dSize, nb);
+ }
+
+ protected void updateAxis(double size, int nb) {
+ mRenderer.setXAxisMin(Math.min(mRenderer.getXAxisMin(), size - 1));
+ mRenderer.setXAxisMax(Math.max(mRenderer.getXAxisMax(), size + 1));
+ mRenderer.setYAxisMax(Math.max(mRenderer.getYAxisMax(), nb + 1));
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/LogsFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,122 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import com.google.common.base.Preconditions;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Date;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LogsFragment extends MeasurementsDisplayerFragment {
-
- private static final String TAG = "LogsFragment";
-
- protected ArrayAdapter<Log> adapter;
- protected AlertDialog.Builder dialogBuilder;
-
- /* Fragment methods */
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.measurement_logs_fragment, container, false);
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- Activity activity = getActivity();
- adapter = new ArrayAdapter<Log>(activity, android.R.layout.simple_list_item_1);
-
- dialogBuilder = new AlertDialog.Builder(activity)
- .setTitle(R.string.deletion_confirmation_title)
- .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener());
-
- // Find and set up the ListView for paired devices
- ListView logsList = (ListView) activity.findViewById(R.id.logs_list);
- logsList.setAdapter(adapter);
- logsList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
- final Log log = (Log) parent.getItemAtPosition(position);
-
- dialogBuilder.setMessage(getString(R.string.deletion_confirmation_message, log.toString()))
- .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- MeasurementModel measurement = log.getMeasurement();
- measurements.removeMeasurement(measurement);
- }
- })
- .create()
- .show();
- return true;
- }
- });
- }
-
- /* MeasurementsListener methods */
-
- @Override
- public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
- adapter.insert(new Log(measurement), 0);
- }
-
- @Override
- public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
- for (int i = 0 ; i < adapter.getCount() ; i++) {
- Log log = adapter.getItem(i);
- if (log.getMeasurement().equals(measurement)) {
- adapter.remove(log);
- break;
- }
- }
- }
-
- protected class Log {
-
- protected MeasurementModel measurement;
- protected Date date;
-
- private Log(MeasurementModel measurement) {
- Preconditions.checkNotNull(measurement);
- this.measurement = measurement;
- date = new Date();
- }
-
- public MeasurementModel getMeasurement() {
- return measurement;
- }
-
- @Override
- public String toString() {
- Context context = getActivity();
- String dateFormat = UIUtils.getDateFormat(getActivity()) +
- " " + getActivity().getString(R.string.fulltime_format);
- String result = String.format(dateFormat + " - %2$s - %3$s - %4$s - %5$s", date,
- measurement.getSize(),
- UIUtils.getStringOrUndefined(measurement.getGender(), context),
- UIUtils.getStringOrUndefined(measurement.getMaturity(), context),
- UIUtils.getStringOrUndefined(measurement.getAge(), context));
- return result;
- }
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/LogsFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/LogsFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,152 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.BaseModelArrayAdapter;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LogsFragment extends MeasurementsDisplayerFragment {
+
+ private static final String TAG = "LogsFragment";
+
+ protected ArrayAdapter<MeasurementModel> adapter;
+ protected AlertDialog.Builder dialogBuilder;
+
+ /* Fragment methods */
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.measurement_logs_fragment, container, false);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ Activity activity = getActivity();
+ adapter = new BaseModelArrayAdapter<MeasurementModel>(activity, android.R.layout.simple_list_item_1,
+ new Function<MeasurementModel, String>() {
+ @Override
+ public String apply(MeasurementModel measurement) {
+ Context context = getActivity();
+ String result = measurement.toString(context,measurements.getPrecision()) + "\n";
+
+ List<Object> cats = Lists.newArrayList();
+ Object cat1 = DataCache.getGenderById(context, measurement.getCategory1());
+ if (cat1 != null) {
+ cats.add(cat1);
+ }
+ Object cat2 = DataCache.getMaturityById(context, measurement.getCategory2());
+ if (cat2 != null) {
+ cats.add(cat2);
+ }
+ Object cat3 = DataCache.getAgeById(context, measurement.getCategory3());
+ if (cat3 != null) {
+ cats.add(cat3);
+ }
+ result += StringUtils.join(cats, " - ");
+ return result;
+ }
+ });
+
+ dialogBuilder = new AlertDialog.Builder(activity)
+ .setTitle(R.string.deletion_confirmation_title)
+ .setNegativeButton(android.R.string.cancel, UIUtils.getCancelClickListener());
+
+ // Find and set up the ListView for paired devices
+ ListView logsList = (ListView) activity.findViewById(R.id.logs_list);
+ logsList.setAdapter(adapter);
+ logsList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ final MeasurementModel measurement = (MeasurementModel) parent.getItemAtPosition(position);
+
+ dialogBuilder.setMessage(getString(R.string.deletion_confirmation_message,
+ measurement.toString(getActivity(), measurements.getPrecision())))
+ .setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ measurements.removeMeasurement(measurement);
+ }
+ })
+ .create()
+ .show();
+ return true;
+ }
+ });
+
+ for (MeasurementModel measurement : measurements.getMeasurements().values()) {
+ onMeasurementAdded(measurements, measurement);
+ }
+ adapter.sort(new Comparator<MeasurementModel>() {
+ @Override
+ public int compare(MeasurementModel lhs, MeasurementModel rhs) {
+ return ObjectUtils.compare(rhs.getDate(), lhs.getDate());
+ }
+ });
+ }
+
+ /* MeasurementsListener methods */
+
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ adapter.insert(measurement, 0);
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ adapter.remove(measurement);
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,354 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.app.ActionBar;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.support.v4.app.ActionBarDrawerToggle;
-import android.support.v4.widget.DrawerLayout;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.RadioButton;
-import android.widget.RadioGroup;
-import android.widget.Spinner;
-import android.widget.TabHost;
-import android.widget.TextView;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.CommercialSpeciesFormActivity;
-import fr.ifremer.wlo.MainActivity;
-import fr.ifremer.wlo.MetierFormActivity;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.ScientificSpeciesActivity;
-import fr.ifremer.wlo.ScientificSpeciesFormActivity;
-import fr.ifremer.wlo.VesselFormActivity;
-import fr.ifremer.wlo.WloBaseActivity;
-import fr.ifremer.wlo.WloModelEditionActivity;
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.Maturity;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.Gender;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MeasurementActivity extends WloBaseActivity implements AdapterView.OnItemSelectedListener {
-
- private static final String TAG = "MeasurementActivity";
-
- public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
- public static final String INTENT_EXTRA_SCIENTIFIC_SPECIES = "scientificSpecies";
-
- protected static final String GRAPH_TAB = "graph";
- protected static final String TABLE_TAB = "table";
- protected static final String LOGS_TAB = "logs";
-
- protected TabHost tabs;
- protected EditText sizeText;
- protected ActionBarDrawerToggle mDrawerToggle;
-
- protected MeasurementModel measurement;
- protected MeasurementsModel measurements;
-
- protected ScientificSpeciesModel scientificSpecies;
- protected CommercialSpeciesModel commercialSpecies;
- protected MetierModel metier;
- protected VesselModel vessel;
-
- ListView mDrawerList;
-
- @Override
- protected Integer getContentView() {
- return R.layout.measurement;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return ScientificSpeciesActivity.class;
- }
-
- /* Activity methods */
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
- if (measurements != null) {
- scientificSpecies = measurements.getScientificSpecies();
-
- } else {
- scientificSpecies = (ScientificSpeciesModel) getIntent().getSerializableExtra(INTENT_EXTRA_SCIENTIFIC_SPECIES);
- measurements = new MeasurementsModel();
- measurements.setScientificSpecies(scientificSpecies);
- }
- commercialSpecies = scientificSpecies.getParent();
- metier = commercialSpecies.getParent();
- vessel = metier.getParent();
- LocationModel location = vessel.getParent();
-
- tabs = (TabHost)findViewById(android.R.id.tabhost);
-
- tabs.setup();
-
- setupTab(R.id.graph, GRAPH_TAB, R.string.graph_tab);
- setupTab(R.id.table, TABLE_TAB, R.string.table_tab);
- setupTab(R.id.logs, LOGS_TAB, R.string.logs_tab);
-
- sizeText = (EditText) findViewById(R.id.size);
-
- Spinner genderSpinner = (Spinner) findViewById(R.id.gender_spinner);
- genderSpinner.setOnItemSelectedListener(this);
- List<Gender> genders = Lists.newArrayList(DataCache.getAllGenders(this));
- ArrayAdapter<Gender> gendersAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1, genders);
- genderSpinner.setAdapter(gendersAdapter);
-
- Spinner maturitySpinner = (Spinner) findViewById(R.id.maturity_spinner);
- maturitySpinner.setOnItemSelectedListener(this);
- List<Maturity> maturities = Lists.newArrayList(DataCache.getAllMaturities(this));
- ArrayAdapter<Maturity> maturitiesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1, maturities);
- maturitySpinner.setAdapter(maturitiesAdapter);
-
- Spinner ageSpinner = (Spinner) findViewById(R.id.age_spinner);
- ageSpinner.setOnItemSelectedListener(this);
- List<Age> ages = Lists.newArrayList(DataCache.getAllAges(this));
- ArrayAdapter<Age> agesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, android.R.id.text1, ages);
- ageSpinner.setAdapter(agesAdapter);
-
- initFishMeasurement(10, null);
-
- DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- mDrawerList = (ListView) findViewById(R.id.left_drawer);
-
- // Set the adapter for the list view
- setDrawerListAdapter();
-
- // Set the list's click listener
- mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
- mDrawerToggle = new ActionBarDrawerToggle(
- this, /* host Activity */
- mDrawerLayout, /* DrawerLayout object */
- R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
- R.string.drawer_open, /* "open drawer" description */
- R.string.drawer_close /* "close drawer" description */
- );
-
- // Set the drawer toggle as the DrawerListener
- mDrawerLayout.setDrawerListener(mDrawerToggle);
-
- ActionBar actionBar = getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setHomeButtonEnabled(true);
- actionBar.setTitle(vessel.toString(this) + " / " +
- metier.toString(this) + " / " +
- commercialSpecies.toString(this) + " / " +
- scientificSpecies.toString(this));
- actionBar.setSubtitle(commercialSpecies.getMeasurementMethod().toString(this));
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- // Sync the toggle state after onRestoreInstanceState has occurred.
- mDrawerToggle.syncState();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK) {
- switch (requestCode) {
- case 1:
- vessel = (VesselModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- case 2:
- metier = (MetierModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- case 3:
- commercialSpecies = (CommercialSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- case 4:
- scientificSpecies = (ScientificSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
- break;
- }
- setDrawerListAdapter();
- }
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- mDrawerToggle.onConfigurationChanged(newConfig);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Pass the event to ActionBarDrawerToggle, if it returns
- // true, then it has handled the app icon touch event
- if (mDrawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
- // Handle your other action bar items...
-
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
- switch(adapterView.getId()) {
- case R.id.gender_spinner:
- measurement.setGender((Gender) adapterView.getItemAtPosition(i));
- break;
- case R.id.maturity_spinner:
- measurement.setMaturity((Maturity) adapterView.getItemAtPosition(i));
- break;
- case R.id.age_spinner:
- measurement.setAge((Age) adapterView.getItemAtPosition(i));
- break;
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> adapterView) {
- }
-
- /* Public methods */
-
- public void incSize(View source) {
- measurement.incSize();
- }
-
- public void decSize(View source) {
- measurement.decSize();
- }
-
- public void addMeasurement(View source) {
- measurements.addMeasurement(measurement);
-
- Integer size = measurement.getSize();
- Gender gender = measurement.getGender();
- initFishMeasurement(size, gender);
- }
-
- /* Protected methods */
-
- protected void initFishMeasurement(Integer size, Gender gender) {
- measurement = new MeasurementModel();
- measurement.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String propertyName = event.getPropertyName();
-
- if (MeasurementModel.SIZE_PROPERTY.equals(propertyName)) {
- Integer newValue = (Integer) event.getNewValue();
- sizeText.setText(newValue != null ? newValue.toString() : null);
-
- } else if (MeasurementModel.GENDER_PROPERTY.equals(propertyName)) {
- Gender newValue = (Gender) event.getNewValue();
-// int radioId;
-// switch (newValue) {
-// case M:
-// radioId = R.id.genderMaleRadio;
-// break;
-// case F:
-// radioId = R.id.genderFemaleRadio;
-// break;
-// default:
-// radioId = R.id.genderUndefinedRadio;
-// }
-// genderGroup.check(radioId);
- }
- }
- });
- measurement.setSize(size);
- measurement.setGender(gender);
- }
-
- protected void setupTab(int contentId, String tag, int label) {
- View tabview = LayoutInflater.from(this).inflate(R.layout.tabs_bg, null);
- TextView tv = (TextView) tabview.findViewById(R.id.tabsText);
- tv.setText(label);
-
- TabHost.TabSpec content = tabs.newTabSpec(tag).setIndicator(tabview).setContent(contentId);
- tabs.addTab(content);
-
- MeasurementsDisplayerFragment fragment =
- (MeasurementsDisplayerFragment) getFragmentManager().findFragmentById(contentId);
- fragment.setMeasurements(measurements);
-
- }
-
- protected void setDrawerListAdapter() {
- mDrawerList.setAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_1,
- new String[]{
- getString(R.string.home_title),
- vessel.toString(this),
- metier.toString(this),
- commercialSpecies.toString(this),
- scientificSpecies.toString(this)
- }));
- }
-
- private class DrawerItemClickListener implements ListView.OnItemClickListener {
- @Override
- public void onItemClick(AdapterView parent, View view, int position, long id) {
- selectItem(position);
- }
- }
-
- /** Swaps fragments in the main content view */
- private void selectItem(int position) {
- Class clazz;
- BaseModel modelToEdit;
- switch (position) {
- case 0:
- clazz = MainActivity.class;
- modelToEdit = null;
- break;
- case 1:
- clazz = VesselFormActivity.class;
- modelToEdit = vessel;
- break;
- case 2:
- clazz = MetierFormActivity.class;
- modelToEdit = metier;
- break;
- case 3:
- clazz = CommercialSpeciesFormActivity.class;
- modelToEdit = commercialSpecies;
- break;
- case 4:
- clazz = ScientificSpeciesFormActivity.class;
- modelToEdit = scientificSpecies;
- break;
- default:
- clazz = null;
- modelToEdit = null;
- }
- Intent intent = new Intent(this, clazz);
- intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, modelToEdit);
- startActivityForResult(intent, position);
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/MeasurementActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,473 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.ActionBar;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.widget.DrawerLayout;
+import android.text.InputType;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.Spinner;
+import android.widget.TabHost;
+import android.widget.TextView;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.CommercialSpeciesFormActivity;
+import fr.ifremer.wlo.MainActivity;
+import fr.ifremer.wlo.MetierFormActivity;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.ScientificSpeciesActivity;
+import fr.ifremer.wlo.ScientificSpeciesFormActivity;
+import fr.ifremer.wlo.VesselFormActivity;
+import fr.ifremer.wlo.WloBaseActivity;
+import fr.ifremer.wlo.WloModelEditionActivity;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.utils.BaseTextWatcher;
+import fr.ifremer.wlo.utils.UIUtils;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MeasurementActivity extends WloBaseActivity implements AdapterView.OnItemSelectedListener {
+
+ private static final String TAG = "MeasurementActivity";
+
+ public static final String INTENT_EXTRA_MEASUREMENTS = "measurements";
+ public static final String INTENT_EXTRA_SCIENTIFIC_SPECIES = "scientificSpecies";
+
+ protected static final String GRAPH_TAB = "graph";
+ protected static final String TABLE_TAB = "table";
+ protected static final String LOGS_TAB = "logs";
+
+ protected WloSqlOpenHelper soh = new WloSqlOpenHelper(this);
+
+ protected TabHost tabs;
+ protected EditText sizeText;
+ protected ActionBarDrawerToggle mDrawerToggle;
+
+ protected MeasurementModel measurement;
+ protected MeasurementsModel measurements;
+
+ protected ScientificSpeciesModel scientificSpecies;
+ protected CommercialSpeciesModel commercialSpecies;
+ protected MetierModel metier;
+ protected VesselModel vessel;
+
+ ListView mDrawerList;
+
+ @Override
+ protected Integer getContentView() {
+ return R.layout.measurement;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return ScientificSpeciesActivity.class;
+ }
+
+ /* Activity methods */
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ measurements = (MeasurementsModel) getIntent().getSerializableExtra(INTENT_EXTRA_MEASUREMENTS);
+ if (measurements != null) {
+ scientificSpecies = measurements.getScientificSpecies();
+
+ } else {
+ scientificSpecies = (ScientificSpeciesModel) getIntent().getSerializableExtra(INTENT_EXTRA_SCIENTIFIC_SPECIES);
+ measurements = new MeasurementsModel();
+ measurements.setScientificSpecies(scientificSpecies);
+
+ Cursor cursor = soh.getAllMeasurements(scientificSpecies.getId());
+ List<MeasurementModel> measurementList = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, MeasurementModel>() {
+ @Override
+ public MeasurementModel apply(Cursor cursor) {
+ return new MeasurementModel(cursor);
+ }
+ });
+ for (MeasurementModel measurement : measurementList) {
+ measurements.addMeasurement(measurement);
+ }
+ }
+ measurements.addMeasurementsListener(new MeasurementsModel.MeasurementsListener() {
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ soh.deleteMeasurement(measurement);
+ }
+ });
+
+ commercialSpecies = scientificSpecies.getParent();
+ measurements.setPrecision(commercialSpecies.getPrecision());
+ metier = commercialSpecies.getParent();
+ vessel = metier.getParent();
+
+ tabs = (TabHost)findViewById(android.R.id.tabhost);
+
+ tabs.setup();
+
+ setupTab(R.id.graph, GRAPH_TAB, R.string.graph_tab);
+ setupTab(R.id.table, TABLE_TAB, R.string.table_tab);
+ setupTab(R.id.logs, LOGS_TAB, R.string.logs_tab);
+
+ sizeText = (EditText) findViewById(R.id.size);
+ int inputType = InputType.TYPE_CLASS_NUMBER;
+ if (measurements.getPrecision().isDecimal()) {
+ inputType |= InputType.TYPE_NUMBER_FLAG_DECIMAL;
+ }
+ sizeText.setRawInputType(inputType);
+ sizeText.addTextChangedListener(new BaseTextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ Log.d(TAG, "beforetextchnage " + s);
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ Mensuration.Precision precision = measurements.getPrecision();
+ int multiplier = precision.getUnitDivider();
+ try {
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+ Number number = format.parse(s.toString());
+ double d = number.doubleValue();
+ int size = (int)(d * multiplier);
+ measurement.setSize(size);
+
+ } catch (ParseException e) {
+ Log.e(TAG, "ParseException ", e);
+ measurement.setSize(null);
+ }
+ }
+ });
+
+ Spinner genderSpinner = (Spinner) findViewById(R.id.gender_spinner);
+ genderSpinner.setOnItemSelectedListener(this);
+ List<Gender> genders = Lists.newArrayList(DataCache.getAllGenders(this));
+ ArrayAdapter<Gender> gendersAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, genders);
+ genderSpinner.setAdapter(gendersAdapter);
+
+ Spinner maturitySpinner = (Spinner) findViewById(R.id.maturity_spinner);
+ maturitySpinner.setOnItemSelectedListener(this);
+ List<Maturity> maturities = Lists.newArrayList(DataCache.getAllMaturities(this));
+ ArrayAdapter<Maturity> maturitiesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, maturities);
+ maturitySpinner.setAdapter(maturitiesAdapter);
+
+ Spinner ageSpinner = (Spinner) findViewById(R.id.age_spinner);
+ ageSpinner.setOnItemSelectedListener(this);
+ List<Age> ages = Lists.newArrayList(DataCache.getAllAges(this));
+ ArrayAdapter<Age> agesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, ages);
+ ageSpinner.setAdapter(agesAdapter);
+
+ initFishMeasurement(10 * measurements.getPrecision().getUnitDivider(), null, null, null);
+
+ DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerList = (ListView) findViewById(R.id.left_drawer);
+
+ // Set the adapter for the list view
+ setDrawerListAdapter();
+
+ // Set the list's click listener
+ mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
+ mDrawerToggle = new ActionBarDrawerToggle(
+ this, /* host Activity */
+ mDrawerLayout, /* DrawerLayout object */
+ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
+ R.string.drawer_open, /* "open drawer" description */
+ R.string.drawer_close /* "close drawer" description */
+ );
+
+ // Set the drawer toggle as the DrawerListener
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
+ actionBar.setTitle(commercialSpecies.toString(this) + " / " +
+ scientificSpecies.toString(this) + " / " +
+ commercialSpecies.getMeasurementMethod().toString(this) + " / " +
+ commercialSpecies.getPrecision());
+ actionBar.setSubtitle(vessel.toString(this) + " / " +
+ metier.toString(this));
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (resultCode == RESULT_OK) {
+ switch (requestCode) {
+ case 1:
+ vessel = (VesselModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ break;
+ case 2:
+ metier = (MetierModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ break;
+ case 3:
+ commercialSpecies = (CommercialSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ measurements.setPrecision(commercialSpecies.getPrecision());
+ break;
+ case 4:
+ scientificSpecies = (ScientificSpeciesModel) data.getSerializableExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL);
+ break;
+ }
+ setDrawerListAdapter();
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Pass the event to ActionBarDrawerToggle, if it returns
+ // true, then it has handled the app icon touch event
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ // Handle your other action bar items...
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ soh.close();
+ }
+
+ @Override
+ public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
+ BaseModel selected = (BaseModel) adapterView.getItemAtPosition(i);
+ switch(adapterView.getId()) {
+ case R.id.gender_spinner:
+ measurement.setCategory1(selected.getId());
+ break;
+ case R.id.maturity_spinner:
+ measurement.setCategory2(selected.getId());
+ break;
+ case R.id.age_spinner:
+ measurement.setCategory3(selected.getId());
+ break;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> adapterView) {
+ }
+
+ /* Public methods */
+
+ public void incSize(View source) {
+ measurement.incSize(measurements.getPrecision().getValue());
+ }
+
+ public void decSize(View source) {
+ measurement.decSize(measurements.getPrecision().getValue());
+ }
+
+ public void addMeasurement(View source) {
+ measurement.setDate(Calendar.getInstance());
+ measurement.roundSize(measurements.getPrecision());
+ soh.saveData(measurement);
+ measurements.addMeasurement(measurement);
+
+ Integer size = measurement.getSize();
+ String cat1 = measurement.getCategory1();
+ String cat2 = measurement.getCategory2();
+ String cat3 = measurement.getCategory3();
+ initFishMeasurement(size, cat1, cat2, cat3);
+ }
+
+ /* Protected methods */
+
+ protected void initFishMeasurement(Integer size, String cat1, String cat2, String cat3) {
+ measurement = new MeasurementModel();
+ measurement.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String propertyName = event.getPropertyName();
+
+ Object newValue = event.getNewValue();
+ switch(propertyName) {
+ case MeasurementModel.COLUMN_SIZE:
+ String text = null;
+ if (newValue != null) {
+ text = UIUtils.getFormattedSize((Integer) newValue, measurements.getPrecision());
+ }
+ sizeText.setText(text);
+ break;
+
+ case MeasurementModel.COLUMN_CATEGORY_1:
+ Spinner spinner = (Spinner) findViewById(R.id.gender_spinner);
+ ArrayAdapter adapter = (ArrayAdapter) spinner.getAdapter();
+ Object o = DataCache.getGenderById(MeasurementActivity.this, (String) newValue);
+ int position = adapter.getPosition(o);
+ spinner.setSelection(position);
+ break;
+
+ case MeasurementModel.COLUMN_CATEGORY_2:
+ newValue = event.getNewValue();
+ spinner = (Spinner) findViewById(R.id.maturity_spinner);
+ adapter = (ArrayAdapter) spinner.getAdapter();
+ o = DataCache.getMaturityById(MeasurementActivity.this, (String) newValue);
+ position = adapter.getPosition(o);
+ spinner.setSelection(position);
+ break;
+
+ case MeasurementModel.COLUMN_CATEGORY_3:
+ newValue = event.getNewValue();
+ spinner = (Spinner) findViewById(R.id.age_spinner);
+ adapter = (ArrayAdapter) spinner.getAdapter();
+ o = DataCache.getAgeById(MeasurementActivity.this, (String) newValue);
+ position = adapter.getPosition(o);
+ spinner.setSelection(position);
+ break;
+ }
+ }
+ });
+ measurement.setSize(size);
+ measurement.setCategory1(cat1);
+ measurement.setCategory2(cat2);
+ measurement.setCategory3(cat3);
+ measurement.setParent(scientificSpecies);
+ }
+
+ protected void setupTab(int contentId, String tag, int label) {
+ View tabview = LayoutInflater.from(this).inflate(R.layout.tabs_bg, null);
+ TextView tv = (TextView) tabview.findViewById(R.id.tabsText);
+ tv.setText(label);
+
+ TabHost.TabSpec content = tabs.newTabSpec(tag).setIndicator(tabview).setContent(contentId);
+ tabs.addTab(content);
+
+ MeasurementsDisplayerFragment fragment =
+ (MeasurementsDisplayerFragment) getFragmentManager().findFragmentById(contentId);
+ fragment.setMeasurements(measurements);
+
+ }
+
+ protected void setDrawerListAdapter() {
+ mDrawerList.setAdapter(new ArrayAdapter<String>(this,
+ android.R.layout.simple_list_item_1,
+ new String[]{
+ getString(R.string.home_title),
+ vessel.toString(this),
+ metier.toString(this),
+ commercialSpecies.toString(this),
+ scientificSpecies.toString(this)
+ }));
+ }
+
+ private class DrawerItemClickListener implements ListView.OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView parent, View view, int position, long id) {
+ selectItem(position);
+ }
+ }
+
+ /** Swaps fragments in the main content view */
+ private void selectItem(int position) {
+ Class clazz;
+ BaseModel modelToEdit;
+ switch (position) {
+ case 0:
+ clazz = MainActivity.class;
+ modelToEdit = null;
+ break;
+ case 1:
+ clazz = VesselFormActivity.class;
+ modelToEdit = vessel;
+ break;
+ case 2:
+ clazz = MetierFormActivity.class;
+ modelToEdit = metier;
+ break;
+ case 3:
+ clazz = CommercialSpeciesFormActivity.class;
+ modelToEdit = commercialSpecies;
+ break;
+ case 4:
+ clazz = ScientificSpeciesFormActivity.class;
+ modelToEdit = scientificSpecies;
+ break;
+ default:
+ clazz = null;
+ modelToEdit = null;
+ }
+ Intent intent = new Intent(this, clazz);
+ intent.putExtra(WloModelEditionActivity.INTENT_EXTRA_MODEL, modelToEdit);
+ startActivityForResult(intent, position);
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,21 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.app.Fragment;
-import fr.ifremer.wlo.models.MeasurementsModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class MeasurementsDisplayerFragment extends Fragment
- implements MeasurementsModel.MeasurementsListener {
-
- private static final String TAG = "MeasurementsDisplayerFragment";
-
- protected MeasurementsModel measurements;
-
- public void setMeasurements(MeasurementsModel measurements) {
- this.measurements = measurements;
- this.measurements.addMeasurementsListener(this);
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/MeasurementsDisplayerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,45 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Fragment;
+import fr.ifremer.wlo.models.MeasurementsModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class MeasurementsDisplayerFragment extends Fragment
+ implements MeasurementsModel.MeasurementsListener {
+
+ private static final String TAG = "MeasurementsDisplayerFragment";
+
+ protected MeasurementsModel measurements;
+
+ public void setMeasurements(MeasurementsModel measurements) {
+ this.measurements = measurements;
+ this.measurements.addMeasurementsListener(this);
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/TableAdapter.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,96 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-import fr.ifremer.wlo.R;
-
-import java.util.TreeMap;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class TableAdapter extends BaseAdapter {
-
- private static final String TAG = "TableAdapter";
-
- protected TreeMap<Integer, Integer> data = new TreeMap<Integer, Integer>();
- protected Context context;
-
- public TableAdapter(Context context) {
- this.context = context;
- }
-
- /* BaseAdapter methods */
-
- @Override
- public int getCount() {
- return data.size();
- }
-
- @Override
- public Object getItem(int position) {
- if (position < 0 || position >= data.size()) {
- return null;
- }
- return data.keySet().toArray()[position];
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder;
-
- if (convertView == null) {
- convertView = LayoutInflater.from(context)
- .inflate(R.layout.measurement_table_row, parent, false);
-// convertView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
-
- viewHolder = new ViewHolder();
- viewHolder.sizeText = (TextView) convertView.findViewById(R.id.table_size);
- viewHolder.nbText = (TextView) convertView.findViewById(R.id.table_nb);
- convertView.setTag(viewHolder);
-
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
-
- Integer size = (Integer) getItem(position);
- viewHolder.sizeText.setText(String.valueOf(size));
- viewHolder.nbText.setText(String.valueOf(data.get(size)));
-
- int color;
- if (position % 2 == 0) {
- color = android.R.color.holo_blue_dark;
- } else {
- color = android.R.color.black;
- }
- convertView.setBackgroundResource(color);
-
- return convertView;
- }
-
- public void set(int size, int nb) {
- if (nb == 0) {
- data.remove(size);
- } else {
- data.put(size, nb);
- }
- notifyDataSetChanged();
- }
-
- /* Cache for the views of the table items */
- static class ViewHolder {
- TextView sizeText;
- TextView nbText;
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/TableAdapter.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/TableAdapter.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,124 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.TreeMap;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class TableAdapter extends BaseAdapter {
+
+ private static final String TAG = "TableAdapter";
+
+ protected TreeMap<Integer, Integer> data = new TreeMap<>();
+ protected Context context;
+ protected Mensuration.Precision precision;
+
+ public TableAdapter(Context context, Mensuration.Precision precision) {
+ this.context = context;
+ this.precision = precision;
+ }
+
+ /* BaseAdapter methods */
+
+ @Override
+ public int getCount() {
+ return data.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ if (position < 0 || position >= data.size()) {
+ return null;
+ }
+ return data.keySet().toArray()[position];
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder;
+
+ if (convertView == null) {
+ convertView = LayoutInflater.from(context)
+ .inflate(R.layout.measurement_table_row, parent, false);
+// convertView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
+
+ viewHolder = new ViewHolder();
+ viewHolder.sizeText = (TextView) convertView.findViewById(R.id.table_size);
+ viewHolder.nbText = (TextView) convertView.findViewById(R.id.table_nb);
+ convertView.setTag(viewHolder);
+
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+
+ Integer size = (Integer) getItem(position);
+ viewHolder.sizeText.setText(UIUtils.getFormattedSize(size, precision));
+ viewHolder.nbText.setText(String.valueOf(data.get(size)));
+
+ int color;
+ if (position % 2 == 0) {
+ color = android.R.color.holo_blue_dark;
+ } else {
+ color = android.R.color.black;
+ }
+ convertView.setBackgroundResource(color);
+
+ return convertView;
+ }
+
+ public void set(int size, int nb) {
+ if (nb == 0) {
+ data.remove(size);
+ } else {
+ data.put(size, nb);
+ }
+ notifyDataSetChanged();
+ }
+
+ /* Cache for the views of the table items */
+ static class ViewHolder {
+ TextView sizeText;
+ TextView nbText;
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/measurement/TableFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,53 +0,0 @@
-package fr.ifremer.wlo.measurement;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListView;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.MeasurementModel;
-import fr.ifremer.wlo.models.MeasurementsModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class TableFragment extends MeasurementsDisplayerFragment {
-
- private static final String TAG = "TableFragment";
-
- protected ListView table;
- protected TableAdapter adapter;
-
- /* Fragment methods */
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- return inflater.inflate(R.layout.measurement_table_fragment, container, false);
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
- table = (ListView) getActivity().findViewById(R.id.table_content);
- adapter = new TableAdapter(getActivity());
- table.setAdapter(adapter);
- }
-
- /* MeasurementsListener methods */
-
- @Override
- public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
- int size = measurement.getSize();
- adapter.set(size, source.getMeasurementNb(size));
- }
-
- @Override
- public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
- int size = measurement.getSize();
- adapter.set(size, source.getMeasurementNb(size));
- }
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/measurement/TableFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/measurement/TableFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,81 @@
+package fr.ifremer.wlo.measurement;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MeasurementsModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class TableFragment extends MeasurementsDisplayerFragment {
+
+ private static final String TAG = "TableFragment";
+
+ protected ListView table;
+ protected TableAdapter adapter;
+
+ /* Fragment methods */
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.measurement_table_fragment, container, false);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ table = (ListView) getActivity().findViewById(R.id.table_content);
+ adapter = new TableAdapter(getActivity(), measurements.getPrecision());
+ table.setAdapter(adapter);
+
+ for (MeasurementModel measurement : measurements.getMeasurements().values()) {
+ onMeasurementAdded(measurements, measurement);
+ }
+ }
+
+ /* MeasurementsListener methods */
+
+ @Override
+ public void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement) {
+ int size = measurement.getSize();
+ adapter.set(size, source.getMeasurementNb(size));
+ }
+
+ @Override
+ public void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement) {
+ int size = measurement.getSize();
+ adapter.set(size, source.getMeasurementNb(size));
+ }
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,156 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.provider.BaseColumns;
-import android.util.Log;
-import com.google.common.base.Function;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class BaseModel implements Serializable, BaseColumns {
-
- private static final String TAG = "BaseModel";
-
- public static final Function<BaseModel, String> GET_ID_FUNCTION = new Function<BaseModel, String>() {
- @Override
- public String apply(BaseModel input) {
- return input.getId();
- }
- };
-
- public enum ErrorType {
- REQUIRED,
- ONE_REQUIRED
- }
-
- protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
-
- protected String id;
-
- public BaseModel() {}
-
- public BaseModel(Cursor cursor) {
- id = cursor.getString(0);
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public boolean isNew() {
- return id == null;
- }
-
- public abstract String getTableName();
-
- public String toString(android.content.Context context) {
- return toString();
- }
-
- public ContentValues convertIntoContentValues() {
- ContentValues value = new ContentValues();
- value.put(_ID, id);
- return value;
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(property, listener);
- }
-
- public Set<String> getRequiredFields() {
- return Sets.newHashSet();
- }
-
- /**
- * @return A set of sets containing fields. At least one of these fields must have a value.
- */
- public Set<Set<String>> getOneRequiredFields() {
- return Sets.newHashSet();
- }
-
- /**
- * Check if the model is valid
- * @return a map of the fields in error by error type
- */
- public Multimap<ErrorType, String> checkValidity() {
- Multimap<ErrorType, String> result = HashMultimap.create();
- // check required
- for (String requiredField : getRequiredFields()) {
- try {
- if (getClass().getDeclaredField(requiredField).get(this) == null) {
- result.put(ErrorType.REQUIRED, requiredField);
- }
- } catch (Exception e) {
- Log.e(TAG, "Error while accessing the field " + requiredField, e);
- }
- }
-
- // check one required
- for (Set<String> oneRequiredFields : getOneRequiredFields()) {
- boolean notNull = false;
- for (String oneRequiredField : oneRequiredFields) {
- try {
- if (getClass().getDeclaredField(oneRequiredField).get(this) != null) {
- notNull = true;
- break;
- }
- } catch (Exception e) {
- Log.e(TAG, "Error while accessing the field " + oneRequiredField, e);
- }
- }
- if (!notNull) {
- result.putAll(ErrorType.ONE_REQUIRED, oneRequiredFields);
- }
- }
-
- return result;
- }
-
- protected void putValue(ContentValues values, String column, String value) {
- if (value == null) {
- values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
- } else {
- values.put(column, value);
- }
- }
-
- protected void putValue(ContentValues values, String column, Long value) {
- if (value == null) {
- values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
- } else {
- values.put(column, value);
- }
- }
-
- protected void putValue(ContentValues values, String column, Integer value) {
- if (value == null) {
- values.putNull(column);
- Log.d(TAG, "put value null for column " + column);
- } else {
- values.put(column, value);
- }
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/BaseModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/BaseModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,180 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.provider.BaseColumns;
+import android.util.Log;
+import com.google.common.base.Function;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class BaseModel implements Serializable, BaseColumns {
+
+ private static final String TAG = "BaseModel";
+
+ public static final Function<BaseModel, String> GET_ID_FUNCTION = new Function<BaseModel, String>() {
+ @Override
+ public String apply(BaseModel input) {
+ return input.getId();
+ }
+ };
+
+ public enum ErrorType {
+ REQUIRED,
+ ONE_REQUIRED
+ }
+
+ protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
+
+ protected String id;
+
+ public BaseModel() {}
+
+ public BaseModel(Cursor cursor) {
+ id = cursor.getString(0);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public boolean isNew() {
+ return id == null;
+ }
+
+ public abstract String getTableName();
+
+ public String toString(android.content.Context context) {
+ return toString();
+ }
+
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = new ContentValues();
+ value.put(_ID, id);
+ return value;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ changeSupport.addPropertyChangeListener(property, listener);
+ }
+
+ public Set<String> getRequiredFields() {
+ return Sets.newHashSet();
+ }
+
+ /**
+ * @return A set of sets containing fields. At least one of these fields must have a value.
+ */
+ public Set<Set<String>> getOneRequiredFields() {
+ return Sets.newHashSet();
+ }
+
+ /**
+ * Check if the model is valid
+ * @return a map of the fields in error by error type
+ */
+ public Multimap<ErrorType, String> checkValidity() {
+ Multimap<ErrorType, String> result = HashMultimap.create();
+ // check required
+ for (String requiredField : getRequiredFields()) {
+ try {
+ if (getClass().getDeclaredField(requiredField).get(this) == null) {
+ result.put(ErrorType.REQUIRED, requiredField);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Error while accessing the field " + requiredField, e);
+ }
+ }
+
+ // check one required
+ for (Set<String> oneRequiredFields : getOneRequiredFields()) {
+ boolean notNull = false;
+ for (String oneRequiredField : oneRequiredFields) {
+ try {
+ if (getClass().getDeclaredField(oneRequiredField).get(this) != null) {
+ notNull = true;
+ break;
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Error while accessing the field " + oneRequiredField, e);
+ }
+ }
+ if (!notNull) {
+ result.putAll(ErrorType.ONE_REQUIRED, oneRequiredFields);
+ }
+ }
+
+ return result;
+ }
+
+ protected void putValue(ContentValues values, String column, String value) {
+ if (value == null) {
+ values.putNull(column);
+ Log.d(TAG, "put value null for column " + column);
+ } else {
+ values.put(column, value);
+ }
+ }
+
+ protected void putValue(ContentValues values, String column, Long value) {
+ if (value == null) {
+ values.putNull(column);
+ Log.d(TAG, "put value null for column " + column);
+ } else {
+ values.put(column, value);
+ }
+ }
+
+ protected void putValue(ContentValues values, String column, Integer value) {
+ if (value == null) {
+ values.putNull(column);
+ Log.d(TAG, "put value null for column " + column);
+ } else {
+ values.put(column, value);
+ }
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,159 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.util.Log;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesModel extends HierarchicalModel<MetierModel> {
-
- private static final String TAG = "CommercialSpecies";
-
- public static final String TABLE_NAME = "commercial_species";
- public static final String COLUMN_FAO_CODE = "faoCode";
- public static final String COLUMN_MEASUREMENT_METHOD = "measurementMethod";
- public static final String COLUMN_PRECISION = "precision";
- public static final String COLUMN_SPECIES_MIX = "speciesMix";
- public static final String COLUMN_SORT_CATEGORY = "sortCategory";
- public static final String COLUMN_STATE = "state";
- public static final String COLUMN_PRESENTATION = "presentation";
- public static final String COLUMN_METIER_ID = "metierId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_FAO_CODE,
- COLUMN_MEASUREMENT_METHOD,
- COLUMN_PRECISION,
- COLUMN_SPECIES_MIX,
- COLUMN_SORT_CATEGORY,
- COLUMN_STATE,
- COLUMN_PRESENTATION,
- COLUMN_METIER_ID
- };
-
- protected CommercialSpecies faoCode;
- protected Mensuration measurementMethod;
- protected Mensuration.Precision precision = Mensuration.Precision.CM1;
- protected boolean speciesMix;
- protected String sortCategory;
- protected State state;
- protected Presentation presentation;
-
- public CommercialSpeciesModel() {
- }
-
- public CommercialSpeciesModel(Context context, Cursor cursor) {
- super(cursor);
- String faoCodeId = cursor.getString(1);
- faoCode = DataCache.getCommercialSpeciesById(context, faoCodeId);
- String measurementMethodId = cursor.getString(2);
- measurementMethod = DataCache.getMensurationById(context, measurementMethodId);
- precision = Mensuration.Precision.valueOf(cursor.getString(3));
- speciesMix = cursor.getShort(4) > 0;
- sortCategory = cursor.getString(5);
- String stateId = cursor.getString(6);
- state = DataCache.getStateById(context, stateId);
- String presentationId = cursor.getString(7);
- presentation = DataCache.getPresentationById(context, presentationId);
- }
-
- public CommercialSpecies getFaoCode() {
- return faoCode;
- }
-
- public void setFaoCode(CommercialSpecies faoCode) {
- this.faoCode = faoCode;
- }
-
- public Mensuration getMeasurementMethod() {
- return measurementMethod;
- }
-
- public void setMeasurementMethod(Mensuration measurementMethod) {
- this.measurementMethod = measurementMethod;
- }
-
- public Mensuration.Precision getPrecision() {
- return precision;
- }
-
- public void setPrecision(Mensuration.Precision precision) {
- this.precision = precision;
- }
-
- public boolean isSpeciesMix() {
- return speciesMix;
- }
-
- public void setSpeciesMix(boolean speciesMix) {
- this.speciesMix = speciesMix;
- }
-
- public String getSortCategory() {
- return sortCategory;
- }
-
- public void setSortCategory(String sortCategory) {
- this.sortCategory = sortCategory;
- }
-
- public State getState() {
- return state;
- }
-
- public void setState(State state) {
- this.state = state;
- }
-
- public Presentation getPresentation() {
- return presentation;
- }
-
- public void setPresentation(Presentation presentation) {
- this.presentation = presentation;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(faoCode, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_FAO_CODE, faoCode != null ? faoCode.getId() : null);
- putValue(value, COLUMN_MEASUREMENT_METHOD, measurementMethod != null ? measurementMethod.getId() : null);
- putValue(value, COLUMN_PRECISION, precision.name());
- putValue(value, COLUMN_SPECIES_MIX, speciesMix ? 1 : 0);
- putValue(value, COLUMN_SORT_CATEGORY, sortCategory);
- putValue(value, COLUMN_STATE, state != null ? state.getId() : null);
- putValue(value, COLUMN_PRESENTATION, presentation != null ? presentation.getId() : null);
- putValue(value, COLUMN_METIER_ID, getParentId());
- return value;
- }
-
- @Override
- public Set<String> getRequiredFields() {
- Set<String> result = super.getRequiredFields();
- result.add(COLUMN_FAO_CODE);
- result.add(COLUMN_MEASUREMENT_METHOD);
- result.add(COLUMN_PRECISION);
- return result;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/CommercialSpeciesModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,185 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesModel extends HierarchicalModel<MetierModel> {
+
+ private static final String TAG = "CommercialSpecies";
+
+ public static final String TABLE_NAME = "commercial_species";
+ public static final String COLUMN_FAO_CODE = "faoCode";
+ public static final String COLUMN_MEASUREMENT_METHOD = "measurementMethod";
+ public static final String COLUMN_PRECISION = "precision";
+ public static final String COLUMN_SPECIES_MIX = "speciesMix";
+ public static final String COLUMN_SORT_CATEGORY = "sortCategory";
+ public static final String COLUMN_STATE = "state";
+ public static final String COLUMN_PRESENTATION = "presentation";
+ public static final String COLUMN_METIER_ID = "metierId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_FAO_CODE,
+ COLUMN_MEASUREMENT_METHOD,
+ COLUMN_PRECISION,
+ COLUMN_SPECIES_MIX,
+ COLUMN_SORT_CATEGORY,
+ COLUMN_STATE,
+ COLUMN_PRESENTATION,
+ COLUMN_METIER_ID
+ };
+
+ protected CommercialSpecies faoCode;
+ protected Mensuration measurementMethod;
+ protected Mensuration.Precision precision = Mensuration.Precision.CM1;
+ protected boolean speciesMix;
+ protected String sortCategory;
+ protected State state;
+ protected Presentation presentation;
+
+ public CommercialSpeciesModel() {
+ }
+
+ public CommercialSpeciesModel(Context context, Cursor cursor) {
+ super(cursor);
+ String faoCodeId = cursor.getString(1);
+ faoCode = DataCache.getCommercialSpeciesById(context, faoCodeId);
+ String measurementMethodId = cursor.getString(2);
+ measurementMethod = DataCache.getMensurationById(context, measurementMethodId);
+ Log.d(TAG, cursor.getString(3));
+ precision = Mensuration.Precision.valueOf(cursor.getString(3));
+ Log.d(TAG, precision.toString());
+ speciesMix = cursor.getShort(4) > 0;
+ sortCategory = cursor.getString(5);
+ String stateId = cursor.getString(6);
+ state = DataCache.getStateById(context, stateId);
+ String presentationId = cursor.getString(7);
+ presentation = DataCache.getPresentationById(context, presentationId);
+ }
+
+ public CommercialSpecies getFaoCode() {
+ return faoCode;
+ }
+
+ public void setFaoCode(CommercialSpecies faoCode) {
+ this.faoCode = faoCode;
+ }
+
+ public Mensuration getMeasurementMethod() {
+ return measurementMethod;
+ }
+
+ public void setMeasurementMethod(Mensuration measurementMethod) {
+ this.measurementMethod = measurementMethod;
+ }
+
+ public Mensuration.Precision getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(Mensuration.Precision precision) {
+ this.precision = precision;
+ }
+
+ public boolean isSpeciesMix() {
+ return speciesMix;
+ }
+
+ public void setSpeciesMix(boolean speciesMix) {
+ this.speciesMix = speciesMix;
+ }
+
+ public String getSortCategory() {
+ return sortCategory;
+ }
+
+ public void setSortCategory(String sortCategory) {
+ this.sortCategory = sortCategory;
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ public Presentation getPresentation() {
+ return presentation;
+ }
+
+ public void setPresentation(Presentation presentation) {
+ this.presentation = presentation;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(faoCode, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_FAO_CODE, faoCode != null ? faoCode.getId() : null);
+ putValue(value, COLUMN_MEASUREMENT_METHOD, measurementMethod != null ? measurementMethod.getId() : null);
+ putValue(value, COLUMN_PRECISION, precision.name());
+ putValue(value, COLUMN_SPECIES_MIX, speciesMix ? 1 : 0);
+ putValue(value, COLUMN_SORT_CATEGORY, sortCategory);
+ putValue(value, COLUMN_STATE, state != null ? state.getId() : null);
+ putValue(value, COLUMN_PRESENTATION, presentation != null ? presentation.getId() : null);
+ putValue(value, COLUMN_METIER_ID, getParentId());
+ return value;
+ }
+
+ @Override
+ public Set<String> getRequiredFields() {
+ Set<String> result = super.getRequiredFields();
+ result.add(COLUMN_FAO_CODE);
+ result.add(COLUMN_MEASUREMENT_METHOD);
+ result.add(COLUMN_PRECISION);
+ return result;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,65 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import com.google.common.collect.Multimap;
-
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ContextModel extends BaseModel {
-
- private static final String TAG = "Context";
-
- public static final String TABLE_NAME = "contexts";
- public static final String COLUMN_NAME = "name";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_NAME
- };
-
- protected String name;
-
- public ContextModel() {
- }
-
- public ContextModel(Cursor cursor) {
- super(cursor);
- name = cursor.getString(1);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return name;
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_NAME, name);
- return value;
- }
-
- @Override
- public Set<String> getRequiredFields() {
- Set<String> result = super.getRequiredFields();
- result.add(COLUMN_NAME);
- return result;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/ContextModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/ContextModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,89 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import com.google.common.collect.Multimap;
+
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ContextModel extends BaseModel {
+
+ private static final String TAG = "Context";
+
+ public static final String TABLE_NAME = "contexts";
+ public static final String COLUMN_NAME = "name";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_NAME
+ };
+
+ protected String name;
+
+ public ContextModel() {
+ }
+
+ public ContextModel(Cursor cursor) {
+ super(cursor);
+ name = cursor.getString(1);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return name;
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_NAME, name);
+ return value;
+ }
+
+ @Override
+ public Set<String> getRequiredFields() {
+ Set<String> result = super.getRequiredFields();
+ result.add(COLUMN_NAME);
+ return result;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,40 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.database.Cursor;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class HierarchicalModel<P extends BaseModel> extends BaseModel {
-
- protected P parent;
-
- public HierarchicalModel() {}
-
- public HierarchicalModel(Cursor cursor) {
- id = cursor.getString(0);
- }
-
- public P getParent() {
- return parent;
- }
-
- public BaseModel getParent(int level) {
- BaseModel result = this;
- //TODO kmorin 20131219 handle NPE
- for (int i = 0 ; i < level ; i++) {
- result = ((HierarchicalModel) result).getParent();
- }
- return result;
- }
-
- public void setParent(P parent) {
- this.parent = parent;
- }
-
- public String getParentId() {
- return parent != null ? parent.getId() : null;
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/HierarchicalModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/HierarchicalModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,64 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.database.Cursor;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class HierarchicalModel<P extends BaseModel> extends BaseModel {
+
+ protected P parent;
+
+ public HierarchicalModel() {}
+
+ public HierarchicalModel(Cursor cursor) {
+ id = cursor.getString(0);
+ }
+
+ public P getParent() {
+ return parent;
+ }
+
+ public BaseModel getParent(int level) {
+ BaseModel result = this;
+ //TODO kmorin 20131219 handle NPE
+ for (int i = 0 ; i < level ; i++) {
+ result = ((HierarchicalModel) result).getParent();
+ }
+ return result;
+ }
+
+ public void setParent(P parent) {
+ this.parent = parent;
+ }
+
+ public String getParentId() {
+ return parent != null ? parent.getId() : null;
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,112 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Calendar;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationModel extends HierarchicalModel<ContextModel> {
-
- private static final String TAG = "Location";
-
- public static final String TABLE_NAME = "locations";
- public static final String COLUMN_OPERATOR = "operator";
- public static final String COLUMN_START_DATE = "startDate";
- public static final String COLUMN_END_DATE = "endDate";
- public static final String COLUMN_LOCATION = "location";
- public static final String COLUMN_CONTEXT_ID = "contextId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_OPERATOR,
- COLUMN_START_DATE,
- COLUMN_END_DATE,
- COLUMN_LOCATION,
- COLUMN_CONTEXT_ID
- };
-
- protected String operator;
- protected Calendar startDate;
- protected Calendar endDate;
- protected Location location;
-
- public LocationModel() {
- }
-
- public LocationModel(Context context, Cursor cursor) {
- super(cursor);
- operator = cursor.getString(1);
- startDate = UIUtils.getCalendarFromCursor(cursor, 2);
- endDate = UIUtils.getCalendarFromCursor(cursor, 3);
- String locationId = cursor.getString(4);
- location = DataCache.getLocationById(context, locationId);
- }
-
- public String getOperator() {
- return operator;
- }
-
- public void setOperator(String operator) {
- this.operator = operator;
- }
-
- public Calendar getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Calendar startDate) {
- this.startDate = startDate;
- }
-
- public Calendar getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Calendar endDate) {
- this.endDate = endDate;
- }
-
- public Location getLocation() {
- return location;
- }
-
- public void setLocation(Location location) {
- this.location = location;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(location, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_OPERATOR, operator);
- putValue(value, COLUMN_START_DATE, startDate != null ? startDate.getTimeInMillis() : null);
- putValue(value, COLUMN_END_DATE, endDate != null ? endDate.getTimeInMillis() : null);
- putValue(value, COLUMN_LOCATION, location != null ? location.getId() : null);
- putValue(value, COLUMN_CONTEXT_ID, getParentId());
- return value;
- }
-
- @Override
- public Set<String> getRequiredFields() {
- Set<String> result = super.getRequiredFields();
- result.add(COLUMN_LOCATION);
- return result;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/LocationModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/LocationModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,136 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationModel extends HierarchicalModel<ContextModel> {
+
+ private static final String TAG = "Location";
+
+ public static final String TABLE_NAME = "locations";
+ public static final String COLUMN_OPERATOR = "operator";
+ public static final String COLUMN_START_DATE = "startDate";
+ public static final String COLUMN_END_DATE = "endDate";
+ public static final String COLUMN_LOCATION = "location";
+ public static final String COLUMN_CONTEXT_ID = "contextId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_OPERATOR,
+ COLUMN_START_DATE,
+ COLUMN_END_DATE,
+ COLUMN_LOCATION,
+ COLUMN_CONTEXT_ID
+ };
+
+ protected String operator;
+ protected Calendar startDate;
+ protected Calendar endDate;
+ protected Location location;
+
+ public LocationModel() {
+ }
+
+ public LocationModel(Context context, Cursor cursor) {
+ super(cursor);
+ operator = cursor.getString(1);
+ startDate = UIUtils.getCalendarFromCursor(cursor, 2);
+ endDate = UIUtils.getCalendarFromCursor(cursor, 3);
+ String locationId = cursor.getString(4);
+ location = DataCache.getLocationById(context, locationId);
+ }
+
+ public String getOperator() {
+ return operator;
+ }
+
+ public void setOperator(String operator) {
+ this.operator = operator;
+ }
+
+ public Calendar getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Calendar startDate) {
+ this.startDate = startDate;
+ }
+
+ public Calendar getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Calendar endDate) {
+ this.endDate = endDate;
+ }
+
+ public Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(location, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_OPERATOR, operator);
+ putValue(value, COLUMN_START_DATE, startDate != null ? startDate.getTimeInMillis() : null);
+ putValue(value, COLUMN_END_DATE, endDate != null ? endDate.getTimeInMillis() : null);
+ putValue(value, COLUMN_LOCATION, location != null ? location.getId() : null);
+ putValue(value, COLUMN_CONTEXT_ID, getParentId());
+ return value;
+ }
+
+ @Override
+ public Set<String> getRequiredFields() {
+ Set<String> result = super.getRequiredFields();
+ result.add(COLUMN_LOCATION);
+ return result;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.Gender;
-import fr.ifremer.wlo.models.referentials.Maturity;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MeasurementModel implements Serializable {
-
- private static final String TAG = "Measurement";
-
- public static final String SIZE_PROPERTY = "size";
- public static final String GENDER_PROPERTY = "gender";
- public static final String MATURITY_PROPERTY = "maturity";
- public static final String AGE_PROPERTY = "age";
-
- protected Integer size;
- protected Gender gender;
- protected Maturity maturity;
- protected Age age;
-
- protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
-
- public Integer getSize() {
- return size;
- }
-
- public void setSize(Integer size) {
- Integer oldValue = this.size;
- this.size = size;
- changeSupport.firePropertyChange(SIZE_PROPERTY, oldValue, size);
- }
-
- public void incSize() {
- if (size != null) {
- setSize(size + 1);
- }
- }
-
- public void decSize() {
- if (size != null) {
- setSize(size - 1);
- }
- }
-
- public Gender getGender() {
- return gender;
- }
-
- public void setGender(Gender gender) {
- Object oldValue = this.gender;
- this.gender = gender;
- changeSupport.firePropertyChange(GENDER_PROPERTY, oldValue, gender);
- }
-
- public Maturity getMaturity() {
- return maturity;
- }
-
- public void setMaturity(Maturity maturity) {
- Object oldValue = this.maturity;
- this.maturity = maturity;
- changeSupport.firePropertyChange(MATURITY_PROPERTY, oldValue, maturity);
- }
-
- public Age getAge() {
- return age;
- }
-
- public void setAge(Age age) {
- Object oldValue = this.age;
- this.age = age;
- changeSupport.firePropertyChange(AGE_PROPERTY, oldValue, age);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(property, listener);
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/MeasurementModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/MeasurementModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,173 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MeasurementModel extends HierarchicalModel<ScientificSpeciesModel> {
+
+ private static final String TAG = "MeasurementModel";
+
+ public static final String TABLE_NAME = "measurements";
+ public static final String COLUMN_SIZE = "size";
+ public static final String COLUMN_DATE = "date";
+ public static final String COLUMN_CATEGORY_1 = "category1";
+ public static final String COLUMN_CATEGORY_2 = "category2";
+ public static final String COLUMN_CATEGORY_3 = "category3";
+ public static final String COLUMN_SCIENTIFIC_SPECIES_ID = "scientificSpeciesId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_SIZE,
+ COLUMN_DATE,
+ COLUMN_CATEGORY_1,
+ COLUMN_CATEGORY_2,
+ COLUMN_CATEGORY_3,
+ COLUMN_SCIENTIFIC_SPECIES_ID
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected Integer size;
+ protected Calendar date;
+ protected String category1;
+ protected String category2;
+ protected String category3;
+
+ public MeasurementModel() {
+ }
+
+ public MeasurementModel(Cursor cursor) {
+ super(cursor);
+ size = cursor.getInt(1);
+ date = UIUtils.getCalendarFromCursor(cursor, 2);
+ category1 = cursor.getString(3);
+ category2 = cursor.getString(4);
+ category3 = cursor.getString(5);
+ }
+
+ public Integer getSize() {
+ return size;
+ }
+
+ public void setSize(Integer size) {
+ Integer oldValue = this.size;
+ this.size = size;
+ Log.d(TAG, size + " " + oldValue + " " + size.equals(oldValue));
+ changeSupport.firePropertyChange(COLUMN_SIZE, oldValue, size);
+ }
+
+ public void incSize(int inc) {
+ if (size != null) {
+ setSize(size + inc);
+ }
+ }
+
+ public void decSize(int dec) {
+ if (size != null) {
+ setSize(size - dec);
+ }
+ }
+
+ public void roundSize(Mensuration.Precision precision) {
+ if (size == null) {
+ return;
+ }
+ int precisionValue = precision.getValue();
+ int roundedSize = (size / precisionValue) * precisionValue;
+ setSize(roundedSize);
+ }
+
+ public Calendar getDate() {
+ return date;
+ }
+
+ public void setDate(Calendar date) {
+ this.date = date;
+ }
+
+ public String getCategory1() {
+ return category1;
+ }
+
+ public void setCategory1(String category1) {
+ this.category1 = category1;
+ }
+
+ public String getCategory2() {
+ return category2;
+ }
+
+ public void setCategory2(String category2) {
+ this.category2 = category2;
+ }
+
+ public String getCategory3() {
+ return category3;
+ }
+
+ public void setCategory3(String category3) {
+ this.category3 = category3;
+ }
+
+ public String toString(Context context, Mensuration.Precision precision) {
+ String dateFormat = UIUtils.getDateFormat(context) +
+ " " + context.getString(R.string.fulltime_format);
+
+ String result = String.format(dateFormat, date);
+ result += " - " + UIUtils.getFormattedSize(size, precision);
+ return result;
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_SIZE, size);
+ putValue(value, COLUMN_DATE, date != null ? date.getTimeInMillis() : null);
+ putValue(value, COLUMN_CATEGORY_1, category1);
+ putValue(value, COLUMN_CATEGORY_2, category2);
+ putValue(value, COLUMN_CATEGORY_3, category3);
+ putValue(value, COLUMN_SCIENTIFIC_SPECIES_ID, getParentId());
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,92 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MeasurementsModel implements Serializable {
-
- private static final String TAG = "Measurements";
-
- protected ScientificSpeciesModel scientificSpecies;
-
- protected Multimap<Integer, MeasurementModel> measurements = HashMultimap.create();
-
- transient protected List<MeasurementsListener> listeners = new ArrayList<MeasurementsListener>();
-
- public ScientificSpeciesModel getScientificSpecies() {
- return scientificSpecies;
- }
-
- public void setScientificSpecies(ScientificSpeciesModel scientificSpecies) {
- this.scientificSpecies = scientificSpecies;
- }
-
- public Multimap<Integer, MeasurementModel> getMeasurements() {
- return measurements;
- }
-
- public List<MeasurementModel> getMeasurements(int size) {
- return Lists.newArrayList(measurements.get(size));
- }
-
- public int getMeasurementNb(int size) {
- return measurements.get(size).size();
- }
-
- public void addMeasurement(MeasurementModel fishMeasurement) {
- int size = fishMeasurement.getSize();
- measurements.put(size, fishMeasurement);
- fireMeasurementAdded(fishMeasurement);
- }
-
- public void removeMeasurement(MeasurementModel fishMeasurement) {
- int size = fishMeasurement.getSize();
- measurements.remove(size, fishMeasurement);
- fireMeasurementRemoved(fishMeasurement);
- }
-
- public void addMeasurementsListener(MeasurementsListener listener) {
- ensureListeners();
- listeners.add(listener);
- }
-
- public void removeMeasurementsListener(MeasurementsListener listener) {
- ensureListeners();
- listeners.remove(listener);
- }
-
- protected void fireMeasurementAdded(MeasurementModel measurement) {
- for (MeasurementsListener listener : listeners) {
- listener.onMeasurementAdded(this, measurement);
- }
- }
-
- protected void ensureListeners() {
- if (listeners == null) {
- listeners = Lists.newArrayList();
- }
- }
-
- protected void fireMeasurementRemoved(MeasurementModel measurement) {
- for (MeasurementsListener listener : listeners) {
- listener.onMeasurementRemoved(this, measurement);
- }
- }
-
- public static interface MeasurementsListener {
-
- void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement);
-
- void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement);
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/MeasurementsModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/MeasurementsModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,127 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MeasurementsModel implements Serializable {
+
+ private static final String TAG = "Measurements";
+
+ protected ScientificSpeciesModel scientificSpecies;
+
+ protected Mensuration.Precision precision;
+
+ protected Multimap<Integer, MeasurementModel> measurements = HashMultimap.create();
+
+ transient protected List<MeasurementsListener> listeners = new ArrayList<MeasurementsListener>();
+
+ public ScientificSpeciesModel getScientificSpecies() {
+ return scientificSpecies;
+ }
+
+ public void setScientificSpecies(ScientificSpeciesModel scientificSpecies) {
+ this.scientificSpecies = scientificSpecies;
+ }
+
+ public Mensuration.Precision getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(Mensuration.Precision precision) {
+ this.precision = precision;
+ }
+
+ public Multimap<Integer, MeasurementModel> getMeasurements() {
+ return measurements;
+ }
+
+ public List<MeasurementModel> getMeasurements(int size) {
+ return Lists.newArrayList(measurements.get(size));
+ }
+
+ public int getMeasurementNb(int size) {
+ return measurements.get(size).size();
+ }
+
+ public void addMeasurement(MeasurementModel fishMeasurement) {
+ int size = fishMeasurement.getSize();
+ measurements.put(size, fishMeasurement);
+ fireMeasurementAdded(fishMeasurement);
+ }
+
+ public void removeMeasurement(MeasurementModel fishMeasurement) {
+ int size = fishMeasurement.getSize();
+ measurements.remove(size, fishMeasurement);
+ fireMeasurementRemoved(fishMeasurement);
+ }
+
+ public void addMeasurementsListener(MeasurementsListener listener) {
+ ensureListeners();
+ listeners.add(listener);
+ }
+
+ public void removeMeasurementsListener(MeasurementsListener listener) {
+ ensureListeners();
+ listeners.remove(listener);
+ }
+
+ protected void fireMeasurementAdded(MeasurementModel measurement) {
+ for (MeasurementsListener listener : listeners) {
+ listener.onMeasurementAdded(this, measurement);
+ }
+ }
+
+ protected void ensureListeners() {
+ if (listeners == null) {
+ listeners = Lists.newArrayList();
+ }
+ }
+
+ protected void fireMeasurementRemoved(MeasurementModel measurement) {
+ for (MeasurementsListener listener : listeners) {
+ listener.onMeasurementRemoved(this, measurement);
+ }
+ }
+
+ public static interface MeasurementsListener {
+
+ void onMeasurementAdded(MeasurementsModel source, MeasurementModel measurement);
+
+ void onMeasurementRemoved(MeasurementsModel source, MeasurementModel measurement);
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetierModel extends HierarchicalModel<VesselModel> {
-
- private static final String TAG = "Metier";
-
- public static final String TABLE_NAME = "metiers";
- public static final String COLUMN_GEAR_SPECIES = "gearSpecies";
- public static final String COLUMN_ZONE = "zone";
- public static final String COLUMN_SAMPLE_ROW_CODE = "sampleRowCode";
- public static final String COLUMN_VESSEL_ID = "vesselId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_GEAR_SPECIES,
- COLUMN_ZONE,
- COLUMN_SAMPLE_ROW_CODE,
- COLUMN_VESSEL_ID
- };
-
- protected Metier gearSpecies;
- protected String zone;
- protected String sampleRowCode;
-
- public MetierModel() {
- }
-
- public MetierModel(Context context, Cursor cursor) {
- super(cursor);
- String gearSpeciesId = cursor.getString(1);
- gearSpecies = DataCache.getMetierById(context, gearSpeciesId);
- zone = cursor.getString(2);
- sampleRowCode = cursor.getString(3);
- }
-
- public Metier getGearSpecies() {
- return gearSpecies;
- }
-
- public void setGearSpecies(Metier gearSpecies) {
- this.gearSpecies = gearSpecies;
- }
-
- public String getZone() {
- return zone;
- }
-
- public void setZone(String zone) {
- this.zone = zone;
- }
-
- public String getSampleRowCode() {
- return sampleRowCode;
- }
-
- public void setSampleRowCode(String sampleRowCode) {
- this.sampleRowCode = sampleRowCode;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(Context context) {
- return UIUtils.getStringOrUndefined(gearSpecies, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_GEAR_SPECIES, gearSpecies != null ? gearSpecies.getId() : null);
- putValue(value, COLUMN_ZONE, zone);
- putValue(value, COLUMN_SAMPLE_ROW_CODE, sampleRowCode);
- putValue(value, COLUMN_VESSEL_ID, getParentId());
- return value;
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/MetierModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/MetierModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,114 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetierModel extends HierarchicalModel<VesselModel> {
+
+ private static final String TAG = "Metier";
+
+ public static final String TABLE_NAME = "metiers";
+ public static final String COLUMN_GEAR_SPECIES = "gearSpecies";
+ public static final String COLUMN_ZONE = "zone";
+ public static final String COLUMN_SAMPLE_ROW_CODE = "sampleRowCode";
+ public static final String COLUMN_VESSEL_ID = "vesselId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_GEAR_SPECIES,
+ COLUMN_ZONE,
+ COLUMN_SAMPLE_ROW_CODE,
+ COLUMN_VESSEL_ID
+ };
+
+ protected Metier gearSpecies;
+ protected String zone;
+ protected String sampleRowCode;
+
+ public MetierModel() {
+ }
+
+ public MetierModel(Context context, Cursor cursor) {
+ super(cursor);
+ String gearSpeciesId = cursor.getString(1);
+ gearSpecies = DataCache.getMetierById(context, gearSpeciesId);
+ zone = cursor.getString(2);
+ sampleRowCode = cursor.getString(3);
+ }
+
+ public Metier getGearSpecies() {
+ return gearSpecies;
+ }
+
+ public void setGearSpecies(Metier gearSpecies) {
+ this.gearSpecies = gearSpecies;
+ }
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getSampleRowCode() {
+ return sampleRowCode;
+ }
+
+ public void setSampleRowCode(String sampleRowCode) {
+ this.sampleRowCode = sampleRowCode;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(Context context) {
+ return UIUtils.getStringOrUndefined(gearSpecies, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_GEAR_SPECIES, gearSpecies != null ? gearSpecies.getId() : null);
+ putValue(value, COLUMN_ZONE, zone);
+ putValue(value, COLUMN_SAMPLE_ROW_CODE, sampleRowCode);
+ putValue(value, COLUMN_VESSEL_ID, getParentId());
+ return value;
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,77 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.util.Log;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesModel extends HierarchicalModel<CommercialSpeciesModel> {
-
- private static final String TAG = "ScientificSpecies";
-
- public static final String TABLE_NAME = "scientific_species";
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_TAKING_ACTIVATION = "takingActivation";
- public static final String COLUMN_COMMERCIAL_SPECIES_ID = "commercialSpeciesId";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_NAME,
- COLUMN_TAKING_ACTIVATION,
- COLUMN_COMMERCIAL_SPECIES_ID
- };
-
- protected ScientificSpecies name;
- protected boolean takingActivation;
-
- public ScientificSpeciesModel() {
- }
-
- public ScientificSpeciesModel(Context context, Cursor cursor) {
- super(cursor);
- String nameId = cursor.getString(1);
- name = DataCache.getScientificSpeciesById(context, nameId);
- takingActivation = cursor.getShort(2) > 0;
- }
-
- public ScientificSpecies getName() {
- return name;
- }
-
- public void setName(ScientificSpecies name) {
- this.name = name;
- }
-
- public boolean isTakingActivation() {
- return takingActivation;
- }
-
- public void setTakingActivation(boolean takingActivation) {
- this.takingActivation = takingActivation;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(name, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_NAME, name != null ? name.getId() : null);
- putValue(value, COLUMN_TAKING_ACTIVATION, takingActivation ? 1 : 0);
- putValue(value, COLUMN_COMMERCIAL_SPECIES_ID, getParentId());
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/ScientificSpeciesModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,101 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesModel extends HierarchicalModel<CommercialSpeciesModel> {
+
+ private static final String TAG = "ScientificSpecies";
+
+ public static final String TABLE_NAME = "scientific_species";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_TAKING_ACTIVATION = "takingActivation";
+ public static final String COLUMN_COMMERCIAL_SPECIES_ID = "commercialSpeciesId";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_NAME,
+ COLUMN_TAKING_ACTIVATION,
+ COLUMN_COMMERCIAL_SPECIES_ID
+ };
+
+ protected ScientificSpecies name;
+ protected boolean takingActivation;
+
+ public ScientificSpeciesModel() {
+ }
+
+ public ScientificSpeciesModel(Context context, Cursor cursor) {
+ super(cursor);
+ String nameId = cursor.getString(1);
+ name = DataCache.getScientificSpeciesById(context, nameId);
+ takingActivation = cursor.getShort(2) > 0;
+ }
+
+ public ScientificSpecies getName() {
+ return name;
+ }
+
+ public void setName(ScientificSpecies name) {
+ this.name = name;
+ }
+
+ public boolean isTakingActivation() {
+ return takingActivation;
+ }
+
+ public void setTakingActivation(boolean takingActivation) {
+ this.takingActivation = takingActivation;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(name, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_NAME, name != null ? name.getId() : null);
+ putValue(value, COLUMN_TAKING_ACTIVATION, takingActivation ? 1 : 0);
+ putValue(value, COLUMN_COMMERCIAL_SPECIES_ID, getParentId());
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,120 +0,0 @@
-package fr.ifremer.wlo.models;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.util.Log;
-import com.google.common.collect.Sets;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.utils.UIUtils;
-
-import java.util.Calendar;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselModel extends HierarchicalModel<LocationModel> {
-
- private static final String TAG = "Vessel";
-
- public static final String TABLE_NAME = "vessels";
- public static final String COLUMN_REGISTRATION_NUMBER = "registrationNumber";
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_LANDING_DATE = "landingDate";
- public static final String COLUMN_LANDING_LOCATION = "landingLocation";
- public static final String COLUMN_LOCATION_ID = "location_id";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_REGISTRATION_NUMBER,
- COLUMN_NAME,
- COLUMN_LANDING_DATE,
- COLUMN_LANDING_LOCATION,
- COLUMN_LOCATION_ID
- };
-
- protected String registrationNumber;
- protected String name;
- protected Calendar landingDate;
- protected Location landingLocation;
-
- public VesselModel() {
- }
-
- public VesselModel(Context context, Cursor cursor) {
- super(cursor);
- registrationNumber = cursor.getString(1);
- name = cursor.getString(2);
- landingDate = UIUtils.getCalendarFromCursor(cursor, 3);
- String landingLocationId = cursor.getString(4);
- landingLocation = DataCache.getLocationById(context, landingLocationId);
- }
-
- public String getRegistrationNumber() {
- return registrationNumber;
- }
-
- public void setRegistrationNumber(String registrationNumber) {
- Object oldValue = this.registrationNumber;
- this.registrationNumber = registrationNumber;
- changeSupport.firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- Object oldValue = this.name;
- this.name = name;
- changeSupport.firePropertyChange(COLUMN_NAME, oldValue, name);
- }
-
- public Calendar getLandingDate() {
- return landingDate;
- }
-
- public void setLandingDate(Calendar landingDate) {
- this.landingDate = landingDate;
- }
-
- public Location getLandingLocation() {
- return landingLocation;
- }
-
- public void setLandingLocation(Location landingLocation) {
- this.landingLocation = landingLocation;
- }
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(registrationNumber, context) + " - "
- + UIUtils.getStringOrUndefined(name, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_REGISTRATION_NUMBER, registrationNumber);
- putValue(value, COLUMN_NAME, name);
- putValue(value, COLUMN_LANDING_DATE, landingDate != null ? landingDate.getTimeInMillis() : null);
- putValue(value, COLUMN_LANDING_LOCATION, landingLocation != null ? landingLocation.getId() : null);
- putValue(value, COLUMN_LOCATION_ID, getParentId());
- return value;
- }
-
- @Override
- public Set<Set<String>> getOneRequiredFields() {
- Set<Set<String>> result = super.getOneRequiredFields();
- Set<String> oneRequired = Sets.newHashSet(COLUMN_REGISTRATION_NUMBER, COLUMN_NAME);
- result.add(oneRequired);
- return result;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/VesselModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/VesselModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,144 @@
+package fr.ifremer.wlo.models;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+import com.google.common.collect.Sets;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.utils.UIUtils;
+
+import java.util.Calendar;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselModel extends HierarchicalModel<LocationModel> {
+
+ private static final String TAG = "Vessel";
+
+ public static final String TABLE_NAME = "vessels";
+ public static final String COLUMN_REGISTRATION_NUMBER = "registrationNumber";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_LANDING_DATE = "landingDate";
+ public static final String COLUMN_LANDING_LOCATION = "landingLocation";
+ public static final String COLUMN_LOCATION_ID = "location_id";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_REGISTRATION_NUMBER,
+ COLUMN_NAME,
+ COLUMN_LANDING_DATE,
+ COLUMN_LANDING_LOCATION,
+ COLUMN_LOCATION_ID
+ };
+
+ protected String registrationNumber;
+ protected String name;
+ protected Calendar landingDate;
+ protected Location landingLocation;
+
+ public VesselModel() {
+ }
+
+ public VesselModel(Context context, Cursor cursor) {
+ super(cursor);
+ registrationNumber = cursor.getString(1);
+ name = cursor.getString(2);
+ landingDate = UIUtils.getCalendarFromCursor(cursor, 3);
+ String landingLocationId = cursor.getString(4);
+ landingLocation = DataCache.getLocationById(context, landingLocationId);
+ }
+
+ public String getRegistrationNumber() {
+ return registrationNumber;
+ }
+
+ public void setRegistrationNumber(String registrationNumber) {
+ Object oldValue = this.registrationNumber;
+ this.registrationNumber = registrationNumber;
+ changeSupport.firePropertyChange(COLUMN_REGISTRATION_NUMBER, oldValue, registrationNumber);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ Object oldValue = this.name;
+ this.name = name;
+ changeSupport.firePropertyChange(COLUMN_NAME, oldValue, name);
+ }
+
+ public Calendar getLandingDate() {
+ return landingDate;
+ }
+
+ public void setLandingDate(Calendar landingDate) {
+ this.landingDate = landingDate;
+ }
+
+ public Location getLandingLocation() {
+ return landingLocation;
+ }
+
+ public void setLandingLocation(Location landingLocation) {
+ this.landingLocation = landingLocation;
+ }
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(registrationNumber, context) + " - "
+ + UIUtils.getStringOrUndefined(name, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_REGISTRATION_NUMBER, registrationNumber);
+ putValue(value, COLUMN_NAME, name);
+ putValue(value, COLUMN_LANDING_DATE, landingDate != null ? landingDate.getTimeInMillis() : null);
+ putValue(value, COLUMN_LANDING_LOCATION, landingLocation != null ? landingLocation.getId() : null);
+ putValue(value, COLUMN_LOCATION_ID, getParentId());
+ return value;
+ }
+
+ @Override
+ public Set<Set<String>> getOneRequiredFields() {
+ Set<Set<String>> result = super.getOneRequiredFields();
+ Set<String> oneRequired = Sets.newHashSet(COLUMN_REGISTRATION_NUMBER, COLUMN_NAME);
+ result.add(oneRequired);
+ return result;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Age.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,62 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Age extends BaseModel {
-
- private static final String TAG = "Age";
-
- public static final String TABLE_NAME = "ref_ages";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String label;
-
- public Age() {
- }
-
- public Age(Cursor cursor) {
- super(cursor);
- label = cursor.getString(1);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Age.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Age.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,86 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Age extends BaseModel {
+
+ private static final String TAG = "Age";
+
+ public static final String TABLE_NAME = "ref_ages";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String label;
+
+ public Age() {
+ }
+
+ public Age(Cursor cursor) {
+ super(cursor);
+ label = cursor.getString(1);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,154 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpecies extends BaseModel implements HasCode {
-
- private static final String TAG = "CommercialSpecies";
-
- public static final String TABLE_NAME = "ref_commercial_species";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_ISSCAP = "isscap";
- public static final String COLUMN_TAXON_CODE = "taxonCode";
- public static final String COLUMN_SCIENTIFIC_LABEL = "scientificLabel";
- public static final String COLUMN_FRENCH_LABEL = "frenchLabel";
- public static final String COLUMN_FAMILY = "family";
- public static final String COLUMN_SPECIES_ORDER = "speciesOrder";
- public static final String COLUMN_ACTIVE = "active";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_ISSCAP,
- COLUMN_TAXON_CODE,
- COLUMN_SCIENTIFIC_LABEL,
- COLUMN_FRENCH_LABEL,
- COLUMN_FAMILY,
- COLUMN_SPECIES_ORDER,
- COLUMN_ACTIVE
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String isscap;
- protected String taxonCode;
- protected String scientificLabel;
- protected String frenchLabel;
- protected String family;
- protected String speciesOrder;
- protected int active;
-
- public CommercialSpecies() {
- }
-
- public CommercialSpecies(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- isscap = cursor.getString(2);
- taxonCode = cursor.getString(3);
- scientificLabel = cursor.getString(4);
- frenchLabel = cursor.getString(5);
- family = cursor.getString(6);
- speciesOrder = cursor.getString(7);
- active = cursor.getInt(8);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getIsscap() {
- return isscap;
- }
-
- public void setIsscap(String isscap) {
- this.isscap = isscap;
- }
-
- public String getTaxonCode() {
- return taxonCode;
- }
-
- public void setTaxonCode(String taxonCode) {
- this.taxonCode = taxonCode;
- }
-
- public String getScientificLabel() {
- return scientificLabel;
- }
-
- public void setScientificLabel(String scientificLabel) {
- this.scientificLabel = scientificLabel;
- }
-
- public String getFrenchLabel() {
- return frenchLabel;
- }
-
- public void setFrenchLabel(String frenchLabel) {
- this.frenchLabel = frenchLabel;
- }
-
- public String getFamily() {
- return family;
- }
-
- public void setFamily(String family) {
- this.family = family;
- }
-
- public String getSpeciesOrder() {
- return speciesOrder;
- }
-
- public void setSpeciesOrder(String speciesOrder) {
- this.speciesOrder = speciesOrder;
- }
-
- public int getActive() {
- return active;
- }
-
- public void setActive(int active) {
- this.active = active;
- }
-
- @Override
- public String toString() {
- return code + " - " + frenchLabel;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(frenchLabel, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_ISSCAP, isscap);
- putValue(value, COLUMN_TAXON_CODE, taxonCode);
- putValue(value, COLUMN_SCIENTIFIC_LABEL, scientificLabel);
- putValue(value, COLUMN_FRENCH_LABEL, frenchLabel);
- putValue(value, COLUMN_FAMILY, family);
- putValue(value, COLUMN_SPECIES_ORDER, speciesOrder);
- putValue(value, COLUMN_ACTIVE, active);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/CommercialSpecies.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,178 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpecies extends BaseModel implements HasCode {
+
+ private static final String TAG = "CommercialSpecies";
+
+ public static final String TABLE_NAME = "ref_commercial_species";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_ISSCAP = "isscap";
+ public static final String COLUMN_TAXON_CODE = "taxonCode";
+ public static final String COLUMN_SCIENTIFIC_LABEL = "scientificLabel";
+ public static final String COLUMN_FRENCH_LABEL = "frenchLabel";
+ public static final String COLUMN_FAMILY = "family";
+ public static final String COLUMN_SPECIES_ORDER = "speciesOrder";
+ public static final String COLUMN_ACTIVE = "active";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_ISSCAP,
+ COLUMN_TAXON_CODE,
+ COLUMN_SCIENTIFIC_LABEL,
+ COLUMN_FRENCH_LABEL,
+ COLUMN_FAMILY,
+ COLUMN_SPECIES_ORDER,
+ COLUMN_ACTIVE
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String isscap;
+ protected String taxonCode;
+ protected String scientificLabel;
+ protected String frenchLabel;
+ protected String family;
+ protected String speciesOrder;
+ protected int active;
+
+ public CommercialSpecies() {
+ }
+
+ public CommercialSpecies(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ isscap = cursor.getString(2);
+ taxonCode = cursor.getString(3);
+ scientificLabel = cursor.getString(4);
+ frenchLabel = cursor.getString(5);
+ family = cursor.getString(6);
+ speciesOrder = cursor.getString(7);
+ active = cursor.getInt(8);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getIsscap() {
+ return isscap;
+ }
+
+ public void setIsscap(String isscap) {
+ this.isscap = isscap;
+ }
+
+ public String getTaxonCode() {
+ return taxonCode;
+ }
+
+ public void setTaxonCode(String taxonCode) {
+ this.taxonCode = taxonCode;
+ }
+
+ public String getScientificLabel() {
+ return scientificLabel;
+ }
+
+ public void setScientificLabel(String scientificLabel) {
+ this.scientificLabel = scientificLabel;
+ }
+
+ public String getFrenchLabel() {
+ return frenchLabel;
+ }
+
+ public void setFrenchLabel(String frenchLabel) {
+ this.frenchLabel = frenchLabel;
+ }
+
+ public String getFamily() {
+ return family;
+ }
+
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ public String getSpeciesOrder() {
+ return speciesOrder;
+ }
+
+ public void setSpeciesOrder(String speciesOrder) {
+ this.speciesOrder = speciesOrder;
+ }
+
+ public int getActive() {
+ return active;
+ }
+
+ public void setActive(int active) {
+ this.active = active;
+ }
+
+ @Override
+ public String toString() {
+ return code + " - " + frenchLabel;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(frenchLabel, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_ISSCAP, isscap);
+ putValue(value, COLUMN_TAXON_CODE, taxonCode);
+ putValue(value, COLUMN_SCIENTIFIC_LABEL, scientificLabel);
+ putValue(value, COLUMN_FRENCH_LABEL, frenchLabel);
+ putValue(value, COLUMN_FAMILY, family);
+ putValue(value, COLUMN_SPECIES_ORDER, speciesOrder);
+ putValue(value, COLUMN_ACTIVE, active);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Gender.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,75 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Gender extends BaseModel implements HasCode {
-
- private static final String TAG = "Gender";
-
- public static final String TABLE_NAME = "ref_genders";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public Gender() {
- }
-
- public Gender(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Gender.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Gender.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,99 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Gender extends BaseModel implements HasCode {
+
+ private static final String TAG = "Gender";
+
+ public static final String TABLE_NAME = "ref_genders";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public Gender() {
+ }
+
+ public Gender(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/HasCode.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,29 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import com.google.common.base.Function;
-import org.apache.commons.lang3.ObjectUtils;
-
-import java.util.Comparator;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public interface HasCode {
-
- String getCode();
-
- public static final Comparator<HasCode> GET_CODE_COMPARATOR = new Comparator<HasCode>() {
- @Override
- public int compare(HasCode lhs, HasCode rhs) {
- return ObjectUtils.compare(lhs.getCode(), rhs.getCode(), true);
- }
- };
-
- public static final Function<HasCode, String> GET_CODE_FUNCTION = new Function<HasCode, String>() {
- @Override
- public String apply(HasCode input) {
- return input.getCode();
- }
- };
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/HasCode.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/HasCode.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,53 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Function;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.util.Comparator;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public interface HasCode {
+
+ String getCode();
+
+ public static final Comparator<HasCode> GET_CODE_COMPARATOR = new Comparator<HasCode>() {
+ @Override
+ public int compare(HasCode lhs, HasCode rhs) {
+ return ObjectUtils.compare(lhs.getCode(), rhs.getCode(), true);
+ }
+ };
+
+ public static final Function<HasCode, String> GET_CODE_FUNCTION = new Function<HasCode, String>() {
+ @Override
+ public String apply(HasCode input) {
+ return input.getCode();
+ }
+ };
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Location.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,90 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Location extends BaseModel implements HasCode {
-
- private static final String TAG = "Locations";
-
- public static final String TABLE_NAME = "ref_location";
- public static final String COLUMN_TYPE_LABEL = "typeLabel";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_TYPE_LABEL,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String typeLabel;
- protected String code;
- protected String label;
-
- public Location() {
- }
-
- public Location(Cursor cursor) {
- super(cursor);
- typeLabel = cursor.getString(1);
- code = cursor.getString(2);
- label = cursor.getString(3);
- }
-
- public String getTypeLabel() {
- return typeLabel;
- }
-
- public void setTypeLabel(String typeLabel) {
- this.typeLabel = typeLabel;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return code + " - " + label + " (" + typeLabel + ")";
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(label, context) + " ("
- + UIUtils.getStringOrUndefined(typeLabel, context) + ")";
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_TYPE_LABEL, typeLabel);
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Location.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Location.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,114 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Location extends BaseModel implements HasCode {
+
+ private static final String TAG = "Locations";
+
+ public static final String TABLE_NAME = "ref_location";
+ public static final String COLUMN_TYPE_LABEL = "typeLabel";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_TYPE_LABEL,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String typeLabel;
+ protected String code;
+ protected String label;
+
+ public Location() {
+ }
+
+ public Location(Cursor cursor) {
+ super(cursor);
+ typeLabel = cursor.getString(1);
+ code = cursor.getString(2);
+ label = cursor.getString(3);
+ }
+
+ public String getTypeLabel() {
+ return typeLabel;
+ }
+
+ public void setTypeLabel(String typeLabel) {
+ this.typeLabel = typeLabel;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return code + " - " + label + " (" + typeLabel + ")";
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(label, context) + " ("
+ + UIUtils.getStringOrUndefined(typeLabel, context) + ")";
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_TYPE_LABEL, typeLabel);
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Maturity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,62 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Maturity extends BaseModel {
-
- private static final String TAG = "Maturity";
-
- public static final String TABLE_NAME = "ref_maturities";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String label;
-
- public Maturity() {
- }
-
- public Maturity(Cursor cursor) {
- super(cursor);
- label = cursor.getString(1);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Maturity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Maturity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,86 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Maturity extends BaseModel {
+
+ private static final String TAG = "Maturity";
+
+ public static final String TABLE_NAME = "ref_maturities";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String label;
+
+ public Maturity() {
+ }
+
+ public Maturity(Cursor cursor) {
+ super(cursor);
+ label = cursor.getString(1);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Mensuration.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,96 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Mensuration extends BaseModel implements HasCode {
-
- private static final String TAG = "Mensuration";
-
- public enum Precision {
- CM1("1 cm"),
- MM5("0.5 cm"),
- MM1("1 mm");
-
- private String label;
-
- private Precision(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
- @Override
- public String toString() {
- return label;
- }
- }
-
- public static final String TABLE_NAME = "ref_mensurations";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public Mensuration() {
- }
-
- public Mensuration(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Mensuration.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Mensuration.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,136 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Mensuration extends BaseModel implements HasCode {
+
+ private static final String TAG = "Mensuration";
+
+ public enum Precision {
+ CM1(10, 10, "1 cm"),
+ MM5(5, 10, "0.5 cm"),
+ MM1(1, 1, "1 mm");
+
+ private int value;
+ private int unitDivider;
+ private String label;
+
+ private Precision(int value, int unitDivider, String label) {
+ this.value = value;
+ this.unitDivider = unitDivider;
+ this.label = label;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public int getUnitDivider() {
+ return unitDivider;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ public boolean isDecimal() {
+ return value % unitDivider > 0;
+ }
+ }
+
+ public static final String TABLE_NAME = "ref_mensurations";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public Mensuration() {
+ }
+
+ public Mensuration(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Metier.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,166 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Metier extends BaseModel implements HasCode {
-
- private static final String TAG = "Metier";
-
- public static final String TABLE_NAME = "ref_metiers";
- public static final String COLUMN_ID = "metierId";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String COLUMN_GEAR_CODE = "gearCode";
- public static final String COLUMN_GEAR_LABEL = "gearLabel";
- public static final String COLUMN_SPECIES_CODE = "speciesCode";
- public static final String COLUMN_SPECIES_LABEL = "speciesLabel";
- public static final String COLUMN_FISHING = "fishing";
- public static final String COLUMN_ACTIVE = "active";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_ID,
- COLUMN_CODE,
- COLUMN_LABEL,
- COLUMN_GEAR_CODE,
- COLUMN_GEAR_LABEL,
- COLUMN_SPECIES_CODE,
- COLUMN_SPECIES_LABEL,
- COLUMN_FISHING,
- COLUMN_ACTIVE
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String metierId;
- protected String code;
- protected String label;
- protected String gearCode;
- protected String gearLabel;
- protected String speciesCode;
- protected String speciesLabel;
- protected int fishing;
- protected int active;
-
- public Metier() {
- }
-
- public Metier(Cursor cursor) {
- super(cursor);
- metierId = cursor.getString(1);
- code = cursor.getString(2);
- label = cursor.getString(3);
- gearCode = cursor.getString(4);
- gearLabel = cursor.getString(5);
- speciesCode = cursor.getString(6);
- speciesLabel = cursor.getString(7);
- fishing = cursor.getInt(8);
- active = cursor.getInt(9);
- }
-
- public String getMetierId() {
- return metierId;
- }
-
- public void setMetierId(String metierId) {
- this.metierId = metierId;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getGearCode() {
- return gearCode;
- }
-
- public void setGearCode(String gearCode) {
- this.gearCode = gearCode;
- }
-
- public String getGearLabel() {
- return gearLabel;
- }
-
- public void setGearLabel(String gearLabel) {
- this.gearLabel = gearLabel;
- }
-
- public String getSpeciesCode() {
- return speciesCode;
- }
-
- public void setSpeciesCode(String speciesCode) {
- this.speciesCode = speciesCode;
- }
-
- public String getSpeciesLabel() {
- return speciesLabel;
- }
-
- public void setSpeciesLabel(String speciesLabel) {
- this.speciesLabel = speciesLabel;
- }
-
- public int getFishing() {
- return fishing;
- }
-
- public void setFishing(int fishing) {
- this.fishing = fishing;
- }
-
- public int getActive() {
- return active;
- }
-
- public void setActive(int active) {
- this.active = active;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_ID, metierId);
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- putValue(value, COLUMN_GEAR_CODE, gearCode);
- putValue(value, COLUMN_GEAR_LABEL, gearLabel);
- putValue(value, COLUMN_SPECIES_CODE, speciesCode);
- putValue(value, COLUMN_SPECIES_LABEL, speciesLabel);
- putValue(value, COLUMN_FISHING, fishing);
- putValue(value, COLUMN_ACTIVE, active);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Metier.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Metier.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,190 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Metier extends BaseModel implements HasCode {
+
+ private static final String TAG = "Metier";
+
+ public static final String TABLE_NAME = "ref_metiers";
+ public static final String COLUMN_ID = "metierId";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String COLUMN_GEAR_CODE = "gearCode";
+ public static final String COLUMN_GEAR_LABEL = "gearLabel";
+ public static final String COLUMN_SPECIES_CODE = "speciesCode";
+ public static final String COLUMN_SPECIES_LABEL = "speciesLabel";
+ public static final String COLUMN_FISHING = "fishing";
+ public static final String COLUMN_ACTIVE = "active";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_ID,
+ COLUMN_CODE,
+ COLUMN_LABEL,
+ COLUMN_GEAR_CODE,
+ COLUMN_GEAR_LABEL,
+ COLUMN_SPECIES_CODE,
+ COLUMN_SPECIES_LABEL,
+ COLUMN_FISHING,
+ COLUMN_ACTIVE
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String metierId;
+ protected String code;
+ protected String label;
+ protected String gearCode;
+ protected String gearLabel;
+ protected String speciesCode;
+ protected String speciesLabel;
+ protected int fishing;
+ protected int active;
+
+ public Metier() {
+ }
+
+ public Metier(Cursor cursor) {
+ super(cursor);
+ metierId = cursor.getString(1);
+ code = cursor.getString(2);
+ label = cursor.getString(3);
+ gearCode = cursor.getString(4);
+ gearLabel = cursor.getString(5);
+ speciesCode = cursor.getString(6);
+ speciesLabel = cursor.getString(7);
+ fishing = cursor.getInt(8);
+ active = cursor.getInt(9);
+ }
+
+ public String getMetierId() {
+ return metierId;
+ }
+
+ public void setMetierId(String metierId) {
+ this.metierId = metierId;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getGearCode() {
+ return gearCode;
+ }
+
+ public void setGearCode(String gearCode) {
+ this.gearCode = gearCode;
+ }
+
+ public String getGearLabel() {
+ return gearLabel;
+ }
+
+ public void setGearLabel(String gearLabel) {
+ this.gearLabel = gearLabel;
+ }
+
+ public String getSpeciesCode() {
+ return speciesCode;
+ }
+
+ public void setSpeciesCode(String speciesCode) {
+ this.speciesCode = speciesCode;
+ }
+
+ public String getSpeciesLabel() {
+ return speciesLabel;
+ }
+
+ public void setSpeciesLabel(String speciesLabel) {
+ this.speciesLabel = speciesLabel;
+ }
+
+ public int getFishing() {
+ return fishing;
+ }
+
+ public void setFishing(int fishing) {
+ this.fishing = fishing;
+ }
+
+ public int getActive() {
+ return active;
+ }
+
+ public void setActive(int active) {
+ this.active = active;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_ID, metierId);
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ putValue(value, COLUMN_GEAR_CODE, gearCode);
+ putValue(value, COLUMN_GEAR_LABEL, gearLabel);
+ putValue(value, COLUMN_SPECIES_CODE, speciesCode);
+ putValue(value, COLUMN_SPECIES_LABEL, speciesLabel);
+ putValue(value, COLUMN_FISHING, fishing);
+ putValue(value, COLUMN_ACTIVE, active);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Presentation.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,75 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Presentation extends BaseModel implements HasCode {
-
- private static final String TAG = "Presentation";
-
- public static final String TABLE_NAME = "ref_presentations";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public Presentation() {
- }
-
- public Presentation(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Presentation.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Presentation.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,99 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Presentation extends BaseModel implements HasCode {
+
+ private static final String TAG = "Presentation";
+
+ public static final String TABLE_NAME = "ref_presentations";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public Presentation() {
+ }
+
+ public Presentation(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,89 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpecies extends BaseModel implements HasCode {
-
- private static final String TAG = "ScientificSpecies";
-
- public static final String TABLE_NAME = "ref_scientific_species";
- public static final String COLUMN_PERM_CODE = "permCode";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_PERM_CODE,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String permCode;
- protected String code;
- protected String label;
-
- public ScientificSpecies() {
- }
-
- public ScientificSpecies(Cursor cursor) {
- super(cursor);
- permCode = cursor.getString(1);
- code = cursor.getString(2);
- label = cursor.getString(3);
- }
-
- public String getPermCode() {
- return permCode;
- }
-
- public void setPermCode(String permCode) {
- this.permCode = permCode;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return code + " - " + label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_PERM_CODE, permCode);
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/ScientificSpecies.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,113 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpecies extends BaseModel implements HasCode {
+
+ private static final String TAG = "ScientificSpecies";
+
+ public static final String TABLE_NAME = "ref_scientific_species";
+ public static final String COLUMN_PERM_CODE = "permCode";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_PERM_CODE,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String permCode;
+ protected String code;
+ protected String label;
+
+ public ScientificSpecies() {
+ }
+
+ public ScientificSpecies(Cursor cursor) {
+ super(cursor);
+ permCode = cursor.getString(1);
+ code = cursor.getString(2);
+ label = cursor.getString(3);
+ }
+
+ public String getPermCode() {
+ return permCode;
+ }
+
+ public void setPermCode(String permCode) {
+ this.permCode = permCode;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return code + " - " + label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_PERM_CODE, permCode);
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/State.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,75 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class State extends BaseModel implements HasCode {
-
- private static final String TAG = "State";
-
- public static final String TABLE_NAME = "ref_states";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_LABEL = "label";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_LABEL
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String label;
-
- public State() {
- }
-
- public State(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- label = cursor.getString(2);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- @Override
- public String toString() {
- return label;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(label, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_LABEL, label);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/State.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/State.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,99 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class State extends BaseModel implements HasCode {
+
+ private static final String TAG = "State";
+
+ public static final String TABLE_NAME = "ref_states";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_LABEL = "label";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_LABEL
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String label;
+
+ public State() {
+ }
+
+ public State(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ label = cursor.getString(2);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ @Override
+ public String toString() {
+ return label;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(label, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_LABEL, label);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/Vessel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,84 +0,0 @@
-package fr.ifremer.wlo.models.referentials;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.utils.UIUtils;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class Vessel extends BaseModel implements HasCode {
-
- private static final String TAG = "Vessel";
-
- public static final String TABLE_NAME = "ref_vessel";
- public static final String COLUMN_CODE = "code";
- public static final String COLUMN_NAME = "name";
- public static final String COLUMN_QUARTER_CODE = "quarterCode";
- public static final String[] ALL_COLUMNS = new String[] {
- _ID,
- COLUMN_CODE,
- COLUMN_NAME,
- COLUMN_QUARTER_CODE
- };
-
- @Override
- public String getTableName() {
- return TABLE_NAME;
- }
-
- protected String code;
- protected String name;
- protected String quarterCode;
-
- public Vessel() {
- }
-
- public Vessel(Cursor cursor) {
- super(cursor);
- code = cursor.getString(1);
- name = cursor.getString(2);
- quarterCode = cursor.getString(3);
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getQuarterCode() {
- return quarterCode;
- }
-
- public void setQuarterCode(String quarterCode) {
- this.quarterCode = quarterCode;
- }
-
- @Override
- public String toString(android.content.Context context) {
- return UIUtils.getStringOrUndefined(code, context) + " - " +
- UIUtils.getStringOrUndefined(name, context);
- }
-
- @Override
- public ContentValues convertIntoContentValues() {
- ContentValues value = super.convertIntoContentValues();
- putValue(value, COLUMN_CODE, code);
- putValue(value, COLUMN_NAME, name);
- putValue(value, COLUMN_QUARTER_CODE, quarterCode);
- return value;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/Vessel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/Vessel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,108 @@
+package fr.ifremer.wlo.models.referentials;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.utils.UIUtils;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class Vessel extends BaseModel implements HasCode {
+
+ private static final String TAG = "Vessel";
+
+ public static final String TABLE_NAME = "ref_vessel";
+ public static final String COLUMN_CODE = "code";
+ public static final String COLUMN_NAME = "name";
+ public static final String COLUMN_QUARTER_CODE = "quarterCode";
+ public static final String[] ALL_COLUMNS = new String[] {
+ _ID,
+ COLUMN_CODE,
+ COLUMN_NAME,
+ COLUMN_QUARTER_CODE
+ };
+
+ @Override
+ public String getTableName() {
+ return TABLE_NAME;
+ }
+
+ protected String code;
+ protected String name;
+ protected String quarterCode;
+
+ public Vessel() {
+ }
+
+ public Vessel(Cursor cursor) {
+ super(cursor);
+ code = cursor.getString(1);
+ name = cursor.getString(2);
+ quarterCode = cursor.getString(3);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getQuarterCode() {
+ return quarterCode;
+ }
+
+ public void setQuarterCode(String quarterCode) {
+ this.quarterCode = quarterCode;
+ }
+
+ @Override
+ public String toString(android.content.Context context) {
+ return UIUtils.getStringOrUndefined(code, context) + " - " +
+ UIUtils.getStringOrUndefined(name, context);
+ }
+
+ @Override
+ public ContentValues convertIntoContentValues() {
+ ContentValues value = super.convertIntoContentValues();
+ putValue(value, COLUMN_CODE, code);
+ putValue(value, COLUMN_NAME, name);
+ putValue(value, COLUMN_QUARTER_CODE, quarterCode);
+ return value;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,28 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Age;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class AgeRowModel extends AbstractImportExportModel<Age> {
-
- public AgeRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Age", new ValueSetter<Age, String>() {
- @Override
- public void set(Age object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Age newEmptyInstance() {
- return new Age();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/AgeRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,52 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Age;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class AgeRowModel extends AbstractImportExportModel<Age> {
+
+ public AgeRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Age", new ValueSetter<Age, String>() {
+ @Override
+ public void set(Age object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Age newEmptyInstance() {
+ return new Age();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,77 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class CommercialSpeciesRowModel extends AbstractImportExportModel<CommercialSpecies> {
-
-
- public CommercialSpeciesRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("ESPF_COD", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("ESPF_ISSCAP", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setIsscap(value);
- }
- });
- newMandatoryColumn("ESPF_TAXON_COD", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setTaxonCode(value);
- }
- });
- newMandatoryColumn("ESPF_SCI_LIB", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setScientificLabel(value);
- }
- });
- newMandatoryColumn("ESPF_FRA_LIB", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setFrenchLabel(value);
- }
- });
- newMandatoryColumn("ESPF_FAMILLE", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setFamily(value);
- }
- });
- newMandatoryColumn("ESPF_ORDRE", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- object.setSpeciesOrder(value);
- }
- });
- newMandatoryColumn("ESPF_ACT", new ValueSetter<CommercialSpecies, String>() {
- @Override
- public void set(CommercialSpecies object, String value) throws Exception {
- Integer iValue;
- try {
- iValue = Integer.valueOf(value);
- } catch (NumberFormatException e) {
- iValue = 0;
- }
- object.setActive(iValue);
- }
- });
- }
-
- @Override
- public CommercialSpecies newEmptyInstance() {
- return new CommercialSpecies();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/CommercialSpeciesRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,101 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class CommercialSpeciesRowModel extends AbstractImportExportModel<CommercialSpecies> {
+
+
+ public CommercialSpeciesRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("ESPF_COD", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("ESPF_ISSCAP", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setIsscap(value);
+ }
+ });
+ newMandatoryColumn("ESPF_TAXON_COD", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setTaxonCode(value);
+ }
+ });
+ newMandatoryColumn("ESPF_SCI_LIB", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setScientificLabel(value);
+ }
+ });
+ newMandatoryColumn("ESPF_FRA_LIB", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setFrenchLabel(value);
+ }
+ });
+ newMandatoryColumn("ESPF_FAMILLE", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setFamily(value);
+ }
+ });
+ newMandatoryColumn("ESPF_ORDRE", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ object.setSpeciesOrder(value);
+ }
+ });
+ newMandatoryColumn("ESPF_ACT", new ValueSetter<CommercialSpecies, String>() {
+ @Override
+ public void set(CommercialSpecies object, String value) throws Exception {
+ Integer iValue;
+ try {
+ iValue = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ iValue = 0;
+ }
+ object.setActive(iValue);
+ }
+ });
+ }
+
+ @Override
+ public CommercialSpecies newEmptyInstance() {
+ return new CommercialSpecies();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Gender;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class GenderRowModel extends AbstractImportExportModel<Gender> {
-
-
- public GenderRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Sexe_cod", new ValueSetter<Gender, String>() {
- @Override
- public void set(Gender object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Sexe_lib", new ValueSetter<Gender, String>() {
- @Override
- public void set(Gender object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Gender newEmptyInstance() {
- return new Gender();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/GenderRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Gender;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class GenderRowModel extends AbstractImportExportModel<Gender> {
+
+
+ public GenderRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Sexe_cod", new ValueSetter<Gender, String>() {
+ @Override
+ public void set(Gender object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Sexe_lib", new ValueSetter<Gender, String>() {
+ @Override
+ public void set(Gender object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Gender newEmptyInstance() {
+ return new Gender();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,254 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import android.content.Context;
-import android.util.Log;
-import android.widget.Toast;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.referentials.HasCode;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.models.BaseModel;
-import org.nuiton.csv.Import;
-import org.nuiton.csv.ImportModel;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ImportUtil {
-
- private static final String TAG = "ImportUtil";
-
- public static final char CSV_SEPARATOR = ';';
-
- public static int importAges(Context context, String path) {
- try {
- return importAges(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importAges(Context context, InputStream inputStream) {
- AgeRowModel ageRowModel = new AgeRowModel(CSV_SEPARATOR);
- int result = importData(context, ageRowModel, inputStream, DataCache.getAllAges(context));
- DataCache.invalidateAges();
- return result;
- }
-
- public static int importCommercialSpecies(Context context, String path) {
- try {
- return importCommercialSpecies(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importCommercialSpecies(Context context, InputStream inputStream) {
- CommercialSpeciesRowModel commercialSpeciesRowModel = new CommercialSpeciesRowModel(CSV_SEPARATOR);
- int result = importData(context, commercialSpeciesRowModel, inputStream, DataCache.getAllCommercialSpecies(context));
- DataCache.invalidateCommercialSpecies();
- return result;
- }
-
- public static int importGenders(Context context, String path) {
- try {
- return importGenders(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importGenders(Context context, InputStream inputStream) {
- GenderRowModel genderRowModel = new GenderRowModel(CSV_SEPARATOR);
- int result = importData(context, genderRowModel, inputStream, DataCache.getAllGenders(context));
- DataCache.invalidateGenders();
- return result;
- }
-
- public static int importLocations(Context context, String path) {
- try {
- return importLocations(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importLocations(Context context, InputStream inputStream) {
- LocationRowModel locationRowModel = new LocationRowModel(CSV_SEPARATOR);
- int result = importData(context, locationRowModel, inputStream, DataCache.getAllLocations(context));
- DataCache.invalidateLocations();
- return result;
- }
-
- public static int importMaturities(Context context, String path) {
- try {
- return importMaturities(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importMaturities(Context context, InputStream inputStream) {
- MaturityRowModel maturityRowModel = new MaturityRowModel(CSV_SEPARATOR);
- int result = importData(context, maturityRowModel, inputStream, DataCache.getAllMaturities(context));
- DataCache.invalidateMaturities();
- return result;
- }
-
- public static int importMensurations(Context context, String path) {
- try {
- return importMensurations(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importMensurations(Context context, InputStream inputStream) {
- MensurationRowModel mensurationRowModel = new MensurationRowModel(CSV_SEPARATOR);
- int result = importData(context, mensurationRowModel, inputStream, DataCache.getAllMensurations(context));
- DataCache.invalidateMensurations();
- return result;
- }
-
- public static int importMetiers(Context context, String path) {
- try {
- return importMetiers(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importMetiers(Context context, InputStream inputStream) {
- MetierRowModel metierRowModel = new MetierRowModel(CSV_SEPARATOR);
- int result = importData(context, metierRowModel, inputStream, DataCache.getAllMetiers(context));
- DataCache.invalidateMetiers();
- return result;
- }
-
- public static int importPresentations(Context context, String path) {
- try {
- return importPresentations(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importPresentations(Context context, InputStream inputStream) {
- PresentationRowModel presentationRowModel = new PresentationRowModel(CSV_SEPARATOR);
- int result = importData(context, presentationRowModel, inputStream, DataCache.getAllPresentations(context));
- DataCache.invalidatePresentations();
- return result;
- }
-
- public static int importScientificSpecies(Context context, String path) {
- try {
- return importScientificSpecies(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importScientificSpecies(Context context, InputStream inputStream) {
- ScientificSpeciesRowModel scientificSpeciesRowModel = new ScientificSpeciesRowModel(CSV_SEPARATOR);
- int result = importData(context, scientificSpeciesRowModel, inputStream, DataCache.getAllScientificSpecies(context));
- DataCache.invalidateScientificSpecies();
- return result;
- }
-
- public static int importStates(Context context, String path) {
- try {
- return importStates(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importStates(Context context, InputStream inputStream) {
- StateRowModel stateRowModel = new StateRowModel(CSV_SEPARATOR);
- int result = importData(context, stateRowModel, inputStream, DataCache.getAllStates(context));
- DataCache.invalidateStates();
- return result;
- }
-
- public static int importVessels(Context context, String path) {
- try {
- return importVessels(context, new FileInputStream(path));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File " + path + " not found", e);
- }
- return 0;
- }
-
- public static int importVessels(Context context, InputStream inputStream) {
- VesselRowModel vesselRowModel = new VesselRowModel(CSV_SEPARATOR);
- int result = importData(context, vesselRowModel, inputStream, DataCache.getAllVessels(context));
- DataCache.invalidateVessels();
- return result;
- }
-
- protected static <M extends BaseModel> int importData(Context context, ImportModel<M> importModel,
- InputStream inputStream, final Collection<M> actualReferential) {
- Preconditions.checkNotNull(actualReferential);
- Import<M> importer = Import.newImport(importModel, inputStream);
- Collection<M> models = Lists.newArrayList(importer.iterator());
-
- if (!models.isEmpty()) {
- Predicate<M> filter;
- //if the models have a code attribute, check
- M first = models.iterator().next();
- if (HasCode.class.isAssignableFrom(first.getClass())) {
- Collection<HasCode> hasCodes = Collections2.transform(actualReferential, new Function<M, HasCode>() {
- @Override
- public HasCode apply(M m) {
- return (HasCode) m;
- }
- });
- final Collection<String> codes = Collections2.transform(hasCodes, HasCode.GET_CODE_FUNCTION);
- filter = new Predicate<M>() {
- @Override
- public boolean apply(M model) {
- HasCode hasCode = (HasCode) model;
- return !codes.contains(hasCode.getCode());
- }
- };
- } else {
- filter = new Predicate<M>() {
- @Override
- public boolean apply(M m) {
- return !actualReferential.contains(m);
- }
- };
- }
-
- models = Collections2.filter(models, filter);
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- soh.saveData(models);
- soh.close();
- }
-
- importer.close();
- return models.size();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ImportUtil.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,278 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.util.Log;
+import android.widget.Toast;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.referentials.HasCode;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.models.BaseModel;
+import org.nuiton.csv.Import;
+import org.nuiton.csv.ImportModel;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ImportUtil {
+
+ private static final String TAG = "ImportUtil";
+
+ public static final char CSV_SEPARATOR = ';';
+
+ public static int importAges(Context context, String path) {
+ try {
+ return importAges(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importAges(Context context, InputStream inputStream) {
+ AgeRowModel ageRowModel = new AgeRowModel(CSV_SEPARATOR);
+ int result = importData(context, ageRowModel, inputStream, DataCache.getAllAges(context));
+ DataCache.invalidateAges();
+ return result;
+ }
+
+ public static int importCommercialSpecies(Context context, String path) {
+ try {
+ return importCommercialSpecies(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importCommercialSpecies(Context context, InputStream inputStream) {
+ CommercialSpeciesRowModel commercialSpeciesRowModel = new CommercialSpeciesRowModel(CSV_SEPARATOR);
+ int result = importData(context, commercialSpeciesRowModel, inputStream, DataCache.getAllCommercialSpecies(context));
+ DataCache.invalidateCommercialSpecies();
+ return result;
+ }
+
+ public static int importGenders(Context context, String path) {
+ try {
+ return importGenders(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importGenders(Context context, InputStream inputStream) {
+ GenderRowModel genderRowModel = new GenderRowModel(CSV_SEPARATOR);
+ int result = importData(context, genderRowModel, inputStream, DataCache.getAllGenders(context));
+ DataCache.invalidateGenders();
+ return result;
+ }
+
+ public static int importLocations(Context context, String path) {
+ try {
+ return importLocations(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importLocations(Context context, InputStream inputStream) {
+ LocationRowModel locationRowModel = new LocationRowModel(CSV_SEPARATOR);
+ int result = importData(context, locationRowModel, inputStream, DataCache.getAllLocations(context));
+ DataCache.invalidateLocations();
+ return result;
+ }
+
+ public static int importMaturities(Context context, String path) {
+ try {
+ return importMaturities(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importMaturities(Context context, InputStream inputStream) {
+ MaturityRowModel maturityRowModel = new MaturityRowModel(CSV_SEPARATOR);
+ int result = importData(context, maturityRowModel, inputStream, DataCache.getAllMaturities(context));
+ DataCache.invalidateMaturities();
+ return result;
+ }
+
+ public static int importMensurations(Context context, String path) {
+ try {
+ return importMensurations(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importMensurations(Context context, InputStream inputStream) {
+ MensurationRowModel mensurationRowModel = new MensurationRowModel(CSV_SEPARATOR);
+ int result = importData(context, mensurationRowModel, inputStream, DataCache.getAllMensurations(context));
+ DataCache.invalidateMensurations();
+ return result;
+ }
+
+ public static int importMetiers(Context context, String path) {
+ try {
+ return importMetiers(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importMetiers(Context context, InputStream inputStream) {
+ MetierRowModel metierRowModel = new MetierRowModel(CSV_SEPARATOR);
+ int result = importData(context, metierRowModel, inputStream, DataCache.getAllMetiers(context));
+ DataCache.invalidateMetiers();
+ return result;
+ }
+
+ public static int importPresentations(Context context, String path) {
+ try {
+ return importPresentations(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importPresentations(Context context, InputStream inputStream) {
+ PresentationRowModel presentationRowModel = new PresentationRowModel(CSV_SEPARATOR);
+ int result = importData(context, presentationRowModel, inputStream, DataCache.getAllPresentations(context));
+ DataCache.invalidatePresentations();
+ return result;
+ }
+
+ public static int importScientificSpecies(Context context, String path) {
+ try {
+ return importScientificSpecies(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importScientificSpecies(Context context, InputStream inputStream) {
+ ScientificSpeciesRowModel scientificSpeciesRowModel = new ScientificSpeciesRowModel(CSV_SEPARATOR);
+ int result = importData(context, scientificSpeciesRowModel, inputStream, DataCache.getAllScientificSpecies(context));
+ DataCache.invalidateScientificSpecies();
+ return result;
+ }
+
+ public static int importStates(Context context, String path) {
+ try {
+ return importStates(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importStates(Context context, InputStream inputStream) {
+ StateRowModel stateRowModel = new StateRowModel(CSV_SEPARATOR);
+ int result = importData(context, stateRowModel, inputStream, DataCache.getAllStates(context));
+ DataCache.invalidateStates();
+ return result;
+ }
+
+ public static int importVessels(Context context, String path) {
+ try {
+ return importVessels(context, new FileInputStream(path));
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File " + path + " not found", e);
+ }
+ return 0;
+ }
+
+ public static int importVessels(Context context, InputStream inputStream) {
+ VesselRowModel vesselRowModel = new VesselRowModel(CSV_SEPARATOR);
+ int result = importData(context, vesselRowModel, inputStream, DataCache.getAllVessels(context));
+ DataCache.invalidateVessels();
+ return result;
+ }
+
+ protected static <M extends BaseModel> int importData(Context context, ImportModel<M> importModel,
+ InputStream inputStream, final Collection<M> actualReferential) {
+ Preconditions.checkNotNull(actualReferential);
+ Import<M> importer = Import.newImport(importModel, inputStream);
+ Collection<M> models = Lists.newArrayList(importer.iterator());
+
+ if (!models.isEmpty()) {
+ Predicate<M> filter;
+ //if the models have a code attribute, check
+ M first = models.iterator().next();
+ if (HasCode.class.isAssignableFrom(first.getClass())) {
+ Collection<HasCode> hasCodes = Collections2.transform(actualReferential, new Function<M, HasCode>() {
+ @Override
+ public HasCode apply(M m) {
+ return (HasCode) m;
+ }
+ });
+ final Collection<String> codes = Collections2.transform(hasCodes, HasCode.GET_CODE_FUNCTION);
+ filter = new Predicate<M>() {
+ @Override
+ public boolean apply(M model) {
+ HasCode hasCode = (HasCode) model;
+ return !codes.contains(hasCode.getCode());
+ }
+ };
+ } else {
+ filter = new Predicate<M>() {
+ @Override
+ public boolean apply(M m) {
+ return !actualReferential.contains(m);
+ }
+ };
+ }
+
+ models = Collections2.filter(models, filter);
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ soh.saveData(models);
+ soh.close();
+ }
+
+ importer.close();
+ return models.size();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,41 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Location;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class LocationRowModel extends AbstractImportExportModel<Location> {
-
-
- public LocationRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("TLIEU_LIB", new ValueSetter<Location, String>() {
- @Override
- public void set(Location object, String value) throws Exception {
- object.setTypeLabel(value);
- }
- });
- newMandatoryColumn("LIEU_COD", new ValueSetter<Location, String>() {
- @Override
- public void set(Location object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("LIEU_LIB", new ValueSetter<Location, String>() {
- @Override
- public void set(Location object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Location newEmptyInstance() {
- return new Location();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/LocationRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,65 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Location;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class LocationRowModel extends AbstractImportExportModel<Location> {
+
+
+ public LocationRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("TLIEU_LIB", new ValueSetter<Location, String>() {
+ @Override
+ public void set(Location object, String value) throws Exception {
+ object.setTypeLabel(value);
+ }
+ });
+ newMandatoryColumn("LIEU_COD", new ValueSetter<Location, String>() {
+ @Override
+ public void set(Location object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("LIEU_LIB", new ValueSetter<Location, String>() {
+ @Override
+ public void set(Location object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Location newEmptyInstance() {
+ return new Location();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,29 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Maturity;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MaturityRowModel extends AbstractImportExportModel<Maturity> {
-
-
- public MaturityRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Maturite", new ValueSetter<Maturity, String>() {
- @Override
- public void set(Maturity object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Maturity newEmptyInstance() {
- return new Maturity();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MaturityRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,53 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Maturity;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MaturityRowModel extends AbstractImportExportModel<Maturity> {
+
+
+ public MaturityRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Maturite", new ValueSetter<Maturity, String>() {
+ @Override
+ public void set(Maturity object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Maturity newEmptyInstance() {
+ return new Maturity();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MensurationRowModel extends AbstractImportExportModel<Mensuration> {
-
-
- public MensurationRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Type_Longueur_cod", new ValueSetter<Mensuration, String>() {
- @Override
- public void set(Mensuration object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Type_Longueur_lib", new ValueSetter<Mensuration, String>() {
- @Override
- public void set(Mensuration object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Mensuration newEmptyInstance() {
- return new Mensuration();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MensurationRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MensurationRowModel extends AbstractImportExportModel<Mensuration> {
+
+
+ public MensurationRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Type_Longueur_cod", new ValueSetter<Mensuration, String>() {
+ @Override
+ public void set(Mensuration object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Type_Longueur_lib", new ValueSetter<Mensuration, String>() {
+ @Override
+ public void set(Mensuration object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Mensuration newEmptyInstance() {
+ return new Mensuration();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,89 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Metier;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class MetierRowModel extends AbstractImportExportModel<Metier> {
-
-
- public MetierRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("MET_ID", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setMetierId(value);
- }
- });
- newMandatoryColumn("MET_COD", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("MET_LIB", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- newMandatoryColumn("MET_ENGIN_COD", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setGearCode(value);
- }
- });
- newMandatoryColumn("MET_ENGIN_LIB", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setGearLabel(value);
- }
- });
- newMandatoryColumn("MET_ESPECE_COD", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setSpeciesCode(value);
- }
- });
- newMandatoryColumn("MET_ESPECE_LIB", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- object.setSpeciesLabel(value);
- }
- });
- newMandatoryColumn("MET_PECHE", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- Integer iValue;
- try {
- iValue = Integer.valueOf(value);
- } catch (NumberFormatException e) {
- iValue = 0;
- }
- object.setFishing(iValue);
- }
- });
- newMandatoryColumn("MET_ACT", new ValueSetter<Metier, String>() {
- @Override
- public void set(Metier object, String value) throws Exception {
- Integer iValue;
- try {
- iValue = Integer.valueOf(value);
- } catch (NumberFormatException e) {
- iValue = 0;
- }
- object.setActive(iValue);
- }
- });
- }
-
- @Override
- public Metier newEmptyInstance() {
- return new Metier();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/MetierRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,113 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Metier;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class MetierRowModel extends AbstractImportExportModel<Metier> {
+
+
+ public MetierRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("MET_ID", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setMetierId(value);
+ }
+ });
+ newMandatoryColumn("MET_COD", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("MET_LIB", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ newMandatoryColumn("MET_ENGIN_COD", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setGearCode(value);
+ }
+ });
+ newMandatoryColumn("MET_ENGIN_LIB", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setGearLabel(value);
+ }
+ });
+ newMandatoryColumn("MET_ESPECE_COD", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setSpeciesCode(value);
+ }
+ });
+ newMandatoryColumn("MET_ESPECE_LIB", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ object.setSpeciesLabel(value);
+ }
+ });
+ newMandatoryColumn("MET_PECHE", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ Integer iValue;
+ try {
+ iValue = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ iValue = 0;
+ }
+ object.setFishing(iValue);
+ }
+ });
+ newMandatoryColumn("MET_ACT", new ValueSetter<Metier, String>() {
+ @Override
+ public void set(Metier object, String value) throws Exception {
+ Integer iValue;
+ try {
+ iValue = Integer.valueOf(value);
+ } catch (NumberFormatException e) {
+ iValue = 0;
+ }
+ object.setActive(iValue);
+ }
+ });
+ }
+
+ @Override
+ public Metier newEmptyInstance() {
+ return new Metier();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Presentation;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class PresentationRowModel extends AbstractImportExportModel<Presentation> {
-
-
- public PresentationRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Presentation_cod", new ValueSetter<Presentation, String>() {
- @Override
- public void set(Presentation object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Presentation_lib", new ValueSetter<Presentation, String>() {
- @Override
- public void set(Presentation object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public Presentation newEmptyInstance() {
- return new Presentation();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/PresentationRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Presentation;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class PresentationRowModel extends AbstractImportExportModel<Presentation> {
+
+
+ public PresentationRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Presentation_cod", new ValueSetter<Presentation, String>() {
+ @Override
+ public void set(Presentation object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Presentation_lib", new ValueSetter<Presentation, String>() {
+ @Override
+ public void set(Presentation object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public Presentation newEmptyInstance() {
+ return new Presentation();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,41 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class ScientificSpeciesRowModel extends AbstractImportExportModel<ScientificSpecies> {
-
-
- public ScientificSpeciesRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("C_Perm", new ValueSetter<ScientificSpecies, String>() {
- @Override
- public void set(ScientificSpecies object, String value) throws Exception {
- object.setPermCode(value);
- }
- });
- newMandatoryColumn("C_VALIDE", new ValueSetter<ScientificSpecies, String>() {
- @Override
- public void set(ScientificSpecies object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("L_VALIDE", new ValueSetter<ScientificSpecies, String>() {
- @Override
- public void set(ScientificSpecies object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public ScientificSpecies newEmptyInstance() {
- return new ScientificSpecies();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/ScientificSpeciesRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,65 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class ScientificSpeciesRowModel extends AbstractImportExportModel<ScientificSpecies> {
+
+
+ public ScientificSpeciesRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("C_Perm", new ValueSetter<ScientificSpecies, String>() {
+ @Override
+ public void set(ScientificSpecies object, String value) throws Exception {
+ object.setPermCode(value);
+ }
+ });
+ newMandatoryColumn("C_VALIDE", new ValueSetter<ScientificSpecies, String>() {
+ @Override
+ public void set(ScientificSpecies object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("L_VALIDE", new ValueSetter<ScientificSpecies, String>() {
+ @Override
+ public void set(ScientificSpecies object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public ScientificSpecies newEmptyInstance() {
+ return new ScientificSpecies();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,35 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.State;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class StateRowModel extends AbstractImportExportModel<State> {
-
-
- public StateRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("Etat_cod", new ValueSetter<State, String>() {
- @Override
- public void set(State object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("Etat_lib", new ValueSetter<State, String>() {
- @Override
- public void set(State object, String value) throws Exception {
- object.setLabel(value);
- }
- });
- }
-
- @Override
- public State newEmptyInstance() {
- return new State();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/StateRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,59 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.State;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class StateRowModel extends AbstractImportExportModel<State> {
+
+
+ public StateRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("Etat_cod", new ValueSetter<State, String>() {
+ @Override
+ public void set(State object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("Etat_lib", new ValueSetter<State, String>() {
+ @Override
+ public void set(State object, String value) throws Exception {
+ object.setLabel(value);
+ }
+ });
+ }
+
+ @Override
+ public State newEmptyInstance() {
+ return new State();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java
===================================================================
--- trunk/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,41 +0,0 @@
-package fr.ifremer.wlo.models.referentials.imports;
-
-import fr.ifremer.wlo.models.referentials.Vessel;
-import org.nuiton.csv.ValueSetter;
-import org.nuiton.csv.ext.AbstractImportExportModel;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class VesselRowModel extends AbstractImportExportModel<Vessel> {
-
-
- public VesselRowModel(char separator) {
- super(separator);
-
- newMandatoryColumn("NAVS_COD", new ValueSetter<Vessel, String>() {
- @Override
- public void set(Vessel object, String value) throws Exception {
- object.setCode(value);
- }
- });
- newMandatoryColumn("CARN_NOM", new ValueSetter<Vessel, String>() {
- @Override
- public void set(Vessel object, String value) throws Exception {
- object.setName(value);
- }
- });
- newMandatoryColumn("QUARTIER_COD", new ValueSetter<Vessel, String>() {
- @Override
- public void set(Vessel object, String value) throws Exception {
- object.setQuarterCode(value);
- }
- });
- }
-
- @Override
- public Vessel newEmptyInstance() {
- return new Vessel();
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java (from rev 25, trunk/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/models/referentials/imports/VesselRowModel.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,65 @@
+package fr.ifremer.wlo.models.referentials.imports;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.wlo.models.referentials.Vessel;
+import org.nuiton.csv.ValueSetter;
+import org.nuiton.csv.ext.AbstractImportExportModel;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class VesselRowModel extends AbstractImportExportModel<Vessel> {
+
+
+ public VesselRowModel(char separator) {
+ super(separator);
+
+ newMandatoryColumn("NAVS_COD", new ValueSetter<Vessel, String>() {
+ @Override
+ public void set(Vessel object, String value) throws Exception {
+ object.setCode(value);
+ }
+ });
+ newMandatoryColumn("CARN_NOM", new ValueSetter<Vessel, String>() {
+ @Override
+ public void set(Vessel object, String value) throws Exception {
+ object.setName(value);
+ }
+ });
+ newMandatoryColumn("QUARTIER_COD", new ValueSetter<Vessel, String>() {
+ @Override
+ public void set(Vessel object, String value) throws Exception {
+ object.setQuarterCode(value);
+ }
+ });
+ }
+
+ @Override
+ public Vessel newEmptyInstance() {
+ return new Vessel();
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/ListItemPreference.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,62 +0,0 @@
-package fr.ifremer.wlo.preferences;
-
-import android.content.Context;
-import com.google.common.collect.Lists;
-import fr.ifremer.wlo.R;
-
-import java.util.List;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public enum ListItemPreference {
-
- WEIGHT_UNIT("preferences_weight_unit", R.array.preferences_weight_unit_entries, R.array.preferences_weight_unit_values),
- DATE_FORMAT("preferences_date_format", R.array.preferences_date_format_entries, R.array.preferences_date_format_values),
- USE_PLACE("preferences_use_place", R.array.preferences_use_place_entries, R.array.preferences_use_place_values);
-
- private static final String TAG = "ListItemPreference";
-
- private String key;
- private int entriesArrayId;
- private int valuesArrayId;
-
- private ListItemPreference(String key, int entriesArrayId, int valuesArrayId) {
- this.key = key;
- this.entriesArrayId = entriesArrayId;
- this.valuesArrayId = valuesArrayId;
- }
-
- public String getKey() {
- return key;
- }
-
- public int getEntriesArrayId() {
- return entriesArrayId;
- }
-
- public int getValuesArrayId() {
- return valuesArrayId;
- }
-
- public String getEntryForValue(Context context, String value) {
- List<String> values = Lists.newArrayList(context.getResources().getStringArray(valuesArrayId));
- String[] entries = context.getResources().getStringArray(entriesArrayId);
- int index = values.indexOf(value);
- if (index < 0) {
- return null;
- }
- return entries[index];
- }
-
- public static ListItemPreference getListItemPreference(String key) {
- for (ListItemPreference pref : values()) {
- if (pref.getKey().equals(key)) {
- return pref;
- }
- }
- return null;
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java (from rev 25, trunk/src/fr/ifremer/wlo/preferences/ListItemPreference.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/preferences/ListItemPreference.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,86 @@
+package fr.ifremer.wlo.preferences;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import com.google.common.collect.Lists;
+import fr.ifremer.wlo.R;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public enum ListItemPreference {
+
+ WEIGHT_UNIT("preferences_weight_unit", R.array.preferences_weight_unit_entries, R.array.preferences_weight_unit_values),
+ DATE_FORMAT("preferences_date_format", R.array.preferences_date_format_entries, R.array.preferences_date_format_values),
+ USE_PLACE("preferences_use_place", R.array.preferences_use_place_entries, R.array.preferences_use_place_values);
+
+ private static final String TAG = "ListItemPreference";
+
+ private String key;
+ private int entriesArrayId;
+ private int valuesArrayId;
+
+ private ListItemPreference(String key, int entriesArrayId, int valuesArrayId) {
+ this.key = key;
+ this.entriesArrayId = entriesArrayId;
+ this.valuesArrayId = valuesArrayId;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public int getEntriesArrayId() {
+ return entriesArrayId;
+ }
+
+ public int getValuesArrayId() {
+ return valuesArrayId;
+ }
+
+ public String getEntryForValue(Context context, String value) {
+ List<String> values = Lists.newArrayList(context.getResources().getStringArray(valuesArrayId));
+ String[] entries = context.getResources().getStringArray(entriesArrayId);
+ int index = values.indexOf(value);
+ if (index < 0) {
+ return null;
+ }
+ return entries[index];
+ }
+
+ public static ListItemPreference getListItemPreference(String key) {
+ for (ListItemPreference pref : values()) {
+ if (pref.getKey().equals(key)) {
+ return pref;
+ }
+ }
+ return null;
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,308 +0,0 @@
-package fr.ifremer.wlo.preferences;
-
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.Environment;
-import android.preference.Preference;
-import android.preference.PreferenceFragment;
-import android.text.format.DateFormat;
-import android.util.Log;
-import android.widget.Toast;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.MainActivity;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.WloBaseActivity;
-import fr.ifremer.wlo.storage.DataCache;
-import fr.ifremer.wlo.storage.StorageUtils;
-import fr.ifremer.wlo.storage.WloSqlOpenHelper;
-import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
-import fr.ifremer.wlo.utils.UIUtils;
-import fr.ifremer.wlo.utils.filechooser.FileDialog;
-import fr.ifremer.wlo.utils.filechooser.SelectionMode;
-import org.apache.commons.io.FileUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class SettingsActivity extends WloBaseActivity {
-
- private static final String TAG = "SettingsActivity";
-
- protected static final int REQUEST_IMPORT_AGES = 0;
- protected static final int REQUEST_IMPORT_COMMERCIAL_SPECIES = 1;
- protected static final int REQUEST_IMPORT_GENDERS = 2;
- protected static final int REQUEST_IMPORT_LOCATIONS = 3;
- protected static final int REQUEST_IMPORT_MATURITIES = 4;
- protected static final int REQUEST_IMPORT_MENSURATIONS = 5;
- protected static final int REQUEST_IMPORT_METIERS = 6;
- protected static final int REQUEST_IMPORT_PRESENTATIONS = 7;
- protected static final int REQUEST_IMPORT_SCIENTIFIC_SPECIES = 8;
- protected static final int REQUEST_IMPORT_STATES = 9;
- protected static final int REQUEST_IMPORT_VESSELS = 10;
- @Override
- protected Integer getContentView() {
- return null;
- }
-
- @Override
- protected Class<? extends WloBaseActivity> getUpActivity() {
- return MainActivity.class;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Display the fragment as the main content.
- getFragmentManager().beginTransaction()
- .replace(android.R.id.content, new SettingsFragment())
- .commit();
-
- }
-
- public static class SettingsFragment extends PreferenceFragment
- implements SharedPreferences.OnSharedPreferenceChangeListener {
-
- // map pref_key / request code
- protected BiMap<String, Integer> requestCodeByPrefKey = HashBiMap.create();
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.preferences);
-
- // create map pref_key / request code
- requestCodeByPrefKey.put("import_ages", REQUEST_IMPORT_AGES);
- requestCodeByPrefKey.put("import_commercial_species", REQUEST_IMPORT_COMMERCIAL_SPECIES);
- requestCodeByPrefKey.put("import_genders", REQUEST_IMPORT_GENDERS);
- requestCodeByPrefKey.put("import_locations", REQUEST_IMPORT_LOCATIONS);
- requestCodeByPrefKey.put("import_maturities", REQUEST_IMPORT_MATURITIES);
- requestCodeByPrefKey.put("import_mensurations", REQUEST_IMPORT_MENSURATIONS);
- requestCodeByPrefKey.put("import_metiers", REQUEST_IMPORT_METIERS);
- requestCodeByPrefKey.put("import_presentations", REQUEST_IMPORT_PRESENTATIONS);
- requestCodeByPrefKey.put("import_scientific_species", REQUEST_IMPORT_SCIENTIFIC_SPECIES);
- requestCodeByPrefKey.put("import_states", REQUEST_IMPORT_STATES);
- requestCodeByPrefKey.put("import_vessels", REQUEST_IMPORT_VESSELS);
-
- Map<String, Integer> nbElementsByPrefKey = Maps.newHashMap();
- Context context = getActivity();
- nbElementsByPrefKey.put("import_ages", DataCache.getAllAges(context).size());
- nbElementsByPrefKey.put("import_commercial_species", DataCache.getAllCommercialSpecies(context).size());
- nbElementsByPrefKey.put("import_genders", DataCache.getAllGenders(context).size());
- nbElementsByPrefKey.put("import_locations", DataCache.getAllLocations(context).size());
- nbElementsByPrefKey.put("import_maturities", DataCache.getAllMaturities(context).size());
- nbElementsByPrefKey.put("import_mensurations", DataCache.getAllMensurations(context).size());
- nbElementsByPrefKey.put("import_metiers", DataCache.getAllMetiers(context).size());
- nbElementsByPrefKey.put("import_presentations", DataCache.getAllPresentations(context).size());
- nbElementsByPrefKey.put("import_scientific_species", DataCache.getAllScientificSpecies(context).size());
- nbElementsByPrefKey.put("import_states", DataCache.getAllStates(context).size());
- nbElementsByPrefKey.put("import_vessels", DataCache.getAllVessels(context).size());
-
- for (String key : requestCodeByPrefKey.keySet()) {
- final Integer requestCode = requestCodeByPrefKey.get(key);
- Preference filePicker = findPreference(key);
- filePicker.setSummary(getString(R.string.preferences_import_summary, nbElementsByPrefKey.get(key)));
- filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- Intent intent = new Intent(getActivity(), FileDialog.class); //Intent to start openIntents File Manager
- intent.putExtra(FileDialog.START_PATH, "/sdcard");
- intent.putExtra(FileDialog.CAN_SELECT_DIR, false);
- intent.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
-
- //alternatively you can set file filter
- intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "csv" });
-
- startActivityForResult(intent, requestCode);
- return true;
- }
- });
- }
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
-
- Preference connectionPref = findPreference(key);
- String summary = null;
-
- ListItemPreference pref = ListItemPreference.getListItemPreference(key);
- if (pref != null) {
- String entry = sharedPreferences.getString(key, "");
- summary = pref.getEntryForValue(getActivity(), entry);
-
- } else {
- summary = sharedPreferences.getString(key, "");
- }
- // Set summary to be the user-description for the selected value
- connectionPref.setSummary(summary);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
-
- for (StringPreference pref : StringPreference.values()) {
- String key = pref.getKey();
- Preference connectionPref = findPreference(key);
- connectionPref.setSummary(sharedPreferences.getString(key, ""));
- }
-
- for (ListItemPreference pref : ListItemPreference.values()) {
- String key = pref.getKey();
- Preference connectionPref = findPreference(key);
- String entry = sharedPreferences.getString(key, "");
- String summary = pref.getEntryForValue(getActivity(), entry);
- connectionPref.setSummary(summary);
- }
-
- sharedPreferences.registerOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onPause() {
- super.onPause();
- getPreferenceScreen().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
- if (resultCode == RESULT_OK
- && requestCode >= REQUEST_IMPORT_AGES && requestCode <= REQUEST_IMPORT_VESSELS) {
-
- Context context = getActivity();
- if (!StorageUtils.isExternalStorageWritable()) {
- AlertDialog dialog = new AlertDialog.Builder(context)
- .setTitle(R.string.preferences_import_no_external_storage_title)
- .setMessage(R.string.preferences_import_no_external_storage_message)
- .setCancelable(false)
- .setNegativeButton(R.string.no, UIUtils.getCancelClickListener())
- .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- importData(requestCode, data, false);
- }
- }).create();
- dialog.show();
-
- } else {
- importData(requestCode, data, true);
- }
-
- } else {
- super.onActivityResult(requestCode, resultCode, data);
- }
- }
-
- protected void importData(final int requestCode, final Intent data, final boolean backupFile) {
- final Context context = getActivity();
-
- final ProgressDialog dialog = new ProgressDialog(context);
- dialog.setCancelable(false);
- dialog.setMessage(getString(R.string.preferences_importing_referential));
- dialog.show();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- String path = data.getStringExtra(FileDialog.RESULT_PATH);
- Log.d(TAG, path);
- final int updatedNb;
- final int newNb;
- switch (requestCode) {
- case REQUEST_IMPORT_AGES:
- newNb = ImportUtil.importAges(context, path);
- updatedNb = DataCache.getAllAges(context).size();
- break;
- case REQUEST_IMPORT_COMMERCIAL_SPECIES:
- newNb = ImportUtil.importCommercialSpecies(context, path);
- updatedNb = DataCache.getAllCommercialSpecies(context).size();
- break;
- case REQUEST_IMPORT_GENDERS:
- newNb = ImportUtil.importGenders(context, path);
- updatedNb = DataCache.getAllGenders(context).size();
- break;
- case REQUEST_IMPORT_LOCATIONS:
- newNb = ImportUtil.importLocations(context, path);
- updatedNb = DataCache.getAllLocations(context).size();
- break;
- case REQUEST_IMPORT_MATURITIES:
- newNb = ImportUtil.importMaturities(context, path);
- updatedNb = DataCache.getAllMaturities(context).size();
- break;
- case REQUEST_IMPORT_MENSURATIONS:
- newNb = ImportUtil.importMensurations(context, path);
- updatedNb = DataCache.getAllMensurations(context).size();
- break;
- case REQUEST_IMPORT_METIERS:
- newNb = ImportUtil.importMetiers(context, path);
- updatedNb = DataCache.getAllMetiers(context).size();
- break;
- case REQUEST_IMPORT_PRESENTATIONS:
- newNb = ImportUtil.importPresentations(context, path);
- updatedNb = DataCache.getAllPresentations(context).size();
- break;
- case REQUEST_IMPORT_SCIENTIFIC_SPECIES:
- newNb = ImportUtil.importScientificSpecies(context, path);
- updatedNb = DataCache.getAllScientificSpecies(context).size();
- break;
- case REQUEST_IMPORT_STATES:
- newNb = ImportUtil.importStates(context, path);
- updatedNb = DataCache.getAllStates(context).size();
- break;
- case REQUEST_IMPORT_VESSELS:
- newNb = ImportUtil.importVessels(context, path);
- updatedNb = DataCache.getAllVessels(context).size();
- break;
- default:
- newNb = 0;
- updatedNb = 0;
- }
-
- dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
- @Override
- public void onDismiss(DialogInterface dialog) {
- String key = requestCodeByPrefKey.inverse().get(requestCode);
- Preference filePicker = findPreference(key);
- filePicker.setSummary(getString(R.string.preferences_import_summary, updatedNb));
-
- Toast.makeText(context, context.getString(R.string.import_new_element_number, newNb), Toast.LENGTH_SHORT).show();
- }
- });
-
- if (backupFile) {
- File importedFile = new File(path);
- String copyFileName = String.format("%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS-", new Date()) + importedFile.getName();
- File dir = Environment.getExternalStoragePublicDirectory(".wlo");
- File file = new File(dir, copyFileName);
- try {
- FileUtils.copyInputStreamToFile(new FileInputStream(path), file);
- } catch (IOException e) {
- Log.e(TAG, "Error while copying the file", e);
- }
- }
-
- dialog.dismiss();
- }
- }).start();
- }
- }
-
-}
\ No newline at end of file
Copied: tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java (from rev 25, trunk/src/fr/ifremer/wlo/preferences/SettingsActivity.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/preferences/SettingsActivity.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,332 @@
+package fr.ifremer.wlo.preferences;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.Environment;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.text.format.DateFormat;
+import android.util.Log;
+import android.widget.Toast;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.MainActivity;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.WloBaseActivity;
+import fr.ifremer.wlo.storage.DataCache;
+import fr.ifremer.wlo.storage.StorageUtils;
+import fr.ifremer.wlo.storage.WloSqlOpenHelper;
+import fr.ifremer.wlo.models.referentials.imports.ImportUtil;
+import fr.ifremer.wlo.utils.UIUtils;
+import fr.ifremer.wlo.utils.filechooser.FileDialog;
+import fr.ifremer.wlo.utils.filechooser.SelectionMode;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class SettingsActivity extends WloBaseActivity {
+
+ private static final String TAG = "SettingsActivity";
+
+ protected static final int REQUEST_IMPORT_AGES = 0;
+ protected static final int REQUEST_IMPORT_COMMERCIAL_SPECIES = 1;
+ protected static final int REQUEST_IMPORT_GENDERS = 2;
+ protected static final int REQUEST_IMPORT_LOCATIONS = 3;
+ protected static final int REQUEST_IMPORT_MATURITIES = 4;
+ protected static final int REQUEST_IMPORT_MENSURATIONS = 5;
+ protected static final int REQUEST_IMPORT_METIERS = 6;
+ protected static final int REQUEST_IMPORT_PRESENTATIONS = 7;
+ protected static final int REQUEST_IMPORT_SCIENTIFIC_SPECIES = 8;
+ protected static final int REQUEST_IMPORT_STATES = 9;
+ protected static final int REQUEST_IMPORT_VESSELS = 10;
+ @Override
+ protected Integer getContentView() {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends WloBaseActivity> getUpActivity() {
+ return MainActivity.class;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Display the fragment as the main content.
+ getFragmentManager().beginTransaction()
+ .replace(android.R.id.content, new SettingsFragment())
+ .commit();
+
+ }
+
+ public static class SettingsFragment extends PreferenceFragment
+ implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+ // map pref_key / request code
+ protected BiMap<String, Integer> requestCodeByPrefKey = HashBiMap.create();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Load the preferences from an XML resource
+ addPreferencesFromResource(R.xml.preferences);
+
+ // create map pref_key / request code
+ requestCodeByPrefKey.put("import_ages", REQUEST_IMPORT_AGES);
+ requestCodeByPrefKey.put("import_commercial_species", REQUEST_IMPORT_COMMERCIAL_SPECIES);
+ requestCodeByPrefKey.put("import_genders", REQUEST_IMPORT_GENDERS);
+ requestCodeByPrefKey.put("import_locations", REQUEST_IMPORT_LOCATIONS);
+ requestCodeByPrefKey.put("import_maturities", REQUEST_IMPORT_MATURITIES);
+ requestCodeByPrefKey.put("import_mensurations", REQUEST_IMPORT_MENSURATIONS);
+ requestCodeByPrefKey.put("import_metiers", REQUEST_IMPORT_METIERS);
+ requestCodeByPrefKey.put("import_presentations", REQUEST_IMPORT_PRESENTATIONS);
+ requestCodeByPrefKey.put("import_scientific_species", REQUEST_IMPORT_SCIENTIFIC_SPECIES);
+ requestCodeByPrefKey.put("import_states", REQUEST_IMPORT_STATES);
+ requestCodeByPrefKey.put("import_vessels", REQUEST_IMPORT_VESSELS);
+
+ Map<String, Integer> nbElementsByPrefKey = Maps.newHashMap();
+ Context context = getActivity();
+ nbElementsByPrefKey.put("import_ages", DataCache.getAllAges(context).size());
+ nbElementsByPrefKey.put("import_commercial_species", DataCache.getAllCommercialSpecies(context).size());
+ nbElementsByPrefKey.put("import_genders", DataCache.getAllGenders(context).size());
+ nbElementsByPrefKey.put("import_locations", DataCache.getAllLocations(context).size());
+ nbElementsByPrefKey.put("import_maturities", DataCache.getAllMaturities(context).size());
+ nbElementsByPrefKey.put("import_mensurations", DataCache.getAllMensurations(context).size());
+ nbElementsByPrefKey.put("import_metiers", DataCache.getAllMetiers(context).size());
+ nbElementsByPrefKey.put("import_presentations", DataCache.getAllPresentations(context).size());
+ nbElementsByPrefKey.put("import_scientific_species", DataCache.getAllScientificSpecies(context).size());
+ nbElementsByPrefKey.put("import_states", DataCache.getAllStates(context).size());
+ nbElementsByPrefKey.put("import_vessels", DataCache.getAllVessels(context).size());
+
+ for (String key : requestCodeByPrefKey.keySet()) {
+ final Integer requestCode = requestCodeByPrefKey.get(key);
+ Preference filePicker = findPreference(key);
+ filePicker.setSummary(getString(R.string.preferences_import_summary, nbElementsByPrefKey.get(key)));
+ filePicker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent intent = new Intent(getActivity(), FileDialog.class); //Intent to start openIntents File Manager
+ intent.putExtra(FileDialog.START_PATH, "/sdcard");
+ intent.putExtra(FileDialog.CAN_SELECT_DIR, false);
+ intent.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN);
+
+ //alternatively you can set file filter
+ intent.putExtra(FileDialog.FORMAT_FILTER, new String[] { "csv" });
+
+ startActivityForResult(intent, requestCode);
+ return true;
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+
+ Preference connectionPref = findPreference(key);
+ String summary = null;
+
+ ListItemPreference pref = ListItemPreference.getListItemPreference(key);
+ if (pref != null) {
+ String entry = sharedPreferences.getString(key, "");
+ summary = pref.getEntryForValue(getActivity(), entry);
+
+ } else {
+ summary = sharedPreferences.getString(key, "");
+ }
+ // Set summary to be the user-description for the selected value
+ connectionPref.setSummary(summary);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+
+ for (StringPreference pref : StringPreference.values()) {
+ String key = pref.getKey();
+ Preference connectionPref = findPreference(key);
+ connectionPref.setSummary(sharedPreferences.getString(key, ""));
+ }
+
+ for (ListItemPreference pref : ListItemPreference.values()) {
+ String key = pref.getKey();
+ Preference connectionPref = findPreference(key);
+ String entry = sharedPreferences.getString(key, "");
+ String summary = pref.getEntryForValue(getActivity(), entry);
+ connectionPref.setSummary(summary);
+ }
+
+ sharedPreferences.registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ getPreferenceScreen().getSharedPreferences()
+ .unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
+ if (resultCode == RESULT_OK
+ && requestCode >= REQUEST_IMPORT_AGES && requestCode <= REQUEST_IMPORT_VESSELS) {
+
+ Context context = getActivity();
+ if (!StorageUtils.isExternalStorageWritable()) {
+ AlertDialog dialog = new AlertDialog.Builder(context)
+ .setTitle(R.string.preferences_import_no_external_storage_title)
+ .setMessage(R.string.preferences_import_no_external_storage_message)
+ .setCancelable(false)
+ .setNegativeButton(R.string.no, UIUtils.getCancelClickListener())
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ importData(requestCode, data, false);
+ }
+ }).create();
+ dialog.show();
+
+ } else {
+ importData(requestCode, data, true);
+ }
+
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+ }
+
+ protected void importData(final int requestCode, final Intent data, final boolean backupFile) {
+ final Context context = getActivity();
+
+ final ProgressDialog dialog = new ProgressDialog(context);
+ dialog.setCancelable(false);
+ dialog.setMessage(getString(R.string.preferences_importing_referential));
+ dialog.show();
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ String path = data.getStringExtra(FileDialog.RESULT_PATH);
+ Log.d(TAG, path);
+ final int updatedNb;
+ final int newNb;
+ switch (requestCode) {
+ case REQUEST_IMPORT_AGES:
+ newNb = ImportUtil.importAges(context, path);
+ updatedNb = DataCache.getAllAges(context).size();
+ break;
+ case REQUEST_IMPORT_COMMERCIAL_SPECIES:
+ newNb = ImportUtil.importCommercialSpecies(context, path);
+ updatedNb = DataCache.getAllCommercialSpecies(context).size();
+ break;
+ case REQUEST_IMPORT_GENDERS:
+ newNb = ImportUtil.importGenders(context, path);
+ updatedNb = DataCache.getAllGenders(context).size();
+ break;
+ case REQUEST_IMPORT_LOCATIONS:
+ newNb = ImportUtil.importLocations(context, path);
+ updatedNb = DataCache.getAllLocations(context).size();
+ break;
+ case REQUEST_IMPORT_MATURITIES:
+ newNb = ImportUtil.importMaturities(context, path);
+ updatedNb = DataCache.getAllMaturities(context).size();
+ break;
+ case REQUEST_IMPORT_MENSURATIONS:
+ newNb = ImportUtil.importMensurations(context, path);
+ updatedNb = DataCache.getAllMensurations(context).size();
+ break;
+ case REQUEST_IMPORT_METIERS:
+ newNb = ImportUtil.importMetiers(context, path);
+ updatedNb = DataCache.getAllMetiers(context).size();
+ break;
+ case REQUEST_IMPORT_PRESENTATIONS:
+ newNb = ImportUtil.importPresentations(context, path);
+ updatedNb = DataCache.getAllPresentations(context).size();
+ break;
+ case REQUEST_IMPORT_SCIENTIFIC_SPECIES:
+ newNb = ImportUtil.importScientificSpecies(context, path);
+ updatedNb = DataCache.getAllScientificSpecies(context).size();
+ break;
+ case REQUEST_IMPORT_STATES:
+ newNb = ImportUtil.importStates(context, path);
+ updatedNb = DataCache.getAllStates(context).size();
+ break;
+ case REQUEST_IMPORT_VESSELS:
+ newNb = ImportUtil.importVessels(context, path);
+ updatedNb = DataCache.getAllVessels(context).size();
+ break;
+ default:
+ newNb = 0;
+ updatedNb = 0;
+ }
+
+ dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ String key = requestCodeByPrefKey.inverse().get(requestCode);
+ Preference filePicker = findPreference(key);
+ filePicker.setSummary(getString(R.string.preferences_import_summary, updatedNb));
+
+ Toast.makeText(context, context.getString(R.string.import_new_element_number, newNb), Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ if (backupFile) {
+ File importedFile = new File(path);
+ String copyFileName = String.format("%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS-", new Date()) + importedFile.getName();
+ File dir = Environment.getExternalStoragePublicDirectory(".wlo");
+ File file = new File(dir, copyFileName);
+ try {
+ FileUtils.copyInputStreamToFile(new FileInputStream(path), file);
+ } catch (IOException e) {
+ Log.e(TAG, "Error while copying the file", e);
+ }
+ }
+
+ dialog.dismiss();
+ }
+ }).start();
+ }
+ }
+
+}
\ No newline at end of file
Deleted: tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java
===================================================================
--- trunk/src/fr/ifremer/wlo/preferences/StringPreference.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,22 +0,0 @@
-package fr.ifremer.wlo.preferences;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public enum StringPreference {
-
- COMPANY("preferences_company"),
- DEFAULT_OPERATOR("preferences_default_operator");
-
- private String key;
-
- private StringPreference(String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java (from rev 25, trunk/src/fr/ifremer/wlo/preferences/StringPreference.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/preferences/StringPreference.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,46 @@
+package fr.ifremer.wlo.preferences;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public enum StringPreference {
+
+ COMPANY("preferences_company"),
+ DEFAULT_OPERATOR("preferences_default_operator");
+
+ private String key;
+
+ private StringPreference(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/DataCache.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,441 +0,0 @@
-package fr.ifremer.wlo.storage;
-
-import android.content.Context;
-import android.database.Cursor;
-import com.google.common.base.Function;
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Table;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Gender;
-import fr.ifremer.wlo.models.referentials.HasCode;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Maturity;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.models.referentials.Vessel;
-import org.apache.commons.lang3.ObjectUtils;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class DataCache {
-
- public static final String DEFAULT_MENSURATION_CODE = "LT";
-
- protected static Map<String, Age> ages;
- protected static Map<String, CommercialSpecies> commercialSpecies;
- protected static Map<String, Gender> genders;
- protected static Map<String, Location> locations;
- protected static Map<String, Maturity> maturities;
- protected static Map<String, Mensuration> mensurations;
- protected static Mensuration defaultMensuration;
- protected static Map<String, Metier> metiers;
- protected static Map<String, Presentation> presentations;
- protected static Map<String, ScientificSpecies> scientificSpecies;
- protected static Map<String, State> states;
- protected static Map<String, Vessel> vessels;
- protected static Set<String> sortCategories;
-
- public static Collection<Age> getAllAges(Context context) {
- initAges(context);
- return ages.values();
- }
-
- public static Age getAgeById(Context context, String id) {
- initAges(context);
- return ages.get(id);
- }
-
- public static void invalidateAges() {
- ages = null;
- }
-
- public static Collection<CommercialSpecies> getAllCommercialSpecies(Context context) {
- initCommercialSpecies(context);
- return commercialSpecies.values();
- }
-
- public static CommercialSpecies getCommercialSpeciesById(Context context, String id) {
- initCommercialSpecies(context);
- return commercialSpecies.get(id);
- }
-
- public static void invalidateCommercialSpecies() {
- commercialSpecies = null;
- }
-
- public static Collection<Gender> getAllGenders(Context context) {
- initGenders(context);
- return genders.values();
- }
-
- public static Gender getGenderById(Context context, String id) {
- initGenders(context);
- return genders.get(id);
- }
-
- public static void invalidateGenders() {
- genders = null;
- }
-
- public static Collection<Location> getAllLocations(Context context) {
- initLocations(context);
- List<Location> result = Lists.newArrayList(locations.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Location getLocationById(Context context, String id) {
- initLocations(context);
- return locations.get(id);
- }
-
- public static void invalidateLocations() {
- locations = null;
- }
-
- public static Collection<Maturity> getAllMaturities(Context context) {
- initMaturities(context);
- return maturities.values();
- }
-
- public static Maturity getMaturityById(Context context, String id) {
- initMaturities(context);
- return maturities.get(id);
- }
-
- public static void invalidateMaturities() {
- maturities = null;
- }
-
- public static Collection<Mensuration> getAllMensurations(Context context) {
- initMensurations(context);
- List<Mensuration> result = Lists.newArrayList(mensurations.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Mensuration getMensurationById(Context context, String id) {
- initMensurations(context);
- return mensurations.get(id);
- }
-
- public static Mensuration getDefaultMensuration(Context context) {
- if (defaultMensuration == null) {
- initMensurations(context);
- Map<String, Mensuration> mensurationsByCode = Maps.uniqueIndex(mensurations.values(), HasCode.GET_CODE_FUNCTION);
- defaultMensuration = mensurationsByCode.get(DEFAULT_MENSURATION_CODE);
- }
- return defaultMensuration;
- }
-
- public static void invalidateMensurations() {
- mensurations = null;
- }
-
- public static Collection<Metier> getAllMetiers(Context context) {
- initMetiers(context);
- List<Metier> result = Lists.newArrayList(metiers.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Metier getMetierById(Context context, String id) {
- initMetiers(context);
- return metiers.get(id);
- }
-
- public static void invalidateMetiers() {
- metiers = null;
- }
-
- public static Collection<Presentation> getAllPresentations(Context context) {
- initPresentations(context);
- List<Presentation> result = Lists.newArrayList(presentations.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Presentation getPresentationById(Context context, String id) {
- initPresentations(context);
- return presentations.get(id);
- }
-
- public static void invalidatePresentations() {
- presentations = null;
- }
-
- public static Collection<ScientificSpecies> getAllScientificSpecies(Context context) {
- initScientificSpecies(context);
- List<ScientificSpecies> result = Lists.newArrayList(scientificSpecies.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static ScientificSpecies getScientificSpeciesById(Context context, String id) {
- initScientificSpecies(context);
- return scientificSpecies.get(id);
- }
-
- public static void invalidateScientificSpecies() {
- scientificSpecies = null;
- }
-
- public static Set<String> getAllSortCategories(Context context) {
- initSortCategories(context);
- return sortCategories;
- }
-
- public static void invalidateSortCategories() {
- sortCategories = null;
- }
-
- public static Collection<State> getAllStates(Context context) {
- initStates(context);
- List<State> result = Lists.newArrayList(states.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static State getStateById(Context context, String id) {
- initStates(context);
- return states.get(id);
- }
-
- public static void invalidateStates() {
- states = null;
- }
-
- public static Collection<Vessel> getAllVessels(Context context) {
- initVessels(context);
- List<Vessel> result = Lists.newArrayList(vessels.values());
- Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
- return result;
- }
-
- public static Vessel getVesselById(Context context, String id) {
- initVessels(context);
- return vessels.get(id);
- }
-
- public static void invalidateVessels() {
- vessels = null;
- }
-
- protected static void initAges(Context context) {
- if (ages == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefAges();
- List<Age> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Age>() {
- @Override
- public Age apply(Cursor input) {
- return new Age(input);
- }
- });
- ages = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initCommercialSpecies(Context context) {
- if (commercialSpecies == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefCommercialSpecies();
- List<CommercialSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, CommercialSpecies>() {
- @Override
- public CommercialSpecies apply(Cursor input) {
- return new CommercialSpecies(input);
- }
- });
-
- commercialSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initGenders(Context context) {
- if (genders == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefGenders();
- List<Gender> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Gender>() {
- @Override
- public Gender apply(Cursor input) {
- return new Gender(input);
- }
- });
-
- genders = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initLocations(Context context) {
- if (locations == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefLocations();
- List<Location> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Location>() {
- @Override
- public Location apply(Cursor input) {
- return new Location(input);
- }
- });
- locations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initMaturities(Context context) {
- if (maturities == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefMaturities();
- List<Maturity> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Maturity>() {
- @Override
- public Maturity apply(Cursor input) {
- return new Maturity(input);
- }
- });
- maturities = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initMensurations(Context context) {
- if (mensurations == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefMensurations();
- List<Mensuration> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Mensuration>() {
- @Override
- public Mensuration apply(Cursor input) {
- return new Mensuration(input);
- }
- });
-
- mensurations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initMetiers(Context context) {
- if (metiers == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefMetiers();
- List<Metier> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Metier>() {
- @Override
- public Metier apply(Cursor input) {
- return new Metier(input);
- }
- });
-
- metiers = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initPresentations(Context context) {
- if (presentations == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefPresentations();
- List<Presentation> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Presentation>() {
- @Override
- public Presentation apply(Cursor input) {
- return new Presentation(input);
- }
- });
-
- presentations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initScientificSpecies(Context context) {
- if (scientificSpecies == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefScientificSpecies();
- List<ScientificSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, ScientificSpecies>() {
- @Override
- public ScientificSpecies apply(Cursor input) {
- return new ScientificSpecies(input);
- }
- });
-
- scientificSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initStates(Context context) {
- if (states == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefStates();
- List<State> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, State>() {
- @Override
- public State apply(Cursor input) {
- return new State(input);
- }
- });
-
- states = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initVessels(Context context) {
- if (vessels == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllRefVessels();
- List<Vessel> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, Vessel>() {
- @Override
- public Vessel apply(Cursor input) {
- return new Vessel(input);
- }
- });
-
- vessels = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
- soh.close();
- }
- }
-
- protected static void initSortCategories(Context context) {
- if (sortCategories == null) {
- WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
- Cursor cursor = soh.getAllSortCategories();
- List<String> sc = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
- new Function<Cursor, String>() {
- @Override
- public String apply(Cursor cursor) {
- return cursor.getString(0);
- }
- });
- sortCategories = Sets.newHashSet(sc);
- soh.close();
- }
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java (from rev 25, trunk/src/fr/ifremer/wlo/storage/DataCache.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/storage/DataCache.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,465 @@
+package fr.ifremer.wlo.storage;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.database.Cursor;
+import com.google.common.base.Function;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.collect.Table;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.models.referentials.HasCode;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.models.referentials.Vessel;
+import org.apache.commons.lang3.ObjectUtils;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class DataCache {
+
+ public static final String DEFAULT_MENSURATION_CODE = "LT";
+
+ protected static Map<String, Age> ages;
+ protected static Map<String, CommercialSpecies> commercialSpecies;
+ protected static Map<String, Gender> genders;
+ protected static Map<String, Location> locations;
+ protected static Map<String, Maturity> maturities;
+ protected static Map<String, Mensuration> mensurations;
+ protected static Mensuration defaultMensuration;
+ protected static Map<String, Metier> metiers;
+ protected static Map<String, Presentation> presentations;
+ protected static Map<String, ScientificSpecies> scientificSpecies;
+ protected static Map<String, State> states;
+ protected static Map<String, Vessel> vessels;
+ protected static Set<String> sortCategories;
+
+ public static Collection<Age> getAllAges(Context context) {
+ initAges(context);
+ return ages.values();
+ }
+
+ public static Age getAgeById(Context context, String id) {
+ initAges(context);
+ return ages.get(id);
+ }
+
+ public static void invalidateAges() {
+ ages = null;
+ }
+
+ public static Collection<CommercialSpecies> getAllCommercialSpecies(Context context) {
+ initCommercialSpecies(context);
+ return commercialSpecies.values();
+ }
+
+ public static CommercialSpecies getCommercialSpeciesById(Context context, String id) {
+ initCommercialSpecies(context);
+ return commercialSpecies.get(id);
+ }
+
+ public static void invalidateCommercialSpecies() {
+ commercialSpecies = null;
+ }
+
+ public static Collection<Gender> getAllGenders(Context context) {
+ initGenders(context);
+ return genders.values();
+ }
+
+ public static Gender getGenderById(Context context, String id) {
+ initGenders(context);
+ return genders.get(id);
+ }
+
+ public static void invalidateGenders() {
+ genders = null;
+ }
+
+ public static Collection<Location> getAllLocations(Context context) {
+ initLocations(context);
+ List<Location> result = Lists.newArrayList(locations.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Location getLocationById(Context context, String id) {
+ initLocations(context);
+ return locations.get(id);
+ }
+
+ public static void invalidateLocations() {
+ locations = null;
+ }
+
+ public static Collection<Maturity> getAllMaturities(Context context) {
+ initMaturities(context);
+ return maturities.values();
+ }
+
+ public static Maturity getMaturityById(Context context, String id) {
+ initMaturities(context);
+ return maturities.get(id);
+ }
+
+ public static void invalidateMaturities() {
+ maturities = null;
+ }
+
+ public static Collection<Mensuration> getAllMensurations(Context context) {
+ initMensurations(context);
+ List<Mensuration> result = Lists.newArrayList(mensurations.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Mensuration getMensurationById(Context context, String id) {
+ initMensurations(context);
+ return mensurations.get(id);
+ }
+
+ public static Mensuration getDefaultMensuration(Context context) {
+ if (defaultMensuration == null) {
+ initMensurations(context);
+ Map<String, Mensuration> mensurationsByCode = Maps.uniqueIndex(mensurations.values(), HasCode.GET_CODE_FUNCTION);
+ defaultMensuration = mensurationsByCode.get(DEFAULT_MENSURATION_CODE);
+ }
+ return defaultMensuration;
+ }
+
+ public static void invalidateMensurations() {
+ mensurations = null;
+ }
+
+ public static Collection<Metier> getAllMetiers(Context context) {
+ initMetiers(context);
+ List<Metier> result = Lists.newArrayList(metiers.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Metier getMetierById(Context context, String id) {
+ initMetiers(context);
+ return metiers.get(id);
+ }
+
+ public static void invalidateMetiers() {
+ metiers = null;
+ }
+
+ public static Collection<Presentation> getAllPresentations(Context context) {
+ initPresentations(context);
+ List<Presentation> result = Lists.newArrayList(presentations.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Presentation getPresentationById(Context context, String id) {
+ initPresentations(context);
+ return presentations.get(id);
+ }
+
+ public static void invalidatePresentations() {
+ presentations = null;
+ }
+
+ public static Collection<ScientificSpecies> getAllScientificSpecies(Context context) {
+ initScientificSpecies(context);
+ List<ScientificSpecies> result = Lists.newArrayList(scientificSpecies.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static ScientificSpecies getScientificSpeciesById(Context context, String id) {
+ initScientificSpecies(context);
+ return scientificSpecies.get(id);
+ }
+
+ public static void invalidateScientificSpecies() {
+ scientificSpecies = null;
+ }
+
+ public static Set<String> getAllSortCategories(Context context) {
+ initSortCategories(context);
+ return sortCategories;
+ }
+
+ public static void invalidateSortCategories() {
+ sortCategories = null;
+ }
+
+ public static Collection<State> getAllStates(Context context) {
+ initStates(context);
+ List<State> result = Lists.newArrayList(states.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static State getStateById(Context context, String id) {
+ initStates(context);
+ return states.get(id);
+ }
+
+ public static void invalidateStates() {
+ states = null;
+ }
+
+ public static Collection<Vessel> getAllVessels(Context context) {
+ initVessels(context);
+ List<Vessel> result = Lists.newArrayList(vessels.values());
+ Collections.sort(result, HasCode.GET_CODE_COMPARATOR);
+ return result;
+ }
+
+ public static Vessel getVesselById(Context context, String id) {
+ initVessels(context);
+ return vessels.get(id);
+ }
+
+ public static void invalidateVessels() {
+ vessels = null;
+ }
+
+ protected static void initAges(Context context) {
+ if (ages == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefAges();
+ List<Age> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Age>() {
+ @Override
+ public Age apply(Cursor input) {
+ return new Age(input);
+ }
+ });
+ ages = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initCommercialSpecies(Context context) {
+ if (commercialSpecies == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefCommercialSpecies();
+ List<CommercialSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, CommercialSpecies>() {
+ @Override
+ public CommercialSpecies apply(Cursor input) {
+ return new CommercialSpecies(input);
+ }
+ });
+
+ commercialSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initGenders(Context context) {
+ if (genders == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefGenders();
+ List<Gender> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Gender>() {
+ @Override
+ public Gender apply(Cursor input) {
+ return new Gender(input);
+ }
+ });
+
+ genders = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initLocations(Context context) {
+ if (locations == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefLocations();
+ List<Location> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Location>() {
+ @Override
+ public Location apply(Cursor input) {
+ return new Location(input);
+ }
+ });
+ locations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initMaturities(Context context) {
+ if (maturities == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefMaturities();
+ List<Maturity> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Maturity>() {
+ @Override
+ public Maturity apply(Cursor input) {
+ return new Maturity(input);
+ }
+ });
+ maturities = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initMensurations(Context context) {
+ if (mensurations == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefMensurations();
+ List<Mensuration> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Mensuration>() {
+ @Override
+ public Mensuration apply(Cursor input) {
+ return new Mensuration(input);
+ }
+ });
+
+ mensurations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initMetiers(Context context) {
+ if (metiers == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefMetiers();
+ List<Metier> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Metier>() {
+ @Override
+ public Metier apply(Cursor input) {
+ return new Metier(input);
+ }
+ });
+
+ metiers = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initPresentations(Context context) {
+ if (presentations == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefPresentations();
+ List<Presentation> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Presentation>() {
+ @Override
+ public Presentation apply(Cursor input) {
+ return new Presentation(input);
+ }
+ });
+
+ presentations = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initScientificSpecies(Context context) {
+ if (scientificSpecies == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefScientificSpecies();
+ List<ScientificSpecies> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, ScientificSpecies>() {
+ @Override
+ public ScientificSpecies apply(Cursor input) {
+ return new ScientificSpecies(input);
+ }
+ });
+
+ scientificSpecies = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initStates(Context context) {
+ if (states == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefStates();
+ List<State> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, State>() {
+ @Override
+ public State apply(Cursor input) {
+ return new State(input);
+ }
+ });
+
+ states = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initVessels(Context context) {
+ if (vessels == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllRefVessels();
+ List<Vessel> data = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, Vessel>() {
+ @Override
+ public Vessel apply(Cursor input) {
+ return new Vessel(input);
+ }
+ });
+
+ vessels = Maps.uniqueIndex(data, BaseModel.GET_ID_FUNCTION);
+ soh.close();
+ }
+ }
+
+ protected static void initSortCategories(Context context) {
+ if (sortCategories == null) {
+ WloSqlOpenHelper soh = new WloSqlOpenHelper(context);
+ Cursor cursor = soh.getAllSortCategories();
+ List<String> sc = WloSqlOpenHelper.transformCursorIntoCollection(cursor,
+ new Function<Cursor, String>() {
+ @Override
+ public String apply(Cursor cursor) {
+ return cursor.getString(0);
+ }
+ });
+ sortCategories = Sets.newHashSet(sc);
+ soh.close();
+ }
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/StorageUtils.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,18 +0,0 @@
-package fr.ifremer.wlo.storage;
-
-import android.os.Environment;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class StorageUtils {
-
- public static boolean isExternalStorageWritable() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- return true;
- }
- return false;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java (from rev 25, trunk/src/fr/ifremer/wlo/storage/StorageUtils.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/storage/StorageUtils.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,42 @@
+package fr.ifremer.wlo.storage;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.os.Environment;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class StorageUtils {
+
+ public static boolean isExternalStorageWritable() {
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
+ return true;
+ }
+ return false;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java
===================================================================
--- trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,571 +0,0 @@
-package fr.ifremer.wlo.storage;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.CommercialSpeciesModel;
-import fr.ifremer.wlo.models.ContextModel;
-import fr.ifremer.wlo.models.LocationModel;
-import fr.ifremer.wlo.models.MetierModel;
-import fr.ifremer.wlo.models.ScientificSpeciesModel;
-import fr.ifremer.wlo.models.VesselModel;
-import fr.ifremer.wlo.models.referentials.Age;
-import fr.ifremer.wlo.models.referentials.CommercialSpecies;
-import fr.ifremer.wlo.models.referentials.Gender;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Maturity;
-import fr.ifremer.wlo.models.referentials.Mensuration;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.models.referentials.Presentation;
-import fr.ifremer.wlo.models.referentials.ScientificSpecies;
-import fr.ifremer.wlo.models.referentials.State;
-import fr.ifremer.wlo.models.referentials.Vessel;
-
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class WloSqlOpenHelper extends SQLiteOpenHelper {
-
- private static final String TAG = "WloOpenHelper";
-
- public static final String DATABASE_NAME = "wlo.db";
- public static final int DATABASE_VERSION = 9;
-
- public static final String TEXT_TYPE = " TEXT";
- public static final String BIGINT_TYPE = " BIGINT";
- public static final String BYTE_TYPE = " BYTE";
- public static final String COMMA_SEP = ",";
- public static final String NOT_NULL = " NOT NULL";
-
- //CONTEXT
- protected static final String SQL_CREATE_CONTEXTS =
- "CREATE TABLE " + ContextModel.TABLE_NAME + " (" +
- ContextModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- ContextModel.COLUMN_NAME + TEXT_TYPE + NOT_NULL +
- " )";
-
- protected static final String SQL_DELETE_CONTEXTS =
- "DROP TABLE IF EXISTS " + ContextModel.TABLE_NAME;
-
-
- //LOCATION
- protected static final String SQL_CREATE_LOCATIONS =
- "CREATE TABLE " + LocationModel.TABLE_NAME + " (" +
- LocationModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- LocationModel.COLUMN_OPERATOR + TEXT_TYPE + COMMA_SEP +
- LocationModel.COLUMN_START_DATE + BIGINT_TYPE + COMMA_SEP +
- LocationModel.COLUMN_END_DATE + BIGINT_TYPE + COMMA_SEP +
- LocationModel.COLUMN_LOCATION + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- LocationModel.COLUMN_CONTEXT_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + LocationModel.COLUMN_CONTEXT_ID + ") REFERENCES " +
- ContextModel.TABLE_NAME + "(" + ContextModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + LocationModel.COLUMN_LOCATION + ") REFERENCES " +
- Location.TABLE_NAME + "(" + Location._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_LOCATIONS =
- "DROP TABLE IF EXISTS " + LocationModel.TABLE_NAME;
-
- // VESSEL
- protected static final String SQL_CREATE_VESSELS =
- "CREATE TABLE " + VesselModel.TABLE_NAME + " (" +
- VesselModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- VesselModel.COLUMN_REGISTRATION_NUMBER + TEXT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_LANDING_DATE + BIGINT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_LANDING_LOCATION + TEXT_TYPE + COMMA_SEP +
- VesselModel.COLUMN_LOCATION_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + VesselModel.COLUMN_LOCATION_ID + ") REFERENCES " +
- LocationModel.TABLE_NAME + "(" + LocationModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + VesselModel.COLUMN_LANDING_LOCATION + ") REFERENCES " +
- Location.TABLE_NAME + "(" + Location._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_VESSELS =
- "DROP TABLE IF EXISTS " + VesselModel.TABLE_NAME;
-
- // METIER
- protected static final String SQL_CREATE_METIERS =
- "CREATE TABLE " + MetierModel.TABLE_NAME + " (" +
- MetierModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- MetierModel.COLUMN_GEAR_SPECIES + TEXT_TYPE + COMMA_SEP +
- MetierModel.COLUMN_ZONE + TEXT_TYPE + COMMA_SEP +
- MetierModel.COLUMN_SAMPLE_ROW_CODE + TEXT_TYPE + COMMA_SEP +
- MetierModel.COLUMN_VESSEL_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + MetierModel.COLUMN_VESSEL_ID + ") REFERENCES " +
- VesselModel.TABLE_NAME + "(" + VesselModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + MetierModel.COLUMN_GEAR_SPECIES + ") REFERENCES " +
- Metier.TABLE_NAME + "(" + Metier._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_METIERS =
- "DROP TABLE IF EXISTS " + MetierModel.TABLE_NAME;
-
- // COMMERCIAL SPECIES
- protected static final String SQL_CREATE_COMMERCIAL_SPECIES =
- "CREATE TABLE " + CommercialSpeciesModel.TABLE_NAME + " (" +
- CommercialSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_FAO_CODE + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_PRECISION + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_SPECIES_MIX + BYTE_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_SORT_CATEGORY + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_STATE + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_PRESENTATION + TEXT_TYPE + COMMA_SEP +
- CommercialSpeciesModel.COLUMN_METIER_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_METIER_ID + ") REFERENCES " +
- MetierModel.TABLE_NAME + "(" + MetierModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_FAO_CODE + ") REFERENCES " +
- CommercialSpecies.TABLE_NAME + "(" + CommercialSpecies._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + ") REFERENCES " +
- Mensuration.TABLE_NAME + "(" + Mensuration._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_STATE + ") REFERENCES " +
- State.TABLE_NAME + "(" + State._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_PRESENTATION + ") REFERENCES " +
- Presentation.TABLE_NAME + "(" + Presentation._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_COMMERCIAL_SPECIES =
- "DROP TABLE IF EXISTS " + CommercialSpeciesModel.TABLE_NAME;
-
- // SCIENTIFIC SPECIES
- protected static final String SQL_CREATE_SCIENTIFIC_SPECIES =
- "CREATE TABLE " + ScientificSpeciesModel.TABLE_NAME + " (" +
- ScientificSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
- ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP +
- ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + ") REFERENCES " +
- CommercialSpeciesModel.TABLE_NAME + "(" + CommercialSpeciesModel._ID + ")" + COMMA_SEP +
- "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_NAME + ") REFERENCES " +
- ScientificSpecies.TABLE_NAME + "(" + ScientificSpecies._ID + ")" +
- " )";
-
- protected static final String SQL_DELETE_SCIENTIFIC_SPECIES =
- "DROP TABLE IF EXISTS " + ScientificSpeciesModel.TABLE_NAME;
-
-
- // Referentials
-
- // Ages
- protected static final String SQL_CREATE_REF_AGES =
- "CREATE TABLE " + Age.TABLE_NAME + " (" +
- Age._ID + TEXT_TYPE + " PRIMARY KEY," +
- Age.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
- " )";
-
- protected static final String SQL_DELETE_REF_AGES =
- "DROP TABLE IF EXISTS " + Age.TABLE_NAME;
-
- // Commercial Species
- protected static final String SQL_CREATE_REF_COMMERCIAL_SPECIES =
- "CREATE TABLE " + CommercialSpecies.TABLE_NAME + " (" +
- CommercialSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- CommercialSpecies.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- CommercialSpecies.COLUMN_ISSCAP + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_TAXON_CODE + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_SCIENTIFIC_LABEL + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_FRENCH_LABEL + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_FAMILY + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_SPECIES_ORDER + TEXT_TYPE + COMMA_SEP +
- CommercialSpecies.COLUMN_ACTIVE + BYTE_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_COMMERCIAL_SPECIES =
- "DROP TABLE IF EXISTS " + CommercialSpecies.TABLE_NAME;
-
- // Genders
- protected static final String SQL_CREATE_REF_GENDERS =
- "CREATE TABLE " + Gender.TABLE_NAME + " (" +
- Gender._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Gender.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Gender.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_GENDERS =
- "DROP TABLE IF EXISTS " + Gender.TABLE_NAME;
-
- // Locations
- protected static final String SQL_CREATE_REF_LOCATIONS =
- "CREATE TABLE " + Location.TABLE_NAME + " (" +
- Location._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Location.COLUMN_TYPE_LABEL + TEXT_TYPE + COMMA_SEP +
- Location.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Location.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_LOCATIONS =
- "DROP TABLE IF EXISTS " + Location.TABLE_NAME;
-
- // Maturities
- protected static final String SQL_CREATE_REF_MATURITIES =
- "CREATE TABLE " + Maturity.TABLE_NAME + " (" +
- Maturity._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Maturity.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
- " )";
-
- protected static final String SQL_DELETE_REF_MATURITIES =
- "DROP TABLE IF EXISTS " + Maturity.TABLE_NAME;
-
- // Mensurations
- protected static final String SQL_CREATE_REF_MENSURATIONS =
- "CREATE TABLE " + Mensuration.TABLE_NAME + " (" +
- Mensuration._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Mensuration.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Mensuration.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_MENSURATIONS =
- "DROP TABLE IF EXISTS " + Mensuration.TABLE_NAME;
-
- // Metiers
- protected static final String SQL_CREATE_REF_METIERS =
- "CREATE TABLE " + Metier.TABLE_NAME + " (" +
- Metier._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Metier.COLUMN_ID + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Metier.COLUMN_LABEL + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_GEAR_CODE + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_GEAR_LABEL + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_SPECIES_CODE + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_SPECIES_LABEL + TEXT_TYPE + COMMA_SEP +
- Metier.COLUMN_FISHING + BYTE_TYPE + COMMA_SEP +
- Metier.COLUMN_ACTIVE + BYTE_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_METIERS =
- "DROP TABLE IF EXISTS " + Metier.TABLE_NAME;
-
- // Presentations
- protected static final String SQL_CREATE_REF_PRESENTATIONS =
- "CREATE TABLE " + Presentation.TABLE_NAME + " (" +
- Presentation._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Presentation.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Presentation.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_PRESENTATIONS =
- "DROP TABLE IF EXISTS " + Presentation.TABLE_NAME;
-
- // Scientific species
- protected static final String SQL_CREATE_REF_SCIENTIFIC_SPECIES =
- "CREATE TABLE " + ScientificSpecies.TABLE_NAME + " (" +
- ScientificSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- ScientificSpecies.COLUMN_PERM_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- ScientificSpecies.COLUMN_CODE + TEXT_TYPE + COMMA_SEP +
- ScientificSpecies.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_SCIENTIFIC_SPECIES =
- "DROP TABLE IF EXISTS " + ScientificSpecies.TABLE_NAME;
-
- // States
- protected static final String SQL_CREATE_REF_STATES =
- "CREATE TABLE " + State.TABLE_NAME + " (" +
- State._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- State.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- State.COLUMN_LABEL + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_STATES =
- "DROP TABLE IF EXISTS " + State.TABLE_NAME;
-
- // Vessels
- protected static final String SQL_CREATE_REF_VESSELS =
- "CREATE TABLE " + Vessel.TABLE_NAME + " (" +
- Vessel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
- Vessel.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
- Vessel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
- Vessel.COLUMN_QUARTER_CODE + TEXT_TYPE +
- " )";
-
- protected static final String SQL_DELETE_REF_VESSELS =
- "DROP TABLE IF EXISTS " + Vessel.TABLE_NAME;
-
-
- public WloSqlOpenHelper(android.content.Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- // referentials
- db.execSQL(SQL_CREATE_REF_AGES);
- db.execSQL(SQL_CREATE_REF_COMMERCIAL_SPECIES);
- db.execSQL(SQL_CREATE_REF_GENDERS);
- db.execSQL(SQL_CREATE_REF_LOCATIONS);
- db.execSQL(SQL_CREATE_REF_MATURITIES);
- db.execSQL(SQL_CREATE_REF_MENSURATIONS);
- db.execSQL(SQL_CREATE_REF_METIERS);
- db.execSQL(SQL_CREATE_REF_PRESENTATIONS);
- db.execSQL(SQL_CREATE_REF_SCIENTIFIC_SPECIES);
- db.execSQL(SQL_CREATE_REF_STATES);
- db.execSQL(SQL_CREATE_REF_VESSELS);
-
- // models
- db.execSQL(SQL_CREATE_CONTEXTS);
- db.execSQL(SQL_CREATE_LOCATIONS);
- db.execSQL(SQL_CREATE_VESSELS);
- db.execSQL(SQL_CREATE_METIERS);
- db.execSQL(SQL_CREATE_COMMERCIAL_SPECIES);
- db.execSQL(SQL_CREATE_SCIENTIFIC_SPECIES);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- //TODO kmorin 20131129 migrate data before droping the table
- // models
- db.execSQL(SQL_DELETE_SCIENTIFIC_SPECIES);
- db.execSQL(SQL_DELETE_COMMERCIAL_SPECIES);
- db.execSQL(SQL_DELETE_METIERS);
- db.execSQL(SQL_DELETE_VESSELS);
- db.execSQL(SQL_DELETE_LOCATIONS);
- db.execSQL(SQL_DELETE_CONTEXTS);
-
- // referentials
- db.execSQL(SQL_DELETE_REF_AGES);
- db.execSQL(SQL_DELETE_REF_COMMERCIAL_SPECIES);
- db.execSQL(SQL_DELETE_REF_GENDERS);
- db.execSQL(SQL_DELETE_REF_LOCATIONS);
- db.execSQL(SQL_DELETE_REF_MATURITIES);
- db.execSQL(SQL_DELETE_REF_MENSURATIONS);
- db.execSQL(SQL_DELETE_REF_METIERS);
- db.execSQL(SQL_DELETE_REF_PRESENTATIONS);
- db.execSQL(SQL_DELETE_REF_SCIENTIFIC_SPECIES);
- db.execSQL(SQL_DELETE_REF_STATES);
- db.execSQL(SQL_DELETE_REF_VESSELS);
- onCreate(db);
- }
-
- @Override
- public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- onUpgrade(db, oldVersion, newVersion);
- }
-
- @Override
- public synchronized void close() {
- super.close();
- getReadableDatabase().close();
- getWritableDatabase().close();
- }
-
- // CONTEXTS
-
- public Cursor getAllContexts() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(ContextModel.TABLE_NAME, ContextModel.ALL_COLUMNS, null, null, null, null, null);
- return cursor;
- }
-
- //LOCATION
-
- public Cursor getAllLocations(String contextId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(LocationModel.TABLE_NAME, LocationModel.ALL_COLUMNS,
- LocationModel.COLUMN_CONTEXT_ID + " = ?", new String[]{ contextId },
- null, null, null);
- return cursor;
- }
-
- //VESSEL
-
- public Cursor getAllVessels(String locationId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(VesselModel.TABLE_NAME, VesselModel.ALL_COLUMNS,
- VesselModel.COLUMN_LOCATION_ID + " = ?", new String[]{ locationId },
- null, null, null);
- return cursor;
- }
-
- //METIERS
-
- public Cursor getAllMetiers(String vesselId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(MetierModel.TABLE_NAME, MetierModel.ALL_COLUMNS,
- MetierModel.COLUMN_VESSEL_ID + " = ?", new String[]{ vesselId },
- null, null, null);
- return cursor;
- }
-
- //COMMERCIAL SPECIES
-
- public Cursor getAllCommercialSpecies(String metierId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, CommercialSpeciesModel.ALL_COLUMNS,
- CommercialSpeciesModel.COLUMN_METIER_ID + " = ?", new String[]{ metierId },
- null, null, null);
- return cursor;
- }
-
- public Cursor getAllSortCategories() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, new String[]{ CommercialSpeciesModel.COLUMN_SORT_CATEGORY },
- null, null, null, null, null);
- return cursor;
- }
-
- //SCIENTIFIC SPECIES
-
- public Cursor getAllScientificSpecies(String commercialSpeciesId) {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(ScientificSpeciesModel.TABLE_NAME, ScientificSpeciesModel.ALL_COLUMNS,
- ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + " = ?", new String[]{ commercialSpeciesId },
- null, null, null);
- return cursor;
- }
-
- // Referentials
-
- public Cursor getAllRefAges() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Age.TABLE_NAME, Age.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefCommercialSpecies() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(CommercialSpecies.TABLE_NAME, CommercialSpecies.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefGenders() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Gender.TABLE_NAME, Gender.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefLocations() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Location.TABLE_NAME, Location.ALL_COLUMNS,
- null, null, null, null, Location.COLUMN_CODE);
- return cursor;
- }
-
- public Cursor getAllRefMaturities() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Maturity.TABLE_NAME, Maturity.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefMensurations() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Mensuration.TABLE_NAME, Mensuration.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefMetiers() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Metier.TABLE_NAME, Metier.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefPresentations() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Presentation.TABLE_NAME, Presentation.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefScientificSpecies() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(ScientificSpecies.TABLE_NAME, ScientificSpecies.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefStates() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(State.TABLE_NAME, State.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- public Cursor getAllRefVessels() {
- SQLiteDatabase db = getReadableDatabase();
- Cursor cursor = db.query(Vessel.TABLE_NAME, Vessel.ALL_COLUMNS,
- null, null, null, null, null);
- return cursor;
- }
-
- //TODO remove when tests are over
- public void clearReferentials() {
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
- db.delete(Age.TABLE_NAME, null, null);
- db.delete(CommercialSpecies.TABLE_NAME, null, null);
- db.delete(Gender.TABLE_NAME, null, null);
- db.delete(Location.TABLE_NAME, null, null);
- db.delete(Maturity.TABLE_NAME, null, null);
- db.delete(Mensuration.TABLE_NAME, null, null);
- db.delete(Metier.TABLE_NAME, null, null);
- db.delete(Presentation.TABLE_NAME, null, null);
- db.delete(ScientificSpecies.TABLE_NAME, null, null);
- db.delete(State.TABLE_NAME, null, null);
- db.delete(Vessel.TABLE_NAME, null, null);
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- public <M extends BaseModel> void saveData(M model) {
- saveData(Lists.newArrayList(model));
- }
-
- public <M extends BaseModel> void saveData(List<M> models) {
- Preconditions.checkNotNull(models);
-
- SQLiteDatabase db = getWritableDatabase();
- db.beginTransaction();
-
- for (BaseModel model : models) {
- String tableName = model.getTableName();
-// Log.d(TAG, "saving data in " + tableName);
-
- boolean newSession = model.isNew();
- if (newSession) {
- String id = UUID.randomUUID().toString();
- model.setId(id);
- }
- ContentValues values = model.convertIntoContentValues();
-
- if (newSession) {
- db.insert(tableName, null, values);
-
- } else {
- db.update(tableName, values, BaseModel._ID + " = ?", new String[]{ model.getId() });
- }
- }
-
- db.setTransactionSuccessful();
- db.endTransaction();
- }
-
- public static <E> List<E> transformCursorIntoCollection(Cursor cursor,
- Function<Cursor, E> function) {
-
- List<E> result = Lists.newArrayList();
- boolean cont = cursor.moveToFirst();
- while (cont) {
- E e = function.apply(cursor);
- result.add(e);
- cont = cursor.moveToNext();
- }
- return result;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java (from rev 25, trunk/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/storage/WloSqlOpenHelper.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,633 @@
+package fr.ifremer.wlo.storage;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.CommercialSpeciesModel;
+import fr.ifremer.wlo.models.ContextModel;
+import fr.ifremer.wlo.models.LocationModel;
+import fr.ifremer.wlo.models.MeasurementModel;
+import fr.ifremer.wlo.models.MetierModel;
+import fr.ifremer.wlo.models.ScientificSpeciesModel;
+import fr.ifremer.wlo.models.VesselModel;
+import fr.ifremer.wlo.models.referentials.Age;
+import fr.ifremer.wlo.models.referentials.CommercialSpecies;
+import fr.ifremer.wlo.models.referentials.Gender;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Maturity;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.models.referentials.Presentation;
+import fr.ifremer.wlo.models.referentials.ScientificSpecies;
+import fr.ifremer.wlo.models.referentials.State;
+import fr.ifremer.wlo.models.referentials.Vessel;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class WloSqlOpenHelper extends SQLiteOpenHelper {
+
+ private static final String TAG = "WloOpenHelper";
+
+ public static final String DATABASE_NAME = "wlo.db";
+ public static final int DATABASE_VERSION = 10;
+
+ public static final String TEXT_TYPE = " TEXT";
+ public static final String BIGINT_TYPE = " BIGINT";
+ public static final String BYTE_TYPE = " BYTE";
+ public static final String COMMA_SEP = ",";
+ public static final String NOT_NULL = " NOT NULL";
+
+ //CONTEXT
+ protected static final String SQL_CREATE_CONTEXTS =
+ "CREATE TABLE " + ContextModel.TABLE_NAME + " (" +
+ ContextModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ ContextModel.COLUMN_NAME + TEXT_TYPE + NOT_NULL +
+ " )";
+
+ protected static final String SQL_DELETE_CONTEXTS =
+ "DROP TABLE IF EXISTS " + ContextModel.TABLE_NAME;
+
+
+ //LOCATION
+ protected static final String SQL_CREATE_LOCATIONS =
+ "CREATE TABLE " + LocationModel.TABLE_NAME + " (" +
+ LocationModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ LocationModel.COLUMN_OPERATOR + TEXT_TYPE + COMMA_SEP +
+ LocationModel.COLUMN_START_DATE + BIGINT_TYPE + COMMA_SEP +
+ LocationModel.COLUMN_END_DATE + BIGINT_TYPE + COMMA_SEP +
+ LocationModel.COLUMN_LOCATION + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ LocationModel.COLUMN_CONTEXT_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + LocationModel.COLUMN_CONTEXT_ID + ") REFERENCES " +
+ ContextModel.TABLE_NAME + "(" + ContextModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + LocationModel.COLUMN_LOCATION + ") REFERENCES " +
+ Location.TABLE_NAME + "(" + Location._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_LOCATIONS =
+ "DROP TABLE IF EXISTS " + LocationModel.TABLE_NAME;
+
+ // VESSEL
+ protected static final String SQL_CREATE_VESSELS =
+ "CREATE TABLE " + VesselModel.TABLE_NAME + " (" +
+ VesselModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ VesselModel.COLUMN_REGISTRATION_NUMBER + TEXT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_LANDING_DATE + BIGINT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_LANDING_LOCATION + TEXT_TYPE + COMMA_SEP +
+ VesselModel.COLUMN_LOCATION_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + VesselModel.COLUMN_LOCATION_ID + ") REFERENCES " +
+ LocationModel.TABLE_NAME + "(" + LocationModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + VesselModel.COLUMN_LANDING_LOCATION + ") REFERENCES " +
+ Location.TABLE_NAME + "(" + Location._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_VESSELS =
+ "DROP TABLE IF EXISTS " + VesselModel.TABLE_NAME;
+
+ // METIER
+ protected static final String SQL_CREATE_METIERS =
+ "CREATE TABLE " + MetierModel.TABLE_NAME + " (" +
+ MetierModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ MetierModel.COLUMN_GEAR_SPECIES + TEXT_TYPE + COMMA_SEP +
+ MetierModel.COLUMN_ZONE + TEXT_TYPE + COMMA_SEP +
+ MetierModel.COLUMN_SAMPLE_ROW_CODE + TEXT_TYPE + COMMA_SEP +
+ MetierModel.COLUMN_VESSEL_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + MetierModel.COLUMN_VESSEL_ID + ") REFERENCES " +
+ VesselModel.TABLE_NAME + "(" + VesselModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + MetierModel.COLUMN_GEAR_SPECIES + ") REFERENCES " +
+ Metier.TABLE_NAME + "(" + Metier._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_METIERS =
+ "DROP TABLE IF EXISTS " + MetierModel.TABLE_NAME;
+
+ // COMMERCIAL SPECIES
+ protected static final String SQL_CREATE_COMMERCIAL_SPECIES =
+ "CREATE TABLE " + CommercialSpeciesModel.TABLE_NAME + " (" +
+ CommercialSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_FAO_CODE + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_PRECISION + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_SPECIES_MIX + BYTE_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_SORT_CATEGORY + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_STATE + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_PRESENTATION + TEXT_TYPE + COMMA_SEP +
+ CommercialSpeciesModel.COLUMN_METIER_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_METIER_ID + ") REFERENCES " +
+ MetierModel.TABLE_NAME + "(" + MetierModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_FAO_CODE + ") REFERENCES " +
+ CommercialSpecies.TABLE_NAME + "(" + CommercialSpecies._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_MEASUREMENT_METHOD + ") REFERENCES " +
+ Mensuration.TABLE_NAME + "(" + Mensuration._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_STATE + ") REFERENCES " +
+ State.TABLE_NAME + "(" + State._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + CommercialSpeciesModel.COLUMN_PRESENTATION + ") REFERENCES " +
+ Presentation.TABLE_NAME + "(" + Presentation._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_COMMERCIAL_SPECIES =
+ "DROP TABLE IF EXISTS " + CommercialSpeciesModel.TABLE_NAME;
+
+ // SCIENTIFIC SPECIES
+ protected static final String SQL_CREATE_SCIENTIFIC_SPECIES =
+ "CREATE TABLE " + ScientificSpeciesModel.TABLE_NAME + " (" +
+ ScientificSpeciesModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ ScientificSpeciesModel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
+ ScientificSpeciesModel.COLUMN_TAKING_ACTIVATION + BYTE_TYPE + COMMA_SEP +
+ ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + ") REFERENCES " +
+ CommercialSpeciesModel.TABLE_NAME + "(" + CommercialSpeciesModel._ID + ")" + COMMA_SEP +
+ "FOREIGN KEY(" + ScientificSpeciesModel.COLUMN_NAME + ") REFERENCES " +
+ ScientificSpecies.TABLE_NAME + "(" + ScientificSpecies._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_SCIENTIFIC_SPECIES =
+ "DROP TABLE IF EXISTS " + ScientificSpeciesModel.TABLE_NAME;
+
+ // MEASUREMENTS
+ protected static final String SQL_CREATE_MEASUREMENTS =
+ "CREATE TABLE " + MeasurementModel.TABLE_NAME + " (" +
+ MeasurementModel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ MeasurementModel.COLUMN_SIZE + BIGINT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_DATE + BIGINT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_CATEGORY_1 + TEXT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_CATEGORY_2 + TEXT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_CATEGORY_3 + TEXT_TYPE + COMMA_SEP +
+ MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ "FOREIGN KEY(" + MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + ") REFERENCES " +
+ ScientificSpeciesModel.TABLE_NAME + "(" + ScientificSpeciesModel._ID + ")" +
+ " )";
+
+ protected static final String SQL_DELETE_MEASUREMENTS =
+ "DROP TABLE IF EXISTS " + MeasurementModel.TABLE_NAME;
+
+
+ // Referentials
+
+ // Ages
+ protected static final String SQL_CREATE_REF_AGES =
+ "CREATE TABLE " + Age.TABLE_NAME + " (" +
+ Age._ID + TEXT_TYPE + " PRIMARY KEY," +
+ Age.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
+ " )";
+
+ protected static final String SQL_DELETE_REF_AGES =
+ "DROP TABLE IF EXISTS " + Age.TABLE_NAME;
+
+ // Commercial Species
+ protected static final String SQL_CREATE_REF_COMMERCIAL_SPECIES =
+ "CREATE TABLE " + CommercialSpecies.TABLE_NAME + " (" +
+ CommercialSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ CommercialSpecies.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ CommercialSpecies.COLUMN_ISSCAP + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_TAXON_CODE + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_SCIENTIFIC_LABEL + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_FRENCH_LABEL + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_FAMILY + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_SPECIES_ORDER + TEXT_TYPE + COMMA_SEP +
+ CommercialSpecies.COLUMN_ACTIVE + BYTE_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_COMMERCIAL_SPECIES =
+ "DROP TABLE IF EXISTS " + CommercialSpecies.TABLE_NAME;
+
+ // Genders
+ protected static final String SQL_CREATE_REF_GENDERS =
+ "CREATE TABLE " + Gender.TABLE_NAME + " (" +
+ Gender._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Gender.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Gender.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_GENDERS =
+ "DROP TABLE IF EXISTS " + Gender.TABLE_NAME;
+
+ // Locations
+ protected static final String SQL_CREATE_REF_LOCATIONS =
+ "CREATE TABLE " + Location.TABLE_NAME + " (" +
+ Location._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Location.COLUMN_TYPE_LABEL + TEXT_TYPE + COMMA_SEP +
+ Location.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Location.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_LOCATIONS =
+ "DROP TABLE IF EXISTS " + Location.TABLE_NAME;
+
+ // Maturities
+ protected static final String SQL_CREATE_REF_MATURITIES =
+ "CREATE TABLE " + Maturity.TABLE_NAME + " (" +
+ Maturity._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Maturity.COLUMN_LABEL + TEXT_TYPE + NOT_NULL +
+ " )";
+
+ protected static final String SQL_DELETE_REF_MATURITIES =
+ "DROP TABLE IF EXISTS " + Maturity.TABLE_NAME;
+
+ // Mensurations
+ protected static final String SQL_CREATE_REF_MENSURATIONS =
+ "CREATE TABLE " + Mensuration.TABLE_NAME + " (" +
+ Mensuration._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Mensuration.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Mensuration.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_MENSURATIONS =
+ "DROP TABLE IF EXISTS " + Mensuration.TABLE_NAME;
+
+ // Metiers
+ protected static final String SQL_CREATE_REF_METIERS =
+ "CREATE TABLE " + Metier.TABLE_NAME + " (" +
+ Metier._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Metier.COLUMN_ID + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Metier.COLUMN_LABEL + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_GEAR_CODE + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_GEAR_LABEL + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_SPECIES_CODE + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_SPECIES_LABEL + TEXT_TYPE + COMMA_SEP +
+ Metier.COLUMN_FISHING + BYTE_TYPE + COMMA_SEP +
+ Metier.COLUMN_ACTIVE + BYTE_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_METIERS =
+ "DROP TABLE IF EXISTS " + Metier.TABLE_NAME;
+
+ // Presentations
+ protected static final String SQL_CREATE_REF_PRESENTATIONS =
+ "CREATE TABLE " + Presentation.TABLE_NAME + " (" +
+ Presentation._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Presentation.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Presentation.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_PRESENTATIONS =
+ "DROP TABLE IF EXISTS " + Presentation.TABLE_NAME;
+
+ // Scientific species
+ protected static final String SQL_CREATE_REF_SCIENTIFIC_SPECIES =
+ "CREATE TABLE " + ScientificSpecies.TABLE_NAME + " (" +
+ ScientificSpecies._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ ScientificSpecies.COLUMN_PERM_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ ScientificSpecies.COLUMN_CODE + TEXT_TYPE + COMMA_SEP +
+ ScientificSpecies.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_SCIENTIFIC_SPECIES =
+ "DROP TABLE IF EXISTS " + ScientificSpecies.TABLE_NAME;
+
+ // States
+ protected static final String SQL_CREATE_REF_STATES =
+ "CREATE TABLE " + State.TABLE_NAME + " (" +
+ State._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ State.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ State.COLUMN_LABEL + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_STATES =
+ "DROP TABLE IF EXISTS " + State.TABLE_NAME;
+
+ // Vessels
+ protected static final String SQL_CREATE_REF_VESSELS =
+ "CREATE TABLE " + Vessel.TABLE_NAME + " (" +
+ Vessel._ID + TEXT_TYPE + " PRIMARY KEY" + COMMA_SEP +
+ Vessel.COLUMN_CODE + TEXT_TYPE + NOT_NULL + COMMA_SEP +
+ Vessel.COLUMN_NAME + TEXT_TYPE + COMMA_SEP +
+ Vessel.COLUMN_QUARTER_CODE + TEXT_TYPE +
+ " )";
+
+ protected static final String SQL_DELETE_REF_VESSELS =
+ "DROP TABLE IF EXISTS " + Vessel.TABLE_NAME;
+
+
+ public WloSqlOpenHelper(android.content.Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ // referentials
+ db.execSQL(SQL_CREATE_REF_AGES);
+ db.execSQL(SQL_CREATE_REF_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_CREATE_REF_GENDERS);
+ db.execSQL(SQL_CREATE_REF_LOCATIONS);
+ db.execSQL(SQL_CREATE_REF_MATURITIES);
+ db.execSQL(SQL_CREATE_REF_MENSURATIONS);
+ db.execSQL(SQL_CREATE_REF_METIERS);
+ db.execSQL(SQL_CREATE_REF_PRESENTATIONS);
+ db.execSQL(SQL_CREATE_REF_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_CREATE_REF_STATES);
+ db.execSQL(SQL_CREATE_REF_VESSELS);
+
+ // models
+ db.execSQL(SQL_CREATE_CONTEXTS);
+ db.execSQL(SQL_CREATE_LOCATIONS);
+ db.execSQL(SQL_CREATE_VESSELS);
+ db.execSQL(SQL_CREATE_METIERS);
+ db.execSQL(SQL_CREATE_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_CREATE_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_CREATE_MEASUREMENTS);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ //TODO kmorin 20131129 migrate data before droping the table
+ // models
+ db.execSQL(SQL_DELETE_MEASUREMENTS);
+ db.execSQL(SQL_DELETE_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_DELETE_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_DELETE_METIERS);
+ db.execSQL(SQL_DELETE_VESSELS);
+ db.execSQL(SQL_DELETE_LOCATIONS);
+ db.execSQL(SQL_DELETE_CONTEXTS);
+
+ // referentials
+ db.execSQL(SQL_DELETE_REF_AGES);
+ db.execSQL(SQL_DELETE_REF_COMMERCIAL_SPECIES);
+ db.execSQL(SQL_DELETE_REF_GENDERS);
+ db.execSQL(SQL_DELETE_REF_LOCATIONS);
+ db.execSQL(SQL_DELETE_REF_MATURITIES);
+ db.execSQL(SQL_DELETE_REF_MENSURATIONS);
+ db.execSQL(SQL_DELETE_REF_METIERS);
+ db.execSQL(SQL_DELETE_REF_PRESENTATIONS);
+ db.execSQL(SQL_DELETE_REF_SCIENTIFIC_SPECIES);
+ db.execSQL(SQL_DELETE_REF_STATES);
+ db.execSQL(SQL_DELETE_REF_VESSELS);
+ onCreate(db);
+ }
+
+ @Override
+ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ onUpgrade(db, oldVersion, newVersion);
+ }
+
+ @Override
+ public synchronized void close() {
+ super.close();
+ getReadableDatabase().close();
+ getWritableDatabase().close();
+ }
+
+ // CONTEXTS
+
+ public Cursor getAllContexts() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(ContextModel.TABLE_NAME, ContextModel.ALL_COLUMNS, null, null, null, null, null);
+ return cursor;
+ }
+
+ //LOCATION
+
+ public Cursor getAllLocations(String contextId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(LocationModel.TABLE_NAME, LocationModel.ALL_COLUMNS,
+ LocationModel.COLUMN_CONTEXT_ID + " = ?", new String[]{ contextId },
+ null, null, null);
+ return cursor;
+ }
+
+ //VESSEL
+
+ public Cursor getAllVessels(String locationId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(VesselModel.TABLE_NAME, VesselModel.ALL_COLUMNS,
+ VesselModel.COLUMN_LOCATION_ID + " = ?", new String[]{ locationId },
+ null, null, null);
+ return cursor;
+ }
+
+ //METIERS
+
+ public Cursor getAllMetiers(String vesselId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(MetierModel.TABLE_NAME, MetierModel.ALL_COLUMNS,
+ MetierModel.COLUMN_VESSEL_ID + " = ?", new String[]{ vesselId },
+ null, null, null);
+ return cursor;
+ }
+
+ //COMMERCIAL SPECIES
+
+ public Cursor getAllCommercialSpecies(String metierId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, CommercialSpeciesModel.ALL_COLUMNS,
+ CommercialSpeciesModel.COLUMN_METIER_ID + " = ?", new String[]{ metierId },
+ null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllSortCategories() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(CommercialSpeciesModel.TABLE_NAME, new String[]{ CommercialSpeciesModel.COLUMN_SORT_CATEGORY },
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ //SCIENTIFIC SPECIES
+
+ public Cursor getAllScientificSpecies(String commercialSpeciesId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(ScientificSpeciesModel.TABLE_NAME, ScientificSpeciesModel.ALL_COLUMNS,
+ ScientificSpeciesModel.COLUMN_COMMERCIAL_SPECIES_ID + " = ?", new String[]{ commercialSpeciesId },
+ null, null, null);
+ return cursor;
+ }
+
+ //MEASUREMENTS
+
+ public Cursor getAllMeasurements(String scientificSpeciesId) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(MeasurementModel.TABLE_NAME, MeasurementModel.ALL_COLUMNS,
+ MeasurementModel.COLUMN_SCIENTIFIC_SPECIES_ID + " = ?", new String[]{ scientificSpeciesId },
+ null, null, MeasurementModel.COLUMN_DATE + " ASC");
+ return cursor;
+ }
+
+ public void deleteMeasurement(MeasurementModel measurement) {
+ if (!measurement.isNew()) {
+ SQLiteDatabase db = getWritableDatabase();
+ db.delete(MeasurementModel.TABLE_NAME, MeasurementModel._ID + " = ?", new String[]{ measurement.getId() });
+ }
+ }
+
+ // Referentials
+
+ public Cursor getAllRefAges() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Age.TABLE_NAME, Age.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefCommercialSpecies() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(CommercialSpecies.TABLE_NAME, CommercialSpecies.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefGenders() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Gender.TABLE_NAME, Gender.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefLocations() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Location.TABLE_NAME, Location.ALL_COLUMNS,
+ null, null, null, null, Location.COLUMN_CODE);
+ return cursor;
+ }
+
+ public Cursor getAllRefMaturities() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Maturity.TABLE_NAME, Maturity.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefMensurations() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Mensuration.TABLE_NAME, Mensuration.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefMetiers() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Metier.TABLE_NAME, Metier.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefPresentations() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Presentation.TABLE_NAME, Presentation.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefScientificSpecies() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(ScientificSpecies.TABLE_NAME, ScientificSpecies.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefStates() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(State.TABLE_NAME, State.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ public Cursor getAllRefVessels() {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor cursor = db.query(Vessel.TABLE_NAME, Vessel.ALL_COLUMNS,
+ null, null, null, null, null);
+ return cursor;
+ }
+
+ //TODO remove when tests are over
+ public void clearReferentials() {
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+ db.delete(Age.TABLE_NAME, null, null);
+ db.delete(CommercialSpecies.TABLE_NAME, null, null);
+ db.delete(Gender.TABLE_NAME, null, null);
+ db.delete(Location.TABLE_NAME, null, null);
+ db.delete(Maturity.TABLE_NAME, null, null);
+ db.delete(Mensuration.TABLE_NAME, null, null);
+ db.delete(Metier.TABLE_NAME, null, null);
+ db.delete(Presentation.TABLE_NAME, null, null);
+ db.delete(ScientificSpecies.TABLE_NAME, null, null);
+ db.delete(State.TABLE_NAME, null, null);
+ db.delete(Vessel.TABLE_NAME, null, null);
+ db.setTransactionSuccessful();
+ db.endTransaction();
+ }
+
+ public <M extends BaseModel> void saveData(M model) {
+ saveData(Lists.newArrayList(model));
+ }
+
+ public <M extends BaseModel> void saveData(Collection<M> models) {
+ Preconditions.checkNotNull(models);
+
+ SQLiteDatabase db = getWritableDatabase();
+ db.beginTransaction();
+
+ for (BaseModel model : models) {
+ String tableName = model.getTableName();
+// Log.d(TAG, "saving data in " + tableName);
+
+ boolean newSession = model.isNew();
+ if (newSession) {
+ String id = UUID.randomUUID().toString();
+ model.setId(id);
+ }
+ ContentValues values = model.convertIntoContentValues();
+
+ if (newSession) {
+ db.insert(tableName, null, values);
+
+ } else {
+ db.update(tableName, values, BaseModel._ID + " = ?", new String[]{ model.getId() });
+ }
+ }
+
+ db.setTransactionSuccessful();
+ db.endTransaction();
+ }
+
+ public static <E> List<E> transformCursorIntoCollection(Cursor cursor,
+ Function<Cursor, E> function) {
+
+ List<E> result = Lists.newArrayList();
+ boolean cont = cursor.moveToFirst();
+ while (cont) {
+ E e = function.apply(cursor);
+ result.add(e);
+ cont = cursor.moveToNext();
+ }
+ return result;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,55 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.widget.TextView;
-import com.google.common.base.Preconditions;
-import fr.ifremer.wlo.models.BaseModel;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public abstract class AbstractDateTimePickerFragment extends DialogFragment {
-
- private static final String TAG = "AbstractDateTimePickerFragment";
-
- protected Calendar date;
- protected TextView view;
- protected BaseModel model;
- protected String attribute;
-
- public AbstractDateTimePickerFragment(BaseModel model, String attribute, TextView view) {
- Preconditions.checkNotNull(model);
- Preconditions.checkNotNull(attribute);
- this.view = view;
- this.model = model;
- this.attribute = attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
-
- Class clazz = model.getClass();
- try {
- date = (Calendar) clazz.getMethod("get" + this.attribute).invoke(model);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on get" + this.attribute + " for class " + clazz, e);
- }
-
- if (date == null) {
- date = Calendar.getInstance();
- }
- }
-
- protected void setDateInModel() {
- Class clazz = model.getClass();
- try {
- clazz.getMethod("set" + attribute, Calendar.class).invoke(model, date);
-
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- Log.e(TAG, "Error on set" + attribute + " for class " + clazz, e);
- }
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/AbstractDateTimePickerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,79 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.widget.TextView;
+import com.google.common.base.Preconditions;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class AbstractDateTimePickerFragment extends DialogFragment {
+
+ private static final String TAG = "AbstractDateTimePickerFragment";
+
+ protected Calendar date;
+ protected TextView view;
+ protected BaseModel model;
+ protected String attribute;
+
+ public AbstractDateTimePickerFragment(BaseModel model, String attribute, TextView view) {
+ Preconditions.checkNotNull(model);
+ Preconditions.checkNotNull(attribute);
+ this.view = view;
+ this.model = model;
+ this.attribute = attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
+
+ Class clazz = model.getClass();
+ try {
+ date = (Calendar) clazz.getMethod("get" + this.attribute).invoke(model);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on get" + this.attribute + " for class " + clazz, e);
+ }
+
+ if (date == null) {
+ date = Calendar.getInstance();
+ }
+ }
+
+ protected void setDateInModel() {
+ Class clazz = model.getClass();
+ try {
+ clazz.getMethod("set" + attribute, Calendar.class).invoke(model, date);
+
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ Log.e(TAG, "Error on set" + attribute + " for class " + clazz, e);
+ }
+ }
+
+}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/BaseModelArrayAdapter.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,188 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+import com.google.common.base.Function;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.util.List;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class BaseModelArrayAdapter<M extends BaseModel> extends ArrayAdapter<M> {
+
+ /**
+ * The resource indicating what views to inflate to display the content of this
+ * array adapter.
+ */
+ protected int mResource;
+
+ /**
+ * If the inflated resource is not a TextView, {@link #mFieldId} is used to find
+ * a TextView inside the inflated views hierarchy. This field must contain the
+ * identifier that matches the one defined in the resource file.
+ */
+ protected int mFieldId = 0;
+
+ protected LayoutInflater mInflater;
+
+ /**
+ * Function to transform object into String
+ */
+ protected Function<M, String> toStringFunction;
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, Function<M, String> toStringFunction) {
+ super(context, textViewResourceId);
+ init(textViewResourceId, 0, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId) {
+ super(context, textViewResourceId);
+ init(textViewResourceId, 0, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, Function<M, String> toStringFunction) {
+ super(context, resource, textViewResourceId);
+ init(resource, textViewResourceId, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId) {
+ super(context, resource, textViewResourceId);
+ init(resource, textViewResourceId, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, M[] objects, Function<M, String> toStringFunction) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, M[] objects) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, M[] objects, Function<M, String> toStringFunction) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, M[] objects) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, List<M> objects, Function<M, String> toStringFunction) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int textViewResourceId, List<M> objects) {
+ super(context, textViewResourceId, objects);
+ init(textViewResourceId, 0, null);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, List<M> objects, Function<M, String> toStringFunction) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, toStringFunction);
+ }
+
+ public BaseModelArrayAdapter(Context context, int resource, int textViewResourceId, List<M> objects) {
+ super(context, resource, textViewResourceId, objects);
+ init(resource, textViewResourceId, null);
+ }
+
+ protected void init(int resource, int textViewResourceId, Function<M, String> toStringFunction) {
+ mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mResource = resource;
+ mFieldId = textViewResourceId;
+ this.toStringFunction = toStringFunction;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ return createViewFromResource(position, convertView, parent, mResource);
+ }
+
+ private View createViewFromResource(int position, View convertView, ViewGroup parent,
+ int resource) {
+ View view;
+ TextView text;
+
+ if (convertView == null) {
+ view = mInflater.inflate(resource, parent, false);
+ } else {
+ view = convertView;
+ }
+
+ try {
+ if (mFieldId == 0) {
+ // If no custom field is assigned, assume the whole resource is a TextView
+ text = (TextView) view;
+ } else {
+ // Otherwise, find the TextView field within the layout
+ text = (TextView) view.findViewById(mFieldId);
+ }
+ } catch (ClassCastException e) {
+ Log.e("BaseModelArrayAdapter", "You must supply a resource ID for a TextView");
+ throw new IllegalStateException(
+ "BaseModelArrayAdapter requires the resource ID to be a TextView", e);
+ }
+
+ M item = getItem(position);
+ String s;
+ if (toStringFunction != null) {
+ s = toStringFunction.apply(item);
+ } else {
+ s = item.toString(getContext());
+ }
+ text.setText(s);
+
+ return view;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/BaseTextWatcher.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,23 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.text.Editable;
-import android.text.TextWatcher;
-
-/**
- * TextWatcher which does nothing. It is only to avoid redefining unuseful methods all the time
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class BaseTextWatcher implements TextWatcher {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/BaseTextWatcher.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/BaseTextWatcher.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,47 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.text.Editable;
+import android.text.TextWatcher;
+
+/**
+ * TextWatcher which does nothing. It is only to avoid redefining unuseful methods all the time
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class BaseTextWatcher implements TextWatcher {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/DatePickerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,45 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.app.DatePickerDialog;
-import android.app.Dialog;
-import android.os.Bundle;
-import android.widget.DatePicker;
-import android.widget.TextView;
-import fr.ifremer.wlo.models.BaseModel;
-
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class DatePickerFragment extends AbstractDateTimePickerFragment
- implements DatePickerDialog.OnDateSetListener {
-
- private static final String TAG = "DatePickerFragment";
-
- public DatePickerFragment(BaseModel model, String attribute, TextView view) {
- super(model, attribute, view);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- int year = date.get(Calendar.YEAR);
- int month = date.get(Calendar.MONTH);
- int day = date.get(Calendar.DAY_OF_MONTH);
-
- // Create a new instance of DatePickerDialog and return it
- return new DatePickerDialog(getActivity(), this, year, month, day);
- }
-
- public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- date.set(Calendar.YEAR, year);
- date.set(Calendar.MONTH, monthOfYear);
- date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- setDateInModel();
-
- String formattedDate = UIUtils.getDateOrUndefined(date, getActivity());
- this.view.setText(formattedDate);
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/DatePickerFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/DatePickerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,69 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.widget.DatePicker;
+import android.widget.TextView;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class DatePickerFragment extends AbstractDateTimePickerFragment
+ implements DatePickerDialog.OnDateSetListener {
+
+ private static final String TAG = "DatePickerFragment";
+
+ public DatePickerFragment(BaseModel model, String attribute, TextView view) {
+ super(model, attribute, view);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ int year = date.get(Calendar.YEAR);
+ int month = date.get(Calendar.MONTH);
+ int day = date.get(Calendar.DAY_OF_MONTH);
+
+ // Create a new instance of DatePickerDialog and return it
+ return new DatePickerDialog(getActivity(), this, year, month, day);
+ }
+
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ date.set(Calendar.YEAR, year);
+ date.set(Calendar.MONTH, monthOfYear);
+ date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ setDateInModel();
+
+ String formattedDate = UIUtils.getDateOrUndefined(date, getActivity());
+ this.view.setText(formattedDate);
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/TimePickerFragment.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,44 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.app.Dialog;
-import android.app.TimePickerDialog;
-import android.os.Bundle;
-import android.text.format.DateFormat;
-import android.widget.TextView;
-import android.widget.TimePicker;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.BaseModel;
-
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class TimePickerFragment extends AbstractDateTimePickerFragment
- implements TimePickerDialog.OnTimeSetListener {
-
- private static final String TAG = "TimePickerFragment";
-
- public TimePickerFragment(BaseModel model, String attribute, TextView view) {
- super(model, attribute, view);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- int hour = date.get(Calendar.HOUR_OF_DAY);
- int minute = date.get(Calendar.MINUTE);
-
- // Create a new instance of TimePickerDialog and return it
- return new TimePickerDialog(getActivity(), this, hour, minute,
- DateFormat.is24HourFormat(getActivity()));
- }
-
- public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
- date.set(Calendar.HOUR_OF_DAY, hourOfDay);
- date.set(Calendar.MINUTE, minute);
- setDateInModel();
- this.view.setText(getString(R.string.time_format, date.getTime()));
- }
-
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/TimePickerFragment.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/TimePickerFragment.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,68 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.Dialog;
+import android.app.TimePickerDialog;
+import android.os.Bundle;
+import android.text.format.DateFormat;
+import android.widget.TextView;
+import android.widget.TimePicker;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.BaseModel;
+
+import java.util.Calendar;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class TimePickerFragment extends AbstractDateTimePickerFragment
+ implements TimePickerDialog.OnTimeSetListener {
+
+ private static final String TAG = "TimePickerFragment";
+
+ public TimePickerFragment(BaseModel model, String attribute, TextView view) {
+ super(model, attribute, view);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ int hour = date.get(Calendar.HOUR_OF_DAY);
+ int minute = date.get(Calendar.MINUTE);
+
+ // Create a new instance of TimePickerDialog and return it
+ return new TimePickerDialog(getActivity(), this, hour, minute,
+ DateFormat.is24HourFormat(getActivity()));
+ }
+
+ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+ date.set(Calendar.HOUR_OF_DAY, hourOfDay);
+ date.set(Calendar.MINUTE, minute);
+ setDateInModel();
+ this.view.setText(getString(R.string.time_format, date.getTime()));
+ }
+
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/UIUtils.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,100 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.database.Cursor;
-import android.preference.PreferenceManager;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.preferences.ListItemPreference;
-
-import java.util.Calendar;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class UIUtils {
-
- private static final String TAG = "UIUtils";
-
- /**
- * @return A dialog click listener which cancel the dialog
- */
- public static DialogInterface.OnClickListener getCancelClickListener() {
- return new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- };
- }
-
- /**
- * Method to get a default string if the one given is null
- * @param s the string to check
- * @param defaultId the id of the string to return if s is null
- * @param context the location
- * @return s or the string with id defaultId
- */
- public static String getStringOrDefault(String s, int defaultId, Context context) {
- if (s != null) {
- return s;
- }
- return context.getString(defaultId);
- }
-
- /**
- * Method to get "undefined" if the one given is null
- * @param model the model to check
- * @param context the location
- * @return s or "undefined"
- */
- public static String getStringOrUndefined(BaseModel model, Context context) {
- String s = model != null ? model.toString(context) : null;
- return getStringOrDefault(s, R.string.undefined, context);
- }
-
- /**
- * Method to get "undefined" if the one given is null
- * @param s the string to check
- * @param context the location
- * @return s or "undefined"
- */
- public static String getStringOrUndefined(String s, Context context) {
- return getStringOrDefault(s, R.string.undefined, context);
- }
-
- /**
- * Method to get "undefined" if the one given is null
- * @param cal the calender to check
- * @param context the location
- * @return the formatted date or "undefined"
- */
- public static String getDateOrUndefined(Calendar cal, Context context) {
- if (cal == null) {
- return context.getString(R.string.undefined);
- }
- String dateFormat = getDateFormat(context);
- return String.format(dateFormat, cal);
- }
-
- public static String getDateFormat(Context context) {
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
- String dateFormat = sharedPref.getString(ListItemPreference.DATE_FORMAT.getKey(), "");
- return dateFormat;
- }
-
-
- public static Calendar getCalendarFromCursor(Cursor cursor, int columnIndex) {
- Calendar cal;
- if (cursor.getType(columnIndex) == Cursor.FIELD_TYPE_NULL) {
- cal = null;
- } else {
- long time = cursor.getLong(columnIndex);
- cal = Calendar.getInstance();
- cal.setTimeInMillis(time);
- }
- return cal;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/UIUtils.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/UIUtils.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,144 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.preference.PreferenceManager;
+import com.google.common.base.Preconditions;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.referentials.Mensuration;
+import fr.ifremer.wlo.preferences.ListItemPreference;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class UIUtils {
+
+ private static final String TAG = "UIUtils";
+
+ /**
+ * @return A dialog click listener which cancel the dialog
+ */
+ public static DialogInterface.OnClickListener getCancelClickListener() {
+ return new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ };
+ }
+
+ /**
+ * Method to get a default string if the one given is null
+ * @param s the string to check
+ * @param defaultId the id of the string to return if s is null
+ * @param context the location
+ * @return s or the string with id defaultId
+ */
+ public static String getStringOrDefault(String s, int defaultId, Context context) {
+ if (s != null) {
+ return s;
+ }
+ return context.getString(defaultId);
+ }
+
+ /**
+ * Method to get "undefined" if the one given is null
+ * @param model the model to check
+ * @param context the location
+ * @return s or "undefined"
+ */
+ public static String getStringOrUndefined(BaseModel model, Context context) {
+ String s = model != null ? model.toString(context) : null;
+ return getStringOrDefault(s, R.string.undefined, context);
+ }
+
+ /**
+ * Method to get "undefined" if the one given is null
+ * @param s the string to check
+ * @param context the location
+ * @return s or "undefined"
+ */
+ public static String getStringOrUndefined(String s, Context context) {
+ return getStringOrDefault(s, R.string.undefined, context);
+ }
+
+ /**
+ * Method to get "undefined" if the one given is null
+ * @param cal the calender to check
+ * @param context the location
+ * @return the formatted date or "undefined"
+ */
+ public static String getDateOrUndefined(Calendar cal, Context context) {
+ if (cal == null) {
+ return context.getString(R.string.undefined);
+ }
+ String dateFormat = getDateFormat(context);
+ return String.format(dateFormat, cal);
+ }
+
+ public static String getDateFormat(Context context) {
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
+ String dateFormat = sharedPref.getString(ListItemPreference.DATE_FORMAT.getKey(), "");
+ return dateFormat;
+ }
+
+ public static Calendar getCalendarFromCursor(Cursor cursor, int columnIndex) {
+ Calendar cal;
+ if (cursor.getType(columnIndex) == Cursor.FIELD_TYPE_NULL) {
+ cal = null;
+ } else {
+ long time = cursor.getLong(columnIndex);
+ cal = Calendar.getInstance();
+ cal.setTimeInMillis(time);
+ }
+ return cal;
+ }
+
+ public static String getSizeFormat(Mensuration.Precision precision) {
+ String sizeFormat;
+ if (precision == Mensuration.Precision.MM5) {
+ sizeFormat = "%.1f";
+ } else {
+ sizeFormat = "%.0f";
+ }
+ return sizeFormat;
+ }
+
+ public static String getFormattedSize(int size, Mensuration.Precision precision) {
+ Preconditions.checkNotNull(precision);
+ String format = getSizeFormat(precision);
+ int divider = precision.getUnitDivider();
+ double dSize = (double) size / divider;
+ return String.format(Locale.US, format, dSize);
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,67 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.AutoCompleteTextView;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class WloAutoCompleteTextView extends AutoCompleteTextView {
-
- private int myThreshold;
-
- public WloAutoCompleteTextView(Context context) {
- super(context);
- init();
- }
-
- public WloAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init();
- }
-
- public WloAutoCompleteTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init();
- }
-
- protected void init() {
- setOnFocusChangeListener(new OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (hasFocus) {
- showDropDown();
- } else {
- dismissDropDown();
- }
- }
- });
- setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- showDropDown();
- }
- });
- }
-
- @Override
- public void setThreshold(int threshold) {
- if (threshold < 0) {
- threshold = 0;
- }
- myThreshold = threshold;
- }
-
- @Override
- public boolean enoughToFilter() {
- return getText().length() >= myThreshold;
- }
-
- @Override
- public int getThreshold() {
- return myThreshold;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/WloAutoCompleteTextView.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,91 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.AutoCompleteTextView;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class WloAutoCompleteTextView extends AutoCompleteTextView {
+
+ private int myThreshold;
+
+ public WloAutoCompleteTextView(Context context) {
+ super(context);
+ init();
+ }
+
+ public WloAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ public WloAutoCompleteTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ protected void init() {
+ setOnFocusChangeListener(new OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus) {
+ showDropDown();
+ } else {
+ dismissDropDown();
+ }
+ }
+ });
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showDropDown();
+ }
+ });
+ }
+
+ @Override
+ public void setThreshold(int threshold) {
+ if (threshold < 0) {
+ threshold = 0;
+ }
+ myThreshold = threshold;
+ }
+
+ @Override
+ public boolean enoughToFilter() {
+ return getText().length() >= myThreshold;
+ }
+
+ @Override
+ public int getThreshold() {
+ return myThreshold;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,113 +0,0 @@
-package fr.ifremer.wlo.utils;
-
-import android.content.Context;
-import android.database.Cursor;
-import android.support.v4.widget.SimpleCursorAdapter;
-import android.util.Log;
-import android.view.View;
-import android.widget.TextView;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.wlo.R;
-import fr.ifremer.wlo.models.BaseModel;
-import fr.ifremer.wlo.models.referentials.Location;
-import fr.ifremer.wlo.models.referentials.Metier;
-import fr.ifremer.wlo.storage.DataCache;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.1
- */
-public class WloItemListViewBinder implements SimpleCursorAdapter.ViewBinder {
-
- private static final String TAG = "WloItemListViewBinder";
-
- public enum DataType {
- DATE, DATETIME, LOCATION, METIER,
- MENSURATION, STATE, PRESENTATION,
- COMMERCIAL_SPECIES, SCIENTIFIC_SPECIES
- }
-
- protected Map<Integer, DataType> dataTypes = Maps.newHashMap();
- protected String dateFormat;
- protected String dateTimeFormat;
- protected Context context;
-
- public WloItemListViewBinder(Context context) {
- this(context, null);
- }
-
- public WloItemListViewBinder(Context context, Map<Integer, DataType> dataTypes) {
- this.context = context;
- dateFormat = UIUtils.getDateFormat(context);
- dateTimeFormat = dateFormat + " " + context.getString(R.string.time_format);
- if (dataTypes != null) {
- this.dataTypes = dataTypes;
- }
- }
-
- @Override
- public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
- DataType dataType = dataTypes.get(columnIndex);
- Log.d(TAG, "dataType for " + columnIndex + " : " + dataType);
-
- if (DataType.DATE.equals(dataType) || DataType.DATETIME.equals(dataType)) {
- if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
- long time = cursor.getLong(columnIndex);
- Date date = new Date(time);
- String format = DataType.DATE.equals(dataType) ? dateFormat : dateTimeFormat;
- String formattedDate = String.format(format, date);
- TextView textView = (TextView) view;
- textView.setText(formattedDate);
- return true;
- }
- }
-
- if (dataType != null) {
- if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
- Context context = view.getContext();
- String id = cursor.getString(columnIndex);
- BaseModel ref = null;
- switch (dataType) {
- case LOCATION:
- ref = DataCache.getLocationById(context, id);
- break;
- case METIER:
- ref = DataCache.getMetierById(context, id);
- break;
- case COMMERCIAL_SPECIES:
- ref = DataCache.getCommercialSpeciesById(context, id);
- break;
- case MENSURATION:
- ref = DataCache.getMensurationById(context, id);
- break;
- case STATE:
- ref = DataCache.getStateById(context, id);
- break;
- case PRESENTATION:
- ref = DataCache.getPresentationById(context, id);
- break;
- case SCIENTIFIC_SPECIES:
- ref = DataCache.getScientificSpeciesById(context, id);
- break;
- }
- TextView textView = (TextView) view;
- textView.setText(UIUtils.getStringOrUndefined(ref, context));
- return true;
- }
- }
-
- String value = cursor.getString(columnIndex);
- if (value == null) {
- TextView textView = (TextView) view;
- textView.setText(R.string.undefined);
- return true;
- }
-
- return false;
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/WloItemListViewBinder.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,137 @@
+package fr.ifremer.wlo.utils;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.content.Context;
+import android.database.Cursor;
+import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.wlo.R;
+import fr.ifremer.wlo.models.BaseModel;
+import fr.ifremer.wlo.models.referentials.Location;
+import fr.ifremer.wlo.models.referentials.Metier;
+import fr.ifremer.wlo.storage.DataCache;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.1
+ */
+public class WloItemListViewBinder implements SimpleCursorAdapter.ViewBinder {
+
+ private static final String TAG = "WloItemListViewBinder";
+
+ public enum DataType {
+ DATE, DATETIME, LOCATION, METIER,
+ MENSURATION, STATE, PRESENTATION,
+ COMMERCIAL_SPECIES, SCIENTIFIC_SPECIES
+ }
+
+ protected Map<Integer, DataType> dataTypes = Maps.newHashMap();
+ protected String dateFormat;
+ protected String dateTimeFormat;
+ protected Context context;
+
+ public WloItemListViewBinder(Context context) {
+ this(context, null);
+ }
+
+ public WloItemListViewBinder(Context context, Map<Integer, DataType> dataTypes) {
+ this.context = context;
+ dateFormat = UIUtils.getDateFormat(context);
+ dateTimeFormat = dateFormat + " " + context.getString(R.string.time_format);
+ if (dataTypes != null) {
+ this.dataTypes = dataTypes;
+ }
+ }
+
+ @Override
+ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
+ DataType dataType = dataTypes.get(columnIndex);
+ Log.d(TAG, "dataType for " + columnIndex + " : " + dataType);
+
+ if (DataType.DATE.equals(dataType) || DataType.DATETIME.equals(dataType)) {
+ if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
+ long time = cursor.getLong(columnIndex);
+ Date date = new Date(time);
+ String format = DataType.DATE.equals(dataType) ? dateFormat : dateTimeFormat;
+ String formattedDate = String.format(format, date);
+ TextView textView = (TextView) view;
+ textView.setText(formattedDate);
+ return true;
+ }
+ }
+
+ if (dataType != null) {
+ if (cursor.getType(columnIndex) != Cursor.FIELD_TYPE_NULL) {
+ Context context = view.getContext();
+ String id = cursor.getString(columnIndex);
+ BaseModel ref = null;
+ switch (dataType) {
+ case LOCATION:
+ ref = DataCache.getLocationById(context, id);
+ break;
+ case METIER:
+ ref = DataCache.getMetierById(context, id);
+ break;
+ case COMMERCIAL_SPECIES:
+ ref = DataCache.getCommercialSpeciesById(context, id);
+ break;
+ case MENSURATION:
+ ref = DataCache.getMensurationById(context, id);
+ break;
+ case STATE:
+ ref = DataCache.getStateById(context, id);
+ break;
+ case PRESENTATION:
+ ref = DataCache.getPresentationById(context, id);
+ break;
+ case SCIENTIFIC_SPECIES:
+ ref = DataCache.getScientificSpeciesById(context, id);
+ break;
+ }
+ TextView textView = (TextView) view;
+ textView.setText(UIUtils.getStringOrUndefined(ref, context));
+ return true;
+ }
+ }
+
+ String value = cursor.getString(columnIndex);
+ if (value == null) {
+ TextView textView = (TextView) view;
+ textView.setText(R.string.undefined);
+ return true;
+ }
+
+ return false;
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,387 +0,0 @@
-package fr.ifremer.wlo.utils.filechooser;
-
-import android.app.AlertDialog;
-import android.app.ListActivity;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.widget.TextView;
-import fr.ifremer.wlo.R;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- * Activity para escolha de arquivos/diretorios.
- *
- * @author android
- *
- */
-public class FileDialog extends ListActivity {
-
- /**
- * Chave de um item da lista de paths.
- */
- private static final String ITEM_KEY = "key";
-
- /**
- * Imagem de um item da lista de paths (diretorio ou arquivo).
- */
- private static final String ITEM_IMAGE = "image";
-
- /**
- * Diretorio raiz.
- */
- private static final String ROOT = "/";
-
- /**
- * Parametro de entrada da Activity: path inicial. Padrao: ROOT.
- */
- public static final String START_PATH = "START_PATH";
-
- /**
- * Parametro de entrada da Activity: filtro de formatos de arquivos. Padrao:
- * null.
- */
- public static final String FORMAT_FILTER = "FORMAT_FILTER";
-
- /**
- * Parametro de saida da Activity: path escolhido. Padrao: null.
- */
- public static final String RESULT_PATH = "RESULT_PATH";
-
- /**
- * Parametro de entrada da Activity: tipo de selecao: pode criar novos paths
- * ou nao. Padrao: nao permite.
- *
- * @see {@link SelectionMode}
- */
- public static final String SELECTION_MODE = "SELECTION_MODE";
-
- /**
- * Parametro de entrada da Activity: se e permitido escolher diretorios.
- * Padrao: falso.
- */
- public static final String CAN_SELECT_DIR = "CAN_SELECT_DIR";
-
- private List<String> path = null;
- private TextView myPath;
- private EditText mFileName;
- private ArrayList<HashMap<String, Object>> mList;
-
- private Button selectButton;
-
- private LinearLayout layoutSelect;
- private LinearLayout layoutCreate;
- private InputMethodManager inputManager;
- private String parentPath;
- private String currentPath = ROOT;
-
- private int selectionMode = SelectionMode.MODE_CREATE;
-
- private String[] formatFilter = null;
-
- private boolean canSelectDir = false;
-
- private File selectedFile;
- private HashMap<String, Integer> lastPositions = new HashMap<String, Integer>();
-
- /**
- * Called when the activity is first created. Configura todos os parametros
- * de entrada e das VIEWS..
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setResult(RESULT_CANCELED, getIntent());
-
- setContentView(R.layout.file_dialog_main);
- myPath = (TextView) findViewById(R.id.path);
- mFileName = (EditText) findViewById(R.id.fdEditTextFile);
-
- inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
-
- selectButton = (Button) findViewById(R.id.fdButtonSelect);
- selectButton.setEnabled(false);
- selectButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (selectedFile != null) {
- getIntent().putExtra(RESULT_PATH, selectedFile.getPath());
- setResult(RESULT_OK, getIntent());
- finish();
- }
- }
- });
-
- final Button newButton = (Button) findViewById(R.id.fdButtonNew);
- newButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- setCreateVisible(v);
-
- mFileName.setText("");
- mFileName.requestFocus();
- }
- });
-
- selectionMode = getIntent().getIntExtra(SELECTION_MODE, SelectionMode.MODE_CREATE);
-
- formatFilter = getIntent().getStringArrayExtra(FORMAT_FILTER);
-
- canSelectDir = getIntent().getBooleanExtra(CAN_SELECT_DIR, false);
-
- if (selectionMode == SelectionMode.MODE_OPEN) {
- newButton.setVisibility(View.GONE);
- }
-
- layoutSelect = (LinearLayout) findViewById(R.id.fdLinearLayoutSelect);
- layoutCreate = (LinearLayout) findViewById(R.id.fdLinearLayoutCreate);
- layoutCreate.setVisibility(View.GONE);
-
- final Button cancelButton = (Button) findViewById(R.id.fdButtonCancel);
- cancelButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- setSelectVisible(v);
- }
-
- });
- final Button createButton = (Button) findViewById(R.id.fdButtonCreate);
- createButton.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (mFileName.getText().length() > 0) {
- getIntent().putExtra(RESULT_PATH, currentPath + "/" + mFileName.getText());
- setResult(RESULT_OK, getIntent());
- finish();
- }
- }
- });
-
- String startPath = getIntent().getStringExtra(START_PATH);
- startPath = startPath != null ? startPath : ROOT;
- if (canSelectDir) {
- File file = new File(startPath);
- selectedFile = file;
- selectButton.setEnabled(true);
- }
- getDir(startPath);
- }
-
- private void getDir(String dirPath) {
-
- boolean useAutoSelection = dirPath.length() < currentPath.length();
-
- Integer position = lastPositions.get(parentPath);
-
- getDirImpl(dirPath);
-
- if (position != null && useAutoSelection) {
- getListView().setSelection(position);
- }
-
- }
-
- /**
- * Monta a estrutura de arquivos e diretorios filhos do diretorio fornecido.
- *
- * @param dirPath
- * Diretorio pai.
- */
- private void getDirImpl(final String dirPath) {
-
- currentPath = dirPath;
-
- final List<String> item = new ArrayList<String>();
- path = new ArrayList<String>();
- mList = new ArrayList<HashMap<String, Object>>();
-
- File f = new File(currentPath);
- File[] files = f.listFiles();
- if (files == null) {
- currentPath = ROOT;
- f = new File(currentPath);
- files = f.listFiles();
- }
- myPath.setText(getText(R.string.file_chooser_location) + ": " + currentPath);
-
- if (!currentPath.equals(ROOT)) {
-
- item.add(ROOT);
- addItem(ROOT, R.drawable.folder);
- path.add(ROOT);
-
- item.add("../");
- addItem("../", R.drawable.folder);
- path.add(f.getParent());
- parentPath = f.getParent();
-
- }
-
- TreeMap<String, String> dirsMap = new TreeMap<String, String>();
- TreeMap<String, String> dirsPathMap = new TreeMap<String, String>();
- TreeMap<String, String> filesMap = new TreeMap<String, String>();
- TreeMap<String, String> filesPathMap = new TreeMap<String, String>();
- for (File file : files) {
- if (file.isDirectory()) {
- String dirName = file.getName();
- dirsMap.put(dirName, dirName);
- dirsPathMap.put(dirName, file.getPath());
- } else {
- final String fileName = file.getName();
- final String fileNameLwr = fileName.toLowerCase();
- // se ha um filtro de formatos, utiliza-o
- if (formatFilter != null) {
- boolean contains = false;
- for (int i = 0; i < formatFilter.length; i++) {
- final String formatLwr = formatFilter[i].toLowerCase();
- if (fileNameLwr.endsWith(formatLwr)) {
- contains = true;
- break;
- }
- }
- if (contains) {
- filesMap.put(fileName, fileName);
- filesPathMap.put(fileName, file.getPath());
- }
- // senao, adiciona todos os arquivos
- } else {
- filesMap.put(fileName, fileName);
- filesPathMap.put(fileName, file.getPath());
- }
- }
- }
- item.addAll(dirsMap.tailMap("").values());
- item.addAll(filesMap.tailMap("").values());
- path.addAll(dirsPathMap.tailMap("").values());
- path.addAll(filesPathMap.tailMap("").values());
-
- SimpleAdapter fileList = new SimpleAdapter(this, mList, R.layout.file_dialog_row, new String[] {
- ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage });
-
- for (String dir : dirsMap.tailMap("").values()) {
- addItem(dir, R.drawable.folder);
- }
-
- for (String file : filesMap.tailMap("").values()) {
- addItem(file, R.drawable.file);
- }
-
- fileList.notifyDataSetChanged();
-
- setListAdapter(fileList);
-
- }
-
- private void addItem(String fileName, int imageId) {
- HashMap<String, Object> item = new HashMap<String, Object>();
- item.put(ITEM_KEY, fileName);
- item.put(ITEM_IMAGE, imageId);
- mList.add(item);
- }
-
- /**
- * Quando clica no item da lista, deve-se: 1) Se for diretorio, abre seus
- * arquivos filhos; 2) Se puder escolher diretorio, define-o como sendo o
- * path escolhido. 3) Se for arquivo, define-o como path escolhido. 4) Ativa
- * botao de selecao.
- */
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
-
- File file = new File(path.get(position));
-
- setSelectVisible(v);
-
- if (file.isDirectory()) {
- selectButton.setEnabled(false);
- if (file.canRead()) {
- lastPositions.put(currentPath, position);
- getDir(path.get(position));
- if (canSelectDir) {
- selectedFile = file;
- v.setSelected(true);
- selectButton.setEnabled(true);
- }
- } else {
- new AlertDialog.Builder(this).setIcon(R.drawable.icon)
- .setTitle("[" + file.getName() + "] " + getText(R.string.file_chooser_cant_read_folder))
- .setPositiveButton("OK", new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
-
- }
- }).show();
- }
- } else {
- selectedFile = file;
- v.setSelected(true);
- selectButton.setEnabled(true);
- }
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if ((keyCode == KeyEvent.KEYCODE_BACK)) {
- selectButton.setEnabled(false);
-
- if (layoutCreate.getVisibility() == View.VISIBLE) {
- layoutCreate.setVisibility(View.GONE);
- layoutSelect.setVisibility(View.VISIBLE);
- } else {
-// if (!currentPath.equals(ROOT)) {
-// getDir(parentPath);
-// } else {
- return super.onKeyDown(keyCode, event);
-// }
- }
-
- return true;
- } else {
- return super.onKeyDown(keyCode, event);
- }
- }
-
- /**
- * Define se o botao de CREATE e visivel.
- *
- * @param v
- */
- private void setCreateVisible(View v) {
- layoutCreate.setVisibility(View.VISIBLE);
- layoutSelect.setVisibility(View.GONE);
-
- inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
- selectButton.setEnabled(false);
- }
-
- /**
- * Define se o botao de SELECT e visivel.
- *
- * @param v
- */
- private void setSelectVisible(View v) {
- layoutCreate.setVisibility(View.GONE);
- layoutSelect.setVisibility(View.VISIBLE);
-
- inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
- selectButton.setEnabled(false);
- }
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/filechooser/FileDialog.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,411 @@
+package fr.ifremer.wlo.utils.filechooser;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import android.app.AlertDialog;
+import android.app.ListActivity;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+import fr.ifremer.wlo.R;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.TreeMap;
+
+/**
+ * Activity para escolha de arquivos/diretorios.
+ *
+ * @author android
+ *
+ */
+public class FileDialog extends ListActivity {
+
+ /**
+ * Chave de um item da lista de paths.
+ */
+ private static final String ITEM_KEY = "key";
+
+ /**
+ * Imagem de um item da lista de paths (diretorio ou arquivo).
+ */
+ private static final String ITEM_IMAGE = "image";
+
+ /**
+ * Diretorio raiz.
+ */
+ private static final String ROOT = "/";
+
+ /**
+ * Parametro de entrada da Activity: path inicial. Padrao: ROOT.
+ */
+ public static final String START_PATH = "START_PATH";
+
+ /**
+ * Parametro de entrada da Activity: filtro de formatos de arquivos. Padrao:
+ * null.
+ */
+ public static final String FORMAT_FILTER = "FORMAT_FILTER";
+
+ /**
+ * Parametro de saida da Activity: path escolhido. Padrao: null.
+ */
+ public static final String RESULT_PATH = "RESULT_PATH";
+
+ /**
+ * Parametro de entrada da Activity: tipo de selecao: pode criar novos paths
+ * ou nao. Padrao: nao permite.
+ *
+ * @see {@link SelectionMode}
+ */
+ public static final String SELECTION_MODE = "SELECTION_MODE";
+
+ /**
+ * Parametro de entrada da Activity: se e permitido escolher diretorios.
+ * Padrao: falso.
+ */
+ public static final String CAN_SELECT_DIR = "CAN_SELECT_DIR";
+
+ private List<String> path = null;
+ private TextView myPath;
+ private EditText mFileName;
+ private ArrayList<HashMap<String, Object>> mList;
+
+ private Button selectButton;
+
+ private LinearLayout layoutSelect;
+ private LinearLayout layoutCreate;
+ private InputMethodManager inputManager;
+ private String parentPath;
+ private String currentPath = ROOT;
+
+ private int selectionMode = SelectionMode.MODE_CREATE;
+
+ private String[] formatFilter = null;
+
+ private boolean canSelectDir = false;
+
+ private File selectedFile;
+ private HashMap<String, Integer> lastPositions = new HashMap<String, Integer>();
+
+ /**
+ * Called when the activity is first created. Configura todos os parametros
+ * de entrada e das VIEWS..
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setResult(RESULT_CANCELED, getIntent());
+
+ setContentView(R.layout.file_dialog_main);
+ myPath = (TextView) findViewById(R.id.path);
+ mFileName = (EditText) findViewById(R.id.fdEditTextFile);
+
+ inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
+
+ selectButton = (Button) findViewById(R.id.fdButtonSelect);
+ selectButton.setEnabled(false);
+ selectButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (selectedFile != null) {
+ getIntent().putExtra(RESULT_PATH, selectedFile.getPath());
+ setResult(RESULT_OK, getIntent());
+ finish();
+ }
+ }
+ });
+
+ final Button newButton = (Button) findViewById(R.id.fdButtonNew);
+ newButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ setCreateVisible(v);
+
+ mFileName.setText("");
+ mFileName.requestFocus();
+ }
+ });
+
+ selectionMode = getIntent().getIntExtra(SELECTION_MODE, SelectionMode.MODE_CREATE);
+
+ formatFilter = getIntent().getStringArrayExtra(FORMAT_FILTER);
+
+ canSelectDir = getIntent().getBooleanExtra(CAN_SELECT_DIR, false);
+
+ if (selectionMode == SelectionMode.MODE_OPEN) {
+ newButton.setVisibility(View.GONE);
+ }
+
+ layoutSelect = (LinearLayout) findViewById(R.id.fdLinearLayoutSelect);
+ layoutCreate = (LinearLayout) findViewById(R.id.fdLinearLayoutCreate);
+ layoutCreate.setVisibility(View.GONE);
+
+ final Button cancelButton = (Button) findViewById(R.id.fdButtonCancel);
+ cancelButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ setSelectVisible(v);
+ }
+
+ });
+ final Button createButton = (Button) findViewById(R.id.fdButtonCreate);
+ createButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (mFileName.getText().length() > 0) {
+ getIntent().putExtra(RESULT_PATH, currentPath + "/" + mFileName.getText());
+ setResult(RESULT_OK, getIntent());
+ finish();
+ }
+ }
+ });
+
+ String startPath = getIntent().getStringExtra(START_PATH);
+ startPath = startPath != null ? startPath : ROOT;
+ if (canSelectDir) {
+ File file = new File(startPath);
+ selectedFile = file;
+ selectButton.setEnabled(true);
+ }
+ getDir(startPath);
+ }
+
+ private void getDir(String dirPath) {
+
+ boolean useAutoSelection = dirPath.length() < currentPath.length();
+
+ Integer position = lastPositions.get(parentPath);
+
+ getDirImpl(dirPath);
+
+ if (position != null && useAutoSelection) {
+ getListView().setSelection(position);
+ }
+
+ }
+
+ /**
+ * Monta a estrutura de arquivos e diretorios filhos do diretorio fornecido.
+ *
+ * @param dirPath
+ * Diretorio pai.
+ */
+ private void getDirImpl(final String dirPath) {
+
+ currentPath = dirPath;
+
+ final List<String> item = new ArrayList<String>();
+ path = new ArrayList<String>();
+ mList = new ArrayList<HashMap<String, Object>>();
+
+ File f = new File(currentPath);
+ File[] files = f.listFiles();
+ if (files == null) {
+ currentPath = ROOT;
+ f = new File(currentPath);
+ files = f.listFiles();
+ }
+ myPath.setText(getText(R.string.file_chooser_location) + ": " + currentPath);
+
+ if (!currentPath.equals(ROOT)) {
+
+ item.add(ROOT);
+ addItem(ROOT, R.drawable.folder);
+ path.add(ROOT);
+
+ item.add("../");
+ addItem("../", R.drawable.folder);
+ path.add(f.getParent());
+ parentPath = f.getParent();
+
+ }
+
+ TreeMap<String, String> dirsMap = new TreeMap<String, String>();
+ TreeMap<String, String> dirsPathMap = new TreeMap<String, String>();
+ TreeMap<String, String> filesMap = new TreeMap<String, String>();
+ TreeMap<String, String> filesPathMap = new TreeMap<String, String>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ String dirName = file.getName();
+ dirsMap.put(dirName, dirName);
+ dirsPathMap.put(dirName, file.getPath());
+ } else {
+ final String fileName = file.getName();
+ final String fileNameLwr = fileName.toLowerCase();
+ // se ha um filtro de formatos, utiliza-o
+ if (formatFilter != null) {
+ boolean contains = false;
+ for (int i = 0; i < formatFilter.length; i++) {
+ final String formatLwr = formatFilter[i].toLowerCase();
+ if (fileNameLwr.endsWith(formatLwr)) {
+ contains = true;
+ break;
+ }
+ }
+ if (contains) {
+ filesMap.put(fileName, fileName);
+ filesPathMap.put(fileName, file.getPath());
+ }
+ // senao, adiciona todos os arquivos
+ } else {
+ filesMap.put(fileName, fileName);
+ filesPathMap.put(fileName, file.getPath());
+ }
+ }
+ }
+ item.addAll(dirsMap.tailMap("").values());
+ item.addAll(filesMap.tailMap("").values());
+ path.addAll(dirsPathMap.tailMap("").values());
+ path.addAll(filesPathMap.tailMap("").values());
+
+ SimpleAdapter fileList = new SimpleAdapter(this, mList, R.layout.file_dialog_row, new String[] {
+ ITEM_KEY, ITEM_IMAGE }, new int[] { R.id.fdrowtext, R.id.fdrowimage });
+
+ for (String dir : dirsMap.tailMap("").values()) {
+ addItem(dir, R.drawable.folder);
+ }
+
+ for (String file : filesMap.tailMap("").values()) {
+ addItem(file, R.drawable.file);
+ }
+
+ fileList.notifyDataSetChanged();
+
+ setListAdapter(fileList);
+
+ }
+
+ private void addItem(String fileName, int imageId) {
+ HashMap<String, Object> item = new HashMap<String, Object>();
+ item.put(ITEM_KEY, fileName);
+ item.put(ITEM_IMAGE, imageId);
+ mList.add(item);
+ }
+
+ /**
+ * Quando clica no item da lista, deve-se: 1) Se for diretorio, abre seus
+ * arquivos filhos; 2) Se puder escolher diretorio, define-o como sendo o
+ * path escolhido. 3) Se for arquivo, define-o como path escolhido. 4) Ativa
+ * botao de selecao.
+ */
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+
+ File file = new File(path.get(position));
+
+ setSelectVisible(v);
+
+ if (file.isDirectory()) {
+ selectButton.setEnabled(false);
+ if (file.canRead()) {
+ lastPositions.put(currentPath, position);
+ getDir(path.get(position));
+ if (canSelectDir) {
+ selectedFile = file;
+ v.setSelected(true);
+ selectButton.setEnabled(true);
+ }
+ } else {
+ new AlertDialog.Builder(this).setIcon(R.drawable.icon)
+ .setTitle("[" + file.getName() + "] " + getText(R.string.file_chooser_cant_read_folder))
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+
+ }
+ }).show();
+ }
+ } else {
+ selectedFile = file;
+ v.setSelected(true);
+ selectButton.setEnabled(true);
+ }
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if ((keyCode == KeyEvent.KEYCODE_BACK)) {
+ selectButton.setEnabled(false);
+
+ if (layoutCreate.getVisibility() == View.VISIBLE) {
+ layoutCreate.setVisibility(View.GONE);
+ layoutSelect.setVisibility(View.VISIBLE);
+ } else {
+// if (!currentPath.equals(ROOT)) {
+// getDir(parentPath);
+// } else {
+ return super.onKeyDown(keyCode, event);
+// }
+ }
+
+ return true;
+ } else {
+ return super.onKeyDown(keyCode, event);
+ }
+ }
+
+ /**
+ * Define se o botao de CREATE e visivel.
+ *
+ * @param v
+ */
+ private void setCreateVisible(View v) {
+ layoutCreate.setVisibility(View.VISIBLE);
+ layoutSelect.setVisibility(View.GONE);
+
+ inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ selectButton.setEnabled(false);
+ }
+
+ /**
+ * Define se o botao de SELECT e visivel.
+ *
+ * @param v
+ */
+ private void setSelectVisible(View v) {
+ layoutCreate.setVisibility(View.GONE);
+ layoutSelect.setVisibility(View.VISIBLE);
+
+ inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ selectButton.setEnabled(false);
+ }
+}
Deleted: tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java
===================================================================
--- trunk/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java 2014-01-24 11:39:51 UTC (rev 23)
+++ tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -1,7 +0,0 @@
-package fr.ifremer.wlo.utils.filechooser;
-
-public class SelectionMode {
- public static final int MODE_CREATE = 0;
-
- public static final int MODE_OPEN = 1;
-}
Copied: tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java (from rev 25, trunk/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java)
===================================================================
--- tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java (rev 0)
+++ tags/0.1/src/fr/ifremer/wlo/utils/filechooser/SelectionMode.java 2014-01-27 09:00:23 UTC (rev 28)
@@ -0,0 +1,31 @@
+package fr.ifremer.wlo.utils.filechooser;
+
+/*
+ * #%L
+ * WLO
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2013 - 2014 Ifremer
+ * %%
+ * This program 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 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+public class SelectionMode {
+ public static final int MODE_CREATE = 0;
+
+ public static final int MODE_OPEN = 1;
+}
1
0
Author: kmorin
Date: 2014-01-27 09:59:07 +0100 (Mon, 27 Jan 2014)
New Revision: 27
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/27
Log:
tag 0.1 (not done with a maven release due to android plugin conflicts)
Added:
tags/
1
0
Author: kmorin
Date: 2014-01-24 19:10:22 +0100 (Fri, 24 Jan 2014)
New Revision: 26
Url: http://forge.codelutin.com/projects/wlo/repository/revisions/26
Log:
prepare release
Added:
trunk/LICENSE.txt
trunk/src/license/
trunk/src/license/THIRD-PARTY.properties
Removed:
trunk/LICENSE.txt
Modified:
trunk/default.properties
trunk/pom.xml
Deleted: trunk/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt 2014-01-24 15:12:07 UTC (rev 25)
+++ trunk/LICENSE.txt 2014-01-24 18:10:22 UTC (rev 26)
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program 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 3 of the License, or
- (at your option) any later version.
-
- This program 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, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Added: trunk/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt (rev 0)
+++ trunk/LICENSE.txt 2014-01-24 18:10:22 UTC (rev 26)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program 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 3 of the License, or
+ (at your option) any later version.
+
+ This program 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Modified: trunk/default.properties
===================================================================
--- trunk/default.properties 2014-01-24 15:12:07 UTC (rev 25)
+++ trunk/default.properties 2014-01-24 18:10:22 UTC (rev 26)
@@ -10,4 +10,4 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
-target=android-4
+target=android-15
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-01-24 15:12:07 UTC (rev 25)
+++ trunk/pom.xml 2014-01-24 18:10:22 UTC (rev 26)
@@ -123,7 +123,6 @@
</properties>
-
<dependencies>
<dependency>
@@ -140,22 +139,6 @@
<scope>test</scope>
</dependency>
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>support-v4</artifactId>-->
- <!--<version>19.0.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>/opt/android/extras/android/m2repository/com/android/support/support-v4/18.0.0/support-v4-18.0.0.jar</systemPath>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>appcompat-v7</artifactId>-->
- <!--<version>19.0.0</version>-->
- <!--<scope>system</scope>-->
- <!--<systemPath>/opt/android/extras/android/m2repository/com/android/support/appcompat-v7/18.0.0/appcompat-v7-18.0.0.aar</systemPath>-->
- <!--</dependency>-->
-
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
@@ -176,13 +159,6 @@
<version>${sdkVersion}</version>
</dependency>
- <!--<dependency>-->
- <!--<groupId>com.android.support</groupId>-->
- <!--<artifactId>support-v4</artifactId>-->
- <!--<version>18.0.0</version>-->
- <!--<scope>compile</scope>-->
- <!--</dependency>-->
-
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -206,12 +182,6 @@
<groupId>org.nuiton</groupId>
<artifactId>nuiton-csv</artifactId>
<version>3.0-alpha-1</version>
- <exclusions>
- <exclusion>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </exclusion>
- </exclusions>
</dependency>
</dependencies>
@@ -281,10 +251,9 @@
</executions>
<configuration>
<sdk>
- <path>/opt/android</path>
+ <path>${env.ANDROID_HOME}</path>
<platform>15</platform>
</sdk>
- <!--<deleteConflictingFiles>true</deleteConflictingFiles>-->
<!--<device>emulator</device>-->
<device>usb</device>
<zipalign>
Added: trunk/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/src/license/THIRD-PARTY.properties 2014-01-24 18:10:22 UTC (rev 26)
@@ -0,0 +1,29 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Apache 2.0
+# - Apache License
+# - Apache Software License, version 1.1
+# - BSD License
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+# - Common Public License Version 1.0
+# - GNU Library or Lesser General Public License
+# - Indiana University Extreme! Lab Software License, vesion 1.1.1
+# - Lesser General Public License (LGPL) v 3.0
+# - Lesser General Public License (LPGL)
+# - Lesser General Public License (LPGL) v 2.1
+# - MIT License
+# - New BSD License
+# - Public Domain
+# - The Apache Software License, Version 2.0
+# - provided without support or warranty
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Fri Jan 24 18:43:16 CET 2014
+android.support--compatibility-v4--19.0.1=The Apache Software License, Version 2.0
+android.support--compatibility-v7-appcompat--19.0.1=The Apache Software License, Version 2.0
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
+org.achartengine--achartengine--1.1.0=The Apache Software License, Version 2.0
+xerces--xmlParserAPIs--2.6.2=The Apache Software License, Version 2.0
1
0