[Git][ultreiaio/ird-observe][develop] more fixes on admin api
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: 1f63ebe6 by tchemit at 2019-09-16T12:11:41Z more fixes on admin api - - - - - 7 changed files: - client-core/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIHandler.java - client-core/src/main/java/fr/ird/observe/client/ui/admin/AdminUIHandler.java - + client-core/src/main/java/fr/ird/observe/client/ui/admin/actions/SelectData.java - client-core/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigModel.java - client-core/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUIHandler.java - client-core/src/main/java/fr/ird/observe/client/ui/admin/config/SelectDataUIHandler.java - client-core/src/main/java/fr/ird/observe/client/ui/admin/export/actions/Start.java Changes: ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/AdminTabUIHandler.java ===================================== @@ -61,8 +61,6 @@ public class AdminTabUIHandler<U extends AdminTabUI> { AdminStep step = ui.getStep(); - //FIXME ? ui.addPropertyChangeListener(parentUI); - log.debug(String.format("common for [%s] for main ui %s@%d", step, parentUI.getClass().getName(), System.identityHashCode(ui))); String stepLabel = I18nEnumHelper.getLabel(step); ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/AdminUIHandler.java ===================================== @@ -21,6 +21,7 @@ */ package fr.ird.observe.client.ui.admin; +import fr.ird.observe.client.ui.admin.actions.SelectData; import fr.ird.observe.client.ui.admin.config.ConfigUI; import fr.ird.observe.client.ui.admin.config.SelectDataUI; import fr.ird.observe.client.ui.admin.consolidate.ConsolidateUI; @@ -180,32 +181,18 @@ public class AdminUIHandler implements UIHandler<AdminUI> { AdminUIModel model = ui.getModel(); - if (oldStep == null - && newStep == AdminStep.CONFIG - && (model.containsOperation(AdminStep.REFERENTIAL_SYNCHRONIZE) || model.containsOperation(AdminStep.DATA_SYNCHRONIZE))) { - - ConfigUI configUI = (ConfigUI) ui.getStepUI(AdminStep.CONFIG); + if (oldStep == null && newStep == AdminStep.CONFIG && (model.containsOperation(AdminStep.REFERENTIAL_SYNCHRONIZE) || model.containsOperation(AdminStep.DATA_SYNCHRONIZE))) { model.getConfigModel().getLocalSourceModel().setLabelPrefix(t("observe.storage.config.left.storage")); model.getConfigModel().getCentralSourceModel().setLabelPrefix(t("observe.storage.config.right.storage")); -// configUI.getLocalSourceConfig().setBorder(new TitledBorder(model.getConfigModel().getLocalSourceLabel())); -// configUI.getCentralSourceConfig().setBorder(new TitledBorder(model.getConfigModel().getCentralSourceLabel())); - } - if (oldStep == null - && newStep == AdminStep.CONFIG - && model.containsOperation(AdminStep.EXPORT_DATA)) { - - ConfigUI configUI = (ConfigUI) ui.getStepUI(AdminStep.CONFIG); + if (oldStep == null && newStep == AdminStep.CONFIG && model.containsOperation(AdminStep.EXPORT_DATA)) { model.getConfigModel().getLocalSourceModel().setLabelPrefix(t("observe.storage.config.exportSource.storage")); model.getConfigModel().getCentralSourceModel().setLabelPrefix(t("observe.storage.config.exportTarget.storage")); -// configUI.getLocalSourceConfig().setBorder(new TitledBorder(model.getConfigModel().getLocalSourceLabel())); -// configUI.getCentralSourceConfig().setBorder(new TitledBorder(model.getConfigModel().getCentralSourceLabel())); - } if (oldStep != null && oldStep.ordinal() < AdminStep.REFERENTIAL_SYNCHRONIZE.ordinal() && newStep == AdminStep.REFERENTIAL_SYNCHRONIZE) { @@ -238,7 +225,7 @@ public class AdminUIHandler implements UIHandler<AdminUI> { if (ui.getModel().getStepState(AdminStep.ACTIVITY_LONGLINE_PAIRING) == WizardState.PENDING) { ActivityLonglinePairingUI tabUI = (ActivityLonglinePairingUI) ui.getStepUI(AdminStep.ACTIVITY_LONGLINE_PAIRING); - tabUI.getPrepare().doClick(); + SwingUtilities.invokeLater(tabUI.getPrepare()::doClick); } } @@ -256,7 +243,7 @@ public class AdminUIHandler implements UIHandler<AdminUI> { if (ui.getModel().getStepState(AdminStep.VALIDATE) == WizardState.PENDING) { ValidateUI tabUI = (ValidateUI) ui.getStepUI(AdminStep.VALIDATE); - tabUI.getStart().doClick(); + SwingUtilities.invokeLater(tabUI.getStart()::doClick); } } @@ -265,7 +252,11 @@ public class AdminUIHandler implements UIHandler<AdminUI> { if (ui.getModel().getStepState(AdminStep.SAVE_LOCAL) == WizardState.PENDING) { SaveLocalUI tabUI = (SaveLocalUI) ui.getStepUI(AdminStep.SAVE_LOCAL); - SwingUtilities.invokeLater(tabUI.getStart()::doClick); + if (tabUI.getStepModel().isLocalSourceNeedSave()) { + SwingUtilities.invokeLater(tabUI.getStart()::doClick); + } else { + SwingUtilities.invokeLater(tabUI.getContinueAction()::doClick); + } } } @@ -304,7 +295,8 @@ public class AdminUIHandler implements UIHandler<AdminUI> { // préparation de l'arbre de sélection SelectDataUI selectDataUI = (SelectDataUI) ui.getStepUI(AdminStep.SELECT_DATA); - selectDataUI.getHandler().onSelectDataOpen(); + SelectData action = SelectData.init(selectDataUI,null, SelectData.class); + action.run(); } } ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/actions/SelectData.java ===================================== @@ -0,0 +1,68 @@ +package fr.ird.observe.client.ui.admin.actions; + +/*- + * #%L + * ObServe :: Client core + * %% + * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io + * %% + * 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% + */ + +import fr.ird.observe.client.db.ObserveSwingDataSource; +import fr.ird.observe.client.ui.admin.config.SelectDataUI; +import fr.ird.observe.client.ui.tree.selection.SelectionTree; + +import javax.swing.SwingUtilities; +import java.awt.event.ActionEvent; + +public class SelectData extends AdminTabUIActionSupport<SelectDataUI> implements Runnable { + + public SelectData() { + super(null, null, null, null); + } + + @Override + protected void doActionPerformed(ActionEvent e, SelectDataUI ui) { + run(); + } + + @Override + public void run() { + getParentUI().getModel().setBusy(true); + try { + SwingUtilities.invokeLater(this::run0); + } finally { + getParentUI().getModel().setBusy(false); + } + } + + private void run0() { + SelectionTree selectTree = ui.getSelectTree(); + selectTree.clearSelection(); + + SwingUtilities.invokeLater(selectTree::grabFocus); + + if (selectTree.getTreeModel().isNotEmpty()) { + + selectTree.setSelectionRow(0); + } + ObserveSwingDataSource localSource = ui.getModel().getConfigModel().getLocalSourceModel().getSafeSource(true); + if (localSource.isLocal()) { + SwingUtilities.invokeLater(selectTree::expandAll); + } + } +} ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigModel.java ===================================== @@ -96,8 +96,7 @@ public class ConfigModel extends AdminActionModel { @Override public void validate() { super.validate(); - ConfigModel.this.firePropertyChange(VALID_PROPERTY_NAME, isValid()); - ConfigModel.this.firePropertyChange(VALID_STEP_PROPERTY_NAME, isValidStep()); + ConfigModel.this.firePropertyChange(AdminUIModel.VALID_STEP_PROPERTY_NAME, isValidStep()); } }; @@ -126,8 +125,7 @@ public class ConfigModel extends AdminActionModel { @Override public void validate() { super.validate(); - ConfigModel.this.firePropertyChange(VALID_PROPERTY_NAME, isValid()); - ConfigModel.this.firePropertyChange(VALID_STEP_PROPERTY_NAME, isValidStep()); + ConfigModel.this.firePropertyChange(AdminUIModel.VALID_STEP_PROPERTY_NAME, isValidStep()); } }; centralSourceModel.setLabelPrefix(n("observe.storage.config.referentiel.storage")); ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/config/ConfigUIHandler.java ===================================== @@ -46,7 +46,8 @@ public class ConfigUIHandler extends AdminTabUIHandler<ConfigUI> implements UIHa UIHelper.setLayerUI(ui.getConfig(), parentUI.getConfigBlockLayerUI()); UIHelper.setLayerUI(ui.getContent(), null); AdminUIModel model = ui.getModel(); - model.addPropertyChangeListener("operations", e -> isOperationSelected(model.getOperations(), ui.EXPORT_DATA)); + model.addPropertyChangeListener(AdminUIModel.OPERATIONS_PROPERTY_NAME, e -> isOperationSelected(model.getOperations(), ui.EXPORT_DATA)); + ui.getModel().getConfigModel().addPropertyChangeListener(AdminUIModel.VALID_STEP_PROPERTY_NAME, e-> model.validate()); } ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/config/SelectDataUIHandler.java ===================================== @@ -27,8 +27,6 @@ import fr.ird.observe.client.ui.tree.selection.SelectionTree; import fr.ird.observe.client.ui.util.UIHelper; import org.nuiton.jaxx.runtime.spi.UIHandler; -import javax.swing.SwingUtilities; - /** * Created on 28/11/16. * @@ -52,21 +50,4 @@ public class SelectDataUIHandler extends AdminTabUIHandler<SelectDataUI> impleme // UIHelper.initUI(tabUI.getSelectTreePane(), tree); } - - public void onSelectDataOpen() { - - SelectionTree selectTree = ui.getSelectTree(); - selectTree.clearSelection(); - - SwingUtilities.invokeLater(selectTree::grabFocus); - - if (selectTree.getTreeModel().isNotEmpty()) { - - selectTree.setSelectionRow(0); - } - if (ui.getModel().getConfigModel().getLocalSourceModel().getSafeSource(true).isLocal()) { - SwingUtilities.invokeLater(selectTree::expandAll); - } - - } } ===================================== client-core/src/main/java/fr/ird/observe/client/ui/admin/export/actions/Start.java ===================================== @@ -88,10 +88,12 @@ public class Start extends ExportUIActionSupport { DecoratorService decoratorService = getDecoratorService(); ReferentialReferenceDecorator<ProgramReference> programDecorator = decoratorService.getReferentialReferenceDecorator(ProgramReference.class); - int stepCount = 4 + 2 * tripEntries.size(); + int stepCount = 6 + 2 * tripEntries.size(); ProgressModel progressModel = stepModel.getProgressModel(); progressModel.setStepsCount(stepCount); + progressModel.setCurrentStep(0); + progressModel.incrementsCurrentStep(); try (ObserveSwingDataSource localDataSource = openSource(stepModel.getSource())) { @@ -137,6 +139,7 @@ public class Start extends ExportUIActionSupport { } } + progressModel.incrementsCurrentStep(); sendMessage(t("observe.actions.operation.message.done", new Date())); View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/1f63ebe64752525a37f86c9002ed... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/1f63ebe64752525a37f86c9002ed... You're receiving this email because of your account on gitlab.com.
participants (1)
-
Tony CHEMIT