|
From: <de...@us...> - 2014-02-03 14:34:39
|
Revision: 8597
http://sourceforge.net/p/fudaa/svn/8597
Author: deniger
Date: 2014-02-03 14:34:34 +0000 (Mon, 03 Feb 2014)
Log Message:
-----------
CRUE-594
Modified Paths:
--------------
trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionChangeBranche.java
trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionRename.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java
trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties
trunk/soft/fudaa-crue/ui-planimetry/src/main/java/org/fudaa/fudaa/crue/planimetry/layer/PlanimetryBrancheModel.java
Modified: trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionChangeBranche.java
===================================================================
--- trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionChangeBranche.java 2014-02-03 13:33:27 UTC (rev 8596)
+++ trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionChangeBranche.java 2014-02-03 14:34:34 UTC (rev 8597)
@@ -41,11 +41,11 @@
this.defaultValues = defaultValues;
}
- public CtuluLog changeBranche(CatEMHBranche initBranche, BrancheEditionContent newContent, CrueConfigMetier ccm) {
+ public CtuluLog changeBranche(CatEMHBranche initBranche, BrancheEditionContent newContent, CrueConfigMetier ccm, boolean renameSection) {
Map<String, CatEMHNoeud> noeudsByIds = TransformerHelper.toMapOfNom(initBranche.getParent().getNoeuds());
CatEMHNoeud noeudAmont = (CatEMHNoeud) noeudsByIds.get(newContent.getNoeudAmont());
CatEMHNoeud noeudAval = (CatEMHNoeud) noeudsByIds.get(newContent.getNoeudAval());
- CtuluLog log = prevalidate(newContent, initBranche, noeudAmont, noeudAval, ccm);
+ CtuluLog log = prevalidate(newContent, initBranche, noeudAmont, noeudAval, ccm, renameSection);
//on s'arrête:
if (log.containsErrorOrSevereError()) {
return log;
@@ -67,16 +67,17 @@
if (!newType.equals(branche.getBrancheType())) {
branche = changeType(ccm, sousModele, initBranche, newContent, newType);
}
- applyModifications(branche, newContent, sousModele, ccm, noeudAmont, noeudAval);
+ applyModifications(branche, newContent, sousModele, ccm, noeudAmont, noeudAval, renameSection);
return log;
}
- private void applyModifications(CatEMHBranche branche, BrancheEditionContent newContent, final EMHSousModele sousModele, CrueConfigMetier ccm, CatEMHNoeud noeudAmont, CatEMHNoeud noeudAval) {
+ private void applyModifications(CatEMHBranche branche, BrancheEditionContent newContent, final EMHSousModele sousModele, CrueConfigMetier ccm,
+ CatEMHNoeud noeudAmont, CatEMHNoeud noeudAval, boolean renameSection) {
EnumBrancheType newType = branche.getBrancheType();
branche.setCommentaire(newContent.getCommentaire());
- new EditionRename().rename(branche, newContent.getNom());
+ new EditionRename().rename(branche, newContent.getNom(), renameSection);
if (newContent.isActive() != branche.getUserActive()) {
branche.setUserActive(newContent.isActive());
EditionChangeActivity activity = new EditionChangeActivity();
@@ -86,7 +87,6 @@
branche.setNoeudAmont(noeudAmont);
branche.setNoeudAval(noeudAval);
-
if (requireDcsp(newType)) {
DonCalcSansPrt dcsp = EMHHelper.selectFirstInstanceOf(branche.getInfosEMH(), DonCalcSansPrt.class);
applyModification(newContent.getDcsp(), dcsp);
@@ -113,7 +113,8 @@
}
}
- private CatEMHBranche changeType(CrueConfigMetier ccm, final EMHSousModele sousModele, CatEMHBranche initBranche, BrancheEditionContent newContent, EnumBrancheType newType) {
+ private CatEMHBranche changeType(CrueConfigMetier ccm, final EMHSousModele sousModele, CatEMHBranche initBranche, BrancheEditionContent newContent,
+ EnumBrancheType newType) {
//on enleve les relations
List<RelationEMHSectionDansBranche> currentSections = initBranche.getListeSectionsSortedXP(ccm);
for (RelationEMHSectionDansBranche relationEMHSectionDansBranche : currentSections) {
@@ -159,7 +160,8 @@
//les sections...
CatEMHSection amont = currentSections.get(0).getEmh();
CatEMHSection aval = currentSections.get(currentSections.size() - 1).getEmh();
- Collection<EnumSectionType> authorizedType = ValidationContentSectionDansBrancheExecutor.createSectionInterneTypeDansBrancheContents().get(newType);
+ Collection<EnumSectionType> authorizedType = ValidationContentSectionDansBrancheExecutor.createSectionInterneTypeDansBrancheContents().
+ get(newType);
EditionCreateEMH creator = new EditionCreateEMH(defaultValues);
if (!authorizedType.contains(amont.getSectionType())) {
if (authorizedType.contains(EnumSectionType.EMHSectionSansGeometrie)) {
@@ -231,11 +233,12 @@
}
}
- private CtuluLog prevalidate(BrancheEditionContent newContent, CatEMHBranche branche, CatEMHNoeud noeudAmont, CatEMHNoeud noeudAval, CrueConfigMetier ccm) {
+ private CtuluLog prevalidate(BrancheEditionContent newContent, CatEMHBranche branche, CatEMHNoeud noeudAmont, CatEMHNoeud noeudAval,
+ CrueConfigMetier ccm, boolean renameSections) {
CtuluLog log = new CtuluLog(BusinessMessages.RESOURCE_BUNDLE);
EditionRename rename = new EditionRename();
if (!newContent.getNom().equals(branche.getNom())) {
- String nameValid = rename.isNameValid(branche, newContent.getNom());
+ String nameValid = rename.isNameValid(branche, newContent.getNom(), renameSections);
if (nameValid != null) {
log.addSevereError(nameValid);
}
@@ -278,11 +281,11 @@
}
int idx = 0;
for (RelationEMHSectionDansBrancheSaintVenant relationEMHSectionDansBrancheSaintVenant : saintVenantCoeff) {
- ValidationHelper.validateObject(BusinessMessages.getString("ChangeEMHBrancheSaintVenant.ValidationRelation", Integer.toString(++idx)), log, relationEMHSectionDansBrancheSaintVenant, ccm);
+ ValidationHelper.validateObject(BusinessMessages.getString("ChangeEMHBrancheSaintVenant.ValidationRelation", Integer.toString(++idx)), log,
+ relationEMHSectionDansBrancheSaintVenant, ccm);
}
}
-
return log;
}
Modified: trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionRename.java
===================================================================
--- trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionRename.java 2014-02-03 13:33:27 UTC (rev 8596)
+++ trunk/soft/fudaa-crue/crue-project/src/main/java/org/fudaa/dodico/crue/edition/EditionRename.java 2014-02-03 14:34:34 UTC (rev 8597)
@@ -5,7 +5,9 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.fudaa.dodico.crue.common.BusinessMessages;
@@ -33,8 +35,37 @@
}
emh.setNom(newName);
propagateName(emh);
+ return null;
+ }
-
+ public String rename(CatEMHBranche emh, String newName, boolean renameSection) {
+ //si section renommée, on vérifie d'abord qu'on peut le faire:
+ Map<EMH, String> map = new HashMap<EMH, String>();
+ if (renameSection) {
+ String oldSectionPrefix = CruePrefix.changePrefix(emh.getNom(), EnumCatEMH.SECTION);
+ String newSectionPref = CruePrefix.changePrefix(newName, EnumCatEMH.SECTION);
+ final List<RelationEMHSectionDansBranche> sections = emh.getSections();
+ for (RelationEMHSectionDansBranche relationEMHSectionDansBranche : sections) {
+ final CatEMHSection section = relationEMHSectionDansBranche.getEmh();
+ if (section.getNom().startsWith(oldSectionPrefix)) {
+ String newSectionName = newSectionPref + section.getNom().substring(oldSectionPrefix.length());
+ String newSectioNameValid = isNameValid(section, newSectionName);
+ if (newSectioNameValid != null) {
+ return newSectioNameValid;
+ }
+ map.put(section, newSectionName);
+ }
+ }
+ }
+ String error = rename(emh, newName);
+ if (error != null) {
+ return error;
+ }
+ if (renameSection) {
+ for (Map.Entry<EMH, String> entry : map.entrySet()) {
+ rename(entry.getKey(), entry.getValue());
+ }
+ }
return null;
}
@@ -52,15 +83,38 @@
batiCasier.setNom(CruePrefix.changePrefix(newCasierName, CruePrefix.P_CASIER, CruePrefix.P_BATI_CASIER));
}
}
-
-
/**
*
* @param emh
* @param newName
+ * @param renameSection true si les sections doivent être renommées.
* @return une chaine non vide si erreur
*/
+ public String isNameValid(CatEMHBranche emh, String newName, boolean renameSection) {
+ final String nameValid = isNameValid(emh, newName);
+ if (nameValid != null) {
+ return nameValid;
+ }
+ if (renameSection) {
+ String oldSectionPrefix = CruePrefix.changePrefix(emh.getNom(), EnumCatEMH.SECTION);
+ String newSectionPref = CruePrefix.changePrefix(newName, EnumCatEMH.SECTION);
+ final List<RelationEMHSectionDansBranche> sections = emh.getSections();
+ for (RelationEMHSectionDansBranche relationEMHSectionDansBranche : sections) {
+ final CatEMHSection section = relationEMHSectionDansBranche.getEmh();
+ if (section.getNom().startsWith(oldSectionPrefix)) {
+ String newSectionName = newSectionPref + section.getNom().substring(oldSectionPrefix.length());
+ String newSectioNameValid = isNameValid(section, newSectionName);
+ if (newSectioNameValid != null) {
+ return newSectioNameValid;
+ }
+ }
+ }
+ }
+ return null;
+
+ }
+
public String isNameValid(EMH emh, String newName) {
String nameValidei18nMessage = ValidationPatternHelper.isNameValidei18nMessage(newName, emh.getCatType());
if (nameValidei18nMessage != null) {
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java 2014-02-03 13:33:27 UTC (rev 8596)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java 2014-02-03 14:34:34 UTC (rev 8597)
@@ -20,6 +20,7 @@
import org.fudaa.dodico.crue.metier.emh.CatEMHNoeud;
import org.fudaa.dodico.crue.metier.emh.EnumBrancheType;
import org.fudaa.dodico.crue.validation.util.DelegateValidatorBranche;
+import org.fudaa.fudaa.crue.common.helper.DialogHelper;
import org.fudaa.fudaa.crue.common.helper.ObjetNommeCellRenderer;
import org.fudaa.fudaa.crue.common.helper.ToStringInternationalizableCellRenderer;
import org.fudaa.fudaa.crue.common.log.LogsDisplayer;
@@ -212,7 +213,16 @@
EditionChangeBranche edition = new EditionChangeBranche(modellingConfigService.getDefaultValues());
currentCenter.second.fillWithData(modifications);
final CatEMHBranche emh = getEMH();
- CtuluLog log = edition.changeBranche(emh, modifications, getCcm());
+ boolean renameSection = false;
+ if (!modifications.getNom().equals(emh.getNom())) {
+ String optionRename = NbBundle.getMessage(ModellingEMHBrancheTopComponent.class, "BrancheChangeName.RenameSection");
+ String optionNot = NbBundle.getMessage(ModellingEMHBrancheTopComponent.class, "BrancheChangeName.NotRenameSection");
+ String dialogContent = org.openide.util.NbBundle.getMessage(ModellingEMHBrancheTopComponent.class, "BrancheChangeName.Content");
+ renameSection = optionRename.equals(DialogHelper.showQuestion(
+ getDisplayName(), dialogContent, new String[]{optionRename, optionNot}));
+ }
+
+ CtuluLog log = edition.changeBranche(emh, modifications, getCcm(), renameSection);
if (!log.containsErrorOrSevereError()) {
modellingScenarioModificationService.setScenarioModified(new ScenarioModificationEvent(EnumModification.EMH));
setModified(false);
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties 2014-02-03 13:33:27 UTC (rev 8596)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties 2014-02-03 14:34:34 UTC (rev 8597)
@@ -51,3 +51,6 @@
Reference.Name=R\u00e9f\u00e9rence
Dz.Name=Dz
changeSection.ProfilSectionWillBeLost=Le ProfilSection associ\u00e9 \u00e0 cette section sera perdu. Voulez-vous continuer ?
+BrancheChangeName.RenameSection=Renommer les sections
+BrancheChangeName.NotRenameSection=Ne pas renommer
+BrancheChangeName.Content=<html><body>Le nom de la branche est modifi\u00e9e. Voulez-vous: <ul><li>Renommer les sections nomm\u00e9es pr\u00e9c\u00e9demment selon le nom de la branche</li><li>Ne renommer aucune section de la branche</li></ul></body></html>
Modified: trunk/soft/fudaa-crue/ui-planimetry/src/main/java/org/fudaa/fudaa/crue/planimetry/layer/PlanimetryBrancheModel.java
===================================================================
--- trunk/soft/fudaa-crue/ui-planimetry/src/main/java/org/fudaa/fudaa/crue/planimetry/layer/PlanimetryBrancheModel.java 2014-02-03 13:33:27 UTC (rev 8596)
+++ trunk/soft/fudaa-crue/ui-planimetry/src/main/java/org/fudaa/fudaa/crue/planimetry/layer/PlanimetryBrancheModel.java 2014-02-03 14:34:34 UTC (rev 8597)
@@ -134,6 +134,9 @@
@Override
public boolean addGeometry(GrPolyligne _p, CtuluCommandContainer _cmd, CtuluUI _ui, ZEditionAttributesDataI _d) {
+ if (_p.nombre() == 0) {
+ return false;
+ }
PlanimetryControllerHelper helper = super.getLayerController().getHelper();
if (!helper.canEMHBeAddedAndDisplayError()) {
return false;
@@ -142,6 +145,7 @@
if (brancheType == null) {
return false;
}
+
GISPolyligne polyligne = _p.toGIS();
double length = polyligne.getLength();
CrueConfigMetier crueConfigMetier = helper.getController().getCrueConfigMetier();
@@ -180,9 +184,8 @@
updateNoeudAvalPosition(nodeController, noeudAvalIdx, polyligne);
}
-
-
- CatEMHBranche createBranche = new EditionCreateEMH(getLayerController().getDefaultValues()).createBranche(helper.getDefaultSousModele(), brancheType, noeudAmont,
+ CatEMHBranche createBranche = new EditionCreateEMH(getLayerController().getDefaultValues()).createBranche(helper.getDefaultSousModele(),
+ brancheType, noeudAmont,
noeudAval, crueConfigMetier, polyligne.getLength());
if (createBranche != null) {
StringBuilder info = new StringBuilder();
@@ -206,7 +209,8 @@
}
Object[] data = helper.getPlanimetryGisModelContainer().buildEdgeData(createBranche);
getGeometries().addGeometry(polyligne, data, null);
- DialogHelper.showNotifyOperationTermine(NbBundle.getMessage(PlanimetryBrancheModel.class, "Info.CreatedBranche", createBranche.getNom()), info.toString());
+ DialogHelper.showNotifyOperationTermine(NbBundle.getMessage(PlanimetryBrancheModel.class, "Info.CreatedBranche", createBranche.getNom()), info.
+ toString());
}
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|