1
0
mirror of https://github.com/1C-Company/v8-code-style.git synced 2025-04-15 21:28:30 +02:00

Merge pull request #1364 from 1C-Company/G5V8DT-24027

G5V8DT-24027. Сортировка объектов и прав в ролях
This commit is contained in:
MaksimDzyuba 2023-10-16 23:27:24 +03:00 committed by GitHub
commit 7b8123d7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 377 additions and 201 deletions

View File

@ -320,11 +320,12 @@ public class SortService
{
for (Notification notification : notifications)
{
if (notification.getEventType() == Notification.ADD)
if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.MOVE
|| notification.getEventType() == Notification.REMOVE)
{
Object notifier = notification.getNotifier();
Object value = notification.getNewValue();
if (notifier instanceof IBmObject && value instanceof MdObject)
if (notifier instanceof IBmObject && (value instanceof MdObject || value == null))
{
changedItems.computeIfAbsent(((IBmObject)notifier).bmGetFqn(), k -> new HashSet<>())
.add(listRef);

View File

@ -24,7 +24,7 @@ Import-Package: com._1c.g5.v8.bm.core;version="[8.0.0,9.0.0)",
com._1c.g5.v8.dt.md;version="[19.0.0,20.0.0)",
com._1c.g5.v8.dt.metadata.mdclass;version="[9.0.0,10.0.0)",
com._1c.g5.v8.dt.platform.version;version="[2.0.0,3.0.0)",
com._1c.g5.v8.dt.rights;version="[6.1.0,7.0.0)",
com._1c.g5.v8.dt.rights;version="[7.0.0,8.0.0)",
com._1c.g5.v8.dt.rights.model;version="[4.0.0,5.0.0)",
com._1c.g5.v8.dt.rights.model.util;version="[6.0.0,7.0.0)",
com._1c.g5.wiring;version="[2.2.0,3.0.0)",

View File

@ -153,7 +153,7 @@ public class CorePlugin
{
try
{
return Guice.createInjector(new ServiceModule(), new ExternalDependenciesModule(this));
return Guice.createInjector(new ExternalDependenciesModule(this));
}
catch (Exception e)
{

View File

@ -20,7 +20,7 @@ import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IConfigurationProvider;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.platform.version.IRuntimeVersionSupport;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.wiring.AbstractServiceAwareModule;
/**
@ -32,7 +32,6 @@ import com._1c.g5.wiring.AbstractServiceAwareModule;
public class ExternalDependenciesModule
extends AbstractServiceAwareModule
{
/**
* @param plugin
*/
@ -50,9 +49,6 @@ public class ExternalDependenciesModule
bind(IBmRightsIndexManager.class).toService();
bind(IBmEmfIndexManager.class).toService();
bind(IConfigurationProvider.class).toService();
// XXX remove this when the IRightInfosService become OSGi service
bind(IRuntimeVersionSupport.class).toService();
bind(IRightInfosService.class).toService();
}
}

View File

@ -1,89 +0,0 @@
/*******************************************************************************
* Copyright (C) 2022, 1C-Soft LLC and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* 1C-Soft LLC - initial API and implementation
*******************************************************************************/
package com.e1c.v8codestyle.internal.right;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import com._1c.g5.v8.dt.core.platform.IConfigurationProvider;
import com._1c.g5.v8.dt.metadata.mdclass.Configuration;
import com._1c.g5.v8.dt.platform.version.IRuntimeVersionSupport;
import com._1c.g5.v8.dt.platform.version.Version;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.Right;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
/**
* This service is a correct wrapper of {@link IRightInfosService} to get correct data corresponding
* project runtime version.
* <br>
* FIXME Replace this service after refactoring of {@link IRightInfosService}.
*
* @author Dmitriy Marmyshev
*/
@Singleton
public class InternalRightInfosService
{
private final IRuntimeVersionSupport runtimeVersionSupport;
private final IConfigurationProvider configurationProvider;
private final Provider<IRightInfosService> rightInfosServiceProvider;
private final Map<Version, IRightInfosService> infos = new ConcurrentHashMap<>();
@Inject
public InternalRightInfosService(IRuntimeVersionSupport runtimeVersionSupport,
IConfigurationProvider configurationProvider, Provider<IRightInfosService> rightInfosServiceProvider)
{
this.runtimeVersionSupport = runtimeVersionSupport;
this.configurationProvider = configurationProvider;
this.rightInfosServiceProvider = rightInfosServiceProvider;
}
/**
* Gets the rights of some {@link EClass} of configuration metadata object that may have some rights.
*
* @param eClass the {@link EClass} of configuration metadata object that has some rights, cannot be {@code null}.
* @param context the context object of the configuration to determine platform version, cannot be {@code null}.
* @return the rights of the {@link EClass}
*/
public Set<Right> getEClassRights(EClass eClass, EObject context)
{
Version version = runtimeVersionSupport.getRuntimeVersionOrDefault(context, Version.LATEST);
IRightInfosService info = infos.computeIfAbsent(version, v -> {
IRightInfosService service = rightInfosServiceProvider.get();
Configuration configuration = configurationProvider.getConfiguration(context);
service.init(configuration);
return service;
});
if (info == null)
{
return Collections.emptySet();
}
return info.getEClassRights(eClass);
}
}

View File

@ -1,48 +0,0 @@
/*******************************************************************************
* Copyright (C) 2022, 1C-Soft LLC and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* 1C-Soft LLC - initial API and implementation
*******************************************************************************/
package com.e1c.v8codestyle.internal.right;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com.google.inject.AbstractModule;
/**
* The internal service module.
*
* @author Dmitriy Marmyshev
*/
public class ServiceModule
extends AbstractModule
{
private static final String SERVICE_CLASS = "com._1c.g5.v8.dt.internal.rights.RightsInfoService"; //$NON-NLS-1$
@SuppressWarnings("unchecked")
@Override
protected void configure()
{
// XXX remove this when the IRightInfosService become OSGi service
Class<? extends IRightInfosService> clazz = null;
try
{
clazz = (Class<? extends IRightInfosService>)Class.forName(SERVICE_CLASS, true,
IRightInfosService.class.getClassLoader());
}
catch (ClassNotFoundException e)
{
CorePlugin.logError(e);
}
// Here create new instance every time - this allows to bind it to specific platform Version
// See com.e1c.v8codestyle.internal.right.InternalRightInfosService for details.
bind(IRightInfosService.class).to(clazz);
}
}

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightActiveUsers
@Inject
public RightActiveUsers(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightAdministration
@Inject
public RightAdministration(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightAllFunctionsMode
@Inject
public RightAllFunctionsMode(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightConfigurationExtensionsAdministration
@Inject
public RightConfigurationExtensionsAdministration(IResourceLookup resourceLookup,
IV8ProjectManager v8ProjectManager, IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightDataAdministration
@Inject
public RightDataAdministration(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightDelete
@Inject
public RightDelete(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -48,7 +48,7 @@ public class RightExclusiveMode
@Inject
public RightExclusiveMode(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -18,10 +18,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -42,7 +42,7 @@ public class RightInteractiveClearDeletionMarkPredefinedData
@Inject
public RightInteractiveClearDeletionMarkPredefinedData(IResourceLookup resourceLookup,
IV8ProjectManager v8ProjectManager, IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -18,10 +18,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -42,7 +42,7 @@ public class RightInteractiveDelete
@Inject
public RightInteractiveDelete(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -18,10 +18,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -42,7 +42,7 @@ public class RightInteractiveDeleteMarkedPredefinedData
@Inject
public RightInteractiveDeleteMarkedPredefinedData(IResourceLookup resourceLookup,
IV8ProjectManager v8ProjectManager, IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -18,10 +18,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -42,7 +42,7 @@ public class RightInteractiveDeletePredefinedData
@Inject
public RightInteractiveDeletePredefinedData(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightInteractiveOpenExternalDataProcessors
@Inject
public RightInteractiveOpenExternalDataProcessors(IResourceLookup resourceLookup,
IV8ProjectManager v8ProjectManager, IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightInteractiveOpenExternalReports
@Inject
public RightInteractiveOpenExternalReports(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -18,10 +18,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -42,7 +42,7 @@ public class RightInteractiveSetDeletionMarkPredefinedData
@Inject
public RightInteractiveSetDeletionMarkPredefinedData(IResourceLookup resourceLookup,
IV8ProjectManager v8ProjectManager, IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightOutputToPrinterFileClipboard
@Inject
public RightOutputToPrinterFileClipboard(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightSaveUserData
@Inject
public RightSaveUserData(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightStartAutomation
@Inject
public RightStartAutomation(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightStartExternalConnection
@Inject
public RightStartExternalConnection(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightStartThickClient
@Inject
public RightStartThickClient(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightStartThinClient
@Inject
public RightStartThinClient(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightStartWebClient
@Inject
public RightStartWebClient(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -46,7 +46,7 @@ public class RightUpdateDatabaseConfiguration
@Inject
public RightUpdateDatabaseConfiguration(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,
rightInfosService);

View File

@ -19,10 +19,10 @@ import com._1c.g5.v8.dt.bm.index.rights.IBmRightsIndexManager;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IResourceLookup;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.util.RightName;
import com.e1c.v8codestyle.check.StandardCheckExtension;
import com.e1c.v8codestyle.internal.right.CorePlugin;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
import com.google.inject.Inject;
/**
@ -49,7 +49,7 @@ public class RightViewEventLog
@Inject
public RightViewEventLog(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService,
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService,
IBmModelManager bmModelManager2)
{
super(resourceLookup, v8ProjectManager, bmModelManager, bmRightsIndexManager, bmEmfIndexManager,

View File

@ -61,6 +61,7 @@ import com._1c.g5.v8.dt.md.MdUtil;
import com._1c.g5.v8.dt.metadata.mdclass.MdObject;
import com._1c.g5.v8.dt.metadata.mdclass.Role;
import com._1c.g5.v8.dt.metadata.mdclass.ScriptVariant;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.rights.model.ObjectRight;
import com._1c.g5.v8.dt.rights.model.ObjectRights;
import com._1c.g5.v8.dt.rights.model.Right;
@ -78,7 +79,6 @@ import com.e1c.g5.v8.dt.check.context.OnModelObjectAssociationContextCollector;
import com.e1c.g5.v8.dt.check.context.OnModelObjectRemovalContextCollector;
import com.e1c.g5.v8.dt.check.settings.IssueSeverity;
import com.e1c.g5.v8.dt.check.settings.IssueType;
import com.e1c.v8codestyle.internal.right.InternalRightInfosService;
/**
* Abstract check that role has some right for any object.
@ -114,7 +114,7 @@ public abstract class RoleRightSetCheck
private final IBmEmfIndexManager bmEmfIndexManager;
private final InternalRightInfosService rightInfosService;
private final IRightInfosService rightInfosService;
/**
* Creates new instance which helps to check that role has specified right for an object.
@ -127,7 +127,7 @@ public abstract class RoleRightSetCheck
*/
protected RoleRightSetCheck(IResourceLookup resourceLookup, IV8ProjectManager v8ProjectManager,
IBmModelManager bmModelManager, IBmRightsIndexManager bmRightsIndexManager,
IBmEmfIndexManager bmEmfIndexManager, InternalRightInfosService rightInfosService)
IBmEmfIndexManager bmEmfIndexManager, IRightInfosService rightInfosService)
{
this.resourceLookup = resourceLookup;
this.v8ProjectManager = v8ProjectManager;
@ -413,7 +413,7 @@ public abstract class RoleRightSetCheck
private boolean hasRight(EClass eClass, EObject context)
{
Set<Right> rights = rightInfosService.getEClassRights(eClass, context);
Set<Right> rights = rightInfosService.getEClassRights(context, eClass);
Set<String> rightNames = rights.stream().map(NamedElement::getName).collect(Collectors.toSet());
return rightNames.contains(getRightName().getName());
}

View File

@ -13,7 +13,7 @@
<!-- EDT -->
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<repository id="dt_repository" location="https://edt.1c.ru/downloads/releases/ruby/2023.2/"/>
<repository id="dt_repository" location="https://edt.1c.ru/downloads/releases/ruby/2023.3/"/>
<unit id="com._1c.g5.aef.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.commons.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.edt.license.feature.group" version="0.0.0"/>

View File

@ -13,7 +13,7 @@
<!-- EDT -->
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<repository id="dt_repository" location="https://edt.1c.ru/downloads/releases/ruby/2023.2/"/>
<repository id="dt_repository" location="https://edt.1c.ru/downloads/releases/ruby/2023.3/"/>
<unit id="com._1c.g5.aef.feature.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.commons.feature.group" version="0.0.0"/>
<unit id="com._1c.g5.edt.license.feature.group" version="0.0.0"/>

View File

@ -16,6 +16,7 @@ import com._1c.g5.v8.activitytracking.core.ISystemIdleService;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IDerivedDataManagerProvider;
import com._1c.g5.v8.dt.core.platform.IDtProjectManager;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.wiring.AbstractServiceAwareModule;
import com.e1c.v8codestyle.autosort.ISortService;
import com.e1c.v8codestyle.internal.autosort.AutoSortPlugin;
@ -41,6 +42,7 @@ public class ExternalDependenciesModule
bind(ISortService.class).toService();
bind(IBmModelManager.class).toService();
bind(IDtProjectManager.class).toService();
bind(IV8ProjectManager.class).toService();
bind(ISystemIdleService.class).toService();
bind(IDerivedDataManagerProvider.class).toService();
}

View File

@ -18,29 +18,49 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.core.event.BmChangeEvent;
import com._1c.g5.v8.bm.core.event.BmEvent;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.bm.integration.event.IBmSyncEventListener;
import com._1c.g5.v8.dt.core.platform.IBmModelManager;
import com._1c.g5.v8.dt.core.platform.IConfigurationAware;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.core.platform.IDtProjectManager;
import com._1c.g5.v8.dt.core.platform.IV8Project;
import com._1c.g5.v8.dt.core.platform.IV8ProjectManager;
import com._1c.g5.v8.dt.md.sort.MdSortPreferences;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.Configuration;
import com._1c.g5.v8.dt.metadata.mdclass.MdClassFactory;
import com._1c.g5.v8.dt.testing.GuiceModules;
import com._1c.g5.v8.dt.testing.JUnitGuiceRunner;
import com._1c.g5.v8.dt.testing.TestingWorkspace;
import com.e1c.v8codestyle.autosort.AutoSortPreferences;
import com.e1c.v8codestyle.autosort.ISortService;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
/**
@ -50,7 +70,6 @@ import com.google.inject.Inject;
@GuiceModules(modules = { ExternalDependenciesModule.class })
public class SortServiceTest
{
private static final String PROJECT_NAME = "Sort";
@Rule
@ -62,6 +81,9 @@ public class SortServiceTest
@Inject
public IDtProjectManager dtProjectManager;
@Inject
private IV8ProjectManager v8ProjectManager;
@Inject
public IBmModelManager bmModelManager;
@ -153,12 +175,241 @@ public class SortServiceTest
assertEquals("ОбщийМодуль", configuration.getCommonModules().get(5).getName());
}
@Ignore("#1365")
@Test
public void testSortAfterRemoveEvent() throws Exception
{
IProject project = testingWorkspace.setUpProject(PROJECT_NAME, getClass());
assertNotNull(project);
IDtProject dtProject = dtProjectManager.getDtProject(project);
assertNotNull(dtProject);
IV8Project v8Project = v8ProjectManager.getProject(dtProject);
assertNotNull(dtProject);
IEclipsePreferences autoSortPrefs = AutoSortPreferences.getPreferences(project);
autoSortPrefs.putBoolean(AutoSortPreferences.KEY_ALL_TOP, true);
autoSortPrefs.flush();
IEclipsePreferences mdSortPrefs = MdSortPreferences.getPreferences(project);
mdSortPrefs.putBoolean(MdSortPreferences.NATURAL_SORT_ORDER, false);
mdSortPrefs.flush();
CountDownLatch waitSortStartedlatch = new CountDownLatch(1);
bmModelManager.addSyncEventListener(bmModelManager.getBmNamespace(project),
new BmEventListener(project, waitSortStartedlatch)
{
boolean isBmObjectRemoved = false;
boolean isStortStarted = false;
@Override
protected void registerEvent(Notification notification)
{
if (notification.getEventType() == Notification.REMOVE)
{
isBmObjectRemoved = true;
}
else if (notification.getEventType() == Notification.MOVE)
{
isStortStarted = true;
}
}
@Override
protected boolean isShouldCountDownLatch()
{
return isBmObjectRemoved && isStortStarted;
}
});
bmModelManager.getModel(project).execute(new AbstractBmTask<Void>("Detach a top object") //$NON-NLS-1$
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject commonModule = transaction.getTopObjectByFqn("CommonModule.ГМодуль");
Configuration configuration =
transaction.toTransactionObject(((IConfigurationAware)v8Project).getConfiguration());
configuration.getCommonModules().remove((CommonModule)commonModule);
transaction.detachTopObject(commonModule);
return null;
}
});
waitSortStartedlatch.await();
// wait until sorting is completed.
TimeUnit.SECONDS.sleep(5);
IBmObject object = getTopObjectByFqn(CONFIGURATION.getName(), dtProject);
assertTrue(object instanceof Configuration);
Configuration configuration = (Configuration)object;
assertFalse(configuration.getCommonModules().isEmpty());
assertEquals("АМ_Модуль", configuration.getCommonModules().get(0).getName());
assertEquals("АМ2_4Модуль", configuration.getCommonModules().get(1).getName());
assertEquals("АМодуль", configuration.getCommonModules().get(2).getName());
assertEquals("БМодуль", configuration.getCommonModules().get(3).getName());
assertEquals("ОбщийМодуль", configuration.getCommonModules().get(4).getName());
}
@Ignore("#1365")
@Test
public void testSortAfterMoveEvent() throws Exception
{
IProject project = testingWorkspace.setUpProject(PROJECT_NAME, getClass());
assertNotNull(project);
IDtProject dtProject = dtProjectManager.getDtProject(project);
assertNotNull(dtProject);
IV8Project v8Project = v8ProjectManager.getProject(dtProject);
assertNotNull(dtProject);
IEclipsePreferences autoSortPrefs = AutoSortPreferences.getPreferences(project);
autoSortPrefs.putBoolean(AutoSortPreferences.KEY_ALL_TOP, true);
autoSortPrefs.flush();
IEclipsePreferences mdSortPrefs = MdSortPreferences.getPreferences(project);
mdSortPrefs.putBoolean(MdSortPreferences.NATURAL_SORT_ORDER, false);
mdSortPrefs.flush();
CountDownLatch waitSortStartedlatch = new CountDownLatch(1);
bmModelManager.addSyncEventListener(bmModelManager.getBmNamespace(project),
new BmEventListener(project, waitSortStartedlatch)
{
private int moveCount = 0;
@Override
protected void registerEvent(Notification notification)
{
if (notification.getEventType() == Notification.MOVE)
{
moveCount++;
}
}
@Override
protected boolean isShouldCountDownLatch()
{
return moveCount == 2;
}
});
bmModelManager.getModel(project).execute(new AbstractBmTask<Void>("Move a top object") //$NON-NLS-1$
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor progressMonitor)
{
IBmObject commonModule = transaction.getTopObjectByFqn("CommonModule.БМодуль");
Configuration configuration =
transaction.toTransactionObject(((IConfigurationAware)v8Project).getConfiguration());
configuration.getCommonModules().move(4, (CommonModule)commonModule);
return null;
}
});
waitSortStartedlatch.await();
// wait until sorting is performed.
TimeUnit.SECONDS.sleep(5);
IBmObject object = getTopObjectByFqn(CONFIGURATION.getName(), dtProject);
assertTrue(object instanceof Configuration);
Configuration configuration = (Configuration)object;
assertFalse(configuration.getCommonModules().isEmpty());
assertEquals("АМ_Модуль", configuration.getCommonModules().get(0).getName());
assertEquals("АМ2_4Модуль", configuration.getCommonModules().get(1).getName());
assertEquals("АМодуль", configuration.getCommonModules().get(2).getName());
assertEquals("БМодуль", configuration.getCommonModules().get(3).getName());
assertEquals("ГМодуль", configuration.getCommonModules().get(4).getName());
assertEquals("ОбщийМодуль", configuration.getCommonModules().get(5).getName());
}
@Ignore("#1365")
@Test
public void testSortAfterAddEvent() throws Exception
{
IProject project = testingWorkspace.setUpProject(PROJECT_NAME, getClass());
assertNotNull(project);
IDtProject dtProject = dtProjectManager.getDtProject(project);
assertNotNull(dtProject);
IV8Project v8Project = v8ProjectManager.getProject(dtProject);
assertNotNull(dtProject);
IEclipsePreferences autoSortPrefs = AutoSortPreferences.getPreferences(project);
autoSortPrefs.putBoolean(AutoSortPreferences.KEY_ALL_TOP, true);
autoSortPrefs.flush();
IEclipsePreferences mdSortPrefs = MdSortPreferences.getPreferences(project);
mdSortPrefs.putBoolean(MdSortPreferences.NATURAL_SORT_ORDER, false);
mdSortPrefs.flush();
CountDownLatch waitSortStartedlatch = new CountDownLatch(1);
bmModelManager.addSyncEventListener(bmModelManager.getBmNamespace(project),
new BmEventListener(project, waitSortStartedlatch)
{
boolean isBmObjectAdded = false;
boolean isStortStarted = false;
@Override
protected void registerEvent(Notification notification)
{
if (notification.getEventType() == Notification.ADD)
{
isBmObjectAdded = true;
}
else if (notification.getEventType() == Notification.MOVE)
{
isStortStarted = true;
}
}
@Override
protected boolean isShouldCountDownLatch()
{
return isBmObjectAdded && isStortStarted;
}
});
bmModelManager.getModel(project).execute(new AbstractBmTask<Void>("Add a top object") //$NON-NLS-1$
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor progressMonitor)
{
CommonModule commonModule = MdClassFactory.eINSTANCE.createCommonModule();
commonModule.setName("КМодуль");
commonModule.setUuid(UUID.randomUUID());
transaction.attachTopObject((IBmObject)commonModule, "CommonModule.КМодуль");
Configuration configuration =
transaction.toTransactionObject(((IConfigurationAware)v8Project).getConfiguration());
configuration.getCommonModules().add(commonModule);
return null;
}
});
waitSortStartedlatch.await();
// wait until sorting is performed.
TimeUnit.SECONDS.sleep(5);
IBmObject object = getTopObjectByFqn(CONFIGURATION.getName(), dtProject);
Configuration configuration = (Configuration)object;
assertFalse(configuration.getCommonModules().isEmpty());
assertEquals("АМ_Модуль", configuration.getCommonModules().get(0).getName());
assertEquals("АМ2_4Модуль", configuration.getCommonModules().get(1).getName());
assertEquals("АМодуль", configuration.getCommonModules().get(2).getName());
assertEquals("БМодуль", configuration.getCommonModules().get(3).getName());
assertEquals("ГМодуль", configuration.getCommonModules().get(4).getName());
assertEquals("КМодуль", configuration.getCommonModules().get(5).getName());
assertEquals("ОбщийМодуль", configuration.getCommonModules().get(6).getName());
}
protected IBmObject getTopObjectByFqn(final String fqn, IDtProject dtProject)
{
IBmModel model = this.bmModelManager.getModel(dtProject);
return model.executeReadonlyTask(new AbstractBmTask<IBmObject>("GetObject")
{
@Override
public IBmObject execute(IBmTransaction transaction, IProgressMonitor progressMonitor)
{
@ -166,4 +417,65 @@ public class SortServiceTest
}
});
}
private abstract class BmEventListener
implements IBmSyncEventListener
{
private final CountDownLatch latch;
private final IProject project;
/**
* Creates instance of listener.
*
* @param project project to listen events to, cannot be {@code null}
* @param latch latch waiting until notified about {@code eventType} and starting sort, cannot be {@code null}
*/
public BmEventListener(IProject project, CountDownLatch latch)
{
this.project = Preconditions.checkNotNull(project);
this.latch = Preconditions.checkNotNull(latch);
}
@Override
public void handleSyncEvent(BmEvent event)
{
for (BmChangeEvent changeEvent : event.getChangeEvents().values())
{
if (changeEvent.getObject() instanceof IBmObject && ((IBmObject)changeEvent.getObject()).bmIsTop()
&& ((IBmObject)changeEvent.getObject()).bmGetFqn() != null)
{
Map<EStructuralFeature, List<Notification>> notifications = changeEvent.getNotifications();
for (Entry<EStructuralFeature, List<Notification>> entry : notifications.entrySet())
{
if (entry.getKey() instanceof EReference
&& AutoSortPreferences.isAllowedToSort(project, (EReference)entry.getKey()))
{
for (Notification notification : entry.getValue())
{
registerEvent(notification);
}
}
}
}
}
if (isShouldCountDownLatch())
{
latch.countDown();
}
}
/**
* Specifies how event must be registered.
*
* @param notification the notification containing event data, cannot be {@code null}
*/
protected abstract void registerEvent(Notification notification);
/**
* Checks if listener should count down latch.
*
* @return {@code true} if should count down latch, {@code false} otherwise
*/
protected abstract boolean isShouldCountDownLatch();
}
}

View File

@ -19,6 +19,7 @@ import com._1c.g5.v8.dt.core.platform.IDerivedDataManagerProvider;
import com._1c.g5.v8.dt.core.platform.IDtProjectManager;
import com._1c.g5.v8.dt.core.platform.IWorkspaceOrchestrator;
import com._1c.g5.v8.dt.md.refactoring.core.IMdRefactoringService;
import com._1c.g5.v8.dt.rights.IRightInfosService;
import com._1c.g5.v8.dt.validation.marker.IMarkerManager;
import com._1c.g5.wiring.AbstractServiceAwareModule;
import com.e1c.g5.v8.dt.check.settings.ICheckRepository;
@ -49,5 +50,6 @@ public class CheckExternalDependenciesModule
bind(IMarkerManager.class).toService();
bind(IMdRefactoringService.class).toService();
bind(IWorkspaceOrchestrator.class).toService();
bind(IRightInfosService.class).toService();
}
}