1 | package com.framsticks.gui.table; |
---|
2 | |
---|
3 | import java.util.Collections; |
---|
4 | import java.util.HashMap; |
---|
5 | import java.util.Map; |
---|
6 | |
---|
7 | import com.framsticks.gui.PanelProvider; |
---|
8 | import com.framsticks.gui.TreePanel; |
---|
9 | import com.framsticks.params.annotations.AutoAppendAnnotation; |
---|
10 | import com.framsticks.params.annotations.FramsClassAnnotation; |
---|
11 | import com.framsticks.params.types.ListParam; |
---|
12 | |
---|
13 | @FramsClassAnnotation |
---|
14 | public class ListPanelProvider implements PanelProvider { |
---|
15 | |
---|
16 | protected final Map<String, ColumnsConfig> columnsConfigs = new HashMap<>(); |
---|
17 | /** |
---|
18 | * |
---|
19 | * That limit is honored only when no explicit ColumnsConfig object is found. |
---|
20 | */ |
---|
21 | protected Integer maximumColumnNumber = 5; |
---|
22 | |
---|
23 | @Override |
---|
24 | public TreePanel providePanel(TreePanel.Parameters parameters) { |
---|
25 | if (parameters.param instanceof ListParam) { |
---|
26 | return new ListPanel(parameters, this); |
---|
27 | } |
---|
28 | return null; |
---|
29 | } |
---|
30 | |
---|
31 | @AutoAppendAnnotation |
---|
32 | public void addColumnsConfig(ColumnsConfig config) { |
---|
33 | columnsConfigs.put(config.getClassName(), config); |
---|
34 | } |
---|
35 | |
---|
36 | /** |
---|
37 | * @return the columnsConfigs |
---|
38 | */ |
---|
39 | public Map<String, ColumnsConfig> getColumnsConfigs() { |
---|
40 | return Collections.unmodifiableMap(columnsConfigs); |
---|
41 | } |
---|
42 | |
---|
43 | /** |
---|
44 | * @return the maximumColumnNumber |
---|
45 | */ |
---|
46 | public Integer getMaximumColumnNumber() { |
---|
47 | return maximumColumnNumber; |
---|
48 | } |
---|
49 | |
---|
50 | /** |
---|
51 | * @param maximumColumnNumber the maximumColumnNumber to set |
---|
52 | */ |
---|
53 | public void setMaximumColumnNumber(Integer maximumColumnNumber) { |
---|
54 | this.maximumColumnNumber = maximumColumnNumber; |
---|
55 | } |
---|
56 | |
---|
57 | } |
---|