Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#504 У поля "Ссылка" таблицы динамического списка не отключена пользовательская видимость #1025

Prev Previous commit
Next Next commit
#504 Правки по замечаниям
  • Loading branch information
olga355 committed May 18, 2022
commit 35c56a5ebfdf9c0a8588f95fb7c03d951395fc42
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
package com.e1c.v8codestyle.form.check;

import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.FORM;
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.VISIBLE;
import static com._1c.g5.v8.dt.form.model.FormPackage.Literals.VISIBLE__USER_VISIBLE;
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ADJUSTABLE_BOOLEAN;
import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.ADJUSTABLE_BOOLEAN__COMMON;

import java.util.List;

Expand All @@ -23,7 +23,8 @@
import org.eclipse.emf.ecore.EObject;

import com._1c.g5.v8.dt.form.model.AbstractDataPath;
import com._1c.g5.v8.dt.form.model.Visible;
import com._1c.g5.v8.dt.form.model.FormField;
import com._1c.g5.v8.dt.metadata.mdclass.AdjustableBoolean;
import com.e1c.g5.v8.dt.check.CheckComplexity;
import com.e1c.g5.v8.dt.check.ICheckParameters;
import com.e1c.g5.v8.dt.check.components.BasicCheck;
Expand All @@ -42,6 +43,7 @@ public class FormListRefUserVisibilityEnabledCheck
{

private static final String CHECK_ID = "form-list-ref-user-visibility-enabled"; //$NON-NLS-1$
private static final String FEATURE_NAME = "userVisible"; //$NON-NLS-1$
private static final List<String> LIST_SEGMENT = List.of("List", "Список"); //$NON-NLS-1$ //$NON-NLS-2$
marmyshev marked this conversation as resolved.
Show resolved Hide resolved
private static final List<String> REF_SEGMENT = List.of("Ref", "Ссылка"); //$NON-NLS-1$ //$NON-NLS-2$

Expand All @@ -61,27 +63,25 @@ protected void configureCheck(CheckConfigurer builder)
.issueType(IssueType.UI_STYLE)
.extension(new StandardCheckExtension(getCheckId(), CorePlugin.PLUGIN_ID))
.topObject(FORM)
.containment(VISIBLE)
.features(VISIBLE__USER_VISIBLE);
.containment(ADJUSTABLE_BOOLEAN)
.features(ADJUSTABLE_BOOLEAN__COMMON);

}

@Override
protected void check(Object object, ResultAcceptor resultAceptor, ICheckParameters parameters,
IProgressMonitor monitor)
{
if (monitor.isCanceled() || !(object instanceof Visible))
{
return;
}

Visible visible = (Visible)object;

if (pathCheck(visible.eContents()) && visible.getUserVisible().isCommon())
AdjustableBoolean adjBoolean = (AdjustableBoolean)object;
if (adjBoolean.isCommon() && adjBoolean.eContainer() instanceof FormField
&& adjBoolean.eContainmentFeature().getName().equals(FEATURE_NAME)
&& pathCheck(adjBoolean.eContainer().eContents()))
{
resultAceptor.addIssue(
Messages.FormListRefUserVisibilityEnabledCheck_User_visibility_is_not_disabled_for_the_Ref_field,
visible);
ADJUSTABLE_BOOLEAN__COMMON);
}

}

private boolean pathCheck(EList<EObject> eContents)
Expand All @@ -90,9 +90,7 @@ private boolean pathCheck(EList<EObject> eContents)
{
return false;
}

EList<String> segments = ((AbstractDataPath)eContents.get(1)).getSegments();

