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 2ef3dab12f32b08ef890810011764f38a336b4a1 Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Sep 2 22:04:51 2016 +0200 Clean some code, remove unused --- application-swing/pom.xml | 2 +- .../application/swing/ObserveActionExecutor.java | 59 +++------------------- .../observe/application/swing/ObserveCLAction.java | 3 -- .../observe/application/swing/ObserveRunner.java | 11 ---- .../swing/ObserveSwingApplicationContext.java | 37 +++++++------- .../swing/ObserveSwingBinderService.java | 50 ------------------ .../{ObserveAdminCLI.java => RunObserve.java} | 11 ++-- .../ui/content/table/ContentTableUIModel.java | 8 +-- .../table/impl/longline/CatchLonglineUIModel.java | 5 +- 9 files changed, 36 insertions(+), 150 deletions(-) diff --git a/application-swing/pom.xml b/application-swing/pom.xml index f69f5be..26f20cb 100644 --- a/application-swing/pom.xml +++ b/application-swing/pom.xml @@ -55,7 +55,7 @@ <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> <!-- main class in JAR --> - <maven.jar.main.class>fr.ird.observe.application.swing.ObserveAdminCLI</maven.jar.main.class> + <maven.jar.main.class>fr.ird.observe.application.swing.RunObserve</maven.jar.main.class> <i18n.bundleOutputName>${projectId}-i18n</i18n.bundleOutputName> <i18n.bundleCsvFile>${projectId}-i18n.csv</i18n.bundleCsvFile> diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveActionExecutor.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveActionExecutor.java index a3c2827..79a3dd1 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveActionExecutor.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveActionExecutor.java @@ -47,11 +47,7 @@ import java.util.concurrent.TimeUnit; public class ObserveActionExecutor extends ActionExecutor { /** Logger */ - private static final Log log = - LogFactory.getLog(ObserveActionExecutor.class); - - public ObserveActionExecutor() { - } + private static final Log log = LogFactory.getLog(ObserveActionExecutor.class); @Override public void onActionStart(ActionWorker<?, ?> source) { @@ -75,7 +71,6 @@ public class ObserveActionExecutor extends ActionExecutor { AdminUIModel model = admin.getHandler().getModel(); model.setBusy(true); model.setStepState(WizardState.RUNNING); -// return; } ObserveMainUI ui = ObserveSwingApplicationContext.get().getMainUI(); if (ui != null) { @@ -88,8 +83,7 @@ public class ObserveActionExecutor extends ActionExecutor { Exception error = source.getError(); if (log.isInfoEnabled()) { if (log.isErrorEnabled()) { - log.error("Action [" + source.getActionLabel() + - "] failed with error " + error.getCause(), error); + log.error("Action [" + source.getActionLabel() + "] failed with error " + error.getCause(), error); } } if (ObserveSwingApplicationContext.get().isClosed()) { @@ -187,8 +181,6 @@ public class ObserveActionExecutor extends ActionExecutor { if (source instanceof AdminActionWorker) { AdminActionWorker admin = (AdminActionWorker) source; admin.getHandler().getModel().setBusy(false); - //admin.getHandler().getUi().removePropertyChangeListener(admin.getHandler().getUi()); -// return; } ObserveMainUI ui = ObserveSwingApplicationContext.get().getMainUI(); if (count < 1 && ui != null) { @@ -249,37 +241,22 @@ public class ObserveActionExecutor extends ActionExecutor { * @return ExecutorService for the {@code SwingWorkers} */ private static ExecutorService getWorkersExecutorService() { -// AppContext appContext = AppContext.getAppContext(); -// ExecutorService executorService = -// (ExecutorService) appContext.get(ActionWorker.class); if (executorService == null) { //this creates daemon threads. ThreadFactory threadFactory = new ThreadFactory() { - final ThreadFactory defaultFactory = - Executors.defaultThreadFactory(); + ThreadFactory defaultFactory = Executors.defaultThreadFactory(); public Thread newThread(Runnable r) { - Thread thread = - defaultFactory.newThread(r); - thread.setName("ActionWorker-" - + thread.getName()); + Thread thread = defaultFactory.newThread(r); + thread.setName("ActionWorker-" + thread.getName()); thread.setDaemon(true); return thread; } }; - executorService = - new ThreadPoolExecutor(5, 10, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(), - threadFactory); - -// appContext.put(ActionWorker.class, executorService); + executorService = new ThreadPoolExecutor(5, 10, 10L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), threadFactory); - // Don't use ShutdownHook here as it's not enough. We should track - // AppContext disposal instead of JVM shutdown, see 6799345 for details -// final ExecutorService es = executorService; Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { @@ -288,30 +265,6 @@ public class ObserveActionExecutor extends ActionExecutor { } } }); -// appContext.addPropertyChangeListener(AppContext.DISPOSED_PROPERTY_NAME, -// new PropertyChangeListener() { -// @Override -// public void propertyChange(PropertyChangeEvent pce) { -// boolean disposed = (Boolean) pce.getNewValue(); -// if (disposed) { -// WeakReference<ExecutorService> executorServiceRef = -// new WeakReference<ExecutorService>(es); -// final ExecutorService executorService = -// executorServiceRef.get(); -// if (executorService != null) { -// AccessController.doPrivileged( -// new PrivilegedAction<Void>() { -// public Void run() { -// executorService.shutdown(); -// return null; -// } -// } -// ); -// } -// } -// } -// } -// ); } return executorService; } diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveCLAction.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveCLAction.java index cba8ef5..30c91ec 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveCLAction.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveCLAction.java @@ -59,9 +59,6 @@ public class ObserveCLAction { /** La configuration de l'application. */ protected ObserveSwingApplicationConfig config; - public ObserveCLAction() { - } - /** Désactiver la possiblite de lancer l'ui principale. */ public void disableMainUI() { if (log.isDebugEnabled()) { diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java index 4bf0f8e..7ad5a4a 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveRunner.java @@ -93,13 +93,6 @@ public abstract class ObserveRunner extends ApplicationRunner { return (ObserveRunner) ApplicationRunner.getRunner(); } -// public static ObserveResourceManager getResourceManager() { -// if (resourceManager == null) { -// throw new IllegalStateException("No resourceManager initialized"); -// } -// return resourceManager; -// } - public static ObserveActionExecutor getActionExecutor() { if (actionExecutor == null) { actionExecutor = new ObserveActionExecutor(); @@ -109,10 +102,6 @@ public abstract class ObserveRunner extends ApplicationRunner { public abstract String getRunnerName(); -// public static boolean isAdmin() { -// return true; -// } - private final boolean init; public ObserveRunner(String... args) { diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingApplicationContext.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingApplicationContext.java index 91d366a..e5127e9 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingApplicationContext.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingApplicationContext.java @@ -24,26 +24,13 @@ package fr.ird.observe.application.swing; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.application.swing.configuration.ObserveSwingApplicationConfig; +import fr.ird.observe.application.swing.configuration.constants.DbMode; import fr.ird.observe.application.swing.db.DataContext; import fr.ird.observe.application.swing.db.ObserveSwingDataSource; -import fr.ird.observe.application.swing.configuration.constants.DbMode; import fr.ird.observe.application.swing.db.event.ObserveSwingDataSourceEvent; import fr.ird.observe.application.swing.db.event.ObserveSwingDataSourceListenerAdapter; -import fr.ird.observe.services.runner.ObserveDataSourceConfigurationMainFactory; -import fr.ird.observe.services.runner.ObserveServiceMainFactory; -import fr.ird.observe.services.ObserveServicesProvider; -import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; -import fr.ird.observe.services.configuration.ObserveDataSourceInformation; -import fr.ird.observe.services.dto.constants.ReferentialLocale; -import fr.ird.observe.services.dto.reference.ReferenceBinderEngine; -import fr.ird.observe.services.dto.reference.ReferenceBinderEngineSupplier; -import fr.ird.observe.services.service.BabModelVersionException; -import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; -import fr.ird.observe.services.service.DatabaseNotFoundException; -import fr.ird.observe.services.service.actions.validate.ValidateServiceUtils; -import fr.ird.observe.services.service.actions.validate.ValidatorDto; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.application.swing.ui.ObserveMainUI; import fr.ird.observe.application.swing.ui.ObserveUIMode; import fr.ird.observe.application.swing.ui.actions.ChangeStorageAction; @@ -68,6 +55,19 @@ import fr.ird.observe.application.swing.ui.actions.shared.SelectOpenNodeUIAction import fr.ird.observe.application.swing.ui.content.ContentUIManager; import fr.ird.observe.application.swing.ui.tree.ObserveTreeHelper; import fr.ird.observe.application.swing.validation.ValidationContext; +import fr.ird.observe.services.ObserveServicesProvider; +import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; +import fr.ird.observe.services.configuration.ObserveDataSourceInformation; +import fr.ird.observe.services.dto.constants.ReferentialLocale; +import fr.ird.observe.services.dto.reference.ReferenceBinderEngine; +import fr.ird.observe.services.dto.reference.ReferenceBinderEngineSupplier; +import fr.ird.observe.services.runner.ObserveDataSourceConfigurationMainFactory; +import fr.ird.observe.services.runner.ObserveServiceMainFactory; +import fr.ird.observe.services.service.BabModelVersionException; +import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; +import fr.ird.observe.services.service.DatabaseNotFoundException; +import fr.ird.observe.services.service.actions.validate.ValidateServiceUtils; +import fr.ird.observe.services.service.actions.validate.ValidatorDto; import jaxx.runtime.context.DefaultApplicationContext; import jaxx.runtime.context.JAXXContextEntryDef; import org.apache.commons.logging.Log; @@ -88,7 +88,6 @@ import java.util.UUID; import static fr.ird.observe.application.swing.ObserveSwingApplicationContext.Entries.ACTIONS; import static fr.ird.observe.application.swing.ObserveSwingApplicationContext.Entries.ACTION_MAP; -import static fr.ird.observe.application.swing.ObserveSwingApplicationContext.Entries.BINDER_SERVICE; import static fr.ird.observe.application.swing.ObserveSwingApplicationContext.Entries.CONFIG; import static fr.ird.observe.application.swing.ObserveSwingApplicationContext.Entries.CONTENT_UI_MANAGER; import static fr.ird.observe.application.swing.ObserveSwingApplicationContext.Entries.DATA_CONTEXT; @@ -136,7 +135,6 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im SERVICE_MAIN_FACTORY("Service main factory", ObserveServiceMainFactory.class), DATA_SOURCE_CONFIGURATION_FACTORY("Data source configuration main factory", ObserveDataSourceConfigurationMainFactory.class), OPEN_DATA_MANAGER("Open data manager", ObserveOpenDataManager.class), - BINDER_SERVICE("Binder service", ObserveSwingBinderService.class), DATA_CONTEXT("Data context", DataContext.class), CONTENT_UI_MANAGER("Content UI manager", ContentUIManager.class), DATA_SOURCES_MANAGER("Data sources manager", ObserveSwingApplicationDataSourcesManager.class), @@ -170,7 +168,7 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im private <O> void set(O instance) { entryDef.setContextValue(ObserveSwingApplicationContext.get(), instance); if (log.isInfoEnabled()) { - log.info("Add to application context " + objectName + ": " + (instance instanceof Collection ? ((Collection)instance).size()+" element(s)": instance)); + log.info("Add to application context " + objectName + ": " + (instance instanceof Collection ? ((Collection) instance).size() + " element(s)" : instance)); } } @@ -178,7 +176,7 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im O instance = get(); entryDef.removeContextValue(ObserveSwingApplicationContext.get()); if (log.isInfoEnabled()) { - log.info("Remove from application context " + objectName + ": " + (instance instanceof Collection ? ((Collection)instance).size()+" element(s)": instance)); + log.info("Remove from application context " + objectName + ": " + (instance instanceof Collection ? ((Collection) instance).size() + " element(s)" : instance)); } } } @@ -223,7 +221,6 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im INSTANCE = this; CONFIG.set(config); - BINDER_SERVICE.set(new ObserveSwingBinderService()); ACTIONS.set(new ObserveCLAction()); CONTENT_UI_MANAGER.set(new ContentUIManager()); DATA_SOURCES_MANAGER.set(new ObserveSwingApplicationDataSourcesManager()); diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingBinderService.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingBinderService.java deleted file mode 100644 index bf47be7..0000000 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveSwingBinderService.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * #%L - * ObServe :: Application Swing - * %% - * Copyright (C) 2008 - 2016 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.application.swing; - -import fr.ird.observe.services.dto.AbstractObserveDto; -import org.nuiton.util.beans.BinderModelBuilder; - -/** - * Service d'utilisation des binders - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.4 - */ -public class ObserveSwingBinderService { - - public <E extends AbstractObserveDto> BinderModelBuilder<E, E> newBinderBuilder(Class<E> type, String... properties) { - BinderModelBuilder<E, E> builder = BinderModelBuilder.newEmptyBuilder(type); - builder.addSimpleProperties(properties); - return builder; - } - - public <E extends AbstractObserveDto> void simpleCopy(E source, E target, boolean tech) { - //FIXME -// Class<E> entityClass = (Class<E>) TopiaEntityHelper.getContractClass(ObserveDAOHelper.getContracts(), target.getClass()); -// TopiaEntityBinder<E> binder = getSimpleTopiaBinder(entityClass); -// if (binder == null) { -// throw new NullPointerException("could not find a simple topia binder of type : " + target.getClass()); -// } -// binder.load(source, target, tech); - } -} diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveAdminCLI.java b/application-swing/src/main/java/fr/ird/observe/application/swing/RunObserve.java similarity index 79% rename from application-swing/src/main/java/fr/ird/observe/application/swing/ObserveAdminCLI.java rename to application-swing/src/main/java/fr/ird/observe/application/swing/RunObserve.java index 742d955..d5816e1 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ObserveAdminCLI.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/RunObserve.java @@ -33,26 +33,25 @@ import java.util.Date; * @author Tony Chemit - chemit@codelutin.com * @since 1.4 */ -public class ObserveAdminCLI extends ObserveRunner { +public class RunObserve extends ObserveRunner { /** Logger */ - private static final Log log = LogFactory.getLog(ObserveAdminCLI.class); + private static final Log log = LogFactory.getLog(RunObserve.class); @Override public String getRunnerName() { return "observe"; } - public ObserveAdminCLI(String... args) { + public RunObserve(String... args) { super(args); } public static void main(String... args) { - log.info("ObServe admin client launch at " + - new Date() + " args: " + Arrays.toString(args)); + log.info("ObServe client launch at " + new Date() + " args: " + Arrays.toString(args)); - new ObserveAdminCLI(args).launch(); + new RunObserve(args).launch(); } } diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/ContentTableUIModel.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/ContentTableUIModel.java index d97f0a8..389e5f6 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/ContentTableUIModel.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/ContentTableUIModel.java @@ -21,7 +21,6 @@ */ package fr.ird.observe.application.swing.ui.content.table; -import fr.ird.observe.application.swing.ObserveSwingBinderService; import fr.ird.observe.application.swing.ObserveSwingTechnicalException; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.application.swing.ui.content.ContentUIModel; @@ -206,11 +205,14 @@ public abstract class ContentTableUIModel<E extends IdDto, D extends IdDto> exte firePropertyChange(PROPERTY_SHOW_DATA, oldValue, showData); } - protected BinderModelBuilder<D, D> prepareChildLoador(ObserveSwingBinderService binderService, String binderName) { + protected BinderModelBuilder<D, D> prepareChildLoador(String binderName) { String[] properties = getChildProperties(); - return binderService.newBinderBuilder(childType, properties); + BinderModelBuilder<D, D> builder = BinderModelBuilder.newEmptyBuilder(childType); + builder.addSimpleProperties(properties); + + return builder; } diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/impl/longline/CatchLonglineUIModel.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/impl/longline/CatchLonglineUIModel.java index c6795a0..02c7d51 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/impl/longline/CatchLonglineUIModel.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/table/impl/longline/CatchLonglineUIModel.java @@ -24,7 +24,6 @@ package fr.ird.observe.application.swing.ui.content.table.impl.longline; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import fr.ird.observe.application.swing.ObserveSwingBinderService; import fr.ird.observe.services.dto.longline.BranchlineDto; import fr.ird.observe.services.dto.longline.CatchLonglineDto; import fr.ird.observe.services.dto.longline.SetLonglineCatchDto; @@ -220,9 +219,9 @@ public class CatchLonglineUIModel extends ContentTableUIModel<SetLonglineCatchDt } @Override - protected BinderModelBuilder<CatchLonglineDto, CatchLonglineDto> prepareChildLoador(ObserveSwingBinderService binderService, String binderName) { + protected BinderModelBuilder<CatchLonglineDto, CatchLonglineDto> prepareChildLoador(String binderName) { - BinderModelBuilder<CatchLonglineDto, CatchLonglineDto> builder = super.prepareChildLoador(binderService, binderName); + BinderModelBuilder<CatchLonglineDto, CatchLonglineDto> builder = super.prepareChildLoador(binderName); builder.addCollectionStrategy(Binder.CollectionStrategy.duplicate, CatchLonglineDto.PROPERTY_PREDATOR); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.