Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe Commits: cdbaa4e7 by Tony CHEMIT at 2018-04-01T13:39:24Z Amélioration de l'arbre de navigation - - - - - 27 changed files: - client-configuration/pom.xml - client-configuration/src/main/config/Client.ini - client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java - + client-configuration/src/main/java/fr/ird/observe/client/configuration/NavigationTreeConfig.java - + client-configuration/src/main/java/fr/ird/observe/client/configuration/NavigationTreeConfigBean.java - client-configuration/src/main/resources/i18n/client-configuration_en_GB.properties - client-configuration/src/main/resources/i18n/client-configuration_es_ES.properties - client-configuration/src/main/resources/i18n/client-configuration_fr_FR.properties - client/pom.xml - client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java - client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroModel.java - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jcss - client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java - client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jcss - − client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeader.jaxx - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeModel.java - + client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeader.jcss → client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss - client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeaderHandler.java → client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUIHandler.java - client/src/main/resources/i18n/client_en_GB.properties - client/src/main/resources/i18n/client_es_ES.properties - client/src/main/resources/i18n/client_fr_FR.properties - pom.xml Changes: ===================================== client-configuration/pom.xml ===================================== --- a/client-configuration/pom.xml +++ b/client-configuration/pom.xml @@ -104,6 +104,14 @@ <groupId>io.ultreia.java4all.jaxx</groupId> <artifactId>jaxx-widgets-gis</artifactId> </dependency> + <dependency> + <groupId>io.ultreia.java4all.jaxx</groupId> + <artifactId>jaxx-widgets-temperature</artifactId> + </dependency> + <dependency> + <groupId>io.ultreia.java4all</groupId> + <artifactId>java-bean</artifactId> + </dependency> </dependencies> ===================================== client-configuration/src/main/config/Client.ini ===================================== --- a/client-configuration/src/main/config/Client.ini +++ b/client-configuration/src/main/config/Client.ini @@ -174,6 +174,11 @@ description = observe.config.h2.can.migrate.description key = h2.canMigrate type = Boolean defaultValue = true +[option h2CanEditReferential] +description = observe.config.h2.can.editReferential.description +key = h2.canEditReferential +type = boolean +defaultValue = false [option h2ServerPort] description = observe.config.h2.serverPort.description @@ -501,6 +506,12 @@ key = ui.coordinate.format type = org.nuiton.jaxx.widgets.gis.CoordinateFormat defaultValue = "dmd" +[option temperatureFormat] +description = observe.config.temperature.format +key = ui.temperature.format +type = org.nuiton.jaxx.widgets.temperature.TemperatureFormat +defaultValue = "C" + [option focusBorderColor] description = observe.config.ui.focusBorderColor key = ui.focusBorder.color @@ -531,6 +542,30 @@ key = server.checkServerVersion type = Boolean defaultValue = true +[option showSeineTrip] +description = observe.config.ui.tree.showSeineTrip.description +key = ui.tree.showSeineTrip +type = Boolean +defaultValue = true + +[option showLonglineTrip] +description = observe.config.ui.tree.showLonglineTrip.description +key = ui.tree.showLonglineTrip +type = Boolean +defaultValue = true + +[option showReferential] +description = observe.config.ui.tree.showReferential.description +key = ui.tree.showReferential +type = Boolean +defaultValue = true + +[option showEmptyProgram] +description = observe.config.ui.tree.showEmptyProgram.description +key = ui.tree.showEmptyProgram +type = Boolean +defaultValue = true + [action help] description = observe.action.commandline.help action = "fr.ird.observe.client.ObserveCLAction#help" ===================================== client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java ===================================== --- a/client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java +++ b/client-configuration/src/main/java/fr/ird/observe/client/configuration/ClientConfig.java @@ -8,12 +8,12 @@ * 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>. @@ -30,6 +30,16 @@ import fr.ird.observe.client.constants.DbMode; import fr.ird.observe.dto.FloatingObjectPreset; import fr.ird.observe.dto.presets.RemoteDataSourceConfiguration; import fr.ird.observe.dto.presets.ServerDataSourceConfiguration; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.config.ApplicationConfig; +import org.nuiton.config.ArgumentsParserException; +import org.nuiton.jaxx.widgets.gis.CoordinateFormat; +import org.nuiton.jaxx.widgets.temperature.TemperatureFormat; +import org.nuiton.version.Version; +import org.nuiton.version.Versions; + import java.beans.PropertyChangeListener; import java.io.File; import java.nio.charset.StandardCharsets; @@ -44,15 +54,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Properties; import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.config.ApplicationConfig; -import org.nuiton.config.ArgumentsParserException; -import org.nuiton.jaxx.widgets.gis.CoordinateFormat; -import org.nuiton.version.Version; -import org.nuiton.version.Versions; - import static org.nuiton.i18n.I18n.t; @@ -62,52 +63,72 @@ import static org.nuiton.i18n.I18n.t; * @author Tony Chemit - dev@tchemit.fr * @since 1.0 */ -public class ClientConfig extends GeneratedClientConfig { +public class ClientConfig extends GeneratedClientConfig implements NavigationTreeConfig { + public static final String DB_NAME = "obstuna"; + public static final List<ClientConfigOption> MAP_LAYERS = ImmutableList.of( + ClientConfigOption.MAP_LAYER1, + ClientConfigOption.MAP_LAYER2, + ClientConfigOption.MAP_LAYER3, + ClientConfigOption.MAP_LAYER4, + ClientConfigOption.MAP_LAYER5, + ClientConfigOption.MAP_LAYER6, + ClientConfigOption.MAP_LAYER7, + ClientConfigOption.MAP_LAYER8, + ClientConfigOption.MAP_LAYER9, + ClientConfigOption.MAP_LAYER10); /** le pattern du fichier de sauvegarde d'une base locale */ private static final String BACKUP_DB_PATTERN = "obstuna-local-%1$tF--%1$tk-%1$tM-%1$tS.sql.gz"; - - public static final String DB_NAME = "obstuna"; - private static final String APPLICATION_VERSION = "application.version"; - private static final String VERSION = "version"; - private static final String PROPERTY_LOCAL_STORAGE_EXIST = "localStorageExist"; - private static final String PROPERTY_INITIAL_DUMP_EXIST = "initialDumpExist"; - private static final String PROPERTY_MAIN_STORAGE_OPENED = "mainStorageOpened"; - /** Logger */ private static final Log log = LogFactory.getLog(ClientConfig.class); - private static final String DEFAULT_OBSERVE_SWING_CONFIGURATION_FILENAME = "observe-client.conf"; - + /** + * Liste des options qu'on ne peut pas sauvegarder (les mots de passes, + * les options d'admin pour les simples utilisateurs,...). + * + * @since 1.5 + */ + private final String[] unsavables = new String[]{ +// ClientConfigOption.OBSTUNA_PASSWORD.getKey(), + ClientConfigOption.H2_PASSWORD.getKey(), + ClientConfigOption.OBSTUNA_CAN_MIGRATE.getKey(), + }; + //FIXME + private final ImmutableSet<String> longlinVesselTypeIds = ImmutableSet.copyOf( + Sets.newHashSet("fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.044156847891821505", + "fr.ird.observe.entities.referentiel.VesselType#1239832675736#0.8708229847859869", + "fr.ird.observe.entities.referentiel.VesselType#1239832686137#0.1")); + private final ImmutableSet<String> seineVesselTypeIds = ImmutableSet.copyOf( + Sets.newHashSet("fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.044156847891821505", + "fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.307197212385357", + "fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.7380146830307519", + "fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.9086075071905084", + "fr.ird.observe.entities.referentiel.VesselType#1239832675737#0.43324169605639407")); + private final SimpleDateFormat dateFormat = new SimpleDateFormat(); /** * un drapeau pour savoir s'il faut lancer l'interface graphique. Cette * valeur peut être programmées lors des actions. */ private boolean displayMainUI = true; - /** drapeau pour savoir si une base locale existe */ private boolean localStorageExist; - /** * drapeau pour savoir si le dump initial a ete chargée depuis la base * centrale */ private boolean initialDumpExist; - /** drapeau pour savoir si une source de données est ouverte */ private boolean mainStorageOpened; - /** * drapeau pour savoir si la source ouverte est locale (attention, lorsqu'il * n'y a pas de storage d'ouvert, la valeur est null). */ private Boolean mainStorageOpenedLocal; - /** * drapeau pour savoir si on peut utiliser des ui dans l'environnement. * <p> @@ -116,37 +137,12 @@ public class ClientConfig extends GeneratedClientConfig { * trouvé. */ private boolean canUseUI = true; - /** La version de l'application */ private Version version; - /** Texte du copyright (calculé dynamiquement). */ private String copyrightText; - - /** - * Liste des options qu'on ne peut pas sauvegarder (les mots de passes, - * les options d'admin pour les simples utilisateurs,...). - * - * @since 1.5 - */ - private final String[] unsavables = new String[]{ -// ClientConfigOption.OBSTUNA_PASSWORD.getKey(), - ClientConfigOption.H2_PASSWORD.getKey(), - ClientConfigOption.OBSTUNA_CAN_MIGRATE.getKey(), - }; - - //FIXME - private final ImmutableSet<String> longlinVesselTypeIds = ImmutableSet.copyOf( - Sets.newHashSet("fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.044156847891821505", - "fr.ird.observe.entities.referentiel.VesselType#1239832675736#0.8708229847859869", - "fr.ird.observe.entities.referentiel.VesselType#1239832686137#0.1")); - - private final ImmutableSet<String> seineVesselTypeIds = ImmutableSet.copyOf( - Sets.newHashSet("fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.044156847891821505", - "fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.307197212385357", - "fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.7380146830307519", - "fr.ird.observe.entities.referentiel.VesselType#1239832675735#0.9086075071905084", - "fr.ird.observe.entities.referentiel.VesselType#1239832675737#0.43324169605639407")); + private ImmutableList<ServerDataSourceConfiguration> serverDataSourceConfigurationList; + private ImmutableList<RemoteDataSourceConfiguration> remoteDataSourceConfigurationList; public ClientConfig() { this(DEFAULT_OBSERVE_SWING_CONFIGURATION_FILENAME); @@ -217,6 +213,11 @@ public class ClientConfig extends GeneratedClientConfig { return CoordinateFormat.valueOf(get().getOption(ClientConfigOption.COORDINATE_FORMAT.getKey())); } + @Override + public TemperatureFormat getTemperatureFormat() { + return get().getOption(TemperatureFormat.class, ClientConfigOption.TEMPERATURE_FORMAT.getKey()); + } + public String getCopyrightText() { if (copyrightText == null) { Date date = new Date(); @@ -232,6 +233,10 @@ public class ClientConfig extends GeneratedClientConfig { return version; } + private void setVersion(Version version) { + this.version = version; + } + public boolean isShowTimeEditorSlider() { return isShowDateTimeEditorSlider(); } @@ -244,24 +249,24 @@ public class ClientConfig extends GeneratedClientConfig { return displayMainUI; } - public boolean isCanUseUI() { - return canUseUI; - } - - public boolean isLocalStorageExist() { - return localStorageExist; + public void setDisplayMainUI(boolean b) { + displayMainUI = b; } - public boolean isInitialDumpExist() { - return initialDumpExist; + public boolean isCanUseUI() { + return canUseUI; } - public boolean isMainStorageOpened() { - return mainStorageOpened; + public void setCanUseUI(boolean canUseUI) { + this.canUseUI = canUseUI; + if (!canUseUI) { + // on ne pourra pas lancer l'ui principale + setDisplayMainUI(false); + } } - public Boolean getMainStorageOpenedLocal() { - return mainStorageOpenedLocal; + public boolean isLocalStorageExist() { + return localStorageExist; } public void setLocalStorageExist(boolean newValue) { @@ -270,12 +275,20 @@ public class ClientConfig extends GeneratedClientConfig { firePropertyChange(PROPERTY_LOCAL_STORAGE_EXIST, newValue); } + public boolean isInitialDumpExist() { + return initialDumpExist; + } + public void setInitialDumpExist(boolean newValue) { initialDumpExist = newValue; // always force propagation firePropertyChange(PROPERTY_INITIAL_DUMP_EXIST, newValue); } + public boolean isMainStorageOpened() { + return mainStorageOpened; + } + public void setMainStorageOpened(boolean newValue) { mainStorageOpened = newValue; if (!newValue) { @@ -286,36 +299,16 @@ public class ClientConfig extends GeneratedClientConfig { firePropertyChange(PROPERTY_MAIN_STORAGE_OPENED, newValue); } + public Boolean getMainStorageOpenedLocal() { + return mainStorageOpenedLocal; + } + public void setMainStorageOpenedLocal(Boolean newValue) { mainStorageOpenedLocal = newValue; // always force propagation firePropertyChange(PROPERTY_MAIN_STORAGE_OPENED + "Local", newValue); } - public void setDisplayMainUI(boolean b) { - displayMainUI = b; - } - - public void setCanUseUI(boolean canUseUI) { - this.canUseUI = canUseUI; - if (!canUseUI) { - // on ne pourra pas lancer l'ui principale - setDisplayMainUI(false); - } - } - - public static final List<ClientConfigOption> MAP_LAYERS = ImmutableList.of( - ClientConfigOption.MAP_LAYER1, - ClientConfigOption.MAP_LAYER2, - ClientConfigOption.MAP_LAYER3, - ClientConfigOption.MAP_LAYER4, - ClientConfigOption.MAP_LAYER5, - ClientConfigOption.MAP_LAYER6, - ClientConfigOption.MAP_LAYER7, - ClientConfigOption.MAP_LAYER8, - ClientConfigOption.MAP_LAYER9, - ClientConfigOption.MAP_LAYER10); - public List<File> getMapLayerFiles() { List<File> layers = new LinkedList<>(); @@ -399,10 +392,6 @@ public class ClientConfig extends GeneratedClientConfig { } } - private void setVersion(Version version) { - this.version = version; - } - public Set<String> getSeineVesselTypeIds() { return seineVesselTypeIds; } @@ -429,10 +418,17 @@ public class ClientConfig extends GeneratedClientConfig { return option == null ? new RemoteDataSourceConfiguration[0] : new Gson().fromJson(option, RemoteDataSourceConfiguration[].class); } + @Override + public void setRemoteDataSourceConfigurations(RemoteDataSourceConfiguration[] configurations) { + String option = new Gson().toJson(configurations); + get().setOption(ClientConfigOption.REMOTE_DATA_SOURCE_CONFIGURATIONS.getKey(), option); + remoteDataSourceConfigurationList = null; + } + public void addRemoteDataSourceConfiguration(RemoteDataSourceConfiguration configuration) { List<RemoteDataSourceConfiguration> remoteDataSourceConfigurations = new ArrayList<>(Arrays.asList(getRemoteDataSourceConfigurations())); remoteDataSourceConfigurations.add(configuration); - setRemoteDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new RemoteDataSourceConfiguration[remoteDataSourceConfigurations.size()])); + setRemoteDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new RemoteDataSourceConfiguration[0])); saveForUser(); } @@ -440,27 +436,17 @@ public class ClientConfig extends GeneratedClientConfig { List<RemoteDataSourceConfiguration> remoteDataSourceConfigurations = new ArrayList<>(Arrays.asList(getRemoteDataSourceConfigurations())); remoteDataSourceConfigurations.remove(configuration); remoteDataSourceConfigurations.add(configuration); - setRemoteDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new RemoteDataSourceConfiguration[remoteDataSourceConfigurations.size()])); + setRemoteDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new RemoteDataSourceConfiguration[0])); saveForUser(); } public void removeRemoteDataSourceConfiguration(RemoteDataSourceConfiguration configuration) { List<RemoteDataSourceConfiguration> remoteDataSourceConfigurations = new ArrayList<>(Arrays.asList(getRemoteDataSourceConfigurations())); remoteDataSourceConfigurations.remove(configuration); - setRemoteDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new RemoteDataSourceConfiguration[remoteDataSourceConfigurations.size()])); + setRemoteDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new RemoteDataSourceConfiguration[0])); saveForUser(); } - @Override - public void setRemoteDataSourceConfigurations(RemoteDataSourceConfiguration[] configurations) { - String option = new Gson().toJson(configurations); - get().setOption(ClientConfigOption.REMOTE_DATA_SOURCE_CONFIGURATIONS.getKey(), option); - remoteDataSourceConfigurationList=null; - } - - ImmutableList<ServerDataSourceConfiguration> serverDataSourceConfigurationList; - ImmutableList<RemoteDataSourceConfiguration> remoteDataSourceConfigurationList; - public ImmutableList<RemoteDataSourceConfiguration> getRemoteDataSourceConfigurationList() { if (remoteDataSourceConfigurationList == null) { List<RemoteDataSourceConfiguration> configurations = new ArrayList<>(Arrays.asList(getRemoteDataSourceConfigurations())); @@ -485,10 +471,17 @@ public class ClientConfig extends GeneratedClientConfig { return option == null ? new ServerDataSourceConfiguration[0] : new Gson().fromJson(option, ServerDataSourceConfiguration[].class); } + @Override + public void setServerDataSourceConfigurations(ServerDataSourceConfiguration[] configurations) { + String option = new Gson().toJson(configurations); + get().setOption(ClientConfigOption.SERVER_DATA_SOURCE_CONFIGURATIONS.getKey(), option); + serverDataSourceConfigurationList = null; + } + public void addServerDataSourceConfiguration(ServerDataSourceConfiguration configuration) { List<ServerDataSourceConfiguration> remoteDataSourceConfigurations = new ArrayList<>(Arrays.asList(getServerDataSourceConfigurations())); remoteDataSourceConfigurations.add(configuration); - setServerDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new ServerDataSourceConfiguration[remoteDataSourceConfigurations.size()])); + setServerDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new ServerDataSourceConfiguration[0])); saveForUser(); } @@ -496,27 +489,18 @@ public class ClientConfig extends GeneratedClientConfig { List<ServerDataSourceConfiguration> remoteDataSourceConfigurations = new ArrayList<>(Arrays.asList(getServerDataSourceConfigurations())); remoteDataSourceConfigurations.remove(configuration); remoteDataSourceConfigurations.add(configuration); - setServerDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new ServerDataSourceConfiguration[remoteDataSourceConfigurations.size()])); + setServerDataSourceConfigurations(remoteDataSourceConfigurations.toArray(new ServerDataSourceConfiguration[0])); saveForUser(); } public void removeServerDataSourceConfiguration(ServerDataSourceConfiguration configuration) { List<ServerDataSourceConfiguration> serverDataSourceConfigurations = new ArrayList<>(Arrays.asList(getServerDataSourceConfigurations())); serverDataSourceConfigurations.remove(configuration); - setServerDataSourceConfigurations(serverDataSourceConfigurations.toArray(new ServerDataSourceConfiguration[serverDataSourceConfigurations.size()])); + setServerDataSourceConfigurations(serverDataSourceConfigurations.toArray(new ServerDataSourceConfiguration[0])); saveForUser(); } @Override - public void setServerDataSourceConfigurations(ServerDataSourceConfiguration[] configurations) { - String option = new Gson().toJson(configurations); - get().setOption(ClientConfigOption.SERVER_DATA_SOURCE_CONFIGURATIONS.getKey(), option); - serverDataSourceConfigurationList=null; - } - - private final SimpleDateFormat dateFormat = new SimpleDateFormat(); - - @Override public Date getBuildDate() { String dateStr = get().getOption(ClientConfigOption.BUILD_DATE.getKey()); try { ===================================== client-configuration/src/main/java/fr/ird/observe/client/configuration/NavigationTreeConfig.java ===================================== --- /dev/null +++ b/client-configuration/src/main/java/fr/ird/observe/client/configuration/NavigationTreeConfig.java @@ -0,0 +1,64 @@ +package fr.ird.observe.client.configuration; + +/*- + * #%L + * ObServe :: Client Configuration + * %% + * Copyright (C) 2008 - 2018 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.services.service.data.NavigationRequest; + +/** + * Created by tchemit on 01/04/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public interface NavigationTreeConfig { + + boolean isShowSeineTrip(); + + void setShowSeineTrip(boolean showSeineTrip); + + boolean isShowLonglineTrip(); + + void setShowLonglineTrip(boolean showLonglineTrip); + + boolean isShowReferential(); + + void setShowReferential(boolean showReferential); + + boolean isShowEmptyProgram(); + + void setShowEmptyProgram(boolean showEmptyProgram); + + default NavigationRequest toRequest() { + NavigationRequest navigationRequest = new NavigationRequest(); + navigationRequest.setLoadLongline(isShowLonglineTrip()); + navigationRequest.setLoadSeine(isShowSeineTrip()); + navigationRequest.setLoadEmptyProgram(isShowEmptyProgram()); + return navigationRequest; + } + + default void load(NavigationTreeConfig config) { + setShowEmptyProgram(config.isShowEmptyProgram()); + setShowReferential(config.isShowReferential()); + setShowLonglineTrip(config.isShowLonglineTrip()); + setShowSeineTrip(config.isShowSeineTrip()); + } +} ===================================== client-configuration/src/main/java/fr/ird/observe/client/configuration/NavigationTreeConfigBean.java ===================================== --- /dev/null +++ b/client-configuration/src/main/java/fr/ird/observe/client/configuration/NavigationTreeConfigBean.java @@ -0,0 +1,87 @@ +package fr.ird.observe.client.configuration; + +/*- + * #%L + * ObServe :: Client Configuration + * %% + * Copyright (C) 2008 - 2018 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 io.ultreia.java4all.bean.AbstractJavaBean; + +/** + * Created by tchemit on 01/04/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class NavigationTreeConfigBean extends AbstractJavaBean implements NavigationTreeConfig { + + + private boolean showSeineTrip = true; + private boolean showLonglineTrip = true; + private boolean showReferential = true; + private boolean showEmptyProgram = true; + + @Override + public boolean isShowSeineTrip() { + return showSeineTrip; + } + + @Override + public void setShowSeineTrip(boolean showSeineTrip) { + boolean oldValue = isShowSeineTrip(); + this.showSeineTrip = showSeineTrip; + firePropertyChange("showSeineTrip", oldValue, showSeineTrip); + } + + @Override + public boolean isShowLonglineTrip() { + return showLonglineTrip; + } + + @Override + public void setShowLonglineTrip(boolean showLonglineTrip) { + boolean oldValue = isShowLonglineTrip(); + this.showLonglineTrip = showLonglineTrip; + firePropertyChange("showLonglineTrip", oldValue, showLonglineTrip); + } + + @Override + public boolean isShowReferential() { + return showReferential; + } + + @Override + public void setShowReferential(boolean showReferential) { + boolean oldValue = isShowReferential(); + this.showReferential = showReferential; + firePropertyChange("showReferential", oldValue, showReferential); + } + + @Override + public boolean isShowEmptyProgram() { + return showEmptyProgram; + } + + @Override + public void setShowEmptyProgram(boolean showEmptyProgram) { + boolean oldValue = isShowEmptyProgram(); + this.showEmptyProgram = showEmptyProgram; + firePropertyChange("showEmptyProgram", oldValue, showEmptyProgram); + } +} ===================================== client-configuration/src/main/resources/i18n/client-configuration_en_GB.properties ===================================== --- a/client-configuration/src/main/resources/i18n/client-configuration_en_GB.properties +++ b/client-configuration/src/main/resources/i18n/client-configuration_en_GB.properties @@ -33,6 +33,7 @@ observe.config.defaultTmpDirectory.description=Default temporary directory used observe.config.defaultValidationReportDirectory.description=Default validation report directory observe.config.devMode=Dev mode observe.config.floatingObjectPresets.description=Floating Objects references +observe.config.h2.can.editReferential.description=Local database can edit referential observe.config.h2.can.migrate.description=Flag to know if you can migrate h2 data sources observe.config.h2.login.description=H2 Login observe.config.h2.password.description=H2 Password @@ -74,6 +75,7 @@ observe.config.speciesList.seine.objectSchoolEstimate=Species for object school observe.config.speciesList.seine.schoolEstimate=Species for school esitmates observe.config.speciesList.seine.targetCatch=Species for target catches observe.config.swingSessionFile.description=Swing session file. +observe.config.temperature.format=Default temperature format observe.config.ui.autoPopupNumberEditor=Flag sets to true when number editor show automaticly popup observe.config.ui.changeSynchroSrc=Flag sets to true if you can change local source in admin tasks observe.config.ui.focusBorderColor=Color of the focus container border @@ -85,6 +87,10 @@ observe.config.ui.showMnemonic=Show mnemonic on actions observe.config.ui.showNumberEditorButton=Flag sets to true to show button to invoke popup on number's editors observe.config.ui.showTimeEditorSlider=Show timer slider observe.config.ui.storeRemoteStorage=Flag sets to true to store in config a remote connexion (except passwords) +observe.config.ui.tree.showEmptyProgram.description=Show programs with no trip inside +observe.config.ui.tree.showLonglineTrip.description=Show Longline trips +observe.config.ui.tree.showReferential.description=Show Referential +observe.config.ui.tree.showSeineTrip.description=Show Seine Trips observe.config.ui.treeOpenNodes=Opened data from last session observe.config.ui.treeSelectedNodes.description=Selected nodes on last data source observe.config.validation.lengthWeightEnable=Force validation of species length max ===================================== client-configuration/src/main/resources/i18n/client-configuration_es_ES.properties ===================================== --- a/client-configuration/src/main/resources/i18n/client-configuration_es_ES.properties +++ b/client-configuration/src/main/resources/i18n/client-configuration_es_ES.properties @@ -33,6 +33,7 @@ observe.config.defaultTmpDirectory.description=Directorio temporal por defecto observe.config.defaultValidationReportDirectory.description=Directorio por defecto de almacenamiento de los informes de validación observe.config.devMode=Modo desarrollador observe.config.floatingObjectPresets.description=Objets flottants de référence \#TODO +observe.config.h2.can.editReferential.description=Local database can edit referential \#TODO observe.config.h2.can.migrate.description=Autorizar la actualización de las bases locales (h2) observe.config.h2.login.description=Login h2 observe.config.h2.password.description=Contraseña h2 @@ -74,6 +75,7 @@ observe.config.speciesList.seine.objectSchoolEstimate=Especies para las estimaci observe.config.speciesList.seine.schoolEstimate=Especies para las estimaciones observe.config.speciesList.seine.targetCatch=Especies par las capturas objetivo observe.config.swingSessionFile.description=Fichier de sauvegarde des états des UI. \#TODO +observe.config.temperature.format=Default temperature format \#TODO observe.config.ui.autoPopupNumberEditor=Para mostrar automáticamente el editor numérico durante la edición de un número observe.config.ui.changeSynchroSrc=Pour autoriser la sélection de la base source dans les opérations sur base observe.config.ui.focusBorderColor=Couleur de la bordure de la zone qui a le focus \#TODO @@ -85,6 +87,10 @@ observe.config.ui.showMnemonic=Afficher les racourcis clavier \#TODO observe.config.ui.showNumberEditorButton=Para mostrar el botón que permite usar el editor numérico a la izquierda de cada campo numérico observe.config.ui.showTimeEditorSlider=Para mostrar la regla de edición de las horas observe.config.ui.storeRemoteStorage=Para activar la copia de seguridad de la configuración de la fuente de datos remota +observe.config.ui.tree.showEmptyProgram.description=Show programs with no trip inside \#TODO +observe.config.ui.tree.showLonglineTrip.description=Show Longline trips \#TODO +observe.config.ui.tree.showReferential.description=Show Referential \#TODO +observe.config.ui.tree.showSeineTrip.description=Show Seine Trips \#TODO observe.config.ui.treeOpenNodes=Nudos abiertos del arbol abiertos cuando se cerró la base por última vez observe.config.ui.treeSelectedNodes.description=Selected nodes on last data source \#TODO observe.config.validation.lengthWeightEnable=Forcer la validation des bormes min/max de taille d'espèce \#TODO ===================================== client-configuration/src/main/resources/i18n/client-configuration_fr_FR.properties ===================================== --- a/client-configuration/src/main/resources/i18n/client-configuration_fr_FR.properties +++ b/client-configuration/src/main/resources/i18n/client-configuration_fr_FR.properties @@ -33,6 +33,7 @@ observe.config.defaultTmpDirectory.description=Le répertoire temporaire par dé observe.config.defaultValidationReportDirectory.description=Le répertoire par défaut où sont stockés les rapports de validation observe.config.devMode=Mode développeur observe.config.floatingObjectPresets.description=Objets flottants de référence +observe.config.h2.can.editReferential.description=Pour pouvoir éditer le référentiel d'une base locale observe.config.h2.can.migrate.description=Autoriser la mise à jour des bases locales (H2) observe.config.h2.login.description=L'identifiant H2 observe.config.h2.password.description=Le mot de passe H2 @@ -74,6 +75,7 @@ observe.config.speciesList.seine.objectSchoolEstimate=Espèces pour les estimati observe.config.speciesList.seine.schoolEstimate=Espèces pour les estimations observe.config.speciesList.seine.targetCatch=Espèces pour les captures cible observe.config.swingSessionFile.description=Fichier de sauvegarde des états des UI. +observe.config.temperature.format=Unité de température observe.config.ui.autoPopupNumberEditor=Pour afficher automatiquement l'éditeur numérique lors de l'édition d'un nombre observe.config.ui.changeSynchroSrc=Pour autoriser la sélection de la base source dans les opérations sur base observe.config.ui.focusBorderColor=Couleur de la bordure de la zone qui a le focus @@ -85,6 +87,10 @@ observe.config.ui.showMnemonic=Afficher les racourcis clavier observe.config.ui.showNumberEditorButton=Pour afficher le bouton qui permet d'utiliser l'éditeur numérique à gauche de chaque champs numérique observe.config.ui.showTimeEditorSlider=Pour afficher la réglette d'édition des heures observe.config.ui.storeRemoteStorage=Pour activer la sauvegarde de la configuration de la source distante +observe.config.ui.tree.showEmptyProgram.description=Voir les programmes sans marée +observe.config.ui.tree.showLonglineTrip.description=Voir les marées Palangre +observe.config.ui.tree.showReferential.description=Voir le référentiel +observe.config.ui.tree.showSeineTrip.description=Voir les marées Senne observe.config.ui.treeOpenNodes=Nœuds de l'arbre ouverts lors de la dernière fermeture de la base observe.config.ui.treeSelectedNodes.description=Nœuds sélectionnés sur la dernière base ouverte observe.config.validation.lengthWeightEnable=Forcer la validation des bormes min/max de taille d'espèce ===================================== client/pom.xml ===================================== --- a/client/pom.xml +++ b/client/pom.xml @@ -382,10 +382,20 @@ <artifactId>class-mapping</artifactId> </dependency> + <dependency> + <groupId>io.ultreia.java4all</groupId> + <artifactId>java-lang</artifactId> + <scope>runtime</scope> + </dependency> + <!-- jaxx dependencies --> <dependency> <groupId>io.ultreia.java4all.jaxx</groupId> + <artifactId>jaxx-runtime-spi</artifactId> + </dependency> + <dependency> + <groupId>io.ultreia.java4all.jaxx</groupId> <artifactId>jaxx-runtime</artifactId> </dependency> <dependency> ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java +++ b/client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java @@ -61,10 +61,11 @@ public abstract class ObserveKeyStrokes { public static final KeyStroke KEY_STROKE_RELOAD_DEFAULT_CONFIGURATION = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK); public static final KeyStroke KEY_STROKE_ESCAPE = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); public static final KeyStroke KEY_STROKE_ENTER = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); - public static final KeyStroke KEY_STROKE_SHOW_SEINE = KeyStroke.getKeyStroke("ctrl pressed F1"); - public static final KeyStroke KEY_STROKE_SHOW_LONGLINE = KeyStroke.getKeyStroke("ctrl pressed F2"); - public static final KeyStroke KEY_STROKE_SHOW_REFERENTIAL = KeyStroke.getKeyStroke("ctrl pressed F3"); - public static final KeyStroke KEY_STROKE_SHOW_EMPTY_PROGRAM = KeyStroke.getKeyStroke("ctrl pressed F4"); + public static final KeyStroke KEY_STROKE_NAVIGATION_CONFIGURE = KeyStroke.getKeyStroke("ctrl pressed F1"); + public static final KeyStroke KEY_STROKE_SHOW_SEINE = KeyStroke.getKeyStroke("ctrl pressed F2"); + public static final KeyStroke KEY_STROKE_SHOW_LONGLINE = KeyStroke.getKeyStroke("ctrl pressed F3"); + public static final KeyStroke KEY_STROKE_SHOW_REFERENTIAL = KeyStroke.getKeyStroke("ctrl pressed F4"); + public static final KeyStroke KEY_STROKE_SHOW_EMPTY_PROGRAM = KeyStroke.getKeyStroke("ctrl pressed F5"); public static final KeyStroke KEY_STROKE_CONFIGURE_LOCAL_SOURCE = KeyStroke.getKeyStroke("ctrl pressed L"); public static final KeyStroke KEY_STROKE_CONFIGURE_REMOTE_SOURCE = KeyStroke.getKeyStroke("ctrl pressed R"); public static final KeyStroke KEY_STROKE_SAVE_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed S"); ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx +++ b/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUI.jaxx @@ -77,8 +77,10 @@ fr.ird.observe.client.ui.content.ContentUIManager fr.ird.observe.client.ui.content.ObserveActionMap + fr.ird.observe.client.ui.tree.navigation.NavigationUI fr.ird.observe.client.ui.tree.navigation.NavigationTree - fr.ird.observe.client.ui.tree.navigation.NavigationTreeHeader + fr.ird.observe.client.ui.tree.navigation.NavigationTreeModel + fr.ird.observe.client.ui.tree.navigation.NavigationTreeModel fr.ird.observe.client.ui.util.UIHelper fr.ird.observe.client.ui.util.ObserveBlockingLayerUI @@ -252,10 +254,8 @@ protected void finalize() throws Throwable { <!-- left : navigation --> <JXTitledPanel id='navigationView'> - <JScrollPane id='navigationScrollPane' columnHeaderView='{navigationTreeHeader}'> - <NavigationTree id="navigation"/> - <NavigationTreeHeader id='navigationTreeHeader' tree='{navigation}'/> - </JScrollPane> + <NavigationUI id="navigationUI" initializer="new NavigationUI((JAXXContext)this)"/> + <NavigationTree id="navigation" initializer="navigationUI.getTree()"/> </JXTitledPanel> <!-- right : (content + messages) --> ===================================== client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java +++ b/client/src/main/java/fr/ird/observe/client/ui/ObserveMainUIInitializer.java @@ -6,15 +6,15 @@ * %% * 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 + * 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 + * + * 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% @@ -32,7 +32,6 @@ import fr.ird.observe.client.ui.content.ContentUIManager; import fr.ird.observe.client.ui.content.ObserveActionMap; import fr.ird.observe.client.ui.tree.ObserveNavigationTreeShowPopupAction; import fr.ird.observe.client.ui.tree.navigation.NavigationTree; -import fr.ird.observe.client.ui.tree.navigation.NavigationTreeHeader; import fr.ird.observe.client.ui.tree.navigation.NavigationTreeModel; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.client.ui.tree.navigation.nodes.ReferenceNavigationTreeNodeSupport; @@ -44,19 +43,14 @@ import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.dto.decoration.DecoratorService; import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper; import fr.ird.observe.dto.referential.ReferentialLocale; -import java.awt.Component; -import java.awt.Container; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.Objects; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.I18n; +import org.nuiton.jaxx.runtime.context.JAXXInitialContext; +import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; +import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; +import org.nuiton.jaxx.widgets.error.ErrorDialogUI; + import javax.swing.AbstractButton; import javax.swing.JComponent; import javax.swing.JSplitPane; @@ -67,14 +61,16 @@ import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreePath; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.i18n.I18n; -import org.nuiton.jaxx.runtime.context.JAXXInitialContext; -import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel; -import org.nuiton.jaxx.validator.swing.SwingValidatorUtil; -import org.nuiton.jaxx.widgets.error.ErrorDialogUI; - +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Objects; import static fr.ird.observe.client.ui.content.ContentUIInitializer.OBSERVE_ACTION; import static org.nuiton.i18n.I18n.t; @@ -94,11 +90,87 @@ public class ObserveMainUIInitializer { private static final String EMPTY_SELECTION = "emptySelection"; private final ObserveMainUI ui; + private Border focusBorder; + private Border noFocusBorder; ObserveMainUIInitializer(ObserveMainUI ui) { this.ui = ui; } + /** + * Methode pour initialiser l'ui principale sans l'afficher. + * + * @param context le context applicatif + * @param config la configuration a utiliser + * @return l'ui instancie et initialisee mais non visible encore + */ + public static ObserveMainUI initUI(ObserveSwingApplicationContext context, ClientConfig config) { + + SwingValidatorMessageTableModel errorModel = new ObserveSwingValidatorMessageTableModel(); + + DecoratorService decoratorService = context.getDecoratorService(); + + boolean reloadDecorators = false; + Locale currentLocale = I18n.getDefaultLocale(); + Locale configurationLocale = config.getLocale(); + if (!configurationLocale.equals(currentLocale)) { + if (log.isInfoEnabled()) { + log.info("re-init I18n with locale " + configurationLocale); + } + I18n.setDefaultLocale(configurationLocale); + reloadDecorators = true; + } + if (!config.getDbLocale().equals(decoratorService.getReferentialLocale().getLocale())) { + if (log.isInfoEnabled()) { + log.info("re-init db with locale " + config.getDbLocale()); + } + decoratorService.setReferentialLocale(ReferentialLocale.valueOf(config.getDbLocale())); + + reloadDecorators = true; + } + + if (reloadDecorators) { + if (log.isInfoEnabled()) { + log.info("reload decorators"); + } + decoratorService.reload(); + } + + JAXXInitialContext tx = new JAXXInitialContext(); + tx.add(context).add(errorModel); + + // show main ui + ObserveMainUI ui = new ObserveMainUI(tx); + ui.setUndecorated(config.isFullScreen()); + + String title = t("observe.title.welcome.admin") + (" v " + config.getVersion()); + ui.setTitle(title); + + context.setMainUI(ui); + + ErrorDialogUI.init(ui); + + // set fullscreen propery on main ui + ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(config.isFullScreen() ? ui : null); + + new ObserveNavigationTreeShowPopupAction(ui.getNavigation(), ui.getNavigationUI(), ui.getNavigationPopup()); + + return ui; + } + + public static void setMainUIVisible(ObserveSwingApplicationContext rootContext, ObserveMainUI ui, boolean replace) { + + // force le redimensionnement du splitpane + ui.getSplitpane().revalidate(); + + // force le redimensionnement du splitpane2 + ui.getSplitpane2().revalidate(); + + // affichage de l'interface graphique + SwingUtilities.invokeLater(() -> ui.setVisible(true)); + rootContext.getSwingSessionHelper().addComponent(ui, replace); + } + private void changeNavigationNode(TreeSelectionEvent event) { ObserveSwingDataSource source = ObserveSwingApplicationContext.get().getDataSourcesManager().getMainDataSource(); @@ -196,7 +268,7 @@ public class ObserveMainUIInitializer { if (ui.getNavigation().equals(focusOwner)) { focusOnNavigation = true; } - if (ui.getNavigationTreeHeader().equals(focusOwner)) { + if (ui.getNavigationUI().equals(focusOwner)) { focusOnNavigation = true; } if (ui.getNavigationView().equals(focusOwner)) { @@ -209,7 +281,7 @@ public class ObserveMainUIInitializer { focusOnNavigation = true; break; } - if (ui.getNavigationTreeHeader().equals(focusOwnerParent)) { + if (ui.getNavigationUI().equals(focusOwnerParent)) { focusOnNavigation = true; break; } @@ -243,67 +315,6 @@ public class ObserveMainUIInitializer { } /** - * Methode pour initialiser l'ui principale sans l'afficher. - * - * @param context le context applicatif - * @param config la configuration a utiliser - * @return l'ui instancie et initialisee mais non visible encore - */ - public static ObserveMainUI initUI(ObserveSwingApplicationContext context, ClientConfig config) { - - SwingValidatorMessageTableModel errorModel = new ObserveSwingValidatorMessageTableModel(); - - DecoratorService decoratorService = context.getDecoratorService(); - - boolean reloadDecorators = false; - Locale currentLocale = I18n.getDefaultLocale(); - Locale configurationLocale = config.getLocale(); - if (!configurationLocale.equals(currentLocale)) { - if (log.isInfoEnabled()) { - log.info("re-init I18n with locale " + configurationLocale); - } - I18n.setDefaultLocale(configurationLocale); - reloadDecorators = true; - } - if (!config.getDbLocale().equals(decoratorService.getReferentialLocale().getLocale())) { - if (log.isInfoEnabled()) { - log.info("re-init db with locale " + config.getDbLocale()); - } - decoratorService.setReferentialLocale(ReferentialLocale.valueOf(config.getDbLocale())); - - reloadDecorators = true; - } - - if (reloadDecorators) { - if (log.isInfoEnabled()) { - log.info("reload decorators"); - } - decoratorService.reload(); - } - - JAXXInitialContext tx = new JAXXInitialContext(); - tx.add(context).add(errorModel); - - // show main ui - ObserveMainUI ui = new ObserveMainUI(tx); - ui.setUndecorated(config.isFullScreen()); - - String title = t("observe.title.welcome.admin") + (" v " + config.getVersion()); - ui.setTitle(title); - - context.setMainUI(ui); - - ErrorDialogUI.init(ui); - - // set fullscreen propery on main ui - ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(config.isFullScreen() ? ui : null); - - new ObserveNavigationTreeShowPopupAction(ui.getNavigation(), ui.getNavigationScrollPane(), ui.getNavigationPopup()); - - return ui; - } - - /** * Permet de recharger l'ui principale et de changer de le mode * d'affichage. * @@ -358,11 +369,7 @@ public class ObserveMainUIInitializer { // on met à jour le modèle de navigation NavigationTreeModel treeModel = ui.getNavigation().getTreeModel(); - treeModel.setLoadSeine(ui.getNavigationTreeHeader().getShowSeine().isSelected()); - treeModel.setLoadLongline(ui.getNavigationTreeHeader().getShowLongline().isSelected()); - treeModel.setLoadReferential(ui.getNavigationTreeHeader().getShowReferential().isSelected()); - treeModel.setLoadEmptyProgram(ui.getNavigationTreeHeader().getShowEmptyProgram().isSelected()); - + treeModel.load(config); treeModel.populate(); // on conserve les noeuds a reselectionner @@ -378,19 +385,6 @@ public class ObserveMainUIInitializer { setMainUIVisible(rootContext, ui, true); } - public static void setMainUIVisible(ObserveSwingApplicationContext rootContext, ObserveMainUI ui, boolean replace) { - - // force le redimensionnement du splitpane - ui.getSplitpane().revalidate(); - - // force le redimensionnement du splitpane2 - ui.getSplitpane2().revalidate(); - - // affichage de l'interface graphique - SwingUtilities.invokeLater(() -> ui.setVisible(true)); - rootContext.getSwingSessionHelper().addComponent(ui, replace); - } - void initialize() { ObserveActionMap actionMap = ui.getObserveActionMap(); @@ -440,43 +434,43 @@ public class ObserveMainUIInitializer { }; ui.getNavigationView().addMouseListener(mouseAdapter); ui.getNavigation().addMouseListener(mouseAdapter); - ui.getNavigationTreeHeader().addMouseListener(mouseAdapter); + ui.getNavigationUI().addMouseListener(mouseAdapter); init(ui.getSplitpane()); init(ui.getSplitpane2()); init(ui.getNavigation()); - ui.getNavigationView().setRightDecoration(ui.getNavigationTreeHeader().getToolbar()); - ui.getNavigationView().addComponentListener(new ComponentAdapter() { - - @Override - public void componentResized(ComponentEvent e) { - - JComponent source = (JComponent) e.getSource(); - - NavigationTreeHeader actions = ui.getNavigationTreeHeader(); - - Dimension preferredLayoutSize = actions.getLayout().preferredLayoutSize(actions); - - Dimension showLonglineSize = actions.getShowLongline().getSize(); - Dimension showSeineSize = actions.getShowSeine().getSize(); - Dimension showReferential = actions.getShowReferential().getSize(); - Dimension showEmpty = actions.getShowEmptyProgram().getSize(); - int minWidth = 18 + (int) Math.max(showLonglineSize.getWidth() + showSeineSize.getWidth(), showReferential.getWidth() + showEmpty.getWidth()); - source.setMinimumSize(new Dimension(minWidth, (int) source.getSize().getHeight())); - log.debug("Header resized to minumun: " + source.getMinimumSize()); - - int maxWidth = ui.getNavigationView().getWidth() - 10; - - int currentWidth = (int) preferredLayoutSize.getWidth(); - int height = 32; - if (currentWidth > maxWidth) { - height += 32; - } - actions.setPreferredSize(new Dimension(maxWidth, height)); - - } - }); + ui.getNavigationView().setRightDecoration(ui.getNavigationUI().getToolbar()); +// ui.getNavigationView().addComponentListener(new ComponentAdapter() { +// +// @Override +// public void componentResized(ComponentEvent e) { +// +// JComponent source = (JComponent) e.getSource(); +// +// NavigationTreeHeader actions = ui.getNavigationUI(); +// +// Dimension preferredLayoutSize = actions.getLayout().preferredLayoutSize(actions); +// +// Dimension showLonglineSize = actions.getShowLongline().getSize(); +// Dimension showSeineSize = actions.getShowSeine().getSize(); +// Dimension showReferential = actions.getShowReferential().getSize(); +// Dimension showEmpty = actions.getShowEmptyProgram().getSize(); +// int minWidth = 18 + (int) Math.max(showLonglineSize.getWidth() + showSeineSize.getWidth(), showReferential.getWidth() + showEmpty.getWidth()); +// source.setMinimumSize(new Dimension(minWidth, (int) source.getSize().getHeight())); +// log.debug("Header resized to minumun: " + source.getMinimumSize()); +// +// int maxWidth = ui.getNavigationView().getWidth() - 10; +// +// int currentWidth = (int) preferredLayoutSize.getWidth(); +// int height = 32; +// if (currentWidth > maxWidth) { +// height += 32; +// } +// actions.setPreferredSize(new Dimension(maxWidth, height)); +// +// } +// }); } protected void init(ObserveActionMap actionMap, AbstractButton editor) { @@ -498,9 +492,6 @@ public class ObserveMainUIInitializer { } - private Border focusBorder; - private Border noFocusBorder; - private Border getFocusBorder() { if (focusBorder == null) { focusBorder = new LineBorder(ObserveSwingApplicationContext.get().getConfig().getFocusBorderColor(), 3, true); @@ -549,7 +540,7 @@ public class ObserveMainUIInitializer { /** * Nettoye des ui tout ce qui concerne un modèle de navigation. - * <p> + * * <b>Note:</b> cette méthode doit être appelée avant tout rechargement de modèle de naivgation. * * @param progressModel progress model to interact with ui @@ -576,7 +567,7 @@ public class ObserveMainUIInitializer { /** * Charge dans l'ui un nouveau modèle de navigation. - * <p> + * * <b>Note:</b> cette méthode doit être appelée après tout rechargement de modèle de naivgation. * * @param progressModel the progress model to interact with ui ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroModel.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroModel.java +++ b/client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroModel.java @@ -72,15 +72,15 @@ public class DataSynchroModel extends AdminActionModel { super(AdminStep.DATA_SYNCHRONIZE); // leftSelectionDataModel = new SelectionTreeModel(); -// leftSelectionDataModel.setLoadLongline(true); -// leftSelectionDataModel.setLoadSeine(true); -// leftSelectionDataModel.setLoadReferential(false); +// leftSelectionDataModel.setShowLonglineTrip(true); +// leftSelectionDataModel.setShowSeineTrip(true); +// leftSelectionDataModel.setShowReferential(false); // leftSelectionDataModel.setShowEmptyTrips(false); // // rightSelectionDataModel = new SelectionTreeModel(); -// rightSelectionDataModel.setLoadLongline(true); -// rightSelectionDataModel.setLoadSeine(true); -// rightSelectionDataModel.setLoadReferential(false); +// rightSelectionDataModel.setShowLonglineTrip(true); +// rightSelectionDataModel.setShowSeineTrip(true); +// rightSelectionDataModel.setShowReferential(false); // rightSelectionDataModel.setShowEmptyTrips(false); tasks = new DefaultListModel<>(); ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jaxx ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jaxx +++ b/client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jaxx @@ -33,6 +33,7 @@ fr.ird.observe.client.constants.ValidationModelMode org.nuiton.validator.NuitonValidatorScope + org.nuiton.i18n.I18n java.io.File ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jcss ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jcss +++ b/client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/referential/ng/ReferentialSynchroConfigUI.jcss @@ -24,7 +24,7 @@ layout:{new BorderLayout()}; } #referentialSynchronizeConfigPanel { - border:{new TitledBorder(t("observe.actions.synchro.referential.config.mode"))}; + border:{new TitledBorder(I18n.t("observe.actions.synchro.referential.config.mode"))}; } #synchronizeMode { ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java +++ b/client/src/main/java/fr/ird/observe/client/ui/content/ContentUIInitializer.java @@ -415,7 +415,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> Action resetAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - beanComboBox.doActionPerformed__on__resetButton(null); + beanComboBox.getResetButton().doClick(); SwingUtilities.invokeLater(beanComboBox::grabFocus); } }; @@ -768,7 +768,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> list.init(decorator, new ArrayList<>(), new ArrayList<>()); JList<R> selectedList = list.getSelectedList(); - ListCellRenderer<? super R> renderer = selectedList.getCellRenderer(); + ListCellRenderer renderer = selectedList.getCellRenderer(); selectedList.setCellRenderer(new DataReferenceListCellRenderer<>(renderer)); list.getUniverseList().setCellRenderer(new DataReferenceListCellRenderer<>(renderer)); @@ -795,7 +795,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> list.init(decorator, new ArrayList<>(), new ArrayList<>()); JList<R> selectedList = list.getSelectedList(); - ListCellRenderer<? super R> renderer = selectedList.getCellRenderer(); + ListCellRenderer renderer = selectedList.getCellRenderer(); selectedList.setCellRenderer(new ReferentialReferenceListCellRenderer<>(renderer)); list.getUniverseList().setCellRenderer(new ReferentialReferenceListCellRenderer<>(renderer)); @@ -822,7 +822,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> list.init(decorator, Collections.emptyList()); JList<R> list1 = list.getList(); - ListCellRenderer<? super R> renderer = list1.getCellRenderer(); + ListCellRenderer renderer = list1.getCellRenderer(); list1.setCellRenderer(new DataReferenceListCellRenderer<>(renderer)); } @@ -847,7 +847,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ContentUI<E, UI>> list.init(decorator, Collections.emptyList()); JList<R> list1 = list.getList(); - ListCellRenderer<? super R> renderer = list1.getCellRenderer(); + ListCellRenderer renderer = list1.getCellRenderer(); list1.setCellRenderer(new ReferentialReferenceListCellRenderer<>(renderer)); } ===================================== client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jaxx ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jaxx +++ b/client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jaxx @@ -30,6 +30,8 @@ fr.ird.observe.client.ui.storage.tabs.SecurityModel fr.ird.observe.client.ui.storage.StorageStep fr.ird.observe.client.ui.storage.StorageUIModel + + org.nuiton.i18n.I18n </import> <StorageStep id='step' initializer='StorageStep.ROLES'/> @@ -44,7 +46,7 @@ <script><![CDATA[ public String updateAdministrateur(String role) { - return t("observe.storage.security.administrateur", role); + return I18n.t("observe.storage.security.administrateur", role); } ]]> </script> ===================================== client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jcss ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jcss +++ b/client/src/main/java/fr/ird/observe/client/ui/storage/tabs/RolesUI.jcss @@ -25,7 +25,7 @@ } #administrateurPanel { - border:{new TitledBorder(t("observe.storage.security.administrateur"))}; + border:{new TitledBorder(I18n.t("observe.storage.security.administrateur"))}; layout:{new BorderLayout()}; } @@ -43,13 +43,13 @@ } #techniciens { - border:{new TitledBorder(t("observe.storage.security.technicien"))}; + border:{new TitledBorder(I18n.t("observe.storage.security.technicien"))}; } #readers { - border:{new TitledBorder(t("observe.storage.security.reader"))}; + border:{new TitledBorder(I18n.t("observe.storage.security.reader"))}; } #referentiels { - border:{new TitledBorder(t("observe.storage.security.referentiel"))}; + border:{new TitledBorder(I18n.t("observe.storage.security.referentiel"))}; } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeader.jaxx deleted ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeader.jaxx +++ /dev/null @@ -1,38 +0,0 @@ -<!-- - #%L - ObServe :: Client - %% - Copyright (C) 2008 - 2017 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% - --> -<JPanel layout='{new FlowLayout(FlowLayout.LEFT, 2, 2)}'> - - <import> - java.awt.FlowLayout - </import> - - <JToggleButton id='showSeine' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - <JToggleButton id='showLongline' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - <JToggleButton id='showReferential' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - <JToggleButton id='showEmptyProgram' onActionPerformed="handler.tryToUpdateNavigationTree()"/> - - <NavigationTree id='tree' javaBean='new NavigationTree()'/> - - <JToolBar id='toolbar'> - <JButton id='colapseAll' onActionPerformed='handler.collapseAll()'/> - <JButton id='expandAll' onActionPerformed='handler.expandAll()'/> - </JToolBar> - -</JPanel> ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeModel.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeModel.java +++ b/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeModel.java @@ -10,18 +10,20 @@ package fr.ird.observe.client.ui.tree.navigation; * 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.configuration.ClientConfig; +import fr.ird.observe.client.configuration.NavigationTreeConfigBean; import fr.ird.observe.client.db.ObserveSwingDataSource; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.client.ui.tree.navigation.nodes.RootNavigationTreeNode; @@ -33,19 +35,20 @@ import fr.ird.observe.client.ui.tree.navigation.nodes.referential.ReferentialsSe import fr.ird.observe.client.ui.tree.navigation.nodes.seine.ProgramSeineNavigationTreeNode; import fr.ird.observe.dto.data.longline.TripLonglineHelper; import fr.ird.observe.dto.data.longline.TripLonglineReference; -import fr.ird.observe.dto.referential.ProgramHelper; -import fr.ird.observe.dto.referential.ProgramReference; import fr.ird.observe.dto.data.seine.TripSeineHelper; import fr.ird.observe.dto.data.seine.TripSeineReference; +import fr.ird.observe.dto.referential.ProgramHelper; +import fr.ird.observe.dto.referential.ProgramReference; import fr.ird.observe.services.service.data.NavigationRequest; import fr.ird.observe.services.service.data.NavigationResult; import fr.ird.observe.services.service.data.NavigationService; + +import javax.swing.tree.DefaultTreeModel; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; -import javax.swing.tree.DefaultTreeModel; /** * Created on 14/11/16. @@ -55,44 +58,50 @@ import javax.swing.tree.DefaultTreeModel; */ public class NavigationTreeModel extends DefaultTreeModel { - private boolean loadSeine = true; - private boolean loadLongline = true; - private boolean loadReferential = true; - private boolean loadEmptyProgram = true; + private final NavigationTreeConfigBean config; - public NavigationTreeModel() { + NavigationTreeModel() { super(new RootNavigationTreeNode()); + config = new NavigationTreeConfigBean(); } - public NavigationTreeNodeSupport<?> findNode(NavigationTreeNodeSupport<?> node, Object... ids) { - NavigationTreeNodeSupport<?> result = null; - for (Object id : ids) { + public NavigationTreeConfigBean getConfig() { + return config; + } - if (id instanceof String) { - result = node.findChildById((String) id); - } else if (id instanceof Class) { - result = node.findChildByType((Class) id); + @Override + public RootNavigationTreeNode getRoot() { + return (RootNavigationTreeNode) super.getRoot(); + } - } - if (result == null) { + public <N extends NavigationTreeNodeSupport> void reload(N node) { + node.reload(); + super.reload(node); + } - // un des noeud n'a pas ete trouve, on sortReferential - break; + public <N extends NavigationTreeNodeSupport> void open(N node) { + if (node instanceof WithChildsToReload) { + boolean updated = node.populateChilds(); + if (updated) { + reload(node); } - node = result; } - return result; } - public NavigationTreeNodeSupport<?> findNodeByType(NavigationTreeNodeSupport<?> node, Class<?> nodeType) { - return node.findChildByType(nodeType); + public void save(ClientConfig config) { + config.load(this.config); + config.saveForUser(); + } + + public void load(ClientConfig config) { + this.config.load(config); } public void populate() { NavigationService navigationService = ObserveSwingDataSource.MAIN.getNavigationService(); - NavigationRequest navigationRequest = toNavigationRequest(); + NavigationRequest navigationRequest = config.toRequest(); NavigationResult navigationResult = navigationService.getNavigation(navigationRequest); List<ProgramReference> programs = new ArrayList<>(navigationResult.getPrograms()); @@ -119,75 +128,38 @@ public class NavigationTreeModel extends DefaultTreeModel { ProgramSeineNavigationTreeNode programNode = new ProgramSeineNavigationTreeNode(program, references); root.add(programNode); } - } - if (isLoadReferential()) { + if (config.isShowReferential()) { root.add(new ReferentialsCommonNavigationTreeNode()); root.add(new ReferentialsLonglineNavigationTreeNode()); root.add(new ReferentialsSeineNavigationTreeNode()); } - setRoot(root); } - private NavigationRequest toNavigationRequest() { - NavigationRequest navigationRequest = new NavigationRequest(); - navigationRequest.setLoadLongline(isLoadLongline()); - navigationRequest.setLoadSeine(isLoadSeine()); - navigationRequest.setLoadEmptyProgram(isLoadEmptyProgram()); - return navigationRequest; - } - - @Override - public RootNavigationTreeNode getRoot() { - return (RootNavigationTreeNode) super.getRoot(); - } - - public boolean isLoadSeine() { - return loadSeine; - } - - public void setLoadSeine(boolean loadSeine) { - this.loadSeine = loadSeine; - } - - public boolean isLoadLongline() { - return loadLongline; - } - - public void setLoadLongline(boolean loadLongline) { - this.loadLongline = loadLongline; - } - - public boolean isLoadReferential() { - return loadReferential; - } - - public void setLoadReferential(boolean loadReferential) { - this.loadReferential = loadReferential; - } - - public boolean isLoadEmptyProgram() { - return loadEmptyProgram; - } + NavigationTreeNodeSupport<?> findNode(NavigationTreeNodeSupport<?> node, Object... ids) { + NavigationTreeNodeSupport<?> result = null; + for (Object id : ids) { - public void setLoadEmptyProgram(boolean loadEmptyProgram) { - this.loadEmptyProgram = loadEmptyProgram; - } + if (id instanceof String) { + result = node.findChildById((String) id); + } else if (id instanceof Class) { + result = node.findChildByType((Class) id); - public <N extends NavigationTreeNodeSupport> void reload(N node) { - node.reload(); - super.reload(node); - } + } + if (result == null) { - public <N extends NavigationTreeNodeSupport> void open(N node) { - if (node instanceof WithChildsToReload) { - boolean updated = node.populateChilds(); - if (updated) { - reload(node); + // un des noeud n'a pas ete trouve, on sortReferential + break; } + node = result; } + return result; + } + + NavigationTreeNodeSupport<?> findNodeByType(NavigationTreeNodeSupport<?> node, Class<?> nodeType) { + return node.findChildByType(nodeType); } } ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jaxx ===================================== --- /dev/null +++ b/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jaxx @@ -0,0 +1,24 @@ +<JScrollPane id='navigationScrollPane' columnHeaderView='{toolbar}' viewportView="{tree}"> + + <import> + fr.ird.observe.client.configuration.NavigationTreeConfigBean + static org.nuiton.i18n.I18n.t + </import> + <NavigationTree id='tree' /> + <NavigationTreeModel id='treeModel' javaBean='{tree.getTreeModel()}'/> + <NavigationTreeConfigBean id='navigationConfig' javaBean='treeModel.getConfig()'/> + + <JPopupMenu id='configurePopup'> + <JCheckBoxMenuItem id='showSeineTrip' onActionPerformed="handler.tryToUpdateNavigationTree()"/> + <JCheckBoxMenuItem id='showLonglineTrip' onActionPerformed="handler.tryToUpdateNavigationTree()"/> + <JCheckBoxMenuItem id='showReferential' onActionPerformed="handler.tryToUpdateNavigationTree()"/> + <JCheckBoxMenuItem id='showEmptyProgram' onActionPerformed="handler.tryToUpdateNavigationTree()"/> + </JPopupMenu> + + <JToolBar id='toolbar'> + <JButton id='colapseAll' onActionPerformed='handler.collapseAll()'/> + <JButton id='expandAll' onActionPerformed='handler.expandAll()'/> + <JToggleButton id='configure' onActionPerformed='handler.configure()'/> + </JToolBar> + +</JScrollPane> ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeader.jcss → client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeader.jcss +++ b/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUI.jcss @@ -8,36 +8,35 @@ * 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% */ -#showSeine { - selected: {tree.getTreeModel().isLoadSeine()}; +#showSeineTrip { + selected: {navigationConfig.isShowSeineTrip()}; text:"observe.constant.ObserveModelType.PS"; toolTipText:"observe.constant.ObserveModelType.PS.description"; } -#showLongline { - selected: {tree.getTreeModel().isLoadLongline()}; +#showLonglineTrip { + selected: {navigationConfig.isShowLonglineTrip()}; text:"observe.constant.ObserveModelType.LL"; toolTipText:"observe.constant.ObserveModelType.LL.description"; } #showReferential { - selected: {tree.getTreeModel().isLoadReferential()}; + selected: {navigationConfig.isShowReferential()}; text:"observe.constant.ObserveModelType.REF"; toolTipText:"observe.constant.ObserveModelType.REF.description"; } - #showEmptyProgram { - selected: {tree.getTreeModel().isLoadEmptyProgram()}; + selected: {navigationConfig.isShowEmptyProgram()}; text:"observe.constant.ObserveModelType.EMPTY"; toolTipText:"observe.constant.ObserveModelType.EMPTY.description"; } @@ -61,3 +60,8 @@ JButton { actionIcon:expand; toolTipText:"observe.tree.action.expandAll.tip"; } + +#configure { + actionIcon:generate; + toolTipText:"observe.tree.action.configure.tip"; +} ===================================== client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeaderHandler.java → client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUIHandler.java ===================================== --- a/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationTreeHeaderHandler.java +++ b/client/src/main/java/fr/ird/observe/client/ui/tree/navigation/NavigationUIHandler.java @@ -1,39 +1,11 @@ package fr.ird.observe.client.ui.tree.navigation; -/* - * #%L - * ObServe :: Client - * %% - * Copyright (C) 2008 - 2017 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.ObserveSwingApplicationContext; +import fr.ird.observe.client.configuration.ClientConfig; +import fr.ird.observe.client.configuration.NavigationTreeConfig; import fr.ird.observe.client.ui.ObserveKeyStrokes; -import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; -import fr.ird.observe.dto.referential.ProgramDto; -import fr.ird.observe.dto.data.seine.TripSeineDto; -import java.awt.Color; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.ActionMap; -import javax.swing.InputMap; -import javax.swing.JComponent; +import fr.ird.observe.client.ui.util.UIHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.decorator.ColorHighlighter; @@ -41,17 +13,29 @@ import org.jdesktop.swingx.search.Searchable; import org.jdesktop.swingx.search.TreeSearchable; import org.nuiton.jaxx.runtime.spi.UIHandler; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.ActionEvent; + /** - * @author Samuel Maisonneuve- maisonneuve@codelutin.com + * Created by tchemit on 01/04/2018. + * + * @author Tony Chemit - dev@tchemit.fr */ -public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHeader> { +public class NavigationUIHandler implements UIHandler<NavigationUI> { /** Logger */ - private static final Log log = LogFactory.getLog(NavigationTreeHeaderHandler.class); + private static final Log log = LogFactory.getLog(NavigationUIHandler.class); - private NavigationTreeHeader ui; + private NavigationUI ui; - public NavigationTreeHeader getUi() { + public NavigationUI getUi() { return ui; } @@ -60,15 +44,15 @@ public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHead } @Override - public void beforeInit(NavigationTreeHeader ui) { + public void beforeInit(NavigationUI ui) { this.ui = ui; } @Override - public void afterInit(NavigationTreeHeader ui) { + public void afterInit(NavigationUI ui) { - ui.getShowSeine().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16")); - ui.getShowLongline().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16")); + ui.getShowSeineTrip().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16")); + ui.getShowLonglineTrip().setIcon(UIHelper.getUIManagerIcon("navigation.referential.Program-16")); ui.getShowReferential().setIcon(UIHelper.getUIManagerIcon("navigation.referentiel-16")); ui.getShowEmptyProgram().setIcon(UIHelper.getUIManagerIcon("navigation.data.seine.TripSeine-16")); @@ -77,10 +61,16 @@ public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHead tree.setSearchable(searchable); searchable.setMatchHighlighter(new ColorHighlighter(Color.YELLOW, Color.BLACK)); - ObserveKeyStrokes.addKeyStroke(ui.getShowSeine(), ObserveKeyStrokes.KEY_STROKE_SHOW_SEINE); - ObserveKeyStrokes.addKeyStroke(ui.getShowLongline(), ObserveKeyStrokes.KEY_STROKE_SHOW_LONGLINE); + ObserveKeyStrokes.addKeyStroke(ui.getShowSeineTrip(), ObserveKeyStrokes.KEY_STROKE_SHOW_SEINE); + ObserveKeyStrokes.addKeyStroke(ui.getShowLonglineTrip(), ObserveKeyStrokes.KEY_STROKE_SHOW_LONGLINE); ObserveKeyStrokes.addKeyStroke(ui.getShowReferential(), ObserveKeyStrokes.KEY_STROKE_SHOW_REFERENTIAL); ObserveKeyStrokes.addKeyStroke(ui.getShowEmptyProgram(), ObserveKeyStrokes.KEY_STROKE_SHOW_EMPTY_PROGRAM); + ObserveKeyStrokes.addKeyStroke(ui.getConfigure(), ObserveKeyStrokes.KEY_STROKE_NAVIGATION_CONFIGURE); + //FIXME (no text, so no text after...) + ui.getConfigure().setText(null); + ClientConfig config = ObserveSwingApplicationContext.get().getConfig(); + NavigationTreeModel treeModel = (NavigationTreeModel) tree.getModel(); + treeModel.load(config); InputMap inputMap = ui.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = ui.getActionMap(); @@ -88,32 +78,66 @@ public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHead actionMap.put("showSeine", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - ui.getShowSeine().doClick(); + if (ui.getConfigurePopup().isVisible()) { + ui.getShowSeineTrip().doClick(); + } + ui.getConfigurePopup().setVisible(false); } }); inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_LONGLINE, "showLongline"); actionMap.put("showLongline", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - ui.getShowLongline().doClick(); + if (ui.getConfigurePopup().isVisible()) { + ui.getShowLonglineTrip().doClick(); + } + ui.getConfigurePopup().setVisible(false); } }); inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_REFERENTIAL, "showReferential"); actionMap.put("showReferential", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - ui.getShowReferential().doClick(); + if (ui.getConfigurePopup().isVisible()) { + ui.getShowReferential().doClick(); + } + ui.getConfigurePopup().setVisible(false); } }); inputMap.put(ObserveKeyStrokes.KEY_STROKE_SHOW_EMPTY_PROGRAM, "showEmptyProgram"); actionMap.put("showEmptyProgram", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - ui.getShowEmptyProgram().doClick(); + if (ui.getConfigurePopup().isVisible()) { + ui.getShowEmptyProgram().doClick(); + } + ui.getConfigurePopup().setVisible(false); + } + }); + inputMap.put(ObserveKeyStrokes.KEY_STROKE_NAVIGATION_CONFIGURE, "configure"); + actionMap.put("configure", new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + ui.getConfigure().doClick(); } }); } + void configure() { + SwingUtilities.invokeLater(() -> { + JComponent c = ui.getConfigure(); + JPopupMenu p = ui.getConfigurePopup(); + if (p.isVisible()) { + p.setVisible(false); + return; + } + int width = ui.getParent().getWidth() - 5; + int height = p.getPreferredSize().height; + p.setPreferredSize(new Dimension(width, height)); + p.show(c, (c.getWidth() == 0 ? 24 : c.getWidth()) - width + 2, c.getHeight()); + }); + } + public void search(String term) { Searchable searchable = getTree().getSearchable(); @@ -121,7 +145,7 @@ public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHead } - public void tryToUpdateNavigationTree() { + void tryToUpdateNavigationTree() { boolean canContinue = ObserveSwingApplicationContext.get().getContentUIManager().closeSelectedContentUI(); @@ -137,23 +161,24 @@ public class NavigationTreeHeaderHandler implements UIHandler<NavigationTreeHead } tree.clearSelection(); - boolean showSeine = ui.getShowSeine().isSelected(); - boolean showLongline = ui.getShowLongline().isSelected(); + boolean showSeine = ui.getShowSeineTrip().isSelected(); + boolean showLongline = ui.getShowLonglineTrip().isSelected(); boolean showReferential = ui.getShowReferential().isSelected(); boolean showEmptyProgram = ui.getShowEmptyProgram().isSelected(); NavigationTreeModel treeModel = tree.getTreeModel(); - treeModel.setLoadSeine(showSeine); - treeModel.setLoadLongline(showLongline); - treeModel.setLoadReferential(showReferential); - treeModel.setLoadEmptyProgram(showEmptyProgram); - + NavigationTreeConfig navigationTreeConfig = treeModel.getConfig(); + navigationTreeConfig.setShowSeineTrip(showSeine); + navigationTreeConfig.setShowLonglineTrip(showLongline); + navigationTreeConfig.setShowReferential(showReferential); + navigationTreeConfig.setShowEmptyProgram(showEmptyProgram); + treeModel.save(ObserveSwingApplicationContext.get().getConfig()); treeModel.populate(); - //FIXME repositionner le nœud sélectionné if (!treeModel.getRoot().isLeaf()) { tree.setSelectionRow(0); } + ui.getConfigure().setSelected(false); } public void collapseAll() { ===================================== client/src/main/resources/i18n/client_en_GB.properties ===================================== --- a/client/src/main/resources/i18n/client_en_GB.properties +++ b/client/src/main/resources/i18n/client_en_GB.properties @@ -1488,6 +1488,7 @@ observe.title.storage.info=Storage details observe.title.unique.key=Unique keys used in a referentiel observe.title.welcome.admin=ObServe observe.tree.action.collapseAll.tip=Collapse all +observe.tree.action.configure.tip=Configure observe.tree.action.expandAll.tip=Expand all observe.tree.action.selectAll.tip=Select All observe.tree.action.unselectAll.tip=Unselect All ===================================== client/src/main/resources/i18n/client_es_ES.properties ===================================== --- a/client/src/main/resources/i18n/client_es_ES.properties +++ b/client/src/main/resources/i18n/client_es_ES.properties @@ -1488,6 +1488,7 @@ observe.title.storage.info=Información sobre la fuente de datos observe.title.unique.key=Ids de negocio del referencial %1$s observe.title.welcome.admin=ObServe observe.tree.action.collapseAll.tip=Cerrar los nudos +observe.tree.action.configure.tip=Configure \#TODO observe.tree.action.expandAll.tip=Abrir los nudos observe.tree.action.selectAll.tip=Seleccionar todo observe.tree.action.unselectAll.tip=Deseleccionar todo ===================================== client/src/main/resources/i18n/client_fr_FR.properties ===================================== --- a/client/src/main/resources/i18n/client_fr_FR.properties +++ b/client/src/main/resources/i18n/client_fr_FR.properties @@ -1488,6 +1488,7 @@ observe.title.storage.info=Information sur la source de données observe.title.unique.key=Clefs métier du référentiel %1$s observe.title.welcome.admin=ObServe observe.tree.action.collapseAll.tip=Tout grouper +observe.tree.action.configure.tip=Configurer observe.tree.action.expandAll.tip=Tout déplier observe.tree.action.selectAll.tip=Tout sélectionner observe.tree.action.unselectAll.tip=Tout désélectionner ===================================== pom.xml ===================================== --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ <packaging>pom</packaging> <name>ObServe :: Pom</name> - <description>Projet ObServe</description> + <description>Project ObServe</description> <url>https://ultreiaio.gitlab.io/ird-observe</url> <inceptionYear>2008</inceptionYear> <organization> @@ -142,10 +142,10 @@ <projectId>ird-observe</projectId> <stageId>frirdobserve</stageId> - <!-- dev version (for develop purpose --> + <!-- dev version --> <devMode>true</devMode> - <!--Modèle version--> + <!--persistence model version--> <observe.model.version>7.0</observe.model.version> <!-- build timestamp configuration --> @@ -157,7 +157,7 @@ <!--<eugenePluginVersion>3.0-alpha-13</eugenePluginVersion>--> <!--<processorPluginVersion>1.3</processorPluginVersion>--> - <lib.version.java4all.jaxx>3.0-alpha-12</lib.version.java4all.jaxx> + <lib.version.java4all.jaxx>3.0-alpha-26</lib.version.java4all.jaxx> <lib.version.nuiton.topia>3.3</lib.version.nuiton.topia> <lib.version.nuiton.validation>3.1</lib.version.nuiton.validation> <xworkVersion>2.3.34</xworkVersion> View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/cdbaa4e78c89734f40c43e7cc036... --- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/commit/cdbaa4e78c89734f40c43e7cc036... You're receiving this email because of your account on gitlab.com.