Skip to content

Commit f8550df

Browse files
committed
Formatting improvements
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
1 parent 03ba87a commit f8550df

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Image:
5858
Video:
5959
'Video' (('item=' item=ItemRef) | ('label=' label=(ID | STRING)) |
6060
('icon=' icon=Icon) | ('icon=' IconRules=IconRuleList) | ('staticIcon=' staticIcon=Icon) |
61-
('url=' url=STRING) & ('encoding=' encoding=STRING) |
61+
('url=' url=STRING) | ('encoding=' encoding=STRING) |
6262
('labelcolor=' labelColor=ColorArrayList) |
6363
('valuecolor=' valueColor=ColorArrayList) |
6464
('iconcolor=' iconColor=ColorArrayList) |
@@ -169,8 +169,8 @@ Buttongrid:
169169
Button:
170170
'Button' (('item=' item=ItemRef) | ('label=' label=(ID | STRING)) |
171171
('icon=' icon=Icon) | ('icon=' IconRules=IconRuleList) | ('staticIcon=' staticIcon=Icon) |
172-
('row=' row=INT) & ('column=' column=INT) & (stateless?='stateless') |
173-
('click=' cmd=Command) & ('release=' releaseCmd=Command) |
172+
('row=' row=INT) | ('column=' column=INT) | (stateless?='stateless') |
173+
('click=' cmd=Command) | ('release=' releaseCmd=Command) |
174174
('labelcolor=' labelColor=ColorArrayList) |
175175
('valuecolor=' valueColor=ColorArrayList) |
176176
('iconcolor=' iconColor=ColorArrayList) |

bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/SitemapRuntimeModule.xtend

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import com.google.inject.Binder
2323
import com.google.inject.name.Names
2424
import org.openhab.core.model.sitemap.formatting.SitemapFormatter
2525
import org.eclipse.xtext.formatting.IFormatter
26+
import org.openhab.core.model.sitemap.formatting.SitemapIndentationInformation
27+
import org.eclipse.xtext.formatting.IIndentationInformation
2628

2729
/**
2830
* Use this class to register components to be used at runtime / without the Equinox extension registry.
@@ -36,6 +38,11 @@ class SitemapRuntimeModule extends org.openhab.core.model.sitemap.AbstractSitema
3638
return SitemapFormatter
3739
}
3840

41+
override void configure(Binder binder) {
42+
super.configure(binder)
43+
binder.bind(IIndentationInformation).to(SitemapIndentationInformation)
44+
}
45+
3946
override void configureUseIndexFragmentsForLazyLinking(Binder binder) {
4047
binder.bind(Boolean.TYPE).annotatedWith(Names.named(LazyURIEncoder.USE_INDEXED_FRAGMENTS_BINDING)).toInstance(
4148
Boolean.FALSE)

bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/formatting/SitemapFormatter.xtend

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class SitemapFormatter extends AbstractDeclarativeFormatter {
2828
@Inject extension SitemapGrammarAccess
2929

3030
override protected void configureFormatting(FormattingConfig c) {
31-
c.wrappedLineIndentation = 1
32-
c.autoLinewrap = 120
33-
31+
c.wrappedLineIndentation = 4
32+
c.autoLinewrap = 200
33+
3434
c.setLinewrap(1, 1, 2).before(widgetRule)
3535

3636
c.setIndentationIncrement.after("{")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.openhab.core.model.sitemap.formatting;
2+
3+
import org.eclipse.xtext.formatting.IIndentationInformation;
4+
5+
public class SitemapIndentationInformation implements IIndentationInformation {
6+
@Override
7+
public String getIndentString() {
8+
return " "; // 2 spaces
9+
}
10+
}

0 commit comments

Comments
 (0)