03/23: UI for data synchronize action
This is an automated email from the git hooks/post-receive script. New commit to branch feature/4304_synchro_marees in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit e3b7181a75318c871b39513055120a426551e870 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Aug 2 17:37:26 2016 +0200 UI for data synchronize action --- .../main/java/fr/ird/observe/ui/ObserveMainUI.jaxx | 1 + .../main/java/fr/ird/observe/ui/ObserveMainUI.jcss | 4 + .../java/fr/ird/observe/ui/admin/AdminStep.java | 21 ++++ .../fr/ird/observe/ui/admin/AdminTabUIHandler.java | 51 ++++++--- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 55 +++++++++ .../ui/admin/datasynchro/DataSynchroModel.java | 97 ++++++++++++++++ .../ui/admin/datasynchro/DataSynchroUI.jaxx | 127 +++++++++++++++++++++ .../ui/admin/datasynchro/DataSynchroUI.jcss | 106 +++++++++++++++++ .../ui/admin/datasynchro/DataSynchroUIHandler.java | 121 ++++++++++++++++++++ .../observe-application-swing_en_GB.properties | 20 ++++ .../observe-application-swing_es_ES.properties | 20 ++++ .../observe-application-swing_fr_FR.properties | 19 +++ 12 files changed, 623 insertions(+), 19 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jaxx index e97816a..7f43933 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jaxx @@ -172,6 +172,7 @@ void $afterCompleteSetup() { <JMenuItem id='menuActionsExportData'/> <JMenuItem id='menuActionsReport'/> <JMenuItem id='menuActionsConsolidate'/> + <JMenuItem id='menuActionsDataSynchro'/> </JMenu> <JMenu id='menuNavigation'> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jcss b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jcss index 50f53e1..999d7b2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jcss +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUI.jcss @@ -204,6 +204,10 @@ JSplitPane { enabled: {getHandler().acceptMode(getMode(), !isBusy() && !isMainFromSynchro(), ObserveUIMode.DB, ObserveUIMode.NO_DB)}; } +#menuActionsDataSynchro { + action: {new fr.ird.observe.ui.actions.LaunchAdminAction(this, AdminStep.DATA_SYNCHRONIZE)}; +} + #menuActionsSynchronize { action: {new fr.ird.observe.ui.actions.LaunchAdminAction(this, AdminStep.SYNCHRONIZE)}; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java index 41032c0..2819d66 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminStep.java @@ -27,6 +27,8 @@ import fr.ird.observe.ui.admin.config.ConfigUI; import fr.ird.observe.ui.admin.config.SelectDataUI; import fr.ird.observe.ui.admin.consolidate.ConsolidateModel; import fr.ird.observe.ui.admin.consolidate.ConsolidateUI; +import fr.ird.observe.ui.admin.datasynchro.DataSynchroModel; +import fr.ird.observe.ui.admin.datasynchro.DataSynchroUI; import fr.ird.observe.ui.admin.export.ExportModel; import fr.ird.observe.ui.admin.export.ExportUI; import fr.ird.observe.ui.admin.report.ReportModel; @@ -99,6 +101,25 @@ public enum AdminStep implements WizardExtStep { DbMode.USE_REMOTE ), + DATA_SYNCHRONIZE( + n("observe.synchro.step.dataSynchronize"), + n("observe.synchro.step.dataSynchronize.description"), + n("observe.title.dataSynchronize"), + n("observe.title.dataSynchronize.tip"), + "dataSynchronize", + n("observe.synchro.operation.dataSynchronize"), + n("observe.synchro.operation.dataSynchronize.description"), + DataSynchroModel.class, + DataSynchroUI.class, + true, + false, + false, + false, + DbMode.USE_LOCAL, + DbMode.USE_REMOTE, + DbMode.USE_SERVER + ), + /** pour lancer la validation des donnees */ VALIDATE( n("observe.synchro.step.validate"), diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java index 8e1e171..97e1ed0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminTabUIHandler.java @@ -23,11 +23,11 @@ package fr.ird.observe.ui.admin; import fr.ird.observe.ObserveRunner; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.service.BabModelVersionException; import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; import fr.ird.observe.services.service.DatabaseNotFoundException; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.admin.config.SelectDataUI; import fr.ird.observe.ui.admin.resume.ShowResumeUI; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; @@ -196,33 +196,17 @@ public class AdminTabUIHandler { DataSelectionModel selectDataModel = tabUI.getSelectDataModel(); DataSelectionTreeSelectionModel selectionModel = tabUI.getSelectionModel(); ObserveTreeHelper helper = tabUI.getTreeHelper(); - - if (log.isDebugEnabled()) { - log.debug("reload model " + selectDataModel); - } - - selectionModel.clearSelection(); ObserveSwingDataSource source = tabUI.getModel().getSafeLocalSource(true); - if (log.isDebugEnabled()) { - log.debug("Will treeHelper : " + helper); - log.debug("selection model : " + selectDataModel); - log.debug("use referentiel : " + selectDataModel.isUseReferentiel()); - log.debug("use data : " + selectDataModel.isUseData()); - } - - TreeModel model = helper.createModel(tabUI, selectDataModel, source); + updateSelectionModel(tabUI, helper, selectTree, source, selectDataModel, selectionModel); - selectTree.setModel(model); - - selectionModel.initUI(selectTree); } protected void checkStepIsOperation(AdminTabUI ui) { if (!ui.getStep().isOperation()) { throw new IllegalStateException( "can not launch objectOperation on none operation step " + - ui.getStep()); + ui.getStep()); } } @@ -248,4 +232,33 @@ public class AdminTabUIHandler { ObserveRunner.getActionExecutor().addAction(worker); } + protected void updateSelectionModel(AdminTabUI tabUI, + ObserveTreeHelper helper, + JTree selectTree, + ObserveSwingDataSource source, + DataSelectionModel selectDataModel, + DataSelectionTreeSelectionModel selectionModel) { + + + if (log.isDebugEnabled()) { + log.debug("reload model " + selectDataModel); + } + + selectionModel.clearSelection(); + + if (log.isDebugEnabled()) { + log.debug("Will treeHelper : " + helper); + log.debug("selection model : " + selectDataModel); + log.debug("use referentiel : " + selectDataModel.isUseReferentiel()); + log.debug("use data : " + selectDataModel.isUseData()); + } + + helper.setUI(selectTree, false); + + TreeModel model = helper.createModel(tabUI, selectDataModel, source); + selectTree.setModel(model); + + selectionModel.initUI(selectTree); + } + } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java index ac8553b..80930e2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java @@ -44,6 +44,7 @@ import fr.ird.observe.services.service.actions.validate.ValidateServiceUtils; import fr.ird.observe.services.service.longline.TripLonglineService; import fr.ird.observe.services.service.seine.TripSeineService; import fr.ird.observe.ui.admin.consolidate.ConsolidateModel; +import fr.ird.observe.ui.admin.datasynchro.DataSynchroModel; import fr.ird.observe.ui.admin.export.ExportModel; import fr.ird.observe.ui.admin.report.ReportModel; import fr.ird.observe.ui.admin.save.SaveLocalModel; @@ -569,6 +570,12 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { getConsolidateModel().addPropertyChangeListener(listenConsolidateModified); } + if (containsOperation(AdminStep.DATA_SYNCHRONIZE)) { + + //TODO ? + + } + // on ecoute les modifications d'étapes pour remplir les modèles de sélection // si nécessaire @@ -882,6 +889,10 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { return (SaveLocalModel) getStepModel(AdminStep.SAVE_LOCAL); } + public DataSynchroModel getDataSynchroModel() { + return (DataSynchroModel) getStepModel(AdminStep.DATA_SYNCHRONIZE); + } + @Override public void cancel() { super.cancel(); @@ -1047,6 +1058,44 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } } } + if (validate && containsOperation(AdminStep.DATA_SYNCHRONIZE)) { + + // les deux bases (source et referentiel) doivent etre different + DbMode dbMode = localSourceModel.getDbMode(); + if (dbMode == centralSourceModel.getDbMode()) { + if (dbMode == DbMode.USE_REMOTE) { + validate &= !localSourceModel.getPgConfig().getJdbcUrl().equals(centralSourceModel.getPgConfig().getJdbcUrl()); + } else { + + // pour le moment ce cas n'est pas possible + // la base de référence est obligatoirement une base distante + //FIXME + } + } + + ObserveDataSourceInformation leftDataSourceInformation = getLocalSourceInformation(); + if (!(leftDataSourceInformation.canReadData() && leftDataSourceInformation.canWriteData())) { + if (log.isDebugEnabled()) { + log.debug("can not read and write data on left data source"); + } + return false; + } + + if (centralSourceModel.getDataSourceInformation() != null) { + + ObserveDataSourceInformation rightDataSourceInformation = centralSourceModel.getDataSourceInformation(); + if (!(rightDataSourceInformation.canReadData() && rightDataSourceInformation.canWriteData())) { + if (log.isDebugEnabled()) { + log.debug("can not read and write data on right data source"); + } + return false; + } + + } + + + + } if (containsOperation(AdminStep.SYNCHRONIZE)) { // les deux bases (source et referentiel) doivent etre different @@ -1179,6 +1228,12 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { universe.add(AdminStep.SELECT_DATA); } + if (containsOperation(AdminStep.DATA_SYNCHRONIZE)) { + + // ajout de l'onglet de resolution des entites obsoletes + universe.add(AdminStep.DATA_SYNCHRONIZE); + } + if (containsOperation(AdminStep.SYNCHRONIZE)) { // ajout de l'onglet de resolution des entites obsoletes diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroModel.java new file mode 100644 index 0000000..1371502 --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroModel.java @@ -0,0 +1,97 @@ +package fr.ird.observe.ui.admin.datasynchro; + +import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.ui.admin.AdminActionModel; +import fr.ird.observe.ui.admin.AdminStep; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Created on 02/08/16. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public class DataSynchroModel extends AdminActionModel { + + /** Logger. */ + private static final Log log = LogFactory.getLog(DataSynchroModel.class); + + public static final String LEFT_SELECTION_MODEL_CHANGED_PROPERTY_NAME = "leftSelectionModelChanged"; + public static final String RIGHT_SELECTION_MODEL_CHANGED_PROPERTY_NAME = "rightSelectionModelChanged"; + + /** la source sur le panneau de gauche. */ + protected ObserveSwingDataSource leftSource; + + /** la source sur le panneau de droite. */ + protected ObserveSwingDataSource rightSource; + + /** les données sélectionnées sur le panneau de gauche. */ + protected final DataSelectionModel leftSelectionDataModel; + + /** les données sélectionnées sur le panneau de droite. */ + protected final DataSelectionModel rightSelectionDataModel; + + public DataSynchroModel() { + super(AdminStep.DATA_SYNCHRONIZE); + + leftSelectionDataModel = new DataSelectionModel(); + leftSelectionDataModel.setUseData(true); + + rightSelectionDataModel = new DataSelectionModel(); + rightSelectionDataModel.setUseData(true); + } + + public ObserveSwingDataSource getLeftSource() { + return leftSource; + } + + public void setLeftSource(ObserveSwingDataSource leftSource) { + this.leftSource = leftSource; + } + + public ObserveSwingDataSource getRightSource() { + return rightSource; + } + + public void setRightSource(ObserveSwingDataSource rightSource) { + this.rightSource = rightSource; + } + + public DataSelectionModel getLeftSelectionDataModel() { + return leftSelectionDataModel; + } + + public DataSelectionModel getRightSelectionDataModel() { + return rightSelectionDataModel; + } + + public void populateLeftSelectionModel() { + populateSelectionModel(leftSource, leftSelectionDataModel, LEFT_SELECTION_MODEL_CHANGED_PROPERTY_NAME); + } + + public void populateRightSelectionModel() { + populateSelectionModel(rightSource, rightSelectionDataModel, RIGHT_SELECTION_MODEL_CHANGED_PROPERTY_NAME); + } + + private void populateSelectionModel(ObserveSwingDataSource dataSource, DataSelectionModel selectionDataModel, String propertyName) { + + try { + + DataSelectionModel.populate(selectionDataModel, dataSource); + + } catch (Exception e) { + + if (log.isErrorEnabled()) { + log.error("could not populate selected model", e); + } + + } finally { + + // on notifie que le modèle de sélection a changé + // (il faut donc recalculé l'arbre de sélection) + firePropertyChange(propertyName, selectionDataModel); + + } + } +} \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUI.jaxx new file mode 100644 index 0000000..0d21a11 --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUI.jaxx @@ -0,0 +1,127 @@ +<!-- + #%L + ObServe :: Swing + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<!-- ************************************************************* --> +<!-- L'écran de synchronisation bi-directionnel des données --> +<!-- ************************************************************* --> + +<fr.ird.observe.ui.admin.AdminTabUI> + + <import> + fr.ird.observe.ui.UIHelper + fr.ird.observe.ui.admin.AdminUI + fr.ird.observe.ui.admin.AdminStep + fr.ird.observe.ui.tree.ObserveTreeHelper + fr.ird.observe.ui.tree.DataSelectionTreeCellRenderer + fr.ird.observe.ui.tree.DataSelectionTreeSelectionModel + fr.ird.observe.ui.storage.tabs.DataSelectionModel + + jaxx.runtime.SwingUtil + + javax.swing.tree.TreeSelectionModel + + </import> + + <ObserveTreeHelper id='leftTreeHelper'/> + <ObserveTreeHelper id='rightTreeHelper'/> + + <DataSynchroUIHandler id='handler' constructorParams='this'/> + + <DataSynchroModel id='stepModel' initializer='getModel().getDataSynchroModel()'/> + + <DataSelectionModel id='leftSelectDataModel' + initializer='getModel().getDataSynchroModel().getLeftSelectionDataModel()'/> + <DataSelectionTreeSelectionModel id='leftSelectionModel'/> + <DataSelectionTreeCellRenderer id='leftSelectionRenderer' constraints='BorderLayout.EAST'/> + + <DataSelectionModel id='rightSelectDataModel' + initializer='getModel().getDataSynchroModel().getRightSelectionDataModel()'/> + <DataSelectionTreeSelectionModel id='rightSelectionModel'/> + <DataSelectionTreeCellRenderer id='rightSelectionRenderer' constraints='BorderLayout.EAST'/> + + <script><![CDATA[ +public DataSynchroUI(AdminUI parentContext) { + super(AdminStep.DATA_SYNCHRONIZE, parentContext); +} + +public void initUI(AdminUI ui) { + getHandler().initTabUI(ui, this); +} + +@Override +public void destroy() { + leftSelectionModel.clearSelection(); + rightSelectionModel.clearSelection(); + super.destroy(); +} +]]> + </script> + + <JPanel id='PENDING_content'> + <Table constraints='BorderLayout.CENTER' fill='both' weightx='1' + weighty='1'> + <row> + <cell> + <JButton id='startAction' onActionPerformed="getHandler().doPrepareAction()"/> + </cell> + </row> + </Table> + </JPanel> + + <JPanel id='NEED_FIX_content'> + <Table fill="both" constraints='BorderLayout.CENTER'> + <row weighty="0.8"> + <cell weightx="0.4"> + <JScrollPane id='leftTreePane' decorator='boxed'> + <JTree id='leftTree'/> + </JScrollPane> + </cell> + <cell weightx="0.2"> + <JPanel layout="{new BorderLayout()}" border='{new TitledBorder(" ")}'> + <JPanel id="middleActions" layout="{new GridLayout(0, 1)}" constraints='BorderLayout.CENTER'> + <JButton id="copyToRight"/> + <JButton id="copyToLeft"/> + <JButton id="deleteFromLeft"/> + <JButton id="deleteFromRight"/> + </JPanel> + </JPanel> + </cell> + <cell weightx="0.4"> + <JScrollPane id='rightTreePane' decorator='boxed'> + <JTree id='rightTree'/> + </JScrollPane> + </cell> + </row> + <row weighty="0.8"> + <cell columns="3"> + <JList id="actionsToConsume"/> + </cell> + </row> + <row> + <cell columns='3'> + <JButton id='applyAction' onActionPerformed='getHandler().doExecuteAction()'/> + </cell> + </row> + </Table> + </JPanel> + +</fr.ird.observe.ui.admin.AdminTabUI> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUI.jcss b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUI.jcss new file mode 100644 index 0000000..c7781a4 --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUI.jcss @@ -0,0 +1,106 @@ +/* + * #%L + * ObServe :: Swing + * %% + * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +#NEED_FIX_content { + layout:{new BorderLayout()}; +} + +#PENDING_content { + layout:{new BorderLayout()}; +} + +#startAction { + actionIcon:"wizard-start"; +} + +#applyAction { + actionIcon:accept; + text:"observe.action.apply"; +} + +#leftTree { + rootVisible:false; + largeModel:true; + minimumSize:{UIHelper.newMinDimension()}; + font-size:11; + showsRootHandles:false; + toggleClickCount:100; + selectionModel:{leftSelectionModel}; + cellRenderer:{leftSelectionRenderer}; +} + +#leftSelectionModel { + selectionMode: {TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION}; + dataModel:{leftSelectDataModel}; +} + +#leftTreePane { + verticalScrollBarPolicy:{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}; +} + +#rightTree { + rootVisible:false; + largeModel:true; + minimumSize:{UIHelper.newMinDimension()}; + font-size:11; + showsRootHandles:false; + toggleClickCount:100; + selectionModel:{rightSelectionModel}; + cellRenderer:{rightSelectionRenderer}; +} + +#rightSelectionModel { + selectionMode: {TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION}; + dataModel:{rightSelectDataModel}; +} + +#rightTreePane { + verticalScrollBarPolicy:{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}; +} + +#copyToLeft { + text:"observe.action.copyToLeft"; + toolTipText:"observe.action.copyToLeft.tip"; + enabled:false; +} + +#copyToRight { + text:"observe.action.copyToRight"; + toolTipText:"observe.action.copyToRight.tip"; + enabled:false; +} + +#deleteFromLeft { + text:"observe.action.deleteFromLeft"; + toolTipText:"observe.action.deleteFromLeft.tip"; + enabled:false; +} + +#deleteFromRight { + text:"observe.action.deleteFromRight"; + toolTipText:"observe.action.deleteFromRight.tip"; + enabled:false; +} + +#actionsToConsume { + border:{new TitledBorder(t("observe.datasynchro.actionsToPerform"))}; +} \ No newline at end of file diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUIHandler.java new file mode 100644 index 0000000..200b2dc --- /dev/null +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/datasynchro/DataSynchroUIHandler.java @@ -0,0 +1,121 @@ +package fr.ird.observe.ui.admin.datasynchro; + +import fr.ird.observe.db.ObserveSwingDataSource; +import fr.ird.observe.ui.admin.AdminTabUIHandler; +import fr.ird.observe.ui.admin.AdminUI; +import fr.ird.observe.ui.storage.tabs.DataSelectionModel; +import jaxx.runtime.swing.wizard.ext.WizardState; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.border.TitledBorder; + +import static org.nuiton.i18n.I18n.t; + +/** + * Created on 02/08/16. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public class DataSynchroUIHandler extends AdminTabUIHandler { + + /** Logger */ + private static final Log log = LogFactory.getLog(DataSynchroUIHandler.class); + + public DataSynchroUIHandler(DataSynchroUI ui) { + super(ui); + } + + public DataSynchroModel getStepModel() { + return model.getDataSynchroModel(); + } + + @Override + public DataSynchroUI getUi() { + return (DataSynchroUI) super.getUi(); + } + + public void initTabUI(AdminUI ui, DataSynchroUI tabUI) { + + super.initTabUI(ui, tabUI); + + if (log.isDebugEnabled()) { + log.debug(" specialized for [" + tabUI.getStep() + "] for main ui " + ui.getClass().getName() + "@" + System.identityHashCode(ui)); + } + + tabUI.getStartAction().setText(t("observe.action.datasynchro.launch.operation", t(tabUI.getStep().getOperationLabel()))); + + getStepModel().getLeftSelectionDataModel().addPropertyChangeListener(evt -> { + + DataSelectionModel model = (DataSelectionModel) evt.getSource(); + boolean withDataSelected = !model.isDataEmpty(); + + tabUI.getCopyToRight().setEnabled(withDataSelected); + tabUI.getDeleteFromLeft().setEnabled(withDataSelected); + + }); + getStepModel().getRightSelectionDataModel().addPropertyChangeListener(evt -> { + + DataSelectionModel model = (DataSelectionModel) evt.getSource(); + boolean withDataSelected = !model.isDataEmpty(); + + tabUI.getCopyToLeft().setEnabled(withDataSelected); + tabUI.getDeleteFromRight().setEnabled(withDataSelected); + + }); + + } + + public void doPrepareAction() { + + addAdminWorker(getUi().getStartAction().getToolTipText(), this::doAction); + + } + + public void doExecuteAction() { + + //TODO + getModel().setStepState(WizardState.SUCCESSED); + + } + + private WizardState doAction() throws Exception { + + if (log.isDebugEnabled()) { + log.debug(this); + } + + DataSynchroModel stepModel = getStepModel(); + + // on cree les sources de données + + ObserveSwingDataSource leftSource = model.getSafeLocalSource(false); + stepModel.setLeftSource(leftSource); + + ObserveSwingDataSource rightSource = model.getSafeCentralSource(false); + stepModel.setRightSource(rightSource); + + openSource(leftSource); + openSource(rightSource); + + // Populate tree models + + DataSynchroUI tabUI = getUi(); + + tabUI.getLeftTreePane().setBorder(new TitledBorder(leftSource.getLabel())); + stepModel.populateLeftSelectionModel(); + updateSelectionModel(tabUI, tabUI.getLeftTreeHelper(), tabUI.getLeftTree(), leftSource, stepModel.getLeftSelectionDataModel(), tabUI.getLeftSelectionModel()); + sendMessage(t("observe.message.datasynchro.leftData.loaded")); + + tabUI.getRightTreePane().setBorder(new TitledBorder(rightSource.getLabel())); + stepModel.populateRightSelectionModel(); + updateSelectionModel(tabUI, tabUI.getRightTreeHelper(), tabUI.getRightTree(), rightSource, stepModel.getRightSelectionDataModel(), tabUI.getRightSelectionModel()); + sendMessage(t("observe.message.datasynchro.rightData.loaded")); + + sendMessage(t("observe.message.datasynchro.ready")); + + return WizardState.NEED_FIX; + + } + +} \ No newline at end of file diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties index 236fb11..908924b 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_en_GB.properties @@ -96,6 +96,10 @@ observe.action.copy.column.headers= observe.action.copy.column.headers.tip= observe.action.copy.row.headers= observe.action.copy.row.headers.tip= +observe.action.copyToLeft= +observe.action.copyToLeft.tip= +observe.action.copyToRight= +observe.action.copyToRight.tip= observe.action.country.create.tip= observe.action.country.delete.tip= observe.action.country.detail.tip= @@ -129,6 +133,7 @@ observe.action.create.targetSample= observe.action.create.targetSample.tip= observe.action.create.targetSampleCapture= observe.action.create.targetSampleCapture.tip= +observe.action.datasynchro.launch.operation= observe.action.db.locale.es.tip=Change database language in spanish observe.action.db.locale.fr.tip=Change database language in french observe.action.db.locale.uk.tip=Change database language in english @@ -140,6 +145,11 @@ observe.action.delete.maree.tip= observe.action.delete.route.tip= observe.action.delete.set.tip= observe.action.delete.tip=Delete +observe.action.deleteFromBoth= +observe.action.deleteFromLeft= +observe.action.deleteFromLeft.tip= +observe.action.deleteFromRight= +observe.action.deleteFromRight.tip= observe.action.detail=Details observe.action.detectionMode.create.tip= observe.action.detectionMode.delete.tip= @@ -1031,6 +1041,7 @@ observe.configuration.description= observe.content.mode.create.tip= observe.content.mode.read.tip= observe.content.mode.update.tip= +observe.datasynchro.actionsToPerform= observe.encounter.action.create=Insert this encounter observe.encounter.action.create.tip=Insert this encounter observe.encounter.count=Count @@ -1337,6 +1348,9 @@ observe.message.consolidate.operation.done= observe.message.consolidate.save.changes= observe.message.consolidate.trip= observe.message.creating.referentiel= +observe.message.datasynchro.leftData.loaded= +observe.message.datasynchro.ready= +observe.message.datasynchro.rightData.loaded= observe.message.db.closed=%1$s was closed observe.message.db.loaded=%1$s was loaded observe.message.db.loading=%1$s loading... @@ -1779,6 +1793,8 @@ observe.synchro.obsolete.entity.fix= observe.synchro.operation.canceled= observe.synchro.operation.consolidate= observe.synchro.operation.consolidate.description= +observe.synchro.operation.dataSynchronize= +observe.synchro.operation.dataSynchronize.description= observe.synchro.operation.exportData= observe.synchro.operation.exportData.description= observe.synchro.operation.failed= @@ -1805,6 +1821,8 @@ observe.synchro.step.config= observe.synchro.step.config.description= observe.synchro.step.consolidate= observe.synchro.step.consolidate.description= +observe.synchro.step.dataSynchronize= +observe.synchro.step.dataSynchronize.description= observe.synchro.step.exportData= observe.synchro.step.exportData.description= observe.synchro.step.report= @@ -2002,6 +2020,8 @@ observe.title.content.weightCategory= observe.title.content.weightMeasureTypes= observe.title.content.windSpeeds= observe.title.create.local.db=Loading local database +observe.title.dataSynchronize= +observe.title.dataSynchronize.tip= observe.title.delete=Confirm a delete observe.title.error.dialog=An error occurs\! observe.title.exportData=Export datas diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties index e9bdcc2..6b9c8cf 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_es_ES.properties @@ -96,6 +96,10 @@ observe.action.copy.column.headers=Copiar los encabezados de columnas observe.action.copy.column.headers.tip=Añadir al resultado las cabeceras de columna observe.action.copy.row.headers=Copiar las cabeceras de linea observe.action.copy.row.headers.tip=Añadir al resultado las cabeceras de linea (ej. la primera columna) +observe.action.copyToLeft= +observe.action.copyToLeft.tip= +observe.action.copyToRight= +observe.action.copyToRight.tip= observe.action.country.create.tip=Crear un nuevo país observe.action.country.delete.tip=Eliminar el país seleccionado observe.action.country.detail.tip=Ver los detalles del país seleccionado @@ -129,6 +133,7 @@ observe.action.create.targetSample=Insertar muestreo observe.action.create.targetSample.tip=Insertar muestreo de atún descartado observe.action.create.targetSampleCapture=Insertar muestreo observe.action.create.targetSampleCapture.tip=Insertar muestreo de atún capturado +observe.action.datasynchro.launch.operation= observe.action.db.locale.es.tip=Cambia el idioma del referencial al español observe.action.db.locale.fr.tip=Cambiar el idioma del referencial al francés observe.action.db.locale.uk.tip=Cambiar el idioma del referencial al inglés @@ -140,6 +145,11 @@ observe.action.delete.maree.tip=Eliminar la marea observe.action.delete.route.tip=Eliminar la ruta observe.action.delete.set.tip=Eliminar el lance observe.action.delete.tip=Eliminar +observe.action.deleteFromBoth= +observe.action.deleteFromLeft= +observe.action.deleteFromLeft.tip= +observe.action.deleteFromRight= +observe.action.deleteFromRight.tip= observe.action.detail=Ver detalles observe.action.detectionMode.create.tip=Crear un nuevo modo de detección observe.action.detectionMode.delete.tip=Eliminar el modo de detección seleccionado @@ -1031,6 +1041,7 @@ observe.configuration.description= observe.content.mode.create.tip=Objeto en proceso de creación observe.content.mode.read.tip=Objeto no se puede editar observe.content.mode.update.tip=Objeto en proceso de edición +observe.datasynchro.actionsToPerform= observe.encounter.action.create= observe.encounter.action.create.tip= observe.encounter.count= @@ -1337,6 +1348,9 @@ observe.message.consolidate.operation.done=Operación de calculo de datos termin observe.message.consolidate.save.changes=Guardar las modificaciones de la(s) %1$s marea(s) modificada(s). observe.message.consolidate.trip= observe.message.creating.referentiel=Objeto en proceso de creación. +observe.message.datasynchro.leftData.loaded= +observe.message.datasynchro.ready= +observe.message.datasynchro.rightData.loaded= observe.message.db.closed=%1$s ha sido cerrado observe.message.db.loaded=%1$s cargado observe.message.db.loading=%1$s cargando @@ -1779,6 +1793,8 @@ observe.synchro.obsolete.entity.fix=Cambiar las referencias del objeto seleccion observe.synchro.operation.canceled= observe.synchro.operation.consolidate= observe.synchro.operation.consolidate.description= +observe.synchro.operation.dataSynchronize= +observe.synchro.operation.dataSynchronize.description= observe.synchro.operation.exportData= observe.synchro.operation.exportData.description= observe.synchro.operation.failed= @@ -1805,6 +1821,8 @@ observe.synchro.step.config= observe.synchro.step.config.description= observe.synchro.step.consolidate= observe.synchro.step.consolidate.description= +observe.synchro.step.dataSynchronize= +observe.synchro.step.dataSynchronize.description= observe.synchro.step.exportData= observe.synchro.step.exportData.description= observe.synchro.step.report= @@ -2002,6 +2020,8 @@ observe.title.content.weightCategory= observe.title.content.weightMeasureTypes= observe.title.content.windSpeeds= observe.title.create.local.db= +observe.title.dataSynchronize= +observe.title.dataSynchronize.tip= observe.title.delete= observe.title.error.dialog= observe.title.exportData= diff --git a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties index 19aa237..770bc94 100644 --- a/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties +++ b/observe-application-swing/src/main/resources/i18n/observe-application-swing_fr_FR.properties @@ -96,6 +96,10 @@ observe.action.copy.column.headers=Copier les entêtes de colonne observe.action.copy.column.headers.tip=Ajoute dans le résultat les entêtes de colonne (i.e la première ligne) observe.action.copy.row.headers=Copier les entêtes de ligne observe.action.copy.row.headers.tip=Ajoute dans le résultat les entêtes de ligne (i.e la première colonne) +observe.action.copyToLeft=← +observe.action.copyToLeft.tip=Copier vers la base de gauche +observe.action.copyToRight=→ +observe.action.copyToRight.tip=Copier vers la base de droite observe.action.country.create.tip=Créer un nouveau pays observe.action.country.delete.tip=Supprimer le pays sélectionné observe.action.country.detail.tip=Voir les détails du pays sélectionné @@ -129,6 +133,7 @@ observe.action.create.targetSample=Insérer cet échantillon observe.action.create.targetSample.tip=Insérer cet échantillon de thon rejeté observe.action.create.targetSampleCapture=Insérer cet échantillon observe.action.create.targetSampleCapture.tip=Insérer cet échantillon de thon capturé +observe.action.datasynchro.launch.operation=Récupération des données observe.action.db.locale.es.tip=Changer la langue du référentiel en espagnol observe.action.db.locale.fr.tip=Changer la langue du référentiel en français observe.action.db.locale.uk.tip=Changer la langue du référentiel en anglais @@ -140,6 +145,10 @@ observe.action.delete.maree.tip=Supprimer la marée observe.action.delete.route.tip=Supprimer la route observe.action.delete.set.tip=Supprimer la calée observe.action.delete.tip=Supprimer +observe.action.deleteFromLeft=Supprimer à gauche +observe.action.deleteFromLeft.tip=Supprimer la ou les marées sélectionnée(s) de la base de gauche +observe.action.deleteFromRight=Supprimer à droite +observe.action.deleteFromRight.tip=Supprimer la ou les marées sélectionnée(s) de la base de droite observe.action.detail=Voir les détails observe.action.detectionMode.create.tip=Créer un nouveau mode détection observe.action.detectionMode.delete.tip=Supprimer le mode de détection sélectionné @@ -1031,6 +1040,7 @@ observe.configuration.description= observe.content.mode.create.tip=L'objet est en cours de création observe.content.mode.read.tip=L'objet n'est pas éditable observe.content.mode.update.tip=L'objet est en cours d'édition +observe.datasynchro.actionsToPerform=Opérations à réaliser observe.encounter.action.create=Insérer cette rencontre observe.encounter.action.create.tip=Insérer cette rencontre observe.encounter.count=Nombre @@ -1337,6 +1347,9 @@ observe.message.consolidate.operation.done=Opération de calcul des données ter observe.message.consolidate.save.changes=Sauvegarde des modifications sur la(es) %1$s marée(s) modifiée(s). observe.message.consolidate.trip=Données calculées pour la marée %1$s observe.message.creating.referentiel=L'objet est en cours de création. +observe.message.datasynchro.leftData.loaded=Données du panneau gauche récupérées. +observe.message.datasynchro.ready=Données récupérées. +observe.message.datasynchro.rightData.loaded=Données du panneau droit récupérées. observe.message.db.closed=%1$s a été fermé observe.message.db.loaded=%1$s chargé observe.message.db.loading=%1$s en cours de chargement @@ -1779,6 +1792,8 @@ observe.synchro.obsolete.entity.fix=Changer les références sur l'objet sélect observe.synchro.operation.canceled=L'opération <%1$s> a été annulée. observe.synchro.operation.consolidate=Calculer les données observe.synchro.operation.consolidate.description=Calculer les données non observées +observe.synchro.operation.dataSynchronize=Synchronisation bi-directionnelle de données +observe.synchro.operation.dataSynchronize.description=Synchronisation bi-directionnelle des données utilisateurs observe.synchro.operation.exportData=Exporter les données observateurs observe.synchro.operation.exportData.description=Exporter les données observateurs vers la base centrale observe.synchro.operation.failed=L'opération < %1$s > a échouée. @@ -1805,6 +1820,8 @@ observe.synchro.step.config=Configuration observe.synchro.step.config.description=Configuration des opérations et sources de données à utiliser. observe.synchro.step.consolidate=Calculer les données observe.synchro.step.consolidate.description=Calculer les données non observées +observe.synchro.step.dataSynchronize=Synchronisation bi-directionnelle de données +observe.synchro.step.dataSynchronize.description=Synchronisation bi-directionnelle des données utilisateurs observe.synchro.step.exportData=Exporter observe.synchro.step.exportData.description=Exporter les données observateurs vers la base centrale observe.synchro.step.report=Tableaux de synthèse @@ -2002,6 +2019,8 @@ observe.title.content.weightCategory=Gestion des catégories poids observe.title.content.weightMeasureTypes=Gestion des types de mesure de poids observe.title.content.windSpeeds=Gestion des vents Beaufort observe.title.create.local.db=Chargement d'une base locale +observe.title.dataSynchronize=Synchronisation bi-directionnelle de données +observe.title.dataSynchronize.tip=Synchronisation bi-directionnelle des données utilisateurs observe.title.delete=Confirmation de suppression observe.title.error.dialog=Une erreur est survenue\! observe.title.exportData=Exporter les données -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm