11package com .logicaldoc .gui .frontend .client .impex .converters ;
22
3+ import java .util .List ;
4+
35import com .logicaldoc .gui .common .client .Session ;
46import com .logicaldoc .gui .common .client .data .FormatConvertersDS ;
57import com .logicaldoc .gui .common .client .i18n .I18N ;
8+ import com .logicaldoc .gui .common .client .util .AwesomeFactory ;
69import com .logicaldoc .gui .common .client .util .ItemFactory ;
7- import com .logicaldoc .gui .frontend .client .settings .comparators .ComparatorAssociationsDialog ;
810import com .logicaldoc .gui .frontend .client .settings .comparators .ComparatorsPanel ;
9- import com .smartgwt .client .data .AdvancedCriteria ;
1011import com .smartgwt .client .data .DataSource ;
11- import com .smartgwt .client .data .Record ;
12- import com .smartgwt .client .types .OperatorId ;
1312import com .smartgwt .client .widgets .form .fields .SelectItem ;
1413import com .smartgwt .client .widgets .grid .ListGridField ;
1514import com .smartgwt .client .widgets .grid .ListGridRecord ;
16- import com .smartgwt .client .widgets .toolbar .ToolStrip ;
1715import com .smartgwt .client .widgets .toolbar .ToolStripButton ;
1816
1917/**
2422 */
2523public class FormatConvertersPanel extends ComparatorsPanel {
2624
27- private static final String EENABLED = "eenabled" ;
28-
2925 public FormatConvertersPanel () {
3026 super ("formatconverters" );
31- gridAttributeName = "converter" ;
32- listGridAttributeLabel = I18N .message (gridAttributeName );
33- settingsPrefix = gridAttributeName + "." ;
27+ recordAttributeForName = "converter" ;
28+ listGridAttributeLabel = I18N .message (recordAttributeForName );
29+ settingsPrefix = recordAttributeForName + "." ;
3430 settingsGridTitle = I18N .message ("converters" );
3531 }
3632
3733 @ Override
38- protected ToolStrip prepareToolStrip () {
39- ToolStrip toolStrip = super .prepareToolStrip ();
34+ protected List < ToolStripButton > prepareConfigButtons () {
35+ List < ToolStripButton > buttons = super .prepareConfigButtons ();
4036
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 ());
4639
47- toolStrip .addSeparator ();
48- toolStrip .addButton (aliases );
49- toolStrip .addFill ();
50-
51- return toolStrip ;
40+ buttons .add (configButton );
41+ return buttons ;
5242 }
5343
5444 @ Override
5545 protected void prepareAssociationsGrid () {
5646 buildAssociationsGrid ();
5747
5848 ListGridField in = new ListGridField ("in" , I18N .message ("in" ), 60 );
59- ListGridField converter = new ListGridField (gridAttributeName , listGridAttributeLabel );
49+ ListGridField converter = new ListGridField (recordAttributeForName , listGridAttributeLabel );
6050 converter .setWidth ("*" );
6151 converter .setCanEdit (!Session .get ().isDemo ());
6252 converter .setCellFormatter ((value , rec , rowNum , colNum ) -> {
6353 String label = getConverterShortName (value != null ? value .toString () : null );
64- if (Boolean .FALSE .equals (rec .getAttributeAsBoolean (EENABLED )))
54+ if (Boolean .FALSE .equals (rec .getAttributeAsBoolean (ENABLED )))
6555 label = "<span style='color:red;'>" + label + "</span>" ;
6656
6757 return label ;
@@ -74,7 +64,7 @@ protected void prepareAssociationsGrid() {
7464 associationsGrid .setEditorCustomizer (context -> {
7565 ListGridField field = context .getEditField ();
7666
77- if (field .getName ().equals (gridAttributeName )) {
67+ if (field .getName ().equals (recordAttributeForName )) {
7868 final ListGridRecord selectedRecord = associationsGrid .getSelectedRecord ();
7969 final SelectItem editorItem = ItemFactory .newFormatConverterSelector (
8070 selectedRecord .getAttributeAsString ("in" ), selectedRecord .getAttributeAsString ("out" ));
@@ -83,19 +73,6 @@ protected void prepareAssociationsGrid() {
8373 } else
8474 return context .getDefaultProperties ();
8575 });
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 );
9976 }
10077
10178 @ Override
0 commit comments