This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit cafb99abecb2e084f53984bbbed0ea0cf327fd86 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Nov 27 14:45:49 2016 +0100 refs #8429 Amélioration du focus sur les dialogues de data sources --- .../swing/ui/storage/StorageUIHandler.java | 130 +++++++++++++++------ .../swing/ui/storage/StorageUIModel.java | 8 +- .../ui/tree/selection/SelectionTreeModel.java | 17 ++- 3 files changed, 103 insertions(+), 52 deletions(-) diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIHandler.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIHandler.java index f5ce6de..e69cb74 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIHandler.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIHandler.java @@ -62,6 +62,7 @@ import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JComponent; +import javax.swing.JRadioButton; import javax.swing.JTabbedPane; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; @@ -228,24 +229,7 @@ public class StorageUIHandler { UIHelper.center(ui.getContextValue(Window.class, "parent"), ui); SwingUtilities.invokeLater(() -> { - JComponent focusOwner; - switch (ui.getModel().getStep()) { - - case CHOOSE_DB_MODE: - focusOwner = ui.getCHOOSE_DB_MODE().getUseLocalMode(); - if (!focusOwner.isEnabled() || ui.getCHOOSE_DB_MODE().getUseRemoteMode().isSelected()) { - focusOwner = ui.getCHOOSE_DB_MODE().getUseRemoteMode(); - } - break; - case CONFIG: - focusOwner = ui.getCONFIG().getDumpFile(); - break; - case BACKUP: - focusOwner = ui.getBACKUP().getDirectoryText(); - break; - default: - focusOwner = null; - } + JComponent focusOwner = getFocusComponent(ui, ui.getModel().getStep()); if (focusOwner != null) { focusOwner.grabFocus(); } @@ -255,6 +239,81 @@ public class StorageUIHandler { ui.setVisible(true); } + public JComponent getFocusComponent(StorageUI ui, StorageStep newStep) { + + DbMode dbMode = ui.getModel().getDbMode(); + JComponent focusOwner; + switch (newStep) { + + case CHOOSE_DB_MODE: + switch (dbMode) { + + case USE_LOCAL: + focusOwner = ui.getCHOOSE_DB_MODE().getUseLocalMode(); + if (!focusOwner.isEnabled()) { + focusOwner = ui.getCHOOSE_DB_MODE().getUseRemoteMode(); + } + break; + case CREATE_LOCAL: + focusOwner = ui.getCHOOSE_DB_MODE().getCreateLocalMode(); + + break; + case USE_REMOTE: + focusOwner = ui.getCHOOSE_DB_MODE().getUseRemoteMode(); + break; + case USE_SERVER: + focusOwner = ui.getCHOOSE_DB_MODE().getUseServerMode(); + break; + default: + focusOwner = null; // ne peut pas arriver + } + + break; + case CONFIG: + switch (dbMode) { + + case USE_LOCAL: + focusOwner = null; // on ne peut pas arriver sur cet ecran + break; + case CREATE_LOCAL: + focusOwner = ui.getCONFIG().getDumpFile(); + + break; + case USE_REMOTE: + focusOwner = ui.getCONFIG().getRemoteUrl(); + break; + case USE_SERVER: + focusOwner = ui.getCONFIG().getRemoteUrl(); + break; + default: + focusOwner = null; // ne peut pas arriver + } + + break; + case CONFIG_REFERENTIEL: + focusOwner = ui.getCONFIG_REFERENTIEL().getConfigureCentralSource(); + break; + case CONFIG_DATA: + focusOwner = ui.getCONFIG_DATA().getConfigureCentralSource(); + break; + case BACKUP: + focusOwner = ui.getBACKUP().getDirectoryText(); + break; + case SELECT_DATA: + focusOwner = ui.getSELECT_DATA().getSelectTree(); + break; + case ROLES: + focusOwner = ui.getROLES().getRoles(); + break; + case CONFIRM: + focusOwner = ui.getApplyAction(); + break; + default: + focusOwner = null; + } + return focusOwner; + } + public void onStepChanged(StorageUI ui, StorageStep oldStep, StorageStep newStep) { if (newStep == null) { return; @@ -278,6 +337,14 @@ public class StorageUIHandler { } + if (StorageStep.CHOOSE_DB_MODE == newStep) { + JRadioButton focusOwner = ui.getCHOOSE_DB_MODE().getUseLocalMode(); + if (!focusOwner.isEnabled() || ui.getCHOOSE_DB_MODE().getUseRemoteMode().isSelected()) { + focusOwner = ui.getCHOOSE_DB_MODE().getUseRemoteMode(); + } + focusOwner.requestFocusInWindow(); + } + if (StorageStep.CONFIG_REFERENTIEL == newStep && mustRecompute) { // mise à jour de l'univers des étapes (ajout/suppression étape confg_data et select_data possible) @@ -296,7 +363,6 @@ public class StorageUIHandler { // récupération des données possibles à importer initSelectData(ui); - } if (StorageStep.ROLES == newStep && mustRecompute) { @@ -314,6 +380,11 @@ public class StorageUIHandler { } + + JComponent focusComponent = getFocusComponent(ui, newStep); + if (focusComponent != null) { + focusComponent.requestFocusInWindow(); + } } public void launchApply(final StorageUI ui) { @@ -338,7 +409,6 @@ public class StorageUIHandler { if (log.isWarnEnabled()) { log.warn("Launch standalone apply action " + action); } - //FIXME Action executor will not execute task until previous is finished... action.run(); } else { ObserveActionExecutor executor = ObserveRunner.getActionExecutor(); @@ -356,7 +426,6 @@ public class StorageUIHandler { if (log.isWarnEnabled()) { log.warn("Launch standalone cancel action " + action); } - //FIXME Action executor will not execute task until previous is finished... if (action != null) { action.run(); } @@ -627,8 +696,6 @@ public class StorageUIHandler { config.setShowMigrationProgression(configurationTopiaPG.isShowMigrationProgression()); config.setShowMigrationSql(configurationTopiaPG.isShowMigrationSql()); - //TODO-TC20100311 : on devrait pas regarder si l'utilisateur veut sauver - //TODO-TC20100311 : la configuration ? config.saveForUser(); } else if (model.isEditServerConfig()) { @@ -640,23 +707,11 @@ public class StorageUIHandler { config.setServerPassword(new String(configurationRest.getPassword())); config.setServerDatabaseName(configurationRest.getOptionalDatabaseName().orElse("")); - //TODO-TC20100311 : on devrait pas regarder si l'utilisateur veut sauver - //TODO-TC20100311 : la configuration ? - config.saveForUser(); } } -// /** -// * @return le lastName par defaut du fichier de sauvegarde de la base locale -// * (expression calculée à partir de la date courante et du pattern -// * {@link ObserveSwingApplicationConfig#BACKUP_DB_PATTERN}). -// */ -// public String getDefaultBackupFilename() { -// return String.format(ObserveSwingApplicationConfig.BACKUP_DB_PATTERN, new Date()); -// } - /** * Effectue une sauvegarde de la base locale vers le fichier choisi. * @@ -717,7 +772,6 @@ public class StorageUIHandler { StorageUIModel model = ui.getModel(); - boolean closeSource = true; try { @@ -769,6 +823,10 @@ public class StorageUIHandler { SwingUtilities.invokeLater(() -> selectDataUI.getSelectTree().expandAll()); } + if (selectDataUI.getSelectTree().getRowCount() > 0) { + selectDataUI.getSelectTree().setSelectionRow(0); + } + SwingUtilities.invokeLater(selectDataUI.getSelectTree()::grabFocus); } finally { if (closeSource) { diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIModel.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIModel.java index bab7402..391efa4 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIModel.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/storage/StorageUIModel.java @@ -1150,6 +1150,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { } // ne pas supprimer utiliser dans les templates + @SuppressWarnings("unused") public File getInitialDbDump() { return ObserveSwingApplicationContext.get().getConfig().getInitialDbDump(); } @@ -1392,10 +1393,6 @@ public class StorageUIModel extends WizardModel<StorageStep> { return serverUrl; } -// protected void setServerUrl(String serverUrl) { -// this.serverUrl = serverUrl; -// } - public boolean isUseSsl() { return pgConfig.isUseSsl(); } @@ -1786,8 +1783,6 @@ public class StorageUIModel extends WizardModel<StorageStep> { if (log.isErrorEnabled()) { log.error("Error in test remote", e); } - - setConnexionStatus(null); setConnexionStatus(ConnexionStatus.FAILED); } finally { @@ -1805,6 +1800,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { } // ne pas supprimer, utilisé dans les templates + @SuppressWarnings("unused") public String getConnexionStatusError() { return connexionStatusError; } diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/selection/SelectionTreeModel.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/selection/SelectionTreeModel.java index 274bdde..390cf76 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/selection/SelectionTreeModel.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/tree/selection/SelectionTreeModel.java @@ -194,8 +194,6 @@ public class SelectionTreeModel extends DefaultTreeModel { programs = ProgramHelper.sort(programs); - boolean showEmptyTrips = isShowEmptyTrips(); - RootSelectionTreeNode root = new RootSelectionTreeNode(); Map<ReferentialReference<ProgramDto>, Collection<DataReference<TripLonglineDto>>> tripsLonglineByProgram = navigationResult.getTripsLonglineByProgram().asMap(); @@ -205,17 +203,15 @@ public class SelectionTreeModel extends DefaultTreeModel { if (ProgramHelper.isProgramLongline(program)) { Collection<DataReference<TripLonglineDto>> references = tripsLonglineByProgram.getOrDefault(program, Collections.emptyList()); - if (showEmptyTrips || !references.isEmpty()) { - ProgramSelectionTreeNode programNode = ProgramSelectionTreeNode.ofLongline(program, references); - root.add(programNode); - } + ProgramSelectionTreeNode programNode = ProgramSelectionTreeNode.ofLongline(program, references); + root.add(programNode); + } else if (ProgramHelper.isProgramSeine(program)) { Collection<DataReference<TripSeineDto>> references = tripsSeineByProgram.getOrDefault(program, Collections.emptyList()); - if (showEmptyTrips || !references.isEmpty()) { - ProgramSelectionTreeNode programNode = ProgramSelectionTreeNode.ofSeine(program, references); - root.add(programNode); - } + ProgramSelectionTreeNode programNode = ProgramSelectionTreeNode.ofSeine(program, references); + root.add(programNode); + } } @@ -380,6 +376,7 @@ public class SelectionTreeModel extends DefaultTreeModel { NavigationRequest navigationRequest = new NavigationRequest(); navigationRequest.setLoadLongline(isLoadLongline()); navigationRequest.setLoadSeine(isLoadSeine()); + navigationRequest.setLoadEmptyProgram(isShowEmptyTrips()); return navigationRequest; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.