return segments.size() == 2 && LIST_SEGMENT.contains(segments.get(0)) && REF_SEGMENT.contains(segments.get(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.e1c.v8codestyle.form.check.itests;

import static com._1c.g5.v8.dt.metadata.mdclass.MdClassPackage.Literals.CONFIGURATION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -44,8 +45,9 @@ public class FormListRefUserVisibilityEnabledCheckTest
extends CheckTestBase
{
private static final String CHECK_ID = "form-list-ref-user-visibility-enabled";
private static final String PROJECT_NAME = "FormListRefUseAlwaysFlagDisabled";
private static final String FQN_FORM = "Catalog.TestCatalog.Form.TestListForm.Form";
private static final String PROJECT_NAME = "FormListRefUserVisibilityEnabled";
private static final String FQN_FORM_EN = "Catalog.TestCatalog.Form.TestListForm.Form";
private static final String FQN_FORM_RU = "Catalog.TestCatalog.Form.TestListFormRu.Form";

/**
* Test User Visibility is enabled for the Ref field in dynamic list (En Script variant).
Expand All @@ -58,7 +60,7 @@ public void testUserVisibilityEnabledForRef() throws Exception
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM, dtProject);
IBmObject object = getTopObjectByFqn(FQN_FORM_EN, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
Expand All @@ -82,19 +84,21 @@ public void testUserVisibilityDisabledForRef() throws Exception
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
Form form = (Form)transaction.getTopObjectByFqn(FQN_FORM);
Form form = (Form)transaction.getTopObjectByFqn(FQN_FORM_EN);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
FormField field = (FormField)table.getItems().get(0);
field.setUserVisible(null);
assertEquals("Ref", table.getItems().get(0).getName());
FormField fieldRef = (FormField)table.getItems().get(0);
fieldRef.getUserVisible().setCommon(false);
return null;
}
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM, dtProject);
IBmObject object = getTopObjectByFqn(FQN_FORM_EN, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNull(marker);
}
Expand Down Expand Up @@ -126,10 +130,62 @@ public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM, dtProject);
IBmObject object = getTopObjectByFqn(FQN_FORM_RU, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNotNull(marker);
}

/**
* Test User Visibility is disabled for the Ref field in dynamic list (Ru Script variant).
*
* @throws Exception the exception
*/
@Test
public void testUserVisibilityDisabledForRefRu() throws Exception
{
IDtProject dtProject = openProjectAndWaitForValidationFinish(PROJECT_NAME);
assertNotNull(dtProject);

IBmModel modelChangeLanguage = bmModelManager.getModel(dtProject);
modelChangeLanguage.execute(new AbstractBmTask<Void>("change mode")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(CONFIGURATION.getName());
assertTrue(object instanceof Configuration);
Configuration config = (Configuration)object;
config.setScriptVariant(ScriptVariant.RUSSIAN);
assertTrue(config.getScriptVariant() == ScriptVariant.RUSSIAN);
return null;
}
});
waitForDD(dtProject);

IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change mode")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
Form form = (Form)transaction.getTopObjectByFqn(FQN_FORM_RU);
FormItem item = form.getItems().get(1);
assertTrue(item instanceof Table);
Table table = (Table)item;
assertEquals("Ссылка", table.getItems().get(0).getName());
FormField fieldRef = (FormField)table.getItems().get(0);
fieldRef.getUserVisible().setCommon(false);
return null;
}
});
waitForDD(dtProject);

IBmObject object = getTopObjectByFqn(FQN_FORM_RU, dtProject);
assertTrue(object instanceof Form);

Marker marker = getFirstNestedMarker(CHECK_ID, object.bmGetId(), dtProject);
assertNull(marker);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<Settings xmlns="http://v8.1c.ru/8.1/data-composition-system/settings" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:v8="http://v8.1c.ru/8.1/data/core" xmlns:v8ui="http://v8.1c.ru/8.1/data/ui" xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows" xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core">
<filter>
<viewMode>Normal</viewMode>
<userSettingID>dc8eb9ee-de27-4214-8c1d-5bb6d04f4860</userSettingID>
<userSettingID>bd71abe7-6580-4c97-9411-e8ac65bf019a</userSettingID>
</filter>
<order>
<viewMode>Normal</viewMode>
<userSettingID>3007e363-3960-4bfb-a998-407d01ff5ea6</userSettingID>
<userSettingID>2fd2f731-62df-472a-826b-d5360bb235fd</userSettingID>
</order>
<conditionalAppearance>
<viewMode>Normal</viewMode>
<userSettingID>443851fa-4eb2-49b7-9033-2169b4d0c3dd</userSettingID>
<userSettingID>d97169f7-9014-4ac5-a354-3e11dad469d5</userSettingID>
</conditionalAppearance>
<itemsViewMode>Normal</itemsViewMode>
<itemsUserSettingID>373ffb15-7cdd-44dc-82f3-3f49c05ad5ec</itemsUserSettingID>
<itemsUserSettingID>c0d1a3e5-da13-401f-83fd-472b9f44cfd4</itemsUserSettingID>
</Settings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Settings xmlns="http://v8.1c.ru/8.1/data-composition-system/settings" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:v8="http://v8.1c.ru/8.1/data/core" xmlns:v8ui="http://v8.1c.ru/8.1/data/ui" xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows" xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core">
<filter>
<viewMode>Normal</viewMode>
<userSettingID>97952f95-4dbc-4780-94aa-ed36180dfe75</userSettingID>
</filter>
<order>
<viewMode>Normal</viewMode>
<userSettingID>6fc772b9-08af-440c-9357-edc78ae0c9de</userSettingID>
</order>
<conditionalAppearance>
<viewMode>Normal</viewMode>
<userSettingID>49c1de45-d0bf-4b19-ba58-550b7aa246fd</userSettingID>
</conditionalAppearance>
<itemsViewMode>Normal</itemsViewMode>
<itemsUserSettingID>a7d0faf2-bbb5-4d74-9eef-db02b3771a67</itemsUserSettingID>
</Settings>
Loading