Skip to content

Commit 17add39

Browse files
committed
SemiPropertyOption divided into semiActionOption and semiPropertyOption as in grammar
1 parent cbd3829 commit 17add39

13 files changed

+135
-100
lines changed

src/com/lsfusion/design/DefaultFormView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private void initProperties() {
174174
}
175175

176176
private PropertyGroupContainerView getPropertyContainer(PropertyDrawView property) {
177-
return getPropertyGroupContainer(property.entity.getToDraw(entity));
177+
return getPropertyGroupContainer(property.entity.getToDraw());
178178
}
179179

180180
private PropertyGroupContainerView getPropertyGroupContainer(GroupObjectEntity groupObject) {
@@ -275,7 +275,7 @@ public void addPropertyDrawView(PropertyDrawView propertyDraw) {
275275

276276
public void addPanelPropertyDrawView(PropertyDrawView propertyDraw) {
277277
ContainerView propertyContainer;
278-
if (propertyDraw.entity.isToolbar(entity)) {
278+
if (propertyDraw.entity.isToolbar()) {
279279
propertyContainer = getToolbarPropsContainer(propertyDraw);
280280
propertyDraw.setAlignment(FlexAlignment.CENTER);
281281
} else {

src/com/lsfusion/design/FormView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void addPropertyDrawView(PropertyDrawView propertyDraw) {
189189
}
190190

191191
protected boolean addGridDrawView(PropertyDrawView propertyDraw) { // в том числе и HIDE
192-
GroupObjectEntity groupObject = propertyDraw.entity.getToDraw(entity);
192+
GroupObjectEntity groupObject = propertyDraw.entity.getToDraw();
193193
GroupObjectView groupObjectView = mgroupObjects.get(groupObject);
194194

195195
if (groupObjectView != null && groupObjectView.entity.initClassView == ClassViewType.HIDE || propertyDraw.hide || propertyDraw.isForceHide()) {
@@ -211,7 +211,7 @@ protected boolean addGridDrawView(PropertyDrawView propertyDraw) { // в том
211211

212212
public boolean putInGrid(PropertyDrawView property, GroupObjectView groupObjectView) {
213213
if (groupObjectView != null) {
214-
return !groupObjectView.entity.isFixedPanel() && groupObjectView.entity.initClassView == ClassViewType.GRID && !property.isForcedPanel() && !property.entity.isToolbar(entity);
214+
return !groupObjectView.entity.isFixedPanel() && groupObjectView.entity.initClassView == ClassViewType.GRID && !property.isForcedPanel() && !property.entity.isToolbar();
215215
}
216216
return false;
217217
}

src/com/lsfusion/design/model/PropertyDrawView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public boolean isHorizontalValueFlex() {
386386

387387
@Override
388388
public double getBaseDefaultFlex(FormEntity formEntity) {
389-
if ((container.isHorizontal() || entity.isGrid(formEntity)) && isHorizontalValueFlex())
389+
if ((container.isHorizontal() || entity.isGrid()) && isHorizontalValueFlex())
390390
return getValueWidth(new JLabel());
391391
return super.getBaseDefaultFlex(formEntity);
392392
}

src/com/lsfusion/design/model/entity/PropertyDrawEntity.java

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ protected void initDefaultView() {
3131

3232
public String sID;
3333

34-
public boolean isToolbar(FormEntity entity) {
34+
public boolean isToolbar() {
3535
if(forceViewType != null)
3636
return forceViewType.isToolbar();
3737

38-
GroupObjectEntity toDraw = getToDraw(entity);
38+
GroupObjectEntity toDraw = getToDraw();
3939
return toDraw != null && toDraw.initClassView.isToolbar();
4040
}
4141

42-
public boolean isGrid(FormEntity entity) {
43-
GroupObjectEntity toDraw = getToDraw(entity);
42+
public boolean isGrid() {
43+
GroupObjectEntity toDraw = getToDraw();
4444
return toDraw != null && toDraw.initClassView.isGrid() && (forceViewType == null || forceViewType.isGrid());
4545
}
4646

@@ -53,9 +53,6 @@ public boolean isGrid(FormEntity entity) {
5353

5454
public Project project;
5555

56-
public boolean askConfirm;
57-
public String askConfirmMessage;
58-
5956
public String canonicalName = "";
6057
public String declText;
6158
public String declLocation;
@@ -111,12 +108,11 @@ public PropertyDrawEntity(String alias, String propertyName, List<ObjectEntity>
111108
forceViewType = ClassViewType.PANEL;
112109
}
113110

111+
LSFNonEmptyActionOptions actionOptions = null;
114112
LSFNonEmptyPropertyOptions propertyOptions = null;
115113
if (propDeclaration != null) {
114+
actionOptions = propDeclaration.getNonEmptyActionOptions();
116115
propertyOptions = propDeclaration.getNonEmptyPropertyOptions();
117-
// if (caption == null) {
118-
// caption = propertyStatement.getDeclName();
119-
// }
120116
declText = propDeclaration.getText();
121117
declLocation = propDeclaration.getLocationString();
122118
List<LSFClassSet> paramClasses = propDeclaration.resolveParamClasses();
@@ -132,47 +128,48 @@ public PropertyDrawEntity(String alias, String propertyName, List<ObjectEntity>
132128
}
133129
}
134130

135-
if (propertyOptions != null) {
136-
for(LSFViewTypeSetting viewType : propertyOptions.getViewTypeSettingList())
137-
forceViewType = valueOf(viewType.getClassViewType().getText());
131+
if (actionOptions != null)
132+
applyOptions(actionOptions.getViewTypeSettingList(), actionOptions.getFlexCharWidthSettingList(),
133+
actionOptions.getCharWidthSettingList(), actionOptions.getImageSettingList(),
134+
actionOptions.getChangeKeySettingList(), actionOptions.getInSettingList());
138135

139-
List<LSFFlexCharWidthSetting> fixedCharWidthSettings = propertyOptions.getFlexCharWidthSettingList();
140-
if (!fixedCharWidthSettings.isEmpty()) {
141-
fixedCharWidth = Integer.parseInt(fixedCharWidthSettings.get(fixedCharWidthSettings.size() - 1).getIntLiteral().getText());
142-
}
136+
if (propertyOptions != null)
137+
applyOptions(propertyOptions.getViewTypeSettingList(), propertyOptions.getFlexCharWidthSettingList(),
138+
propertyOptions.getCharWidthSettingList(), propertyOptions.getImageSettingList(),
139+
propertyOptions.getChangeKeySettingList(), propertyOptions.getInSettingList());
143140

144-
List<LSFCharWidthSetting> minCharWidthSettings = propertyOptions.getCharWidthSettingList();
145-
if (!minCharWidthSettings.isEmpty()) {
146-
charWidth = Integer.parseInt(minCharWidthSettings.get(minCharWidthSettings.size() - 1).getIntLiteral().getText());
147-
}
141+
applyFormOptions(commonFormOptions, form);
142+
applyFormOptions(propertyFormOptions, form);
143+
}
148144

149-
List<LSFImageSetting> imageSettings = propertyOptions.getImageSettingList();
150-
if (!imageSettings.isEmpty()) {
151-
iconPath = imageSettings.get(imageSettings.size() - 1).getStringLiteral().getValue();
152-
}
145+
private void applyOptions(List<LSFViewTypeSetting> viewTypeSettingList, List<LSFFlexCharWidthSetting> flexCharWidthSettingList,
146+
List<LSFCharWidthSetting> charWidthSettingList, List<LSFImageSetting> imageSettingList,
147+
List<LSFChangeKeySetting> changeKeySettingList, List<LSFInSetting> inSettingList) {
148+
for(LSFViewTypeSetting viewType : viewTypeSettingList)
149+
forceViewType = valueOf(viewType.getClassViewType().getText());
153150

154-
List<LSFChangeKeySetting> editKeySettings = propertyOptions.getChangeKeySettingList();
155-
if (!editKeySettings.isEmpty()) {
156-
LSFChangeKeySetting editKeySetting = editKeySettings.get(editKeySettings.size() - 1);
157-
changeKey = KeyStroke.getKeyStroke(editKeySetting.getStringLiteral().getValue());
158-
if (editKeySetting.getHideEditKey() != null) {
159-
showChangeKey = false;
160-
}
161-
}
151+
if (!flexCharWidthSettingList.isEmpty())
152+
fixedCharWidth = Integer.parseInt(flexCharWidthSettingList.get(flexCharWidthSettingList.size() - 1).getIntLiteral().getText());
162153

163-
getAbstractGroup(propertyOptions);
164-
}
154+
if (!charWidthSettingList.isEmpty())
155+
charWidth = Integer.parseInt(charWidthSettingList.get(charWidthSettingList.size() - 1).getIntLiteral().getText());
165156

166-
applyFormOptions(commonFormOptions, form);
167-
applyFormOptions(propertyFormOptions, form);
168-
}
157+
if (!imageSettingList.isEmpty()) {
158+
LSFStringLiteral imageLiteral = imageSettingList.get(imageSettingList.size() - 1).getStringLiteral();
159+
if(imageLiteral != null)
160+
iconPath = imageLiteral.getValue();
161+
}
169162

170-
private void getAbstractGroup(LSFNonEmptyPropertyOptions propertyOptions) {
171-
List<LSFGroupUsage> groupUsageList = propertyOptions.getGroupUsageList();
172-
if (!groupUsageList.isEmpty()) {
173-
LSFGroupUsage groupUsage = groupUsageList.get(groupUsageList.size() - 1);
174-
parent = addAbstractGroup(groupUsage);
163+
if (!changeKeySettingList.isEmpty()) {
164+
LSFChangeKeySetting editKeySetting = changeKeySettingList.get(changeKeySettingList.size() - 1);
165+
changeKey = KeyStroke.getKeyStroke(editKeySetting.getStringLiteral().getValue());
166+
if (editKeySetting.getHideEditKey() != null) {
167+
showChangeKey = false;
168+
}
175169
}
170+
171+
if (!inSettingList.isEmpty())
172+
parent = addAbstractGroup(inSettingList.get(inSettingList.size() - 1).getGroupUsage());
176173
}
177174

178175
private AbstractGroup addAbstractGroup(LSFGroupUsage groupUsage) {
@@ -205,14 +202,13 @@ private void applyFormOptions(LSFFormPropertyOptionsList optionList, FormEntity
205202
List<LSFFormOptionForce> formOptionForceList = optionList.getFormOptionForceList();
206203
if (!formOptionForceList.isEmpty()) {
207204
LSFFormOptionForce forceOption = formOptionForceList.get(formOptionForceList.size() - 1);
208-
if (forceOption.getClassViewType() != null) {
209-
String forceText = forceOption.getClassViewType().getText();
210-
forceViewType = ClassViewType.valueOf(forceText);
211-
}
205+
forceOption.getClassViewType();
206+
String forceText = forceOption.getClassViewType().getText();
207+
forceViewType = ClassViewType.valueOf(forceText);
212208
}
213209
}
214210

215-
public GroupObjectEntity getToDraw(FormEntity form) {
211+
public GroupObjectEntity getToDraw() {
216212
return toDraw;
217213
}
218214

src/com/lsfusion/inspections/LSFProblemsVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ static void visitLSFSimpleNameWithCaption(ProblemsHolder holder, LSFSimpleNameWi
6262

6363
private static boolean hasShortCut(LSFDeclaration objectDecl) {
6464
if(objectDecl instanceof LSFPropertyStatementImpl) {
65-
LSFNonEmptyPropertyOptions propertyOptions = ((LSFPropertyStatementImpl) objectDecl).getNonEmptyPropertyOptions();
65+
LSFNonEmptyActionOptions propertyOptions = ((LSFPropertyStatementImpl) objectDecl).getNonEmptyActionOptions();
6666
if(propertyOptions != null) {
6767
for(LSFAsEditActionSetting editAction : propertyOptions.getAsEditActionSettingList()) {
6868
LSFFormEventType formEventType = editAction.getFormEventType();
6969
if(formEventType != null && formEventType.getContextMenuEventType() != null)
7070
return true;
71-
}
71+
}
7272
}
7373
}
7474
return false;

src/com/lsfusion/lang/LSF.bnf

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ explicitInterfaceActStatement ::= actionStatement
246246
}
247247

248248
actionStatement ::= propertyDeclaration
249-
( actionUnfriendlyPD (nonEmptyPropertyOptions | SEMI)
250-
| topActionPropertyDefinitionBody nonEmptyPropertyOptions?
249+
( actionUnfriendlyPD (nonEmptyActionOptions | SEMI)
250+
| topActionPropertyDefinitionBody nonEmptyActionOptions?
251251
)
252252
{
253253
pin(".*") = 1
@@ -642,81 +642,96 @@ typePropertyDefinition ::= typeIs className
642642
methods = [getDocumentation]
643643
}
644644

645-
private semiPropertyOption ::= IN groupUsage
646-
| materializedSetting
647-
| indexedSetting
648-
| complexSetting
649-
| prereadSetting
650-
| hintSetting
651-
| TABLE tableUsage
652-
| asEditActionSetting
645+
private semiActionOrPropertyOption ::=
646+
inSetting
653647
| viewTypeSetting
654648
| customViewSetting
655649
| flexCharWidthSetting
656650
| charWidthSetting
651+
| changeKeySetting
652+
| changeMouseSetting
653+
| stickyOption
654+
| syncTypeLiteral
657655
| imageSetting
658656
| extIdSetting
657+
| ATSIGN2 simpleName
658+
659+
private semiActionOption ::= semiActionOrPropertyOption
660+
| shortcutSetting
661+
| asEditActionSetting
662+
| confirmSetting
663+
664+
private semiPropertyOption ::= semiActionOrPropertyOption
665+
| materializedSetting
666+
| indexedSetting
667+
| complexSetting
668+
| prereadSetting
669+
| hintSetting
670+
| tableSetting
659671
| defaultCompareSetting
660-
| changeKeySetting
661-
| changeMouseSetting
662672
| autosetSetting
663-
| confirmSetting
664673
| patternSetting
665674
| regexpSetting
666-
| loggableSetting
667675
| echoSymbolsSetting
668-
| aggrSetting
669676
| notNullSetting
677+
| aggrSetting
670678
| eventIdSetting
671679
| lazySetting
672-
| stickyOption
673-
| syncTypeLiteral
674-
| ATSIGN2 simpleName
680+
| loggableSetting
681+
675682
private nonSemiPropertyOption ::= onEditEventSetting
676683

677684
//((semiPropertyOption | nonSemiPropertyOption)* (semiPropertyOption SEMI | nonSemiPropertyOption)
678685
// recursive-LL might be better because of pins (? naybe it would not be possible to pin 1 rule because of for example } TABLE X (A)), but needs some refactoring
679686
//semiPropertyOption (SEMI | nonEmptyPropertyOptions) | nonSemiPropertyOption nonEmptyPropertyOptions?
687+
nonEmptyActionOptions ::= ((nonSemiPropertyOption* semiActionOption)+ SEMI | (semiActionOption* nonSemiPropertyOption)+)
688+
{
689+
implements = "com.lsfusion.documentation.LSFDocumentation"
690+
methods = [getDocumentation]
691+
}
692+
680693
nonEmptyPropertyOptions ::= ((nonSemiPropertyOption* semiPropertyOption)+ SEMI | (semiPropertyOption* nonSemiPropertyOption)+)
681694
{
682695
implements = "com.lsfusion.documentation.LSFDocumentation"
683696
methods = [getDocumentation]
684697
}
685698

699+
inSetting ::= IN groupUsage
686700
viewTypeSetting ::= classViewType
687701
customViewSetting ::= propertyCustomView
702+
flexCharWidthSetting ::= CHARWIDTH intLiteral (FLEX | NOFLEX)
703+
charWidthSetting ::= CHARWIDTH intLiteral
704+
changeKeySetting ::= CHANGEKEY stringLiteral (SHOW | hideEditKey)?
705+
changeMouseSetting ::= CHANGEMOUSE stringLiteral (SHOW | hideEditKey)?
706+
hideEditKey ::= HIDE
707+
stickyOption ::= STICKY | NOSTICKY
708+
imageSetting ::= (IMAGE stringLiteral?) | NOIMAGE
709+
staticObjectImage ::= (IMAGE stringLiteral) | NOIMAGE
710+
711+
contextMenuEventType ::= CONTEXTMENU (<<noIDCheck>> localizedStringLiteral)? { pin = 1 } // there are a lot of rules that start from ID, so we'll ignore that cases
712+
keyPressedEventType ::= KEYPRESS stringLiteral { pin = 1 }
713+
formEventType ::= (CHANGE (BEFORE | AFTER)?) | GROUPCHANGE | CHANGEWYS | EDIT | contextMenuEventType | keyPressedEventType
714+
onEditEventSetting ::= ON formEventType topActionPropertyDefinitionBody {pin = 2} // нельзя pin'ить 1 так как после действия ON может идти
715+
shortcutSetting ::= ASON CONTEXTMENU (<<noIDCheck>> localizedStringLiteral)? actionOrPropertyUsage
716+
asEditActionSetting ::= ASON formEventType noContextActionOrPropertyUsage {pin = 1}
717+
confirmSetting ::= CONFIRM
718+
688719
materializedSetting ::= MATERIALIZED stringLiteral?
689720
indexedSetting ::= INDEXED stringLiteral? (LIKE | MATCH)?
690721
complexSetting ::= COMPLEX | NOCOMPLEX
691-
hintSetting ::= HINT | NOHINT
692722
prereadSetting ::= PREREAD
693-
charWidthSetting ::= CHARWIDTH intLiteral
694-
flexCharWidthSetting ::= CHARWIDTH intLiteral (FLEX | NOFLEX)
695-
imageSetting ::= (IMAGE stringLiteral?) | NOIMAGE
696-
staticObjectImage ::= (IMAGE stringLiteral) | NOIMAGE
723+
hintSetting ::= HINT | NOHINT
724+
tableSetting ::= TABLE tableUsage
697725
defaultCompareSetting ::= DEFAULTCOMPARE stringLiteral
698-
changeKeySetting ::= CHANGEKEY stringLiteral (SHOW | hideEditKey)?
699-
changeMouseSetting ::= CHANGEMOUSE stringLiteral (SHOW | hideEditKey)?
700726
autosetSetting ::= AUTOSET
701-
confirmSetting ::= CONFIRM
702727
patternSetting ::= PATTERN localizedStringLiteral
703728
regexpSetting ::= REGEXP localizedStringLiteral (localizedStringLiteral)?
704-
loggableSetting ::= LOGGABLE
705729
echoSymbolsSetting ::= ECHO
706-
aggrSetting ::= AGGR
707730
notNullSetting ::= nullOption (DELETE)? baseEventNotPE
708-
onEditEventSetting ::= ON formEventType topActionPropertyDefinitionBody {pin = 2} // нельзя pin'ить 1 так как после действия ON может идти
709-
asEditActionSetting ::= ASON formEventType noContextActionOrPropertyUsage {pin = 1}
731+
aggrSetting ::= AGGR
710732
eventIdSetting ::= EVENTID stringLiteral
711733
lazySetting ::= LAZY (WEAK | STRONG)?
712-
713-
stickyOption ::= STICKY | NOSTICKY
714-
715-
hideEditKey ::= HIDE
716-
717-
contextMenuEventType ::= CONTEXTMENU (<<noIDCheck>> localizedStringLiteral)? { pin = 1 } // there are a lot of rules that start from ID, so we'll ignore that cases
718-
keyPressedEventType ::= KEYPRESS stringLiteral { pin = 1 }
719-
formEventType ::= (CHANGE (BEFORE | AFTER)?) | GROUPCHANGE | CHANGEWYS | EDIT | contextMenuEventType | keyPressedEventType
734+
loggableSetting ::= LOGGABLE
720735

721736
////////////////////////////////////////////////////////////////////////////////
722737
////////////////////////////////// ACTION PROPERTIES ///////////////////////////

src/com/lsfusion/lang/psi/LSFPsiImplUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4866,6 +4866,10 @@ public static String getDocumentation(LSFTypePropertyDefinition lsfTypePropertyD
48664866
return "IS_AS_operators";
48674867
}
48684868

4869+
public static String getDocumentation(LSFNonEmptyActionOptions lsfNonEmptyActionOptions, PsiElement child) {
4870+
return "Action_options";
4871+
}
4872+
48694873
public static String getDocumentation(LSFNonEmptyPropertyOptions lsfNonEmptyPropertyOptions, PsiElement child) {
48704874
return "Property_options";
48714875
}

src/com/lsfusion/lang/psi/declarations/LSFActionOrGlobalPropDeclaration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import com.intellij.psi.search.searches.ReferencesSearch;
44
import com.intellij.psi.util.PsiTreeUtil;
5-
import com.lsfusion.lang.psi.LSFExplicitClasses;
6-
import com.lsfusion.lang.psi.LSFId;
7-
import com.lsfusion.lang.psi.LSFInterfacePropStatement;
8-
import com.lsfusion.lang.psi.LSFNonEmptyPropertyOptions;
5+
import com.lsfusion.lang.psi.*;
96
import com.lsfusion.lang.psi.stubs.ActionOrPropStubElement;
107
import org.jetbrains.annotations.Nullable;
118

@@ -15,6 +12,9 @@
1512

1613
public interface LSFActionOrGlobalPropDeclaration<This extends LSFActionOrGlobalPropDeclaration<This,Stub>, Stub extends ActionOrPropStubElement<Stub, This>> extends LSFFullNameDeclaration<This, Stub>, LSFInterfacePropStatement, LSFActionOrPropDeclaration {
1714

15+
@Nullable
16+
LSFNonEmptyActionOptions getNonEmptyActionOptions();
17+
1818
@Nullable
1919
LSFNonEmptyPropertyOptions getNonEmptyPropertyOptions();
2020

src/com/lsfusion/lang/psi/declarations/LSFGlobalPropDeclaration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ default String getTableNameNoCache() {
7373

7474
LSFNonEmptyPropertyOptions options = getNonEmptyPropertyOptions();
7575
if(options != null) {
76-
List<LSFTableUsage> tableUsages = options.getTableUsageList();
77-
if(!tableUsages.isEmpty()) {
78-
LSFTableDeclaration table = tableUsages.get(0).resolveDecl();
76+
List<LSFTableSetting> tableSettings = options.getTableSettingList();
77+
if(!tableSettings.isEmpty()) {
78+
LSFTableDeclaration table = tableSettings.get(0).getTableUsage().resolveDecl();
7979
if(table != null)
8080
return dbNamingPolicy.getTableName(table);
8181
}

0 commit comments

Comments
 (0)