Commit da51c382 authored by PECQUOT's avatar PECQUOT

[enh] Change behavior of Programs, Campaigns and Rule Lists screens when...

[enh] Change behavior of Programs, Campaigns and Rule Lists screens when synchro server is unavailable (Mantis #48600)
Signed-off-by: PECQUOT's avatarlp1ee9d <ludovic.pecquot@e-is.pro>
parent 5f32c594
......@@ -171,7 +171,7 @@
<maven.compiler.debug>true</maven.compiler.debug>
<!-- Quadrige3 Core version -->
<quadrige3-core.version>3.5.3-SNAPSHOT</quadrige3-core.version>
<quadrige3-core.version>3.5.4-SNAPSHOT</quadrige3-core.version> <!-- to use 3.5.3 -->
<!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion>
......
......@@ -6,6 +6,7 @@ BeanDoubleList {
showSelectPopupEnabled: true;
highlightFilterText: true;
bean: {model};
enabled: {model.isEditable()};
}
#selectQualitativeValueUI {
......@@ -26,5 +27,6 @@ BeanDoubleList {
text: "reefdb.common.validate";
toolTipText: "reefdb.common.validate";
i18nMnemonic: "reefdb.common.validate.mnemonic";
enabled: {model.isEditable()};
}
......@@ -12,12 +12,12 @@ package fr.ifremer.reefdb.ui.swing.content.manage.referential.pmfm.qualitativeva
* it under the terms of the GNU Affero 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
......@@ -37,6 +37,8 @@ public class SelectQualitativeValueUIModel extends AbstractEmptyUIModel<SelectQu
private List<QualitativeValueDTO> availableList;
public static final String PROPERTY_SELECTED_LIST = "selectedList";
private List<QualitativeValueDTO> selectedList;
private boolean editable;
public static final String PROPERTY_EDITABLE = "editable";
public List<QualitativeValueDTO> getAvailableList() {
return availableList;
......@@ -55,4 +57,13 @@ public class SelectQualitativeValueUIModel extends AbstractEmptyUIModel<SelectQu
this.selectedList = selectedList;
firePropertyChange(PROPERTY_SELECTED_LIST, null, selectedList);
}
public boolean isEditable() {
return editable;
}
public void setEditable(boolean editable) {
this.editable = editable;
firePropertyChange(PROPERTY_EDITABLE, null, editable);
}
}
......@@ -38,7 +38,7 @@
toolTipText: "reefdb.action.save.rules";
_applicationAction: {SaveAction.class};
_applicationActionKey: {fr.ifremer.reefdb.ui.swing.util.ReefDbKeyStrokes.SAVE};
enabled: {model.isModify() && model.isValid() && model.isSaveEnabled()};
enabled: {model.isModify() && model.isValid() && model.isSaveEnabled() && model.isUserIsAdmin()};
}
#ruleMessageScrollPane {
......
......@@ -75,6 +75,12 @@ public class RulesUIHandler extends AbstractReefDbUIHandler<RulesUIModel, RulesU
public void afterInit(final RulesUI ui) {
initUI(ui);
// Initialiser les parametres des ecrans Observation et prelevemnts
getContext().clearObservationPrelevementsIds();
// set model editable if user is admin
getModel().setUserIsAdmin(getContext().isAuthenticatedAsAdmin());
// Save models
getModel().setRuleListUIModel(getUI().getRuleListUI().getModel());
getModel().setProgramsUIModel(getUI().getControlProgramTableUI().getModel());
......@@ -82,12 +88,6 @@ public class RulesUIHandler extends AbstractReefDbUIHandler<RulesUIModel, RulesU
getModel().setControlRuleUIModel(getUI().getControlRuleTableUI().getModel());
getModel().setPmfmUIModel(getUI().getControlPmfmTableUI().getModel());
// Initialiser les parametres des ecrans Observation et prelevemnts
getContext().clearObservationPrelevementsIds();
// set model editable
getModel().setScreenEditable(getContext().isAuthenticatedAsAdmin() && getModel().isSaveEnabled());
// Disable controls regarding editable property
disableControls();
......@@ -174,7 +174,6 @@ public class RulesUIHandler extends AbstractReefDbUIHandler<RulesUIModel, RulesU
// Add listener on saveEnabled property to disable change (Mantis #48002)
getModel().addPropertyChangeListener(RulesUIModel.PROPERTY_SAVE_ENABLED, evt -> {
getModel().getRuleListUIModel().setSaveEnabled(getModel().isSaveEnabled());
getModel().setScreenEditable(getContext().isAuthenticatedAsAdmin() && getModel().isSaveEnabled());
});
}
......
......@@ -27,6 +27,7 @@ import fr.ifremer.reefdb.ui.swing.content.manage.rule.controlrule.ControlRuleTab
import fr.ifremer.reefdb.ui.swing.content.manage.rule.department.ControlDepartmentTableUIModel;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.pmfm.ControlPmfmTableUIModel;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.program.ControlProgramTableUIModel;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.rulelist.RuleListRowModel;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.rulelist.RuleListUIModel;
import fr.ifremer.quadrige3.ui.swing.model.AbstractEmptyUIModel;
......@@ -60,8 +61,9 @@ public class RulesUIModel extends AbstractEmptyUIModel<RulesUIModel> {
*/
private ControlPmfmTableUIModel pmfmUIModel;
private boolean screenEditable;
private boolean selectedRuleListEditable;
private RuleListRowModel selectedRuleList;
private boolean userIsAdmin;
public static final String PROPERTY_RULE_MESSAGE = "ruleMessage";
public static final String PROPERTY_RULE_DESCRIPTION = "ruleDescription";
......@@ -180,20 +182,24 @@ public class RulesUIModel extends AbstractEmptyUIModel<RulesUIModel> {
this.pmfmUIModel.setParentModel(this);
}
public boolean isEditable() {
return screenEditable && selectedRuleListEditable;
public RuleListRowModel getSelectedRuleList() {
return selectedRuleList;
}
public boolean isScreenEditable() {
return screenEditable;
public void setSelectedRuleList(RuleListRowModel selectedRuleList) {
this.selectedRuleList = selectedRuleList;
}
public boolean isEditable() {
return userIsAdmin && selectedRuleList != null && selectedRuleList.isEditable();
}
public void setScreenEditable(boolean screenEditable) {
this.screenEditable = screenEditable;
public boolean isUserIsAdmin() {
return userIsAdmin;
}
public void setSelectedRuleListEditable(boolean selectedRuleListEditable) {
this.selectedRuleListEditable = selectedRuleListEditable;
public void setUserIsAdmin(boolean userIsAdmin) {
this.userIsAdmin = userIsAdmin;
}
public String getRuleMessage() {
......
......@@ -50,7 +50,6 @@ import fr.ifremer.reefdb.ui.swing.content.manage.rule.controlrule.precondition.n
import fr.ifremer.reefdb.ui.swing.content.manage.rule.controlrule.precondition.numerical.RulePrecondNumUIModel;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.controlrule.precondition.qualitative.RulePrecondQualUI;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.controlrule.precondition.qualitative.RulePrecondQualUIModel;
import fr.ifremer.reefdb.ui.swing.content.manage.rule.rulelist.RuleListRowModel;
import fr.ifremer.reefdb.ui.swing.util.AbstractReefDbBeanUIModel;
import fr.ifremer.reefdb.ui.swing.util.ReefDbUI;
import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableModel;
......@@ -241,6 +240,7 @@ public class ControlRuleTableUIHandler extends
orderedAvailableList.sort(new DecoratorComparator<>(getDecorator(QualitativeValueDTO.class, null)));
selectQualitativeValueUI.getModel().setAvailableList(orderedAvailableList);
selectQualitativeValueUI.getModel().setSelectedList(selectedList);
selectQualitativeValueUI.getModel().setEditable(getModel().getParentModel().getSelectedRuleList().isEditable());
openDialog(selectQualitativeValueUI, new Dimension(640, 480));
if (selectQualitativeValueUI.getModel().isValid()) {
......@@ -271,6 +271,7 @@ public class ControlRuleTableUIHandler extends
model.setQvMap(getContext().getRuleListService().buildQualitativeValueMapFromPreconditions(rowModel.getPreconditions()));
model.setBasePmfm(rowModel.getRulePmfms(0).getPmfm());
model.setUsedPmfm(rowModel.getRulePmfms(1).getPmfm());
model.setEditable(getModel().getParentModel().getSelectedRuleList().isEditable());
openDialog(rulePreconditionUI, new Dimension(600, 800));
......@@ -296,6 +297,7 @@ public class ControlRuleTableUIHandler extends
model.setBasePmfm(rowModel.getRulePmfms(0).getPmfm());
model.setUsedPmfm(rowModel.getRulePmfms(1).getPmfm());
model.setBeans(getContext().getRuleListService().buildNumericPreconditionListFromPreconditions(rowModel.getPreconditions()));
model.setEditable(getModel().getParentModel().getSelectedRuleList().isEditable());
openDialog(rulePreconditionUI, new Dimension(600, 800));
......@@ -435,7 +437,7 @@ public class ControlRuleTableUIHandler extends
}
private void saveToParentModel() {
getRuleList().setControlRules(getModel().getBeans());
getModel().getParentModel().getSelectedRuleList().setControlRules(getModel().getBeans());
recomputeRowsValidState(false);
getModel().firePropertyChanged(AbstractReefDbBeanUIModel.PROPERTY_MODIFY, null, true);
......@@ -452,7 +454,7 @@ public class ControlRuleTableUIHandler extends
ControlRuleRowModel row = addedRows.get(0);
// create a new rule by service
ControlRuleDTO newRule = getContext().getRuleListService().newControlRule(getRuleList());
ControlRuleDTO newRule = getContext().getRuleListService().newControlRule(getModel().getParentModel().getSelectedRuleList());
// convert it to the added row
row.fromBean(newRule);
......@@ -462,10 +464,6 @@ public class ControlRuleTableUIHandler extends
}
}
private RuleListRowModel getRuleList() {
return getModel().getParentModel().getRuleListUIModel().getSingleSelectedRow();
}
/**
* <p>removeRules.</p>
*/
......@@ -671,7 +669,7 @@ public class ControlRuleTableUIHandler extends
ControlRuleRowModel row = getModel().getSingleSelectedRow();
if (row != null && row.isNewCode()) {
if (checkNewCode(row)) {
getRuleList().setDirty(true);
getModel().getParentModel().getSelectedRuleList().setDirty(true);
}
}
}
......
......@@ -9,6 +9,10 @@
border: {BorderFactory.createTitledBorder("")};
}
#numericalPreconditionTable {
editable: {model.isEditable()};
}
#cancelButton {
actionIcon: cancel;
text: "reefdb.common.cancel";
......@@ -21,5 +25,5 @@
text: "reefdb.common.validate";
toolTipText: "reefdb.common.validate";
i18nMnemonic: "reefdb.common.validate.mnemonic";
enabled: {model.isValid()};
enabled: {model.isValid() && model.isEditable()};
}
\ No newline at end of file
......@@ -37,6 +37,8 @@ public class RulePrecondNumUIModel extends AbstractReefDbTableUIModel<NumericPre
private PmfmDTO usedPmfm;
static final String PROPERTY_USED_PMFM = "usedPmfm";
private boolean adjusting;
private boolean editable;
public static final String PROPERTY_EDITABLE = "editable";
PmfmDTO getBasePmfm() {
return basePmfm;
......@@ -71,4 +73,12 @@ public class RulePrecondNumUIModel extends AbstractReefDbTableUIModel<NumericPre
public void setRulePreconditionValid(boolean dummy) {
}
public boolean isEditable() {
return editable;
}
public void setEditable(boolean editable) {
this.editable = editable;
firePropertyChange(PROPERTY_EDITABLE, null, editable);
}
}
......@@ -9,6 +9,10 @@
border: {BorderFactory.createTitledBorder("")};
}
#baseRuleQVTable {
editable: {model.isEditable()};
}
#usedRulePanel {
border: {BorderFactory.createTitledBorder("")};
}
......@@ -29,6 +33,7 @@
filterable: true;
showDecorator: true;
alwaysSortSelected: true;
enabled: {model.isEditable()};
}
#cancelButton {
......@@ -43,5 +48,5 @@
text: "reefdb.common.validate";
toolTipText: "reefdb.common.validate";
i18nMnemonic: "reefdb.common.validate.mnemonic";
enabled: {model.isValid()};
enabled: {model.isValid() && model.isEditable()};
}
\ No newline at end of file
......@@ -41,6 +41,8 @@ public class RulePrecondQualUIModel extends AbstractReefDbTableUIModel<Qualitati
private PmfmDTO usedPmfm;
public static final String PROPERTY_USED_PMFM = "usedPmfm";
private boolean adjusting;
private boolean editable;
public static final String PROPERTY_EDITABLE = "editable";
private Multimap<QualitativeValueDTO, QualitativeValueDTO> qvMap;
......@@ -100,4 +102,12 @@ public class RulePrecondQualUIModel extends AbstractReefDbTableUIModel<Qualitati
public void setRulePreconditionValid(boolean dummy) {
}
public boolean isEditable() {
return editable;
}
public void setEditable(boolean editable) {
this.editable = editable;
firePropertyChange(PROPERTY_EDITABLE, null, editable);
}
}
......@@ -151,7 +151,7 @@ public class ControlDepartmentTableUIHandler extends
dialog.getModel().setSelectedElements(departments);
if (!getModel().getParentModel().getRuleListUIModel().getSingleSelectedRow().isLocal()) {
if (!getModel().getParentModel().getSelectedRuleList().isLocal()) {
// filter only national programs if rule list is national
dialog.getHandler().getFilterElementUIHandler().forceLocal(false);
}
......@@ -182,7 +182,7 @@ public class ControlDepartmentTableUIHandler extends
}
private void saveToParentModel() {
getModel().getParentModel().getRuleListUIModel().getSingleSelectedRow().setDepartments(getModel().getBeans());
getModel().getParentModel().getSelectedRuleList().setDepartments(getModel().getBeans());
recomputeRowsValidState(false);
getModel().firePropertyChanged(AbstractReefDbBeanUIModel.PROPERTY_MODIFY, null, true);
......
......@@ -168,7 +168,7 @@ public class ControlProgramTableUIHandler extends
ProgramsMenuUI menuUI = (ProgramsMenuUI) dialog.getHandler().getFilterElementUIHandler().getReferentialMenuUI();
if (!getModel().getParentModel().getRuleListUIModel().getSingleSelectedRow().isLocal()) {
if (!getModel().getParentModel().getSelectedRuleList().isLocal()) {
// filter only national programs if rule list is national
menuUI.getHandler().forceLocal(false);
}
......@@ -205,7 +205,7 @@ public class ControlProgramTableUIHandler extends
}
private void saveToParentModel() {
getModel().getParentModel().getRuleListUIModel().getSingleSelectedRow().setPrograms(getModel().getBeans());
getModel().getParentModel().getSelectedRuleList().setPrograms(getModel().getBeans());
recomputeRowsValidState(false);
getModel().firePropertyChanged(AbstractReefDbBeanUIModel.PROPERTY_MODIFY, null, true);
......
......@@ -29,7 +29,7 @@
actionIcon: add;
text: "reefdb.common.new";
toolTipText: "reefdb.common.new";
enabled: {model.getParentModel().isScreenEditable() && model.isSaveEnabled()};
enabled: {model.getParentModel().isUserIsAdmin() && model.isSaveEnabled()};
}
#duplicateRuleListButton {
......
......@@ -243,7 +243,7 @@ public class RuleListUIHandler extends
final RuleListRowModel ruleList = getModel().getSingleSelectedRow();
// Si un seul element a ete selectionne
rulesUI.getModel().setSelectedRuleListEditable(ruleList != null && !ruleList.isReadOnly());
rulesUI.getModel().setSelectedRuleList(ruleList);
if (ruleList != null) {
// Chargement des ProgrammesControle
......
......@@ -45,7 +45,7 @@
Change measurements fullscreen button
</action>
<action dev="ludovic.pecquot@e-is.pro" type="add" issue="48600">
Change behavior of Programs, Campaigns and Rule Lists screens when synchro server is unavailable TODO to finish
Change behavior of Programs, Campaigns and Rule Lists screens when synchro server is unavailable
</action>
</release>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment