r33 - in trunk: . src/fr/ifremer/wlo src/fr/ifremer/wlo/models src/fr/ifremer/wlo/storage src/fr/ifremer/wlo/utils
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
participants (1)
-
kmorin@users.forge.codelutin.com