1
1
package com .logicaldoc .gui .frontend .client .impex .converters ;
2
2
3
+ import java .util .List ;
4
+
3
5
import com .logicaldoc .gui .common .client .Session ;
4
6
import com .logicaldoc .gui .common .client .data .FormatConvertersDS ;
5
7
import com .logicaldoc .gui .common .client .i18n .I18N ;
8
+ import com .logicaldoc .gui .common .client .util .AwesomeFactory ;
6
9
import com .logicaldoc .gui .common .client .util .ItemFactory ;
7
- import com .logicaldoc .gui .frontend .client .settings .comparators .ComparatorAssociationsDialog ;
8
10
import com .logicaldoc .gui .frontend .client .settings .comparators .ComparatorsPanel ;
9
- import com .smartgwt .client .data .AdvancedCriteria ;
10
11
import com .smartgwt .client .data .DataSource ;
11
- import com .smartgwt .client .data .Record ;
12
- import com .smartgwt .client .types .OperatorId ;
13
12
import com .smartgwt .client .widgets .form .fields .SelectItem ;
14
13
import com .smartgwt .client .widgets .grid .ListGridField ;
15
14
import com .smartgwt .client .widgets .grid .ListGridRecord ;
16
- import com .smartgwt .client .widgets .toolbar .ToolStrip ;
17
15
import com .smartgwt .client .widgets .toolbar .ToolStripButton ;
18
16
19
17
/**
24
22
*/
25
23
public class FormatConvertersPanel extends ComparatorsPanel {
26
24
27
- private static final String EENABLED = "eenabled" ;
28
-
29
25
public FormatConvertersPanel () {
30
26
super ("formatconverters" );
31
- gridAttributeName = "converter" ;
32
- listGridAttributeLabel = I18N .message (gridAttributeName );
33
- settingsPrefix = gridAttributeName + "." ;
27
+ recordAttributeForName = "converter" ;
28
+ listGridAttributeLabel = I18N .message (recordAttributeForName );
29
+ settingsPrefix = recordAttributeForName + "." ;
34
30
settingsGridTitle = I18N .message ("converters" );
35
31
}
36
32
37
33
@ Override
38
- protected ToolStrip prepareToolStrip () {
39
- ToolStrip toolStrip = super .prepareToolStrip ();
34
+ protected List < ToolStripButton > prepareConfigButtons () {
35
+ List < ToolStripButton > buttons = super .prepareConfigButtons ();
40
36
41
- ToolStripButton aliases = new ToolStripButton ();
42
- aliases .setTitle (I18N .message ("extensionaliases" ));
43
- aliases .setDisabled (Session .get ().isDemo ());
44
- aliases .addClickHandler (event -> new ExtensionAliasesDialog ().show ());
45
- aliases .setDisabled (Session .get ().isDemo ());
37
+ ToolStripButton configButton = AwesomeFactory .newToolStripButton ("gears" , "associations" );
38
+ configButton .addClickHandler (click -> new ExtensionAliasesDialog ().show ());
46
39
47
- toolStrip .addSeparator ();
48
- toolStrip .addButton (aliases );
49
- toolStrip .addFill ();
50
-
51
- return toolStrip ;
40
+ buttons .add (configButton );
41
+ return buttons ;
52
42
}
53
43
54
44
@ Override
55
45
protected void prepareAssociationsGrid () {
56
46
buildAssociationsGrid ();
57
47
58
48
ListGridField in = new ListGridField ("in" , I18N .message ("in" ), 60 );
59
- ListGridField converter = new ListGridField (gridAttributeName , listGridAttributeLabel );
49
+ ListGridField converter = new ListGridField (recordAttributeForName , listGridAttributeLabel );
60
50
converter .setWidth ("*" );
61
51
converter .setCanEdit (!Session .get ().isDemo ());
62
52
converter .setCellFormatter ((value , rec , rowNum , colNum ) -> {
63
53
String label = getConverterShortName (value != null ? value .toString () : null );
64
- if (Boolean .FALSE .equals (rec .getAttributeAsBoolean (EENABLED )))
54
+ if (Boolean .FALSE .equals (rec .getAttributeAsBoolean (ENABLED )))
65
55
label = "<span style='color:red;'>" + label + "</span>" ;
66
56
67
57
return label ;
@@ -74,7 +64,7 @@ protected void prepareAssociationsGrid() {
74
64
associationsGrid .setEditorCustomizer (context -> {
75
65
ListGridField field = context .getEditField ();
76
66
77
- if (field .getName ().equals (gridAttributeName )) {
67
+ if (field .getName ().equals (recordAttributeForName )) {
78
68
final ListGridRecord selectedRecord = associationsGrid .getSelectedRecord ();
79
69
final SelectItem editorItem = ItemFactory .newFormatConverterSelector (
80
70
selectedRecord .getAttributeAsString ("in" ), selectedRecord .getAttributeAsString ("out" ));
@@ -83,19 +73,6 @@ protected void prepareAssociationsGrid() {
83
73
} else
84
74
return context .getDefaultProperties ();
85
75
});
86
-
87
- associationsGrid .addEditCompleteHandler (event -> {
88
- Record converterRecord = settingsGrid .find (new AdvancedCriteria ("id" , OperatorId .EQUALS ,
89
- associationsGrid .getSelectedRecord ().getAttributeAsString (gridAttributeName )));
90
- if (converterRecord != null )
91
- associationsGrid .getSelectedRecord ().setAttribute (EENABLED ,
92
- Boolean .TRUE .equals (converterRecord .getAttributeAsBoolean (EENABLED )));
93
- });
94
- }
95
-
96
- @ Override
97
- protected ComparatorAssociationsDialog getAssociationsDialog () {
98
- return new ConverterAssociationsDialog (associationsGrid );
99
76
}
100
77
101
78
@ Override
0 commit comments