Tony CHEMIT pushed to branch feature/refactor_ui at ultreiaio / ird-observe
Commits:
-
458a9a10
by Tony CHEMIT at 2017-10-12T18:35:47+02:00
13 changed files:
- client/src/main/java/fr/ird/observe/client/form/ObserveFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/open/ObserveOpenDataFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/open/ObserveOpenDataFormUIModel.java
- client/src/main/java/fr/ird/observe/client/form/open/seine/ActivitySeineUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/openlist/ObserveOpenDataListFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/openlist/longline/TripLonglineListUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/openlist/seine/TripSeineListUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/referential/ObserveReferentialFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/referential/ObserveReferentialFormUIModel.java
- client/src/main/java/fr/ird/observe/client/form/simple/ObserveMainDataFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/simple/ObserveSimpleDataFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/simplelist/ObserveSimpleDataListFormUIHandler.java
- client/src/main/java/fr/ird/observe/client/form/table/ObserveDataTableFormUIHandler.java
Changes:
| ... | ... | @@ -26,14 +26,14 @@ import com.google.common.collect.ImmutableMap; |
| 26 | 26 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 27 | 27 |
import fr.ird.observe.client.ObserveMainUI;
|
| 28 | 28 |
import fr.ird.observe.client.db.ObserveSwingDataSource;
|
| 29 |
-import fr.ird.observe.client.form.referential.ReferentialFormUIHandler;
|
|
| 29 |
+import fr.ird.observe.client.form.action.FormUIAction;
|
|
| 30 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 30 | 31 |
import fr.ird.observe.client.form.spi.FormUIToModelClassMapping;
|
| 31 | 32 |
import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
| 32 | 33 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 33 | 34 |
import fr.ird.observe.client.spi.ClientDataContext;
|
| 34 | 35 |
import fr.ird.observe.client.tools.ObserveOpenDataManager;
|
| 35 | 36 |
import fr.ird.observe.client.tree.navigation.NavigationTree;
|
| 36 |
-import fr.ird.observe.client.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 37 | 37 |
import fr.ird.observe.client.util.UIHelper;
|
| 38 | 38 |
import fr.ird.observe.dto.IdDto;
|
| 39 | 39 |
import fr.ird.observe.dto.decoration.DecoratorService;
|
| ... | ... | @@ -85,7 +85,7 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 85 | 85 |
protected final ObserveSwingDataSource dataSource;
|
| 86 | 86 |
protected final ObserveOpenDataManager openDataManager;
|
| 87 | 87 |
protected final DecoratorService decoratorService;
|
| 88 |
- |
|
| 88 |
+ private final FormUIAction formUIAction;
|
|
| 89 | 89 |
protected U ui;
|
| 90 | 90 |
protected String prefix;
|
| 91 | 91 |
private boolean init;
|
| ... | ... | @@ -100,6 +100,11 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 100 | 100 |
openDataManager = applicationContext.getOpenDataManager();
|
| 101 | 101 |
decoratorService = applicationContext.getDecoratorService();
|
| 102 | 102 |
dataContext = applicationContext.getDataContext();
|
| 103 |
+ formUIAction = new FormUIAction();
|
|
| 104 |
+ }
|
|
| 105 |
+ |
|
| 106 |
+ protected final void run(FormUIActionHandler handler) {
|
|
| 107 |
+ formUIAction.run(handler);
|
|
| 103 | 108 |
}
|
| 104 | 109 |
|
| 105 | 110 |
protected static DecoratorTableCellRenderer newDecorateTableCellRenderer(TableCellRenderer renderer, Class<?> type) {
|
| ... | ... | @@ -259,6 +264,10 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 259 | 264 |
ui.setContextValue(model = FormUIToModelClassMapping.newModel(ui));
|
| 260 | 265 |
ui.setContextValue(ObserveClientApplicationContext.get().getDataContext());
|
| 261 | 266 |
ui.setContextValue(ObserveClientApplicationContext.get().getConfig());
|
| 267 |
+ if (model instanceof WithBeanTypeFormModel) {
|
|
| 268 |
+ validationManager = new FormUIValidationMessageManager(((WithBeanTypeFormModel) model).getBeanType(), ui);
|
|
| 269 |
+ }
|
|
| 270 |
+ prefix = model.getPrefix();
|
|
| 262 | 271 |
}
|
| 263 | 272 |
|
| 264 | 273 |
@SuppressWarnings("unchecked")
|
| ... | ... | @@ -270,7 +279,6 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 270 | 279 |
init = true;
|
| 271 | 280 |
mainUI = (ObserveMainUI) ui.getMainUI();
|
| 272 | 281 |
navigation = mainUI.getNavigation();
|
| 273 |
- prefix = model.getPrefix();
|
|
| 274 | 282 |
|
| 275 | 283 |
initialize(ui);
|
| 276 | 284 |
installFocusTraversalPolicy();
|
| ... | ... | @@ -288,9 +296,7 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 288 | 296 |
}
|
| 289 | 297 |
|
| 290 | 298 |
protected final void initialize(U ui) {
|
| 291 |
- ImmutableMap<String, ReferentialReferencesFilter> filters = createFilters();
|
|
| 292 |
- ObserveFormUIInitializerContext<U> initializerContext = createInitializerContext(ui, filters);
|
|
| 293 |
- initialize(initializerContext);
|
|
| 299 |
+ initialize(createInitializerContext(ui, createFilters()));
|
|
| 294 | 300 |
}
|
| 295 | 301 |
|
| 296 | 302 |
protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
| ... | ... | @@ -302,8 +308,11 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 302 | 308 |
// ObserveClientApplicationContext.get().getFocusManager().installFocusTraversalPolicy(ui);
|
| 303 | 309 |
}
|
| 304 | 310 |
|
| 311 |
+ protected void updateExtra() {
|
|
| 312 |
+ }
|
|
| 313 |
+ |
|
| 305 | 314 |
@Override
|
| 306 |
- public U getUi() {
|
|
| 315 |
+ public final U getUi() {
|
|
| 307 | 316 |
return ui;
|
| 308 | 317 |
}
|
| 309 | 318 |
|
| ... | ... | @@ -326,49 +335,6 @@ public abstract class ObserveFormUIHandler<M extends FormUIModel, U extends Form |
| 326 | 335 |
}
|
| 327 | 336 |
}
|
| 328 | 337 |
|
| 329 |
- // protected void setContentMode() {
|
|
| 330 |
-// FormUIMode contentMode = model.isCanWrite() ? computeContentMode(dataContext, openDataManager) : FormUIMode.READ;
|
|
| 331 |
-// log.info(String.format("%s content mode %s", prefix, contentMode));
|
|
| 332 |
-// model.setMode(contentMode);
|
|
| 333 |
-// }
|
|
| 334 |
-//
|
|
| 335 |
-// protected void setCanWrite() {
|
|
| 336 |
-// boolean canWrite = model.isReferential() ? dataSource.canWriteReferential() : dataSource.canWriteData();
|
|
| 337 |
-// log.info(String.format("%s can write %s", prefix, canWrite));
|
|
| 338 |
-// model.setCanWrite(canWrite);
|
|
| 339 |
-// }
|
|
| 340 |
-//
|
|
| 341 |
- protected void computeContentIcon() {
|
|
| 342 |
- NavigationTreeNodeSupport node = navigation.getSelectedNode();
|
|
| 343 |
- if (ReferentialFormUIHandler.class.isAssignableFrom(getClass())) {
|
|
| 344 |
- node = node.getParent();
|
|
| 345 |
- }
|
|
| 346 |
- model.setContentIcon(node.getIcon(""));
|
|
| 347 |
- }
|
|
| 348 |
-//
|
|
| 349 |
-// protected void computeValidationMessages() {
|
|
| 350 |
-// validationManager.clear();
|
|
| 351 |
-// if (model.isCanWrite()) {
|
|
| 352 |
-// switch (model.getMode()) {
|
|
| 353 |
-// case CREATE:
|
|
| 354 |
-// computeCreateMessages(dataContext, validationManager);
|
|
| 355 |
-// break;
|
|
| 356 |
-// case UPDATE:
|
|
| 357 |
-// computeUpdateMessages(dataContext, validationManager);
|
|
| 358 |
-// break;
|
|
| 359 |
-// case READ:
|
|
| 360 |
-// computeReadMessages(dataContext, validationManager);
|
|
| 361 |
-// break;
|
|
| 362 |
-// }
|
|
| 363 |
-// } else {
|
|
| 364 |
-// if (model.isReferential()) {
|
|
| 365 |
-// validationManager.addInfoMessage(t("observe.common.ReferentialDto.message.noEditable"));
|
|
| 366 |
-// } else {
|
|
| 367 |
-// validationManager.addInfoMessage(t("observe.common.Dto.message.cantWriteData"));
|
|
| 368 |
-// }
|
|
| 369 |
-// }
|
|
| 370 |
-// }
|
|
| 371 |
- |
|
| 372 | 338 |
protected void grabFocusOnForm() {
|
| 373 | 339 |
boolean focusOnNavigation = mainUI.getModel().isFocusOnNavigation();
|
| 374 | 340 |
if (focusOnNavigation) {
|
| ... | ... | @@ -23,23 +23,20 @@ package fr.ird.observe.client.form.open; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableMap;
|
| 26 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 26 | 27 |
import fr.ird.observe.client.form.FormUIMode;
|
| 27 | 28 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 28 | 29 |
import fr.ird.observe.client.form.ObserveFormUIInitializerContext;
|
| 29 |
-import fr.ird.observe.client.form.action.DeleteFormUIAction;
|
|
| 30 |
-import fr.ird.observe.client.form.action.EditFormUIAction;
|
|
| 31 |
-import fr.ird.observe.client.form.action.OpenCloseDataFormUIAction;
|
|
| 32 |
-import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
|
| 30 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 33 | 31 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 34 |
-import fr.ird.observe.client.tree.navigation.NavigationTree;
|
|
| 35 | 32 |
import fr.ird.observe.client.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| 36 | 33 |
import fr.ird.observe.client.tree.navigation.nodes.longline.TripLonglineListNavigationTreeNode;
|
| 37 | 34 |
import fr.ird.observe.client.tree.navigation.nodes.seine.TripSeineListNavigationTreeNode;
|
| 38 |
-import fr.ird.observe.client.util.UIHelper;
|
|
| 39 | 35 |
import fr.ird.observe.dto.data.OpenableDto;
|
| 40 | 36 |
import fr.ird.observe.dto.reference.DataDtoReference;
|
| 41 | 37 |
import org.apache.commons.logging.Log;
|
| 42 | 38 |
import org.apache.commons.logging.LogFactory;
|
| 39 |
+import org.nuiton.jaxx.runtime.swing.SwingUtil;
|
|
| 43 | 40 |
import org.nuiton.jaxx.validator.swing.SwingValidatorUtil;
|
| 44 | 41 |
|
| 45 | 42 |
/**
|
| ... | ... | @@ -52,67 +49,117 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 52 | 49 |
/** Logger. */
|
| 53 | 50 |
private static final Log log = LogFactory.getLog(ObserveOpenDataFormUIHandler.class);
|
| 54 | 51 |
|
| 55 |
- private final DeleteFormUIAction<D, U> deleteAction;
|
|
| 56 |
- private final EditFormUIAction<D, U> editAction;
|
|
| 57 |
- private final OpenCloseDataFormUIAction<U> openCloseDataAction;
|
|
| 52 |
+ private final FormUIActionHandler editActionHandler = new FormUIActionHandler() {
|
|
| 58 | 53 |
|
| 59 |
- public ObserveOpenDataFormUIHandler() {
|
|
| 60 |
- deleteAction = new DeleteFormUIAction<D, U>() {
|
|
| 54 |
+ private D dto;
|
|
| 55 |
+ boolean created;
|
|
| 61 | 56 |
|
| 62 |
- @Override
|
|
| 63 |
- protected boolean askToDelete(D dto) {
|
|
| 64 |
- return askToDelete0(dto);
|
|
| 65 |
- }
|
|
| 57 |
+ @Override
|
|
| 58 |
+ public boolean before() {
|
|
| 59 |
+ dto = model.getBean();
|
|
| 60 |
+ created = dto.isNotPersisted();
|
|
| 61 |
+ return checkEdit();
|
|
| 62 |
+ }
|
|
| 66 | 63 |
|
| 67 |
- @Override
|
|
| 68 |
- protected void afterDelete(D dto) {
|
|
| 69 |
- afterDelete0(dto);
|
|
| 70 |
- }
|
|
| 64 |
+ @Override
|
|
| 65 |
+ public void run() {
|
|
| 66 |
+ model.save();
|
|
| 67 |
+ }
|
|
| 71 | 68 |
|
| 72 |
- @Override
|
|
| 73 |
- protected void doDelete(D dto) {
|
|
| 74 |
- model.delete();
|
|
| 75 |
- }
|
|
| 76 |
- };
|
|
| 77 |
- editAction = new EditFormUIAction<D, U>() {
|
|
| 69 |
+ @Override
|
|
| 70 |
+ public void after() {
|
|
| 71 |
+ afterSave0(dto, created);
|
|
| 72 |
+ }
|
|
| 78 | 73 |
|
| 79 |
- @Override
|
|
| 80 |
- protected boolean askToSave(D dto) {
|
|
| 81 |
- return askToSave0(dto);
|
|
| 82 |
- }
|
|
| 74 |
+ @Override
|
|
| 75 |
+ public FormUI getUI() {
|
|
| 76 |
+ return ui;
|
|
| 77 |
+ }
|
|
| 78 |
+ };
|
|
| 83 | 79 |
|
| 84 |
- @Override
|
|
| 85 |
- protected void doSave(D dto) {
|
|
| 86 |
- model.save();
|
|
| 87 |
- }
|
|
| 80 |
+ private final FormUIActionHandler deleteActionHandler = new FormUIActionHandler() {
|
|
| 88 | 81 |
|
| 89 |
- @Override
|
|
| 90 |
- protected void afterSave(D dto, boolean created) {
|
|
| 91 |
- afterSave0(dto, created);
|
|
| 92 |
- }
|
|
| 93 |
- };
|
|
| 94 |
- openCloseDataAction = new OpenCloseDataFormUIAction<U>() {
|
|
| 95 | 82 |
|
| 96 |
- @Override
|
|
| 97 |
- protected boolean doOpenData(String parentId, String id) {
|
|
| 98 |
- return false;
|
|
| 99 |
- }
|
|
| 83 |
+ @Override
|
|
| 84 |
+ public boolean before() {
|
|
| 85 |
+ return confirmForEntityDelete(model.getBeanType(), model.getBean());
|
|
| 86 |
+ }
|
|
| 87 |
+ |
|
| 88 |
+ @Override
|
|
| 89 |
+ public void run() {
|
|
| 90 |
+ model.delete();
|
|
| 91 |
+ }
|
|
| 100 | 92 |
|
| 101 |
- @Override
|
|
| 102 |
- protected void afterOpenData(String parentId, String id) {
|
|
| 93 |
+ @Override
|
|
| 94 |
+ public void after() {
|
|
| 103 | 95 |
|
| 104 |
- }
|
|
| 96 |
+ doCloseData();
|
|
| 105 | 97 |
|
| 106 |
- @Override
|
|
| 107 |
- protected boolean doCloseData(String parentId, String id) {
|
|
| 108 |
- return false;
|
|
| 109 |
- }
|
|
| 98 |
+ model.loadFormDependencies(dataSource, true);
|
|
| 99 |
+ model.updateUi();
|
|
| 110 | 100 |
|
| 111 |
- @Override
|
|
| 112 |
- protected void afterCloseData(String parentId, String id) {
|
|
| 101 |
+ stopEdit();
|
|
| 102 |
+ validationManager.removeAllMessages();
|
|
| 113 | 103 |
|
| 114 |
- }
|
|
| 115 |
- };
|
|
| 104 |
+ NavigationTreeNodeSupport node = navigation.getSelectedNode();
|
|
| 105 |
+ NavigationTreeNodeSupport parentNode = node.getParent();
|
|
| 106 |
+ navigation.removeNode(node);
|
|
| 107 |
+ navigation.selectNode(parentNode);
|
|
| 108 |
+ |
|
| 109 |
+ }
|
|
| 110 |
+ |
|
| 111 |
+ @Override
|
|
| 112 |
+ public FormUI getUI() {
|
|
| 113 |
+ return ui;
|
|
| 114 |
+ }
|
|
| 115 |
+ };
|
|
| 116 |
+ |
|
| 117 |
+ private final FormUIActionHandler openDataActionHandler = new FormUIActionHandler() {
|
|
| 118 |
+ |
|
| 119 |
+ @Override
|
|
| 120 |
+ public boolean before() {
|
|
| 121 |
+ return true;
|
|
| 122 |
+ }
|
|
| 123 |
+ |
|
| 124 |
+ @Override
|
|
| 125 |
+ public void run() {
|
|
| 126 |
+ doOpenData();
|
|
| 127 |
+ }
|
|
| 128 |
+ |
|
| 129 |
+ @Override
|
|
| 130 |
+ public void after() {
|
|
| 131 |
+ |
|
| 132 |
+ }
|
|
| 133 |
+ |
|
| 134 |
+ @Override
|
|
| 135 |
+ public FormUI getUI() {
|
|
| 136 |
+ return ui;
|
|
| 137 |
+ }
|
|
| 138 |
+ };
|
|
| 139 |
+ private final FormUIActionHandler closeDataActionHandler = new FormUIActionHandler() {
|
|
| 140 |
+ |
|
| 141 |
+ @Override
|
|
| 142 |
+ public boolean before() {
|
|
| 143 |
+ return true;
|
|
| 144 |
+ }
|
|
| 145 |
+ |
|
| 146 |
+ @Override
|
|
| 147 |
+ public void run() {
|
|
| 148 |
+ doCloseData();
|
|
| 149 |
+ }
|
|
| 150 |
+ |
|
| 151 |
+ @Override
|
|
| 152 |
+ public void after() {
|
|
| 153 |
+ |
|
| 154 |
+ }
|
|
| 155 |
+ |
|
| 156 |
+ @Override
|
|
| 157 |
+ public FormUI getUI() {
|
|
| 158 |
+ return ui;
|
|
| 159 |
+ }
|
|
| 160 |
+ };
|
|
| 161 |
+ |
|
| 162 |
+ protected ObserveOpenDataFormUIHandler() {
|
|
| 116 | 163 |
}
|
| 117 | 164 |
|
| 118 | 165 |
@Override
|
| ... | ... | @@ -125,66 +172,64 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 125 | 172 |
|
| 126 | 173 |
log.info(String.format("%s init ui", prefix));
|
| 127 | 174 |
|
| 128 |
- computeContentIcon();
|
|
| 129 |
- ui.getOpenActions().setVisible(model.isCanWrite());
|
|
| 130 | 175 |
updateToolbarActions();
|
| 131 | 176 |
updateExtra();
|
| 132 |
- setTitle(mainUI.getNavigation());
|
|
| 177 |
+ if (!model.isReadingMode()) {
|
|
| 178 |
+ startEdit();
|
|
| 179 |
+ model.setModified(model.isCreatingMode());
|
|
| 180 |
+ }
|
|
| 133 | 181 |
grabFocusOnForm();
|
| 134 | 182 |
}
|
| 135 | 183 |
|
| 136 |
- protected void updateExtra() {
|
|
| 137 |
- }
|
|
| 138 |
- |
|
| 139 | 184 |
@Override
|
| 140 |
- public final void openData() {
|
|
| 141 |
- openCloseDataAction.openData(ui, model.getSelectedParentId(), model.getBean().getId());
|
|
| 185 |
+ public boolean closeUI() {
|
|
| 186 |
+ //FIXME!!!
|
|
| 187 |
+ return false;
|
|
| 142 | 188 |
}
|
| 143 | 189 |
|
| 144 | 190 |
@Override
|
| 145 |
- public final void closeData() {
|
|
| 146 |
- openCloseDataAction.closeData(ui, model.getSelectedParentId(), model.getBean().getId());
|
|
| 191 |
+ public void destroyUI() {
|
|
| 192 |
+ //FIXME!!!
|
|
| 147 | 193 |
}
|
| 148 | 194 |
|
| 149 | 195 |
@Override
|
| 150 |
- public final void saveEdit() {
|
|
| 151 |
- editAction.save(ui, model.getBean());
|
|
| 196 |
+ public final void openData() {
|
|
| 197 |
+ run(openDataActionHandler);
|
|
| 152 | 198 |
}
|
| 153 | 199 |
|
| 154 | 200 |
@Override
|
| 155 |
- public void destroyUI() {
|
|
| 156 |
-//FIXME!!!
|
|
| 201 |
+ public final void closeData() {
|
|
| 202 |
+ run(closeDataActionHandler);
|
|
| 157 | 203 |
}
|
| 158 | 204 |
|
| 159 | 205 |
@Override
|
| 160 |
- public boolean closeUI() {
|
|
| 206 |
+ public void startEdit() {
|
|
| 161 | 207 |
//FIXME!!!
|
| 162 |
- return false;
|
|
| 163 | 208 |
}
|
| 164 | 209 |
|
| 165 | 210 |
@Override
|
| 166 |
- public void startEdit() {
|
|
| 211 |
+ public void stopEdit() {
|
|
| 167 | 212 |
//FIXME!!!
|
| 168 | 213 |
}
|
| 169 | 214 |
|
| 170 | 215 |
@Override
|
| 171 |
- public void stopEdit() {
|
|
| 216 |
+ public void resetEdit() {
|
|
| 172 | 217 |
//FIXME!!!
|
| 173 | 218 |
}
|
| 174 | 219 |
|
| 175 | 220 |
@Override
|
| 176 |
- public void resetEdit() {
|
|
| 177 |
-//FIXME!!!
|
|
| 221 |
+ public final void saveEdit() {
|
|
| 222 |
+ run(editActionHandler);
|
|
| 178 | 223 |
}
|
| 179 | 224 |
|
| 180 | 225 |
@Override
|
| 181 | 226 |
public void createData() {
|
| 182 |
- |
|
| 227 |
+ //FIXME!!!
|
|
| 183 | 228 |
}
|
| 184 | 229 |
|
| 185 | 230 |
@Override
|
| 186 | 231 |
public final void deleteData() {
|
| 187 |
- deleteAction.delete(ui, model.getBean());
|
|
| 232 |
+ run(deleteActionHandler);
|
|
| 188 | 233 |
}
|
| 189 | 234 |
|
| 190 | 235 |
@Override
|
| ... | ... | @@ -192,12 +237,6 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 192 | 237 |
return new OpenDataFormUIInitializerContext<>(ui, filters);
|
| 193 | 238 |
}
|
| 194 | 239 |
|
| 195 |
- @Override
|
|
| 196 |
- protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
|
| 197 |
- validationManager = new FormUIValidationMessageManager(model.getDataType(), ui);
|
|
| 198 |
- super.initialize(initializerContext);
|
|
| 199 |
- }
|
|
| 200 |
- |
|
| 201 | 240 |
public boolean doCloseData() {
|
| 202 | 241 |
return false;
|
| 203 | 242 |
}
|
| ... | ... | @@ -206,16 +245,6 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 206 | 245 |
return false;
|
| 207 | 246 |
}
|
| 208 | 247 |
|
| 209 |
- protected void setTitle(NavigationTree treeHelper) {
|
|
| 210 |
- //FIXME!!!
|
|
| 211 |
- }
|
|
| 212 |
- |
|
| 213 |
- @Override
|
|
| 214 |
- protected void updateToolbarActions() {
|
|
| 215 |
- super.updateToolbarActions();
|
|
| 216 |
- ui.getOpenActions().setVisible(dataSource.canWriteData());
|
|
| 217 |
- }
|
|
| 218 |
- |
|
| 219 | 248 |
// @Override
|
| 220 | 249 |
// public final FormUIMode computeContentMode(ClientDataContext dataContext, OpenDtoManager openDataManager) {
|
| 221 | 250 |
// String id = getModel().getSelectedId();
|
| ... | ... | @@ -262,9 +291,9 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 262 | 291 |
|
| 263 | 292 |
try {
|
| 264 | 293 |
|
| 265 |
- UIHelper.openLink(url);
|
|
| 294 |
+ SwingUtil.openLink(url);
|
|
| 266 | 295 |
} catch (Exception e) {
|
| 267 |
- UIHelper.handlingError(e);
|
|
| 296 |
+ ui.getMainUI().handlingError(e);
|
|
| 268 | 297 |
}
|
| 269 | 298 |
}
|
| 270 | 299 |
|
| ... | ... | @@ -283,11 +312,7 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 283 | 312 |
|
| 284 | 313 |
}
|
| 285 | 314 |
|
| 286 |
- private boolean askToSave0(D dto) {
|
|
| 287 |
- return checkEdit();
|
|
| 288 |
- }
|
|
| 289 |
- |
|
| 290 |
- public void afterSave0(D bean, boolean create) {
|
|
| 315 |
+ protected void afterSave0(D bean, boolean create) {
|
|
| 291 | 316 |
|
| 292 | 317 |
if (create) {
|
| 293 | 318 |
doOpenData();
|
| ... | ... | @@ -343,28 +368,61 @@ public abstract class ObserveOpenDataFormUIHandler<D extends OpenableDto, R exte |
| 343 | 368 |
}
|
| 344 | 369 |
}
|
| 345 | 370 |
|
| 346 |
- private boolean askToDelete0(D dto) {
|
|
| 347 |
- if (!ObserveFormUIHandler.confirmForEntityDelete(model.getDataType(), dto)) {
|
|
| 348 |
- return false;
|
|
| 349 |
- }
|
|
| 350 |
- return true;
|
|
| 351 |
- }
|
|
| 352 |
- |
|
| 353 |
- private void afterDelete0(D dto) {
|
|
| 354 |
- |
|
| 355 |
- doCloseData();
|
|
| 356 |
- |
|
| 357 |
- model.loadFormDependencies(dataSource, true);
|
|
| 358 |
- model.updateUi();
|
|
| 359 | 371 |
|
| 360 |
- stopEdit();
|
|
| 361 |
- validationManager.removeAllMessages();
|
|
| 362 |
- |
|
| 363 |
- NavigationTreeNodeSupport node = navigation.getSelectedNode();
|
|
| 364 |
- NavigationTreeNodeSupport parentNode = node.getParent();
|
|
| 365 |
- navigation.removeNode(node);
|
|
| 366 |
- navigation.selectNode(parentNode);
|
|
| 372 |
+// protected abstract boolean doCloseData(String parentId, String id);
|
|
| 373 |
+// {
|
|
| 374 |
+// OpenableDtoUIContext<E> type = getModel().getType();
|
|
| 375 |
+// ClientDataContext dataContext = openAction.getDataContext();
|
|
| 376 |
+// boolean result = type.isOpen();
|
|
| 377 |
+// if (result) {
|
|
| 378 |
+// type.close(getModel().getSelectedId());
|
|
| 379 |
+// }
|
|
| 380 |
+// return result;
|
|
| 381 |
+// }
|
|
| 382 |
+//
|
|
| 383 |
+// protected abstract boolean doOpenData(String parentId, String id);
|
|
| 384 |
+// {
|
|
| 385 |
+// OpenableDtoUIContext<E> type = getModel().getType();
|
|
| 386 |
+// String id = getModel().getSelectedId();
|
|
| 387 |
+// boolean result = type.canOpen(id);
|
|
| 388 |
+// if (result) {
|
|
| 389 |
+// type.open(getModel().getSelectedParentId(), id);
|
|
| 390 |
+// }
|
|
| 391 |
+// return result;
|
|
| 392 |
+// }
|
|
| 367 | 393 |
|
| 368 |
- }
|
|
| 394 |
+// protected abstract void afterOpenData(String parentId, String id);
|
|
| 395 |
+// {
|
|
| 396 |
+// U ui = getUi();
|
|
| 397 |
+// // On charge les ensembles de références utilisées dans les combobox
|
|
| 398 |
+// getOpenAction().loadFormDependencies();
|
|
| 399 |
+// getOpenAction().updateUi();
|
|
| 400 |
+//
|
|
| 401 |
+// // on repaint le parent (le program devient alors ouvert)
|
|
| 402 |
+// NavigationTree treeHelper = openAction.getNavigationTree();
|
|
| 403 |
+// treeHelper.reloadSelectedNode(true, true);
|
|
| 404 |
+//
|
|
| 405 |
+// // on chage l'état 'canReopen' du model
|
|
| 406 |
+// ui.getModel().setCanReopen(false);
|
|
| 407 |
+//
|
|
| 408 |
+// // on lance l'édition
|
|
| 409 |
+// ui.restartEdit();
|
|
| 410 |
+// }
|
|
| 369 | 411 |
|
| 412 |
+// protected abstract void afterCloseData(String parentId, String id);
|
|
| 413 |
+// {
|
|
| 414 |
+// ContentOpenableUIModel<E> model = getModel();
|
|
| 415 |
+// model.setCanReopen(true);
|
|
| 416 |
+// E bean = getModel().getBean();
|
|
| 417 |
+// getUi().stopEdit();
|
|
| 418 |
+// model.setMode(FormUIMode.READ);
|
|
| 419 |
+//
|
|
| 420 |
+// getOpenAction().computeMessages();
|
|
| 421 |
+//
|
|
| 422 |
+// NavigationTree treeHelper = openAction.getNavigationTree();
|
|
| 423 |
+// treeHelper.reloadSelectedNode(IdHelper.isTrip(bean), true);
|
|
| 424 |
+// getOpenAction().updateActions();
|
|
| 425 |
+//
|
|
| 426 |
+// getOpenAction().grabFocusOnForm();
|
|
| 427 |
+// }
|
|
| 370 | 428 |
}
|
| ... | ... | @@ -30,6 +30,7 @@ import fr.ird.observe.client.spi.ClientDataContext; |
| 30 | 30 |
import fr.ird.observe.client.spi.context.DtoUIContext;
|
| 31 | 31 |
import fr.ird.observe.client.spi.context.OpenableDtoUIContext;
|
| 32 | 32 |
import fr.ird.observe.client.tools.ObserveOpenDataManager;
|
| 33 |
+import fr.ird.observe.client.tree.navigation.NavigationTree;
|
|
| 33 | 34 |
import fr.ird.observe.client.validation.ClientValidationContext;
|
| 34 | 35 |
import fr.ird.observe.dto.data.OpenableDto;
|
| 35 | 36 |
import fr.ird.observe.dto.data.seine.TripSeineDto;
|
| ... | ... | @@ -63,6 +64,7 @@ public abstract class ObserveOpenDataFormUIModel<D extends OpenableDto, R extend |
| 63 | 64 |
private final SingletonSupplier<ObserveSwingDataSource> dataSource;
|
| 64 | 65 |
private final SingletonSupplier<ObserveOpenDataManager> openDataManager;
|
| 65 | 66 |
private final SingletonSupplier<DecoratorService> decoratorService;
|
| 67 |
+ private final SingletonSupplier<NavigationTree> navigation;
|
|
| 66 | 68 |
|
| 67 | 69 |
public abstract void computeReadMessages(ClientDataContext dataContext, FormUIValidationMessageManager validationManager);
|
| 68 | 70 |
|
| ... | ... | @@ -73,10 +75,11 @@ public abstract class ObserveOpenDataFormUIModel<D extends OpenableDto, R extend |
| 73 | 75 |
public ObserveOpenDataFormUIModel(OpenableDtoUIContext<D, R> dtoContext, Supplier<S> service) {
|
| 74 | 76 |
super(dtoContext);
|
| 75 | 77 |
this.service = SingletonSupplier.of(service);
|
| 76 |
- dataSource = SingletonSupplier.of(ObserveClientApplicationContext.get().getDataSourcesManager()::getMainDataSource);
|
|
| 77 |
- openDataManager = SingletonSupplier.of(ObserveClientApplicationContext.get()::getOpenDataManager);
|
|
| 78 |
- decoratorService = SingletonSupplier.of(ObserveClientApplicationContext.get()::getDecoratorService);
|
|
| 79 |
- dataContext = SingletonSupplier.of(ObserveClientApplicationContext.get()::getDataContext);
|
|
| 78 |
+ dataSource = SingletonSupplier.of(() -> ObserveClientApplicationContext.get().getDataSourcesManager().getMainDataSource());
|
|
| 79 |
+ openDataManager = SingletonSupplier.of(() -> ObserveClientApplicationContext.get().getOpenDataManager());
|
|
| 80 |
+ decoratorService = SingletonSupplier.of(() -> ObserveClientApplicationContext.get().getDecoratorService());
|
|
| 81 |
+ dataContext = SingletonSupplier.of(() -> ObserveClientApplicationContext.get().getDataContext());
|
|
| 82 |
+ navigation = SingletonSupplier.of(() -> ObserveClientApplicationContext.get().getMainUI().getNavigation());
|
|
| 80 | 83 |
}
|
| 81 | 84 |
|
| 82 | 85 |
public final S getService() {
|
| ... | ... | @@ -99,6 +102,10 @@ public abstract class ObserveOpenDataFormUIModel<D extends OpenableDto, R extend |
| 99 | 102 |
return decoratorService.get();
|
| 100 | 103 |
}
|
| 101 | 104 |
|
| 105 |
+ public NavigationTree getNavigation() {
|
|
| 106 |
+ return navigation.get();
|
|
| 107 |
+ }
|
|
| 108 |
+ |
|
| 102 | 109 |
public void loadOrPreCreateForm() {
|
| 103 | 110 |
|
| 104 | 111 |
}
|
| ... | ... | @@ -122,6 +129,7 @@ public abstract class ObserveOpenDataFormUIModel<D extends OpenableDto, R extend |
| 122 | 129 |
setCanWrite();
|
| 123 | 130 |
setContentMode();
|
| 124 | 131 |
setForm();
|
| 132 |
+ setSelectedNode(getNavigation().getSelectedNode());
|
|
| 125 | 133 |
computeValidationMessages(validationManager);
|
| 126 | 134 |
}
|
| 127 | 135 |
|
| ... | ... | @@ -268,6 +276,4 @@ public abstract class ObserveOpenDataFormUIModel<D extends OpenableDto, R extend |
| 268 | 276 |
// public void obtainChildPosition() {
|
| 269 | 277 |
// position = getOpenCloseServiceAction().getDataPosition(getSelectedParentId(), getSelectedId());
|
| 270 | 278 |
// }
|
| 271 |
- |
|
| 272 |
- |
|
| 273 | 279 |
}
|
| ... | ... | @@ -31,7 +31,6 @@ import fr.ird.observe.dto.referential.seine.VesselActivitySeineReference; |
| 31 | 31 |
import java.util.List;
|
| 32 | 32 |
import java.util.Optional;
|
| 33 | 33 |
import javax.swing.SwingUtilities;
|
| 34 |
-import org.nuiton.jaxx.runtime.spi.UIHandler;
|
|
| 35 | 34 |
|
| 36 | 35 |
|
| 37 | 36 |
import static org.nuiton.i18n.I18n.t;
|
| ... | ... | @@ -40,7 +39,7 @@ import static org.nuiton.i18n.I18n.t; |
| 40 | 39 |
* @author Tony Chemit - dev@tchemit.fr
|
| 41 | 40 |
* @since 1.0
|
| 42 | 41 |
*/
|
| 43 |
-class ActivitySeineUIHandler extends ObserveOpenDataFormUIHandler<ActivitySeineDto, ActivitySeineReference, ActivitySeineUIModel, ActivitySeineUI> implements UIHandler<ActivitySeineUI> {
|
|
| 42 |
+class ActivitySeineUIHandler extends ObserveOpenDataFormUIHandler<ActivitySeineDto, ActivitySeineReference, ActivitySeineUIModel, ActivitySeineUI> {
|
|
| 44 | 43 |
|
| 45 | 44 |
ActivitySeineUIHandler() {
|
| 46 | 45 |
super();
|
| ... | ... | @@ -49,7 +48,6 @@ class ActivitySeineUIHandler extends ObserveOpenDataFormUIHandler<ActivitySeineD |
| 49 | 48 |
@Override
|
| 50 | 49 |
protected void initialize(ObserveFormUIInitializerContext<ActivitySeineUI> initializerContext) {
|
| 51 | 50 |
super.initialize(initializerContext);
|
| 52 |
- ActivitySeineUI ui = initializerContext.getUi();
|
|
| 53 | 51 |
String label = getActivity6Label();
|
| 54 | 52 |
String text = t("observe.common.ActivitySeineDto.vesselActivitySeine.comment", label);
|
| 55 | 53 |
ui.vesselActivityInformation.setText(text);
|
| ... | ... | @@ -23,9 +23,10 @@ package fr.ird.observe.client.form.openlist; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableMap;
|
| 26 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 26 | 27 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 27 | 28 |
import fr.ird.observe.client.form.ObserveFormUIInitializerContext;
|
| 28 |
-import fr.ird.observe.client.form.action.OpenCloseDataFormUIAction;
|
|
| 29 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 29 | 30 |
import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
| 30 | 31 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 31 | 32 |
import fr.ird.observe.client.tree.navigation.nodes.NavigationTreeNodeSupport;
|
| ... | ... | @@ -54,31 +55,57 @@ public abstract class ObserveOpenDataListFormUIHandler<D extends OpenableDto, R |
| 54 | 55 |
/** Logger. */
|
| 55 | 56 |
private static final Log log = LogFactory.getLog(ObserveOpenDataListFormUIHandler.class);
|
| 56 | 57 |
|
| 57 |
- private final OpenCloseDataFormUIAction<U> openCloseDataAction;
|
|
| 58 |
+ private final FormUIActionHandler openDataActionHandler = new FormUIActionHandler() {
|
|
| 58 | 59 |
|
| 59 |
- protected ObserveOpenDataListFormUIHandler() {
|
|
| 60 |
- this.openCloseDataAction = new OpenCloseDataFormUIAction<U>() {
|
|
| 60 |
+ @Override
|
|
| 61 |
+ public boolean before() {
|
|
| 62 |
+ return true;
|
|
| 63 |
+ }
|
|
| 61 | 64 |
|
| 62 |
- @Override
|
|
| 63 |
- protected boolean doOpenData(String parentId, String id) {
|
|
| 64 |
- return false;
|
|
| 65 |
- }
|
|
| 65 |
+ @Override
|
|
| 66 |
+ public void run() {
|
|
| 67 |
+ List<R> selectedData = model.getSelectedData();
|
|
| 68 |
+ String parentId = model.getSelectedParentId();
|
|
| 69 |
+ String id = selectedData.get(0).getId();
|
|
| 70 |
+ //FIXME!!!
|
|
| 71 |
+ }
|
|
| 66 | 72 |
|
| 67 |
- @Override
|
|
| 68 |
- protected void afterOpenData(String parentId, String id) {
|
|
| 73 |
+ @Override
|
|
| 74 |
+ public void after() {
|
|
| 69 | 75 |
|
| 70 |
- }
|
|
| 76 |
+ }
|
|
| 71 | 77 |
|
| 72 |
- @Override
|
|
| 73 |
- protected boolean doCloseData(String parentId, String id) {
|
|
| 74 |
- return false;
|
|
| 75 |
- }
|
|
| 78 |
+ @Override
|
|
| 79 |
+ public FormUI getUI() {
|
|
| 80 |
+ return ui;
|
|
| 81 |
+ }
|
|
| 82 |
+ };
|
|
| 83 |
+ private final FormUIActionHandler closeDataActionHandler = new FormUIActionHandler() {
|
|
| 84 |
+ |
|
| 85 |
+ @Override
|
|
| 86 |
+ public boolean before() {
|
|
| 87 |
+ return true;
|
|
| 88 |
+ }
|
|
| 76 | 89 |
|
| 77 |
- @Override
|
|
| 78 |
- protected void afterCloseData(String parentId, String id) {
|
|
| 90 |
+ @Override
|
|
| 91 |
+ public void run() {
|
|
| 92 |
+ String parentId = model.getSelectedParentId();
|
|
| 93 |
+ String id = model.getType().getOpenId();
|
|
| 94 |
+ //FIXME!!!
|
|
| 95 |
+ }
|
|
| 79 | 96 |
|
| 80 |
- }
|
|
| 81 |
- };
|
|
| 97 |
+ @Override
|
|
| 98 |
+ public void after() {
|
|
| 99 |
+ |
|
| 100 |
+ }
|
|
| 101 |
+ |
|
| 102 |
+ @Override
|
|
| 103 |
+ public FormUI getUI() {
|
|
| 104 |
+ return ui;
|
|
| 105 |
+ }
|
|
| 106 |
+ };
|
|
| 107 |
+ |
|
| 108 |
+ protected ObserveOpenDataListFormUIHandler() {
|
|
| 82 | 109 |
}
|
| 83 | 110 |
|
| 84 | 111 |
@Override
|
| ... | ... | @@ -88,7 +115,7 @@ public abstract class ObserveOpenDataListFormUIHandler<D extends OpenableDto, R |
| 88 | 115 |
|
| 89 | 116 |
@Override
|
| 90 | 117 |
protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
| 91 |
- validationManager = new FormUIValidationMessageManager(model.getChildType(), ui);
|
|
| 118 |
+ validationManager = new FormUIValidationMessageManager(model.getBeanType(), ui);
|
|
| 92 | 119 |
super.initialize(initializerContext);
|
| 93 | 120 |
|
| 94 | 121 |
OpenableDataDtoListCellRenderer<D, R> cellRenderer = new OpenableDataDtoListCellRenderer<>(ui.getList().getCellRenderer(), navigation);
|
| ... | ... | @@ -121,15 +148,14 @@ public abstract class ObserveOpenDataListFormUIHandler<D extends OpenableDto, R |
| 121 | 148 |
model.openUI(validationManager, navigation);
|
| 122 | 149 |
|
| 123 | 150 |
log.info(String.format("%s init ui", prefix));
|
| 124 |
- computeContentIcon();
|
|
| 125 | 151 |
updateToolbarActions();
|
| 126 |
- setTitle();
|
|
| 152 |
+ updateExtra();
|
|
| 127 | 153 |
grabFocusOnForm();
|
| 128 | 154 |
}
|
| 129 | 155 |
|
| 130 | 156 |
@Override
|
| 131 | 157 |
public void destroyUI() {
|
| 132 |
- |
|
| 158 |
+ //FIXME!!!
|
|
| 133 | 159 |
}
|
| 134 | 160 |
|
| 135 | 161 |
@Override
|
| ... | ... | @@ -139,14 +165,12 @@ public abstract class ObserveOpenDataListFormUIHandler<D extends OpenableDto, R |
| 139 | 165 |
|
| 140 | 166 |
@Override
|
| 141 | 167 |
public final void openData() {
|
| 142 |
- List<R> selectedData = model.getSelectedData();
|
|
| 143 |
- openCloseDataAction.openData(ui, model.getSelectedParentId(), selectedData.get(0).getId());
|
|
| 168 |
+ run(openDataActionHandler);
|
|
| 144 | 169 |
}
|
| 145 | 170 |
|
| 146 | 171 |
@Override
|
| 147 | 172 |
public final void closeData() {
|
| 148 |
- String selectedData = model.getType().getOpenId();
|
|
| 149 |
- openCloseDataAction.closeData(ui, model.getSelectedParentId(), selectedData);
|
|
| 173 |
+ run(closeDataActionHandler);
|
|
| 150 | 174 |
}
|
| 151 | 175 |
|
| 152 | 176 |
@Override
|
| ... | ... | @@ -163,11 +187,6 @@ public abstract class ObserveOpenDataListFormUIHandler<D extends OpenableDto, R |
| 163 | 187 |
//FIXME!!!
|
| 164 | 188 |
}
|
| 165 | 189 |
|
| 166 |
- protected void setTitle() {
|
|
| 167 |
- //FIXME!!!
|
|
| 168 |
- }
|
|
| 169 |
- |
|
| 170 |
- |
|
| 171 | 190 |
private void updateList(List<R> data) {
|
| 172 | 191 |
BeanListHeader<R> list = ui.getListHeader();
|
| 173 | 192 |
if (CollectionUtils.isNotEmpty(data)) {
|
| ... | ... | @@ -41,7 +41,7 @@ class TripLonglineListUIHandler extends ObserveOpenDataListFormUIHandler<TripLon |
| 41 | 41 |
}
|
| 42 | 42 |
|
| 43 | 43 |
@Override
|
| 44 |
- protected void setTitle() {
|
|
| 44 |
+ protected void updateExtra() {
|
|
| 45 | 45 |
TripLonglineListNavigationTreeNode selectedNode = (TripLonglineListNavigationTreeNode) navigation.getSelectedNode();
|
| 46 | 46 |
ProgramReference data = selectedNode.getData();
|
| 47 | 47 |
//FIXME!!!
|
| ... | ... | @@ -38,7 +38,7 @@ class TripSeineListUIHandler extends ObserveOpenDataListFormUIHandler<TripSeineD |
| 38 | 38 |
}
|
| 39 | 39 |
|
| 40 | 40 |
@Override
|
| 41 |
- protected void setTitle() {
|
|
| 41 |
+ protected void updateExtra() {
|
|
| 42 | 42 |
TripSeineListNavigationTreeNode selectedNode = (TripSeineListNavigationTreeNode) navigation.getSelectedNode();
|
| 43 | 43 |
ProgramReference data = selectedNode.getData();
|
| 44 | 44 |
String title = decoratorService.getReferentialReferenceDecorator(ProgramReference.class).toString(data);
|
| ... | ... | @@ -24,19 +24,19 @@ package fr.ird.observe.client.form.referential; |
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableMap;
|
| 26 | 26 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 27 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 27 | 28 |
import fr.ird.observe.client.form.FormUIMode;
|
| 28 | 29 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 29 | 30 |
import fr.ird.observe.client.form.ObserveFormUIInitializerContext;
|
| 30 |
-import fr.ird.observe.client.form.action.DeleteFormUIAction;
|
|
| 31 |
-import fr.ird.observe.client.form.action.EditFormUIAction;
|
|
| 31 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 32 | 32 |
import fr.ird.observe.client.form.referential.usage.UsageForDeleteUI;
|
| 33 | 33 |
import fr.ird.observe.client.form.referential.usage.UsageForDesactivateUI;
|
| 34 | 34 |
import fr.ird.observe.client.form.referential.usage.UsageForDisplayUI;
|
| 35 | 35 |
import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
| 36 | 36 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 37 |
-import fr.ird.observe.client.tree.navigation.NavigationTree;
|
|
| 38 | 37 |
import fr.ird.observe.client.util.UIHelper;
|
| 39 | 38 |
import fr.ird.observe.client.validation.ClientValidationContext;
|
| 39 |
+import fr.ird.observe.dto.IdHelper;
|
|
| 40 | 40 |
import fr.ird.observe.dto.decoration.DecoratorService;
|
| 41 | 41 |
import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
| 42 | 42 |
import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator;
|
| ... | ... | @@ -46,7 +46,6 @@ import fr.ird.observe.dto.referential.I18nReferentialDto; |
| 46 | 46 |
import fr.ird.observe.dto.referential.ProgramDto;
|
| 47 | 47 |
import fr.ird.observe.dto.referential.ProgramHelper;
|
| 48 | 48 |
import fr.ird.observe.dto.referential.ProgramReference;
|
| 49 |
-import fr.ird.observe.dto.referential.ReferenceStatus;
|
|
| 50 | 49 |
import fr.ird.observe.dto.referential.ReferentialDto;
|
| 51 | 50 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 52 | 51 |
import fr.ird.observe.services.service.referential.ReferentialService;
|
| ... | ... | @@ -99,10 +98,109 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 99 | 98 |
private final Runnable revalidate;
|
| 100 | 99 |
private final ReferentialLocale referentialLocale;
|
| 101 | 100 |
private final ReferentialService referentialService;
|
| 102 |
- private final DeleteFormUIAction<D, U> deleteAction;
|
|
| 103 |
- private final EditFormUIAction<D, U> editAction;
|
|
| 104 | 101 |
private R replaceReference;
|
| 105 | 102 |
|
| 103 |
+ private final FormUIActionHandler editActionHandler = new FormUIActionHandler() {
|
|
| 104 |
+ |
|
| 105 |
+ private D dto;
|
|
| 106 |
+ private boolean created;
|
|
| 107 |
+ |
|
| 108 |
+ @Override
|
|
| 109 |
+ public boolean before() {
|
|
| 110 |
+ dto = model.getBean();
|
|
| 111 |
+ created = dto.isNotPersisted();
|
|
| 112 |
+ return askToSave0(dto);
|
|
| 113 |
+ }
|
|
| 114 |
+ |
|
| 115 |
+ @Override
|
|
| 116 |
+ public void run() {
|
|
| 117 |
+ if (created) {
|
|
| 118 |
+ |
|
| 119 |
+ log.info(String.format("%s Create referential %s", prefix, dto));
|
|
| 120 |
+ |
|
| 121 |
+ model.save();
|
|
| 122 |
+ |
|
| 123 |
+ model.loadFormDependencies(dataSource, true);
|
|
| 124 |
+ |
|
| 125 |
+ return;
|
|
| 126 |
+ }
|
|
| 127 |
+ |
|
| 128 |
+ log.info(String.format("%s Update existing referential : %s", prefix, dto.getId()));
|
|
| 129 |
+ |
|
| 130 |
+ if (replaceReference != null) {
|
|
| 131 |
+ |
|
| 132 |
+ referentialService.replaceReference(model.getBeanType(), dto.getId(), replaceReference.getId());
|
|
| 133 |
+ }
|
|
| 134 |
+ |
|
| 135 |
+ model.save();
|
|
| 136 |
+ |
|
| 137 |
+ model.loadFormDependencies(dataSource, true);
|
|
| 138 |
+ }
|
|
| 139 |
+ |
|
| 140 |
+ @Override
|
|
| 141 |
+ public void after() {
|
|
| 142 |
+ model.updateUi();
|
|
| 143 |
+ |
|
| 144 |
+ if (dto instanceof ProgramDto) {
|
|
| 145 |
+ |
|
| 146 |
+ if (created) {
|
|
| 147 |
+ |
|
| 148 |
+ // add the program in tree
|
|
| 149 |
+ ProgramReference reference = ProgramDto.dtoContext().toReference(referentialLocale, (ProgramDto) dto);
|
|
| 150 |
+ navigation.addProgram(reference);
|
|
| 151 |
+ } else {
|
|
| 152 |
+ |
|
| 153 |
+ // update the program in tree
|
|
| 154 |
+ navigation.updateProgram((ProgramDto) dto);
|
|
| 155 |
+ }
|
|
| 156 |
+ }
|
|
| 157 |
+ }
|
|
| 158 |
+ |
|
| 159 |
+ @Override
|
|
| 160 |
+ public FormUI getUI() {
|
|
| 161 |
+ return ui;
|
|
| 162 |
+ }
|
|
| 163 |
+ };
|
|
| 164 |
+ |
|
| 165 |
+ private final FormUIActionHandler deleteActionHandler = new FormUIActionHandler() {
|
|
| 166 |
+ |
|
| 167 |
+ private String id;
|
|
| 168 |
+ |
|
| 169 |
+ @Override
|
|
| 170 |
+ public boolean before() {
|
|
| 171 |
+ id = model.getBean().getId();
|
|
| 172 |
+ return askToDelete0(model.getBean());
|
|
| 173 |
+ }
|
|
| 174 |
+ |
|
| 175 |
+ @Override
|
|
| 176 |
+ public void run() {
|
|
| 177 |
+ if (replaceReference != null) {
|
|
| 178 |
+ referentialService.replaceReference(model.getBeanType(), id, replaceReference.getId());
|
|
| 179 |
+ }
|
|
| 180 |
+ model.delete();
|
|
| 181 |
+ }
|
|
| 182 |
+ |
|
| 183 |
+ @Override
|
|
| 184 |
+ public void after() {
|
|
| 185 |
+ if (IdHelper.isProgramId(id)) {
|
|
| 186 |
+ |
|
| 187 |
+ // remove the program in tree
|
|
| 188 |
+ navigation.removeProgram(id);
|
|
| 189 |
+ }
|
|
| 190 |
+ |
|
| 191 |
+ model.loadFormDependencies(dataSource, true);
|
|
| 192 |
+ model.updateUi();
|
|
| 193 |
+ |
|
| 194 |
+ stopEdit();
|
|
| 195 |
+ validationManager.removeAllMessages();
|
|
| 196 |
+ }
|
|
| 197 |
+ |
|
| 198 |
+ @Override
|
|
| 199 |
+ public FormUI getUI() {
|
|
| 200 |
+ return ui;
|
|
| 201 |
+ }
|
|
| 202 |
+ };
|
|
| 203 |
+ |
|
| 106 | 204 |
protected ObserveReferentialFormUIHandler() {
|
| 107 | 205 |
revalidate = () -> {
|
| 108 | 206 |
|
| ... | ... | @@ -120,40 +218,6 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 120 | 218 |
};
|
| 121 | 219 |
referentialService = MAIN.getReferentialService();
|
| 122 | 220 |
referentialLocale = decoratorService.getReferentialLocale();
|
| 123 |
- deleteAction = new DeleteFormUIAction<D, U>() {
|
|
| 124 |
- |
|
| 125 |
- @Override
|
|
| 126 |
- protected boolean askToDelete(D dto) {
|
|
| 127 |
- return askToDelete0(dto);
|
|
| 128 |
- }
|
|
| 129 |
- |
|
| 130 |
- @Override
|
|
| 131 |
- protected void afterDelete(D dto) {
|
|
| 132 |
- afterDelete0(dto);
|
|
| 133 |
- }
|
|
| 134 |
- |
|
| 135 |
- @Override
|
|
| 136 |
- protected void doDelete(D dto) {
|
|
| 137 |
- doDelete0(dto);
|
|
| 138 |
- }
|
|
| 139 |
- };
|
|
| 140 |
- editAction = new EditFormUIAction<D, U>() {
|
|
| 141 |
- |
|
| 142 |
- @Override
|
|
| 143 |
- protected boolean askToSave(D dto) {
|
|
| 144 |
- return askToSave0(dto);
|
|
| 145 |
- }
|
|
| 146 |
- |
|
| 147 |
- @Override
|
|
| 148 |
- protected void afterSave(D dto, boolean created) {
|
|
| 149 |
- afterSave0(dto, created);
|
|
| 150 |
- }
|
|
| 151 |
- |
|
| 152 |
- @Override
|
|
| 153 |
- protected void doSave(D dto) {
|
|
| 154 |
- doSave0(dto);
|
|
| 155 |
- }
|
|
| 156 |
- };
|
|
| 157 | 221 |
}
|
| 158 | 222 |
|
| 159 | 223 |
|
| ... | ... | @@ -164,7 +228,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 164 | 228 |
|
| 165 | 229 |
@Override
|
| 166 | 230 |
protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
| 167 |
- validationManager = new FormUIValidationMessageManager(model.getDataType(), ui);
|
|
| 231 |
+ validationManager = new FormUIValidationMessageManager(model.getBeanType(), ui);
|
|
| 168 | 232 |
super.initialize(initializerContext);
|
| 169 | 233 |
ui.getViewLayout().addPropertyChangeListener(CardLayout2Ext.SELECTED_PROPERTY_NAME,
|
| 170 | 234 |
evt -> SwingUtilities.invokeLater(revalidate));
|
| ... | ... | @@ -180,17 +244,15 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 180 | 244 |
model.openUI(validationManager);
|
| 181 | 245 |
|
| 182 | 246 |
log.info(String.format("%s init ui", prefix));
|
| 183 |
- computeContentIcon();
|
|
| 184 | 247 |
updateToolbarActions();
|
| 185 |
- setTitle(navigation);
|
|
| 186 | 248 |
updateExtra();
|
| 187 | 249 |
grabFocusOnForm();
|
| 188 | 250 |
}
|
| 189 | 251 |
|
| 252 |
+ @Override
|
|
| 253 |
+ protected void updateExtra() {
|
|
| 190 | 254 |
|
| 191 |
- private void updateExtra() {
|
|
| 192 |
- |
|
| 193 |
- if (I18nReferentialDto.class.isAssignableFrom(model.getDataType())) {
|
|
| 255 |
+ if (I18nReferentialDto.class.isAssignableFrom(model.getBeanType())) {
|
|
| 194 | 256 |
// on met en gras le libelle selectionne en base
|
| 195 | 257 |
|
| 196 | 258 |
ReferentialLocale localeEnum;
|
| ... | ... | @@ -227,15 +289,6 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 227 | 289 |
}
|
| 228 | 290 |
}
|
| 229 | 291 |
|
| 230 |
- protected void setTitle(NavigationTree treeHelper) {
|
|
| 231 |
- //FIXME!!!
|
|
| 232 |
- }
|
|
| 233 |
- |
|
| 234 |
- @Override
|
|
| 235 |
- public U getUi() {
|
|
| 236 |
- return ui;
|
|
| 237 |
- }
|
|
| 238 |
- |
|
| 239 | 292 |
@Override
|
| 240 | 293 |
public void destroyUI() {
|
| 241 | 294 |
//FIXME!!!
|
| ... | ... | @@ -249,7 +302,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 249 | 302 |
|
| 250 | 303 |
@Override
|
| 251 | 304 |
public final void saveEdit() {
|
| 252 |
- editAction.save(ui, model.getBean());
|
|
| 305 |
+ run(editActionHandler);
|
|
| 253 | 306 |
}
|
| 254 | 307 |
|
| 255 | 308 |
@Override
|
| ... | ... | @@ -261,7 +314,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 261 | 314 |
|
| 262 | 315 |
} else {
|
| 263 | 316 |
|
| 264 |
- Form<D> form = getMainService().loadForm(model.getDataType(), selectedReference.getId());
|
|
| 317 |
+ Form<D> form = getMainService().loadForm(model.getBeanType(), selectedReference.getId());
|
|
| 265 | 318 |
|
| 266 | 319 |
D selectedBean = form.getObject();
|
| 267 | 320 |
|
| ... | ... | @@ -286,7 +339,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 286 | 339 |
|
| 287 | 340 |
@Override
|
| 288 | 341 |
public void showUniqueKeys(JButton button) {
|
| 289 |
- Class<D> beanType = model.getDataType();
|
|
| 342 |
+ Class<D> beanType = model.getBeanType();
|
|
| 290 | 343 |
|
| 291 | 344 |
Class<R> referenceType = model.getReferenceType();
|
| 292 | 345 |
List<R> entities = model.getReferentialReferences(referenceType);
|
| ... | ... | @@ -384,7 +437,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 384 | 437 |
ImmutableSetDtoMap<ReferentialDtoReference> usages = getMainService().findAllUsages(bean);
|
| 385 | 438 |
|
| 386 | 439 |
ReferentialReferenceDecorator<R> decorator = decoratorService.getReferentialReferenceDecorator(model.getReferenceType());
|
| 387 |
- String type = ObserveI18nDecoratorHelper.getTypeI18nKey(model.getDataType());
|
|
| 440 |
+ String type = ObserveI18nDecoratorHelper.getTypeI18nKey(model.getBeanType());
|
|
| 388 | 441 |
type = t(type);
|
| 389 | 442 |
String message = t("observe.message.show.usages", type, decorator.toString(bean));
|
| 390 | 443 |
|
| ... | ... | @@ -422,13 +475,14 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 422 | 475 |
model.setMode(FormUIMode.CREATE);
|
| 423 | 476 |
|
| 424 | 477 |
if (log.isDebugEnabled()) {
|
| 425 |
- log.debug("Will create new entity [" + model.getDataType().getName() + "]");
|
|
| 478 |
+ log.debug("Will create new entity [" + model.getBeanType().getName() + "]");
|
|
| 426 | 479 |
}
|
| 427 | 480 |
|
| 428 | 481 |
model.copyBean(null);
|
| 429 | 482 |
startEdit();
|
| 430 | 483 |
}
|
| 431 | 484 |
|
| 485 |
+ @Override
|
|
| 432 | 486 |
public void startEdit() {
|
| 433 | 487 |
|
| 434 | 488 |
FormUIMode mode = model.getMode();
|
| ... | ... | @@ -535,7 +589,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 535 | 589 |
|
| 536 | 590 |
@Override
|
| 537 | 591 |
public void deleteData() {
|
| 538 |
- deleteAction.delete(ui, model.getBean());
|
|
| 592 |
+ run(deleteActionHandler);
|
|
| 539 | 593 |
}
|
| 540 | 594 |
|
| 541 | 595 |
private void updateView(boolean editing) {
|
| ... | ... | @@ -545,7 +599,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 545 | 599 |
ui.getViewLayout().setSelected(editing ? ReferentialFormUI.DETAIL_VIEW : ReferentialFormUI.LIST_VIEW);
|
| 546 | 600 |
}
|
| 547 | 601 |
|
| 548 |
- protected boolean canSave(String parentId, D bean) {
|
|
| 602 |
+ private boolean askToSave0(D bean) {
|
|
| 549 | 603 |
|
| 550 | 604 |
if (model.isCreatingMode()) {
|
| 551 | 605 |
return true;
|
| ... | ... | @@ -556,9 +610,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 556 | 610 |
|
| 557 | 611 |
replaceReference = null;
|
| 558 | 612 |
|
| 559 |
- if (oldBean != null &&
|
|
| 560 |
- oldBean.getStatus() == ReferenceStatus.enabled &&
|
|
| 561 |
- bean.getStatus() == ReferenceStatus.disabled) {
|
|
| 613 |
+ if (oldBean != null && oldBean.isEnabled() && !bean.isEnabled()) {
|
|
| 562 | 614 |
|
| 563 | 615 |
// l'entite a ete desactive
|
| 564 | 616 |
// on recherche les objets utilisant cette entitee
|
| ... | ... | @@ -584,7 +636,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 584 | 636 |
.filter(r -> !bean.getId().equals(r.getId()))
|
| 585 | 637 |
.collect(Collectors.toList());
|
| 586 | 638 |
|
| 587 |
- if (ProgramDto.class.equals(model.getDataType())) {
|
|
| 639 |
+ if (ProgramDto.class.equals(model.getBeanType())) {
|
|
| 588 | 640 |
referenceList = (List) ProgramHelper.filterGearType((List) referenceList, ((ProgramDto) model.getBean()).getGearType());
|
| 589 | 641 |
}
|
| 590 | 642 |
|
| ... | ... | @@ -669,7 +721,7 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 669 | 721 |
.filter(r -> !dto.getId().equals(r.getId()))
|
| 670 | 722 |
.collect(Collectors.toList());
|
| 671 | 723 |
|
| 672 |
- if (ProgramDto.class.equals(model.getDataType())) {
|
|
| 724 |
+ if (ProgramDto.class.equals(model.getBeanType())) {
|
|
| 673 | 725 |
referenceList = (List) ProgramHelper.filterGearType((List) referenceList, ((ProgramDto) model.getBean()).getGearType());
|
| 674 | 726 |
}
|
| 675 | 727 |
if (log.isDebugEnabled()) {
|
| ... | ... | @@ -694,35 +746,12 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 694 | 746 |
}
|
| 695 | 747 |
}
|
| 696 | 748 |
|
| 697 |
- if (!ObserveFormUIHandler.confirmForEntityDelete(model.getDataType(), dto)) {
|
|
| 749 |
+ if (!ObserveFormUIHandler.confirmForEntityDelete(model.getBeanType(), dto)) {
|
|
| 698 | 750 |
return false;
|
| 699 | 751 |
}
|
| 700 | 752 |
return true;
|
| 701 | 753 |
}
|
| 702 | 754 |
|
| 703 |
- private void doDelete0(D dto) {
|
|
| 704 |
- String id = dto.getId();
|
|
| 705 |
- if (replaceReference != null) {
|
|
| 706 |
- referentialService.replaceReference(model.getDataType(), id, replaceReference.getId());
|
|
| 707 |
- }
|
|
| 708 |
- model.delete();
|
|
| 709 |
- }
|
|
| 710 |
- |
|
| 711 |
- private void afterDelete0(D dto) {
|
|
| 712 |
- if (dto instanceof ProgramDto) {
|
|
| 713 |
- |
|
| 714 |
- // remove the program in tree
|
|
| 715 |
- navigation.removeProgram(dto.getId());
|
|
| 716 |
- }
|
|
| 717 |
- |
|
| 718 |
- model.loadFormDependencies(dataSource, true);
|
|
| 719 |
- model.updateUi();
|
|
| 720 |
- |
|
| 721 |
- stopEdit();
|
|
| 722 |
- validationManager.removeAllMessages();
|
|
| 723 |
- }
|
|
| 724 |
- |
|
| 725 |
- |
|
| 726 | 755 |
private <E extends ReferentialDto, R extends ReferentialDtoReference<E, R>> Pair<Boolean, R> showUsagesForDelete(E entity,
|
| 727 | 756 |
ImmutableSetDtoMap<ReferentialDtoReference> usages,
|
| 728 | 757 |
List<R> referenceList) {
|
| ... | ... | @@ -757,51 +786,4 @@ public abstract class ObserveReferentialFormUIHandler<D extends ReferentialDto, |
| 757 | 786 |
return Pair.of(false, null);
|
| 758 | 787 |
}
|
| 759 | 788 |
|
| 760 |
- |
|
| 761 |
- private boolean askToSave0(D dto) {
|
|
| 762 |
- return true;
|
|
| 763 |
- }
|
|
| 764 |
- |
|
| 765 |
- private void doSave0(D dto) {
|
|
| 766 |
- if (model.isCreatingMode()) {
|
|
| 767 |
- |
|
| 768 |
- log.info(String.format("%s Create referential %s", prefix, dto));
|
|
| 769 |
- |
|
| 770 |
- model.save();
|
|
| 771 |
- |
|
| 772 |
- model.loadFormDependencies(dataSource, true);
|
|
| 773 |
- |
|
| 774 |
- return;
|
|
| 775 |
- }
|
|
| 776 |
- |
|
| 777 |
- log.info(String.format("%s Update existing referential : %s", prefix, dto.getId()));
|
|
| 778 |
- |
|
| 779 |
- if (replaceReference != null) {
|
|
| 780 |
- |
|
| 781 |
- referentialService.replaceReference(model.getDataType(), dto.getId(), replaceReference.getId());
|
|
| 782 |
- }
|
|
| 783 |
- |
|
| 784 |
- model.save();
|
|
| 785 |
- |
|
| 786 |
- model.loadFormDependencies(dataSource, true);
|
|
| 787 |
- }
|
|
| 788 |
- |
|
| 789 |
- private void afterSave0(D dto, boolean created) {
|
|
| 790 |
- model.updateUi();
|
|
| 791 |
- |
|
| 792 |
- if (dto instanceof ProgramDto) {
|
|
| 793 |
- |
|
| 794 |
- if (created) {
|
|
| 795 |
- |
|
| 796 |
- // add the program in tree
|
|
| 797 |
- ProgramReference reference = ProgramDto.dtoContext().toReference(referentialLocale, (ProgramDto) dto);
|
|
| 798 |
- navigation.addProgram(reference);
|
|
| 799 |
- } else {
|
|
| 800 |
- |
|
| 801 |
- // update the program in tree
|
|
| 802 |
- navigation.updateProgram((ProgramDto) dto);
|
|
| 803 |
- }
|
|
| 804 |
- }
|
|
| 805 |
- |
|
| 806 |
- }
|
|
| 807 | 789 |
}
|
| ... | ... | @@ -130,7 +130,7 @@ public abstract class ObserveReferentialFormUIModel<D extends ReferentialDto, R |
| 130 | 130 |
}
|
| 131 | 131 |
|
| 132 | 132 |
public void delete() {
|
| 133 |
- getService().delete(getDataType(), getBean().getId());
|
|
| 133 |
+ getService().delete(getBeanType(), getBean().getId());
|
|
| 134 | 134 |
}
|
| 135 | 135 |
|
| 136 | 136 |
public void openUI(FormUIValidationMessageManager validationManager) {
|
| ... | ... | @@ -22,13 +22,12 @@ package fr.ird.observe.client.form.simple; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 25 | 26 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 27 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 26 | 28 |
import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
| 27 |
-import fr.ird.observe.client.util.UIHelper;
|
|
| 29 |
+import fr.ird.observe.client.tree.navigation.nodes.NavigationTreeNodeSupport;
|
|
| 28 | 30 |
import fr.ird.observe.dto.data.DataDto;
|
| 29 |
-import fr.ird.observe.services.action.DeleteServiceAction;
|
|
| 30 |
-import fr.ird.observe.services.action.SaveDtoServiceAction;
|
|
| 31 |
-import fr.ird.observe.services.service.ObserveService;
|
|
| 32 | 31 |
|
| 33 | 32 |
/**
|
| 34 | 33 |
* Created by tchemit on 02/10/17.
|
| ... | ... | @@ -41,26 +40,34 @@ public abstract class ObserveMainDataFormUIHandler<D extends DataDto, M extends |
| 41 | 40 |
super();
|
| 42 | 41 |
}
|
| 43 | 42 |
|
| 44 |
- public final void delete() {
|
|
| 45 |
- boolean ok = false;
|
|
| 46 |
- stopEdit();
|
|
| 47 |
- validationManager.removeAllMessages();
|
|
| 43 |
+ private final FormUIActionHandler deleteActionHandler = new FormUIActionHandler() {
|
|
| 44 |
+ |
|
| 45 |
+ private String id;
|
|
| 46 |
+ |
|
| 47 |
+ @Override
|
|
| 48 |
+ public boolean before() {
|
|
| 49 |
+ id = model.getBean().getId();
|
|
| 50 |
+ return askToDelete(model.getBean());
|
|
| 51 |
+ }
|
|
| 48 | 52 |
|
| 49 |
- try {
|
|
| 50 |
- ok = askToDelete(getBean());
|
|
| 51 |
- if (ok) {
|
|
| 52 |
- doDelete(model.getSelectedParentId(), model.getBean());
|
|
| 53 |
- } else {
|
|
| 54 |
- restartEditUI();
|
|
| 55 |
- }
|
|
| 56 |
- } catch (Exception e) {
|
|
| 57 |
- UIHelper.handlingError(e);
|
|
| 58 |
- } finally {
|
|
| 59 |
- if (ok) {
|
|
| 60 |
- dataSource.setModified(true);
|
|
| 61 |
- afterDelete(validationManager);
|
|
| 62 |
- }
|
|
| 53 |
+ @Override
|
|
| 54 |
+ public void run() {
|
|
| 55 |
+ doDelete(model.getSelectedParentId(), model.getBean());
|
|
| 63 | 56 |
}
|
| 57 |
+ |
|
| 58 |
+ @Override
|
|
| 59 |
+ public void after() {
|
|
| 60 |
+ afterDelete(validationManager);
|
|
| 61 |
+ }
|
|
| 62 |
+ |
|
| 63 |
+ @Override
|
|
| 64 |
+ public FormUI getUI() {
|
|
| 65 |
+ return ui;
|
|
| 66 |
+ }
|
|
| 67 |
+ };
|
|
| 68 |
+ |
|
| 69 |
+ public final void delete() {
|
|
| 70 |
+ run(deleteActionHandler);
|
|
| 64 | 71 |
}
|
| 65 | 72 |
|
| 66 | 73 |
protected void doDelete(String parentId, D bean) {
|
| ... | ... | @@ -70,19 +77,14 @@ public abstract class ObserveMainDataFormUIHandler<D extends DataDto, M extends |
| 70 | 77 |
protected void afterDelete(FormUIValidationMessageManager validationManager) {
|
| 71 | 78 |
stopEdit();
|
| 72 | 79 |
validationManager.removeAllMessages();
|
| 73 |
- //FIXME!!! Place this on referential ui
|
|
| 74 |
-// if (!(getModel().getBean() instanceof ReferentialDto)) {
|
|
| 75 |
-//
|
|
| 76 |
-// NavigationTree navigation = getOpenAction().getNavigationTree();
|
|
| 77 |
-// NavigationTreeNodeSupport node = navigation .getSelectedNode();
|
|
| 78 |
-// NavigationTreeNodeSupport parentNode = node.getParent();
|
|
| 79 |
-// navigation .removeNode(node);
|
|
| 80 |
-// navigation .selectNode(parentNode);
|
|
| 81 |
-// }
|
|
| 80 |
+ NavigationTreeNodeSupport node = navigation.getSelectedNode();
|
|
| 81 |
+ NavigationTreeNodeSupport parentNode = node.getParent();
|
|
| 82 |
+ navigation.removeNode(node);
|
|
| 83 |
+ navigation.selectNode(parentNode);
|
|
| 82 | 84 |
}
|
| 83 | 85 |
|
| 84 | 86 |
protected boolean askToDelete(D bean) {
|
| 85 |
- return !ObserveFormUIHandler.confirmForEntityDelete(model.getDataType(), bean);
|
|
| 87 |
+ return !ObserveFormUIHandler.confirmForEntityDelete(model.getBeanType(), bean);
|
|
| 86 | 88 |
}
|
| 87 | 89 |
|
| 88 | 90 |
}
|
| ... | ... | @@ -23,13 +23,13 @@ package fr.ird.observe.client.form.simple; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableMap;
|
| 26 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 26 | 27 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 27 | 28 |
import fr.ird.observe.client.form.ObserveFormUIInitializerContext;
|
| 28 |
-import fr.ird.observe.client.form.action.EditFormUIAction;
|
|
| 29 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 29 | 30 |
import fr.ird.observe.client.form.openlist.ObserveOpenDataListFormUIHandler;
|
| 30 | 31 |
import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
| 31 | 32 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 32 |
-import fr.ird.observe.client.tree.navigation.NavigationTree;
|
|
| 33 | 33 |
import fr.ird.observe.dto.data.DataDto;
|
| 34 | 34 |
import org.apache.commons.logging.Log;
|
| 35 | 35 |
import org.apache.commons.logging.LogFactory;
|
| ... | ... | @@ -45,30 +45,33 @@ public abstract class ObserveSimpleDataFormUIHandler<D extends DataDto, M extend |
| 45 | 45 |
/** Logger. */
|
| 46 | 46 |
private static final Log log = LogFactory.getLog(ObserveOpenDataListFormUIHandler.class);
|
| 47 | 47 |
|
| 48 |
- private final EditFormUIAction<D, U> editAction;
|
|
| 48 |
+ private final FormUIActionHandler editActionHandler = new FormUIActionHandler() {
|
|
| 49 |
+ private boolean created;
|
|
| 49 | 50 |
|
| 50 |
- protected ObserveSimpleDataFormUIHandler() {
|
|
| 51 |
- editAction = new EditFormUIAction<D, U>() {
|
|
| 51 |
+ @Override
|
|
| 52 |
+ public boolean before() {
|
|
| 53 |
+ created = model.getBean().isNotPersisted();
|
|
| 54 |
+ return askToSave0(model.getBean());
|
|
| 55 |
+ }
|
|
| 52 | 56 |
|
| 53 |
- @Override
|
|
| 54 |
- protected boolean askToSave(D dto) {
|
|
| 55 |
- return askToSave0(dto);
|
|
| 56 |
- }
|
|
| 57 |
+ @Override
|
|
| 58 |
+ public void run() {
|
|
| 59 |
+ doSave0(model.getSelectedParentId(), model.getBean());
|
|
| 60 |
+ }
|
|
| 57 | 61 |
|
| 58 |
- @Override
|
|
| 59 |
- protected void afterSave(D dto, boolean created) {
|
|
| 60 |
- afterSave0(dto, created);
|
|
| 61 |
- }
|
|
| 62 |
+ @Override
|
|
| 63 |
+ public void after() {
|
|
| 64 |
+ afterSave0(model.getBean(), created);
|
|
| 65 |
+ }
|
|
| 62 | 66 |
|
| 63 |
- @Override
|
|
| 64 |
- protected void doSave(D dto) {
|
|
| 65 |
- doSave0(model.getSelectedParentId(), dto);
|
|
| 66 |
- }
|
|
| 67 |
- };
|
|
| 68 |
- }
|
|
| 67 |
+ @Override
|
|
| 68 |
+ public FormUI getUI() {
|
|
| 69 |
+ return ui;
|
|
| 70 |
+ }
|
|
| 71 |
+ };
|
|
| 69 | 72 |
|
| 70 | 73 |
protected void doSave0(String parentId, D dto) {
|
| 71 |
- model.save();
|
|
| 74 |
+ run(editActionHandler);
|
|
| 72 | 75 |
}
|
| 73 | 76 |
|
| 74 | 77 |
protected boolean askToSave0(D bean) {
|
| ... | ... | @@ -82,7 +85,7 @@ public abstract class ObserveSimpleDataFormUIHandler<D extends DataDto, M extend |
| 82 | 85 |
|
| 83 | 86 |
@Override
|
| 84 | 87 |
protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
| 85 |
- validationManager = new FormUIValidationMessageManager(model.getDataType(), ui);
|
|
| 88 |
+ validationManager = new FormUIValidationMessageManager(model.getBeanType(), ui);
|
|
| 86 | 89 |
super.initialize(initializerContext);
|
| 87 | 90 |
}
|
| 88 | 91 |
|
| ... | ... | @@ -95,9 +98,7 @@ public abstract class ObserveSimpleDataFormUIHandler<D extends DataDto, M extend |
| 95 | 98 |
model.openUI(validationManager);
|
| 96 | 99 |
|
| 97 | 100 |
log.info(String.format("%s init ui", prefix));
|
| 98 |
- computeContentIcon();
|
|
| 99 | 101 |
updateToolbarActions();
|
| 100 |
- setTitle(mainUI.getNavigation());
|
|
| 101 | 102 |
grabFocusOnForm();
|
| 102 | 103 |
}
|
| 103 | 104 |
|
| ... | ... | @@ -113,18 +114,9 @@ public abstract class ObserveSimpleDataFormUIHandler<D extends DataDto, M extend |
| 113 | 114 |
//FIXME!!!
|
| 114 | 115 |
}
|
| 115 | 116 |
|
| 116 |
- protected void setTitle(NavigationTree treeHelper) {
|
|
| 117 |
- //FIXME!!!
|
|
| 118 |
- }
|
|
| 119 |
- |
|
| 120 |
- @Override
|
|
| 121 |
- public U getUi() {
|
|
| 122 |
- return ui;
|
|
| 123 |
- }
|
|
| 124 |
- |
|
| 125 | 117 |
@Override
|
| 126 | 118 |
public void destroyUI() {
|
| 127 |
- |
|
| 119 |
+ //FIXME!!!
|
|
| 128 | 120 |
}
|
| 129 | 121 |
|
| 130 | 122 |
@Override
|
| ... | ... | @@ -139,47 +131,18 @@ public abstract class ObserveSimpleDataFormUIHandler<D extends DataDto, M extend |
| 139 | 131 |
|
| 140 | 132 |
@Override
|
| 141 | 133 |
public void saveEdit() {
|
| 142 |
- editAction.save(ui, getBean());
|
|
| 143 |
- }
|
|
| 144 |
- |
|
| 145 |
- protected void attachValidators(D bean) {
|
|
| 146 |
-//FIXME!!!
|
|
| 147 |
- }
|
|
| 148 |
- |
|
| 149 |
- protected void updateExtra() {
|
|
| 150 |
- |
|
| 134 |
+ run(editActionHandler);
|
|
| 151 | 135 |
}
|
| 152 | 136 |
|
| 153 | 137 |
public void afterSave0(D dto, boolean created) {
|
| 154 | 138 |
|
| 155 | 139 |
dataSource.setModified(true);
|
| 156 | 140 |
|
| 157 |
- // mettre les validateurs en mode non modifié
|
|
| 158 | 141 |
SwingValidatorUtil.setValidatorChanged(ui, false);
|
| 159 | 142 |
}
|
| 160 | 143 |
|
| 161 | 144 |
public D getBean() {
|
| 162 | 145 |
return model.getBean();
|
| 163 | 146 |
}
|
| 164 |
- |
|
| 165 |
-// public final void save(boolean refresh) {
|
|
| 166 |
-// boolean ok = askToSave0(model.getBean());
|
|
| 167 |
-// if (!ok) {
|
|
| 168 |
-// // use cancel save
|
|
| 169 |
-// return;
|
|
| 170 |
-// }
|
|
| 171 |
-// try {
|
|
| 172 |
-// doSave(model.getSelectedParentId(), model.getBean(), openDataManager);
|
|
| 173 |
-// } catch (Exception e) {
|
|
| 174 |
-// UIHelper.handlingError(e);
|
|
| 175 |
-// ok = false;
|
|
| 176 |
-// } finally {
|
|
| 177 |
-// if (ok) {
|
|
| 178 |
-// dataSource.setModified(true);
|
|
| 179 |
-// afterSave0(refresh);
|
|
| 180 |
-// }
|
|
| 181 |
-// }
|
|
| 182 |
-// }
|
|
| 183 |
- |
|
| 184 | 147 |
}
|
| 185 | 148 |
|
| ... | ... | @@ -24,18 +24,15 @@ package fr.ird.observe.client.form.simplelist; |
| 24 | 24 |
|
| 25 | 25 |
import com.google.common.collect.ImmutableMap;
|
| 26 | 26 |
import com.google.common.collect.ImmutableSet;
|
| 27 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 27 | 28 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 28 | 29 |
import fr.ird.observe.client.form.ObserveFormUIInitializerContext;
|
| 29 |
-import fr.ird.observe.client.form.action.EditDataListFormUIAction;
|
|
| 30 |
-import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
|
| 30 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 31 | 31 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 32 | 32 |
import fr.ird.observe.client.form.spi.init.CoordinatesEditorInitializer;
|
| 33 | 33 |
import fr.ird.observe.client.form.spi.init.TabInfoInitializer;
|
| 34 |
-import fr.ird.observe.client.tree.navigation.NavigationTree;
|
|
| 35 | 34 |
import fr.ird.observe.dto.data.DataDto;
|
| 36 | 35 |
import fr.ird.observe.dto.data.DataListDto;
|
| 37 |
-import fr.ird.observe.services.action.SaveDataListDtoServiceAction;
|
|
| 38 |
-import fr.ird.observe.services.action.SaveRequestDto;
|
|
| 39 | 36 |
import java.util.Optional;
|
| 40 | 37 |
import org.apache.commons.logging.Log;
|
| 41 | 38 |
import org.apache.commons.logging.LogFactory;
|
| ... | ... | @@ -54,39 +51,29 @@ public abstract class ObserveSimpleDataListFormUIHandler<D extends DataDto, C ex |
| 54 | 51 |
/** Logger. */
|
| 55 | 52 |
private static final Log log = LogFactory.getLog(ObserveSimpleDataListFormUIHandler.class);
|
| 56 | 53 |
|
| 57 |
- private final EditDataListFormUIAction<D, C, U> editAction;
|
|
| 54 |
+ private final FormUIActionHandler editActionHandler = new FormUIActionHandler() {
|
|
| 55 |
+ @Override
|
|
| 56 |
+ public boolean before() {
|
|
| 57 |
+ return checkEdit();
|
|
| 58 |
+ }
|
|
| 58 | 59 |
|
| 59 |
- protected ObserveSimpleDataListFormUIHandler() {
|
|
| 60 |
- editAction = new EditDataListFormUIAction<D, C, U>() {
|
|
| 61 |
- |
|
| 62 |
- @Override
|
|
| 63 |
- protected boolean askToSave(DataListDto<D, C> dto) {
|
|
| 64 |
- return askToSave0(dto);
|
|
| 65 |
- }
|
|
| 66 |
- |
|
| 67 |
- @Override
|
|
| 68 |
- protected void afterSave(DataListDto<D, C> dto, boolean created) {
|
|
| 69 |
- afterSave0(dto, created);
|
|
| 70 |
- }
|
|
| 71 |
- |
|
| 72 |
- @Override
|
|
| 73 |
- protected void doSave(DataListDto<D, C> dto) {
|
|
| 74 |
- model.save();
|
|
| 75 |
- }
|
|
| 76 |
- };
|
|
| 77 |
- }
|
|
| 60 |
+ @Override
|
|
| 61 |
+ public void run() {
|
|
| 62 |
+ model.save();
|
|
| 63 |
+ }
|
|
| 78 | 64 |
|
| 79 |
- private void doSave0(SaveDataListDtoServiceAction<D, C> saveServiceAction, DataListDto<D, C> dto) {
|
|
| 80 |
- saveServiceAction.save(SaveRequestDto.of(dto));
|
|
| 81 |
- }
|
|
| 65 |
+ @Override
|
|
| 66 |
+ public void after() {
|
|
| 67 |
+ afterSave0();
|
|
| 68 |
+ }
|
|
| 82 | 69 |
|
| 83 |
- private void afterSave0(DataListDto<D, C> dto, boolean created) {
|
|
| 84 |
- dataSource.setModified(true);
|
|
| 85 |
- SwingValidatorUtil.setValidatorChanged(ui, false);
|
|
| 86 |
- }
|
|
| 70 |
+ @Override
|
|
| 71 |
+ public FormUI getUI() {
|
|
| 72 |
+ return ui;
|
|
| 73 |
+ }
|
|
| 74 |
+ };
|
|
| 87 | 75 |
|
| 88 |
- private boolean askToSave0(DataListDto<D, C> dto) {
|
|
| 89 |
- return checkEdit();
|
|
| 76 |
+ protected ObserveSimpleDataListFormUIHandler() {
|
|
| 90 | 77 |
}
|
| 91 | 78 |
|
| 92 | 79 |
@Override
|
| ... | ... | @@ -95,13 +82,7 @@ public abstract class ObserveSimpleDataListFormUIHandler<D extends DataDto, C ex |
| 95 | 82 |
}
|
| 96 | 83 |
|
| 97 | 84 |
@Override
|
| 98 |
- protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
|
| 99 |
- validationManager = new FormUIValidationMessageManager(model.getDataType(), ui);
|
|
| 100 |
- super.initialize(initializerContext);
|
|
| 101 |
- }
|
|
| 102 |
- |
|
| 103 |
- @Override
|
|
| 104 |
- public void openUI() {
|
|
| 85 |
+ public final void openUI() {
|
|
| 105 | 86 |
|
| 106 | 87 |
resetValidationContext();
|
| 107 | 88 |
|
| ... | ... | @@ -115,9 +96,7 @@ public abstract class ObserveSimpleDataListFormUIHandler<D extends DataDto, C ex |
| 115 | 96 |
tabModels.ifPresent(e -> TabInfoInitializer.onOpenUi(ui, e));
|
| 116 | 97 |
|
| 117 | 98 |
log.info(String.format("%s init ui", prefix));
|
| 118 |
- computeContentIcon();
|
|
| 119 | 99 |
updateToolbarActions();
|
| 120 |
- setTitle(navigation);
|
|
| 121 | 100 |
updateExtra();
|
| 122 | 101 |
|
| 123 | 102 |
if (!model.isReadingMode()) {
|
| ... | ... | @@ -127,81 +106,53 @@ public abstract class ObserveSimpleDataListFormUIHandler<D extends DataDto, C ex |
| 127 | 106 |
grabFocusOnForm();
|
| 128 | 107 |
}
|
| 129 | 108 |
|
| 130 |
- public void startEdit() {
|
|
| 131 |
- prepareValidationContext();
|
|
| 132 |
- setEditing();
|
|
| 133 |
- attachValidators(getBean());
|
|
| 109 |
+ private void afterSave0() {
|
|
| 110 |
+ dataSource.setModified(true);
|
|
| 111 |
+ SwingValidatorUtil.setValidatorChanged(ui, false);
|
|
| 134 | 112 |
}
|
| 135 | 113 |
|
| 136 |
- public void stopEdit() {
|
|
| 137 |
- //FIXME!!!
|
|
| 138 |
- }
|
|
| 114 |
+ @Override
|
|
| 115 |
+ public final void startEdit() {
|
|
| 116 |
+ prepareValidationContext();
|
|
| 139 | 117 |
|
| 140 |
- public void restartEditUI() {
|
|
| 141 |
- //FIXME!!!
|
|
| 142 |
- }
|
|
| 118 |
+ model.setEditing(true);
|
|
| 143 | 119 |
|
| 144 |
- protected void setTitle(NavigationTree treeHelper) {
|
|
| 145 |
- //FIXME!!!
|
|
| 120 |
+ attachValidators(getBean());
|
|
| 146 | 121 |
}
|
| 147 | 122 |
|
| 148 | 123 |
@Override
|
| 149 |
- public U getUi() {
|
|
| 150 |
- return ui;
|
|
| 124 |
+ public final void stopEdit() {
|
|
| 125 |
+ //FIXME!!!
|
|
| 151 | 126 |
}
|
| 152 | 127 |
|
| 153 | 128 |
@Override
|
| 154 |
- public void destroyUI() {
|
|
| 129 |
+ public final void destroyUI() {
|
|
| 155 | 130 |
|
| 156 | 131 |
}
|
| 157 | 132 |
|
| 158 | 133 |
@Override
|
| 159 |
- public boolean closeUI() {
|
|
| 134 |
+ public final boolean closeUI() {
|
|
| 160 | 135 |
return false;
|
| 161 | 136 |
}
|
| 162 | 137 |
|
| 163 | 138 |
@Override
|
| 164 |
- public void resetEdit() {
|
|
| 139 |
+ public final void resetEdit() {
|
|
| 165 | 140 |
//FIXME!!!
|
| 166 | 141 |
}
|
| 167 | 142 |
|
| 168 | 143 |
@Override
|
| 169 |
- public void saveEdit() {
|
|
| 170 |
- editAction.save(ui, getBean());
|
|
| 144 |
+ public final void saveEdit() {
|
|
| 145 |
+ run(editActionHandler);
|
|
| 171 | 146 |
}
|
| 172 | 147 |
|
| 173 | 148 |
protected void attachValidators(DataListDto<D, C> bean) {
|
| 174 | 149 |
//FIXME!!!
|
| 175 | 150 |
}
|
| 176 | 151 |
|
| 177 |
- protected void updateExtra() {
|
|
| 178 |
- }
|
|
| 179 |
- |
|
| 180 | 152 |
public DataListDto<D, C> getBean() {
|
| 181 | 153 |
return model.getBean();
|
| 182 | 154 |
}
|
| 183 | 155 |
|
| 184 |
-// protected SaveResultDto save(DataListDto<D, C> bean) {
|
|
| 185 |
-// SaveResultDto saveResult = model.save(bean);
|
|
| 186 |
-// saveResult.toDto(bean);
|
|
| 187 |
-// return saveResult;
|
|
| 188 |
-// }
|
|
| 189 |
-//
|
|
| 190 |
-// protected SaveResultDto save(String parentId, DataListDto<D, C> bean) {
|
|
| 191 |
-// SaveResultDto saveResult = model.save(parentId, bean);
|
|
| 192 |
-// saveResult.toDto(bean);
|
|
| 193 |
-// return saveResult;
|
|
| 194 |
-// }
|
|
| 195 |
-//
|
|
| 196 |
-// public Form<DataListDto<D, C>> loadForm(String id) {
|
|
| 197 |
-// return model.loadForm(dataSource, id);
|
|
| 198 |
-// }
|
|
| 199 |
- |
|
| 200 |
- protected void setEditing() {
|
|
| 201 |
- // mark ui as editing
|
|
| 202 |
- model.setEditing(true);
|
|
| 203 |
- }
|
|
| 204 |
- |
|
| 205 | 156 |
private void prepareValidationContext() {
|
| 206 | 157 |
detachValidators();
|
| 207 | 158 |
resetValidationContext();
|
| ... | ... | @@ -216,7 +167,7 @@ public abstract class ObserveSimpleDataListFormUIHandler<D extends DataDto, C ex |
| 216 | 167 |
// if (referentialListHeader != null) {
|
| 217 | 168 |
// List data = referentialListHeader.getData();
|
| 218 | 169 |
// ClientValidationContext validationContext = ObserveClientApplicationContext.get().getValidationContext();
|
| 219 |
-// log.debug(String.format("%s Set referentiel list [%s] in validation context : %d", prefix, getModel().getDataType().getSimpleName(), data.size()));
|
|
| 170 |
+// log.debug(String.format("%s Set referentiel list [%s] in validation context : %d", prefix, getModel().getBeanType().getSimpleName(), data.size()));
|
|
| 220 | 171 |
// validationContext.setEditingReferentielList(data);
|
| 221 | 172 |
// }
|
| 222 | 173 |
}
|
| ... | ... | @@ -26,15 +26,15 @@ import com.google.common.collect.ImmutableMap; |
| 26 | 26 |
import com.google.common.collect.ImmutableSet;
|
| 27 | 27 |
import fr.ird.observe.client.ObserveClientApplicationContext;
|
| 28 | 28 |
import fr.ird.observe.client.ObserveKeyStrokes;
|
| 29 |
+import fr.ird.observe.client.form.FormUI;
|
|
| 29 | 30 |
import fr.ird.observe.client.form.ObserveFormUIHandler;
|
| 30 | 31 |
import fr.ird.observe.client.form.ObserveFormUIInitializerContext;
|
| 31 |
-import fr.ird.observe.client.form.action.EditDataListFormUIAction;
|
|
| 32 |
+import fr.ird.observe.client.form.action.FormUIActionHandler;
|
|
| 32 | 33 |
import fr.ird.observe.client.form.spi.FormUIValidationMessageManager;
|
| 33 | 34 |
import fr.ird.observe.client.form.spi.ReferentialReferencesFilter;
|
| 34 | 35 |
import fr.ird.observe.client.form.spi.init.CoordinatesEditorInitializer;
|
| 35 | 36 |
import fr.ird.observe.client.form.spi.init.TabInfoInitializer;
|
| 36 | 37 |
import fr.ird.observe.client.form.table.longline.WeightMeasuresTableModel;
|
| 37 |
-import fr.ird.observe.client.tree.navigation.NavigationTree;
|
|
| 38 | 38 |
import fr.ird.observe.client.util.UIHelper;
|
| 39 | 39 |
import fr.ird.observe.client.util.table.EditableTableModelSupport;
|
| 40 | 40 |
import fr.ird.observe.client.util.table.InlineTableAutotSelectRowAndShowPopupAction;
|
| ... | ... | @@ -45,7 +45,6 @@ import fr.ird.observe.dto.data.seine.TargetCatchDto; |
| 45 | 45 |
import fr.ird.observe.dto.referential.SpeciesReference;
|
| 46 | 46 |
import fr.ird.observe.dto.referential.seine.WeightCategoryReference;
|
| 47 | 47 |
import fr.ird.observe.services.action.DataListDtoServiceAction;
|
| 48 |
-import fr.ird.observe.services.action.LoadDataListDtoFormServiceAction;
|
|
| 49 | 48 |
import fr.ird.observe.services.service.ObserveService;
|
| 50 | 49 |
import java.awt.BorderLayout;
|
| 51 | 50 |
import java.awt.Rectangle;
|
| ... | ... | @@ -91,29 +90,31 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 91 | 90 |
private int oldIndex;
|
| 92 | 91 |
|
| 93 | 92 |
protected final S service;
|
| 94 |
- private final EditDataListFormUIAction<D, C, U> editAction;
|
|
| 95 |
- private final LoadDataListDtoFormServiceAction<D, C> loadAction;
|
|
| 96 | 93 |
|
| 97 |
- protected ObserveDataTableFormUIHandler(Class<S> serviceType) {
|
|
| 98 |
- service = MAIN.getService(serviceType);
|
|
| 99 |
- editAction = new EditDataListFormUIAction<D, C, U>() {
|
|
| 94 |
+ private final FormUIActionHandler editActionHandler = new FormUIActionHandler() {
|
|
| 95 |
+ @Override
|
|
| 96 |
+ public boolean before() {
|
|
| 97 |
+ return checkEdit();
|
|
| 98 |
+ }
|
|
| 100 | 99 |
|
| 101 |
- @Override
|
|
| 102 |
- protected boolean askToSave(DataListDto<D, C> dto) {
|
|
| 103 |
- return askToSave0(dto);
|
|
| 104 |
- }
|
|
| 100 |
+ @Override
|
|
| 101 |
+ public void run() {
|
|
| 102 |
+ doSave0(model.getBean());
|
|
| 103 |
+ }
|
|
| 105 | 104 |
|
| 106 |
- @Override
|
|
| 107 |
- protected void afterSave(DataListDto<D, C> dto, boolean created) {
|
|
| 108 |
- afterSave0(dto, created);
|
|
| 109 |
- }
|
|
| 105 |
+ @Override
|
|
| 106 |
+ public void after() {
|
|
| 107 |
+ afterSave0();
|
|
| 108 |
+ }
|
|
| 110 | 109 |
|
| 111 |
- @Override
|
|
| 112 |
- protected void doSave(DataListDto<D, C> dto) {
|
|
| 113 |
- doSave0(dto);
|
|
| 114 |
- }
|
|
| 115 |
- };
|
|
| 116 |
- loadAction = service;
|
|
| 110 |
+ @Override
|
|
| 111 |
+ public FormUI getUI() {
|
|
| 112 |
+ return ui;
|
|
| 113 |
+ }
|
|
| 114 |
+ };
|
|
| 115 |
+ |
|
| 116 |
+ protected ObserveDataTableFormUIHandler(Class<S> serviceType) {
|
|
| 117 |
+ service = MAIN.getService(serviceType);
|
|
| 117 | 118 |
}
|
| 118 | 119 |
|
| 119 | 120 |
@Override
|
| ... | ... | @@ -148,9 +149,9 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 148 | 149 |
// public void computeUpdateMessages(ClientDataContext dataContext, FormUIValidationMessageManager validationManager) {
|
| 149 | 150 |
// String message = n("observe.entity.message.updating");
|
| 150 | 151 |
// NavigationTreeNodeSupport node = navigation.getSelectedNode();
|
| 151 |
-// String entityLabel = ObserveI18nDecoratorHelper.getTypeI18nKey(node.getParent().getDataType());
|
|
| 152 |
+// String entityLabel = ObserveI18nDecoratorHelper.getTypeI18nKey(node.getParent().getBeanType());
|
|
| 152 | 153 |
// message = t(message, t(entityLabel));
|
| 153 |
-// validationManager.addInfoMessage(node.getParent().getDataType(), message);
|
|
| 154 |
+// validationManager.addInfoMessage(node.getParent().getBeanType(), message);
|
|
| 154 | 155 |
// }
|
| 155 | 156 |
//
|
| 156 | 157 |
// @Override
|
| ... | ... | @@ -211,7 +212,7 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 211 | 212 |
|
| 212 | 213 |
@Override
|
| 213 | 214 |
protected void initialize(ObserveFormUIInitializerContext<U> initializerContext) {
|
| 214 |
- validationManager = new FormUIValidationMessageManager(model.getDataType(), ui);
|
|
| 215 |
+ validationManager = new FormUIValidationMessageManager(model.getBeanType(), ui);
|
|
| 215 | 216 |
super.initialize(initializerContext);
|
| 216 | 217 |
|
| 217 | 218 |
ContentTableModel<D, C> tableModel = ui.getTableModel();
|
| ... | ... | @@ -336,9 +337,7 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 336 | 337 |
tabModels.ifPresent(e -> TabInfoInitializer.onOpenUi(ui, e));
|
| 337 | 338 |
|
| 338 | 339 |
log.info(String.format("%s init ui", prefix));
|
| 339 |
- computeContentIcon();
|
|
| 340 | 340 |
updateToolbarActions();
|
| 341 |
- setTitle(navigation);
|
|
| 342 | 341 |
updateExtra();
|
| 343 | 342 |
|
| 344 | 343 |
if (!model.isReadingMode()) {
|
| ... | ... | @@ -352,32 +351,21 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 352 | 351 |
return getModel().getTableEditBean();
|
| 353 | 352 |
}
|
| 354 | 353 |
|
| 354 |
+ @Override
|
|
| 355 | 355 |
public final void startEdit() {
|
| 356 | 356 |
prepareValidationContext();
|
| 357 | 357 |
setEditing();
|
| 358 | 358 |
attachValidators(getBean());
|
| 359 | 359 |
}
|
| 360 | 360 |
|
| 361 |
+ @Override
|
|
| 361 | 362 |
public final void stopEdit() {
|
| 362 | 363 |
//FIXME!!!
|
| 363 | 364 |
}
|
| 364 | 365 |
|
| 365 |
- public final void restartEditUI() {
|
|
| 366 |
- //FIXME!!!
|
|
| 367 |
- }
|
|
| 368 |
- |
|
| 369 |
- protected void setTitle(NavigationTree treeHelper) {
|
|
| 370 |
- //FIXME!!!
|
|
| 371 |
- }
|
|
| 372 |
- |
|
| 373 |
- @Override
|
|
| 374 |
- public U getUi() {
|
|
| 375 |
- return ui;
|
|
| 376 |
- }
|
|
| 377 |
- |
|
| 378 | 366 |
@Override
|
| 379 | 367 |
public void destroyUI() {
|
| 380 |
- |
|
| 368 |
+ //FIXME!!!
|
|
| 381 | 369 |
}
|
| 382 | 370 |
|
| 383 | 371 |
@Override
|
| ... | ... | @@ -392,7 +380,7 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 392 | 380 |
|
| 393 | 381 |
@Override
|
| 394 | 382 |
public final void saveEdit() {
|
| 395 |
- editAction.save(ui, model.getBean());
|
|
| 383 |
+ run(editActionHandler);
|
|
| 396 | 384 |
// boolean ok = askToSave0(model.getSelectedParentId(), model.getBean());
|
| 397 | 385 |
// if (!ok) {
|
| 398 | 386 |
// // use cancel save
|
| ... | ... | @@ -414,31 +402,23 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 414 | 402 |
|
| 415 | 403 |
@Override
|
| 416 | 404 |
public void deleteData() {
|
| 417 |
-//FIXME!!!
|
|
| 418 | 405 |
}
|
| 419 | 406 |
|
| 420 | 407 |
protected void attachValidators(DataListDto<D, C> bean) {
|
| 421 | 408 |
//FIXME!!!
|
| 422 | 409 |
}
|
| 423 | 410 |
|
| 424 |
- protected void updateExtra() {
|
|
| 425 |
- }
|
|
| 426 |
- |
|
| 427 | 411 |
private void doSave0(DataListDto<D, C> dto) {
|
| 428 | 412 |
|
| 429 | 413 |
}
|
| 430 | 414 |
|
| 431 |
- private void afterSave0(DataListDto<D, C> dto, boolean created) {
|
|
| 415 |
+ private void afterSave0() {
|
|
| 432 | 416 |
SwingValidatorUtil.setValidatorChanged(ui, false);
|
| 433 | 417 |
|
| 434 | 418 |
// on recharge l'écran
|
| 435 | 419 |
resetEdit();
|
| 436 | 420 |
}
|
| 437 | 421 |
|
| 438 |
- private boolean askToSave0(DataListDto<D, C> dto) {
|
|
| 439 |
- return false;
|
|
| 440 |
- }
|
|
| 441 |
- |
|
| 442 | 422 |
public DataListDto<D, C> getBean() {
|
| 443 | 423 |
return model.getBean();
|
| 444 | 424 |
}
|
| ... | ... | @@ -497,7 +477,7 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 497 | 477 |
if (referentialListHeader != null) {
|
| 498 | 478 |
List data = referentialListHeader.getData();
|
| 499 | 479 |
ClientValidationContext validationContext = ObserveClientApplicationContext.get().getValidationContext();
|
| 500 |
- log.debug(String.format("%s Set referentiel list [%s] in validation context : %d", prefix, getModel().getDataType().getSimpleName(), data.size()));
|
|
| 480 |
+ log.debug(String.format("%s Set referentiel list [%s] in validation context : %d", prefix, getModel().getBeanType().getSimpleName(), data.size()));
|
|
| 501 | 481 |
validationContext.setEditingReferentielList(data);
|
| 502 | 482 |
}
|
| 503 | 483 |
}
|
| ... | ... | @@ -558,7 +538,7 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 558 | 538 |
return model.getTableModel();
|
| 559 | 539 |
}
|
| 560 | 540 |
|
| 561 |
- public void removeSelectedRow(int selectedRow) {
|
|
| 541 |
+ private void removeSelectedRow(int selectedRow) {
|
|
| 562 | 542 |
try {
|
| 563 | 543 |
getTableModel().doRemoveRow(selectedRow, false);
|
| 564 | 544 |
} finally {
|
| ... | ... | @@ -636,11 +616,6 @@ public abstract class ObserveDataTableFormUIHandler<D extends DataDto, C extends |
| 636 | 616 |
}
|
| 637 | 617 |
|
| 638 | 618 |
@Override
|
| 639 |
- public int askUser(String t, String t1, int message, Object[] objects, int i) {
|
|
| 640 |
- return askUser(t, t1, message, objects, i);
|
|
| 641 |
- }
|
|
| 642 |
- |
|
| 643 |
- @Override
|
|
| 644 | 619 |
public boolean confirmForEntityDelete(Object o, Class<C> klass, C bean, String deleteExtraMessage) {
|
| 645 | 620 |
return ObserveFormUIHandler.confirmForEntityDelete(klass, bean, deleteExtraMessage);
|
| 646 | 621 |
}
|