You've already forked v8-code-style
mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-07-14 19:54:14 +02:00
Merge pull request #932 from 1C-Company/bugfix/928-autosort-editing-service
#928 Добавлен учет системы запрета редактирования объектов
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
### Новые фичи
|
||||
|
||||
- Функциональные опции, добавляемые 1C:Code Style, собраны в одном месте для удобного включения/выключения - в помощнике создания нового проекта или в свойствах проекта.
|
||||
- В автосортировке метаданных добавлен учет системы запрета редактирования объектов (правила поддержки)
|
||||
|
||||
### Новые проверки
|
||||
|
||||
|
@ -20,7 +20,8 @@ Import-Package: com._1c.g5.v8.bm.common.collections;version="[3.0.0,4.0.0)",
|
||||
com._1c.g5.v8.bm.integration;version="[9.0.0,10.0.0)",
|
||||
com._1c.g5.v8.bm.integration.event;version="[1.0.0,2.0.0)",
|
||||
com._1c.g5.v8.dt.core.bm.launch;version="[3.0.0,4.0.0)",
|
||||
com._1c.g5.v8.dt.core.lifecycle;version="6.0.0",
|
||||
com._1c.g5.v8.dt.core.lifecycle;version="[7.0.0,8.0.0)",
|
||||
com._1c.g5.v8.dt.core.model;version="[6.0.0,7.0.0)",
|
||||
com._1c.g5.v8.dt.core.operations;version="[4.0.0,5.0.0)",
|
||||
com._1c.g5.v8.dt.core.platform;version="[10.0.0,11.0.0)",
|
||||
com._1c.g5.v8.dt.lifecycle;version="[3.0.0,4.0.0)",
|
||||
|
@ -13,7 +13,7 @@
|
||||
package com.e1c.v8codestyle.internal.autosort;
|
||||
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
|
||||
import com._1c.g5.v8.dt.core.model.IModelEditingSupport;
|
||||
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.IDtProjectManager;
|
||||
@ -42,7 +42,7 @@ class ExternalDependenciesModule
|
||||
bind(IBmModelManager.class).toService();
|
||||
bind(IConfigurationProvider.class).toService();
|
||||
bind(IWorkspaceOrchestrator.class).toService();
|
||||
|
||||
bind(IModelEditingSupport.class).toService();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ import org.eclipse.emf.edit.command.ChangeCommand;
|
||||
|
||||
import com._1c.g5.v8.bm.core.IBmTransaction;
|
||||
import com._1c.g5.v8.bm.integration.AbstractBmTask;
|
||||
import com._1c.g5.v8.bm.integration.IBmModel;
|
||||
import com._1c.g5.v8.dt.core.model.EditingMode;
|
||||
import com._1c.g5.v8.dt.core.model.IModelEditingSupport;
|
||||
import com.e1c.v8codestyle.autosort.SortItem;
|
||||
|
||||
/**
|
||||
@ -44,6 +45,8 @@ public class SortBmTask
|
||||
|
||||
private final Collection<SortItem> items;
|
||||
|
||||
private final IModelEditingSupport modelEditingSupport;
|
||||
|
||||
/**
|
||||
* Instantiates a new sort BM task.
|
||||
*
|
||||
@ -52,10 +55,11 @@ public class SortBmTask
|
||||
*
|
||||
* @param items the unmodifiable collection of items to sort, cannot be {@code null}.
|
||||
*/
|
||||
public SortBmTask(final Collection<SortItem> items)
|
||||
public SortBmTask(final Collection<SortItem> items, IModelEditingSupport modelEditingSupport)
|
||||
{
|
||||
super("Sort Md objects"); //$NON-NLS-1$
|
||||
this.items = new ArrayList<>(items);
|
||||
this.modelEditingSupport = modelEditingSupport;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,7 +78,7 @@ public class SortBmTask
|
||||
}
|
||||
|
||||
EObject parent = transaction.getTopObjectByFqn(item.getFqn());
|
||||
if (parent != null)
|
||||
if (parent != null && modelEditingSupport.canEdit(parent, EditingMode.DIRECT))
|
||||
{
|
||||
Object value = parent.eGet(item.getListRef());
|
||||
if (!(value instanceof List))
|
||||
|
@ -51,6 +51,7 @@ import com._1c.g5.v8.bm.integration.IBmModel;
|
||||
import com._1c.g5.v8.bm.integration.event.BmEventFilter;
|
||||
import com._1c.g5.v8.bm.integration.event.IBmAsyncEventListener;
|
||||
import com._1c.g5.v8.dt.core.lifecycle.ProjectContext;
|
||||
import com._1c.g5.v8.dt.core.model.IModelEditingSupport;
|
||||
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.IDtProject;
|
||||
@ -91,19 +92,32 @@ public class SortService
|
||||
|
||||
private final IWorkspaceOrchestrator workspaceOrchestrator;
|
||||
|
||||
private final IModelEditingSupport modelEditingSupport;
|
||||
|
||||
private final BmEventFilter filter = BmEventFilter.eClassChangeFilter(MdClassPackage.Literals.MD_OBJECT);
|
||||
|
||||
private final Map<IProject, IBmAsyncEventListener> projectListeners = new ConcurrentHashMap<>();
|
||||
private final Map<IProject, SortJob> jobs = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Instantiates a new sort service.
|
||||
*
|
||||
* @param dtProjectManager the DT project manager service, cannot be {@code null}.
|
||||
* @param modelManager the model manager service, cannot be {@code null}.
|
||||
* @param configurationProvider the configuration provider service, cannot be {@code null}.
|
||||
* @param workspaceOrchestrator the workspace orchestrator service, cannot be {@code null}.
|
||||
* @param modelEditingSupport the model editing support service, cannot be {@code null}.
|
||||
*/
|
||||
@Inject
|
||||
public SortService(IDtProjectManager dtProjectManager, IBmModelManager modelManager,
|
||||
IConfigurationProvider configurationProvider, IWorkspaceOrchestrator workspaceOrchestrator)
|
||||
IConfigurationProvider configurationProvider, IWorkspaceOrchestrator workspaceOrchestrator,
|
||||
IModelEditingSupport modelEditingSupport)
|
||||
{
|
||||
this.dtProjectManager = dtProjectManager;
|
||||
this.modelManager = modelManager;
|
||||
this.configurationProvider = configurationProvider;
|
||||
this.workspaceOrchestrator = workspaceOrchestrator;
|
||||
this.modelEditingSupport = modelEditingSupport;
|
||||
}
|
||||
|
||||
@LifecycleParticipant(phase = LifecyclePhase.RESOURCE_LOADING,
|
||||
@ -205,7 +219,7 @@ public class SortService
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
model.getGlobalContext().execute(new SortBmTask(items));
|
||||
model.getGlobalContext().execute(new SortBmTask(items, modelEditingSupport));
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user