1+ package com .logicaldoc .gui .frontend .client .impex .folders ;
2+
3+ import java .util .ArrayList ;
4+ import java .util .Arrays ;
5+ import java .util .List ;
6+
7+ import com .logicaldoc .gui .common .client .DefaultAsyncCallback ;
8+ import com .logicaldoc .gui .common .client .Session ;
9+ import com .logicaldoc .gui .common .client .beans .GUIParameter ;
10+ import com .logicaldoc .gui .common .client .i18n .I18N ;
11+ import com .logicaldoc .gui .common .client .util .ItemFactory ;
12+ import com .logicaldoc .gui .common .client .util .Util ;
13+ import com .logicaldoc .gui .frontend .client .services .SettingService ;
14+ import com .smartgwt .client .types .HeaderControls ;
15+ import com .smartgwt .client .types .TitleOrientation ;
16+ import com .smartgwt .client .widgets .Window ;
17+ import com .smartgwt .client .widgets .form .DynamicForm ;
18+ import com .smartgwt .client .widgets .form .fields .ButtonItem ;
19+ import com .smartgwt .client .widgets .form .fields .SpinnerItem ;
20+
21+ /**
22+ * This popup window is used to input data and obtain a prediction from the AI
23+ * model.
24+ *
25+ * @author Marco Meschieri - LogicalDOC
26+ * @since 9.2
27+ */
28+ public class ImportFolderSettings extends Window {
29+
30+ private static final String THREADS_SETTING = "threadpool.ImportFolderCrawler.max" ;
31+
32+ private DynamicForm form = new DynamicForm ();
33+
34+ public ImportFolderSettings () {
35+ setHeaderControls (HeaderControls .HEADER_LABEL , HeaderControls .CLOSE_BUTTON );
36+
37+ setTitle (I18N .message ("settings" ));
38+ setAutoSize (true );
39+ setCanDragResize (true );
40+ setIsModal (true );
41+ setShowModalMask (true );
42+ centerInPage ();
43+
44+ SettingService .Instance .get ().loadSettingsByNames (Arrays .asList (new String [] { THREADS_SETTING }),
45+ new DefaultAsyncCallback <>() {
46+
47+ @ Override
48+ public void onSuccess (List <GUIParameter > params ) {
49+ init (params );
50+ }
51+ });
52+ }
53+
54+ private void init (List <GUIParameter > params ) {
55+ ButtonItem save = new ButtonItem ();
56+ save .setTitle (I18N .message ("save" ));
57+ save .setAutoFit (true );
58+ save .setStartRow (true );
59+ save .addClickHandler (event -> onSave ());
60+
61+ SpinnerItem threads = ItemFactory .newSpinnerItem ("threads" ,
62+ Integer .parseInt (Util .getValue (THREADS_SETTING , params )));
63+ threads .setRequired (true );
64+ threads .setMin (1 );
65+ threads .setStep (1 );
66+ threads .setVisible (Session .get ().isDefaultTenant ());
67+
68+ form .setNumCols (1 );
69+ form .setTitleOrientation (TitleOrientation .TOP );
70+ form .setFields (threads , save );
71+
72+ addItem (form );
73+ }
74+
75+ private void onSave () {
76+ if (!form .validate ())
77+ return ;
78+
79+ List <GUIParameter > params = new ArrayList <>();
80+ params .add (new GUIParameter (THREADS_SETTING , form .getValueAsString ("threads" )));
81+ SettingService .Instance .get ().saveSettings (params , new DefaultAsyncCallback <>());
82+
83+ destroy ();
84+ }
85+
86+ @ Override
87+ public boolean equals (Object other ) {
88+ return super .equals (other );
89+ }
90+
91+ @ Override
92+ public int hashCode () {
93+ return super .hashCode ();
94+ }
95+ }
0 commit comments