Skip to content

Commit 1c55570

Browse files
committed
new GWT 2.12.2 and SmartGWT 14.1p
1 parent 2c913a8 commit 1c55570

File tree

18 files changed

+188
-33
lines changed

18 files changed

+188
-33
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/RunLevel.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.slf4j.Logger;
1111
import org.slf4j.LoggerFactory;
1212

13+
import com.logicaldoc.core.exception.AspectDisabledException;
1314
import com.logicaldoc.util.Context;
1415
import com.logicaldoc.util.config.ContextProperties;
1516
import com.logicaldoc.util.plugin.PluginRegistry;
@@ -61,6 +62,12 @@ public boolean aspectEnabled(String aspect) {
6162
return config != null && config.getBoolean(getAspectProperty(aspect), false);
6263
}
6364

65+
public void checkAspect(String aspect) throws AspectDisabledException {
66+
if(!aspectEnabled(aspect))
67+
throw new AspectDisabledException(aspect);
68+
}
69+
70+
6471
public void setAspect(String aspect, boolean enabled) {
6572
ContextProperties config = getConfig();
6673
if (config != null)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.logicaldoc.core.exception;
2+
3+
/**
4+
* Raised when an aspect is disabled
5+
*
6+
* @author Marco Meschieri - LogicalDOC
7+
* @since 9.2
8+
*/
9+
public class AspectDisabledException extends FeatureDisabledException {
10+
11+
private static final long serialVersionUID = 1L;
12+
13+
public AspectDisabledException(String aspectId) {
14+
super(aspectId, "Aspect ", "aspect.");
15+
}
16+
17+
public AspectDisabledException(String aspectId, Throwable cause) {
18+
super(aspectId, "Aspect ", "aspect.", cause);
19+
}
20+
}

logicaldoc-core/src/main/java/com/logicaldoc/core/exception/FeatureDisabledException.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ public class FeatureDisabledException extends Exception {
1212

1313
private static final long serialVersionUID = 1L;
1414

15-
public FeatureDisabledException(int featureId) {
16-
super("Feature " + I18N.message("feature.Feature_" + featureId));
15+
protected FeatureDisabledException(String featureId, String messagePrefix, String featureKeyPrefix,
16+
Throwable cause) {
17+
super(messagePrefix + I18N.message(featureKeyPrefix + featureId), cause);
1718
}
1819

19-
public FeatureDisabledException(int featureId, Throwable cause) {
20-
super("Feature " + I18N.message("feature.Feature_" + featureId), cause);
20+
protected FeatureDisabledException(String featureId, String messagePrefix, String featureKeyPrefix) {
21+
super(messagePrefix + I18N.message(featureKeyPrefix + featureId));
22+
}
23+
24+
public FeatureDisabledException(String featureId) {
25+
this(featureId, "Feature ", "feature.Feature_");
26+
}
27+
28+
public FeatureDisabledException(String featureId, Throwable cause) {
29+
this(featureId, "Feature ", "feature.Feature_", cause);
2130
}
2231
}

logicaldoc-core/src/main/java/com/logicaldoc/core/security/authentication/InvalidSessionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class InvalidSessionException extends AuthenticationException {
1313
private final String sid;
1414

1515
public InvalidSessionException() {
16-
sid = null;
16+
sid = "";
1717
}
1818

1919
public InvalidSessionException(String sid) {

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/Feature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public class Feature {
225225

226226
public static final int ONLYOFFICE = 107;
227227

228-
public static final int BOT = 108;
228+
public static final int ROBOT = 108;
229229

230230
private static Set<String> features = new HashSet<>();
231231

logicaldoc-gui/src/main/java/com/logicaldoc/gui/common/client/Menu.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ public class Menu {
223223

224224
public static final long AI_MODELS = 3001;
225225

226-
public static final long ROBOTS = 3010;
226+
public static final long ADMIN_ROBOTS = 3010;
227+
228+
public static final long ROBOTS = 3020;
227229

228230
private static Set<Long> menus = new HashSet<>();
229231

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/AIMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void addModelsButton() {
3333
addMember(models);
3434
}
3535

36-
if (Menu.enabled(Menu.ROBOTS)) {
36+
if (Menu.enabled(Menu.ADMIN_ROBOTS)) {
3737
Button robots = new Button(I18N.message("robots"));
3838
robots.setWidth100();
3939
robots.setHeight(25);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.logicaldoc.gui.frontend.client.ai.robot;
2+
3+
import com.logicaldoc.gui.common.client.i18n.I18N;
4+
import com.smartgwt.client.widgets.form.fields.SelectItem;
5+
import com.smartgwt.client.widgets.grid.ListGridRecord;
6+
7+
/**
8+
* This widget allows for the selection of a robot
9+
*
10+
* @author Marco Meschieri - LogicalDOC
11+
* @since 9.2
12+
*/
13+
public class RobotSelector extends SelectItem {
14+
15+
private static final String LABEL = "label";
16+
17+
public RobotSelector() {
18+
setName("robot");
19+
setTitle(I18N.message("robot"));
20+
setWrapTitle(false);
21+
22+
RobotListGridField label = new RobotListGridField(LABEL);
23+
24+
setValueField("id");
25+
setDisplayField(LABEL);
26+
setSortField(LABEL);
27+
setPickListWidth(150);
28+
setPickListFields(label);
29+
30+
setOptionDataSource(new RobotsDS());
31+
setHintStyle("hint");
32+
}
33+
34+
public GUIRobot getRobot() {
35+
GUIRobot robot = null;
36+
ListGridRecord selection = getSelectedRecord();
37+
if (selection != null) {
38+
robot = new GUIRobot();
39+
robot.setId(selection.getAttributeAsLong("id"));
40+
robot.setName(selection.getAttributeAsString("name"));
41+
robot.setLabel(selection.getAttributeAsString(LABEL));
42+
robot.setAvatar(selection.getAttributeAsString("avatar"));
43+
}
44+
return robot;
45+
}
46+
}

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/robot/RobotThread.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.logicaldoc.gui.common.client.util.AwesomeFactory;
99
import com.logicaldoc.gui.common.client.util.ItemFactory;
1010
import com.logicaldoc.gui.common.client.util.WindowUtils;
11-
import com.logicaldoc.gui.frontend.client.chatgpt.ThreadWindow;
11+
import com.logicaldoc.gui.frontend.client.chatgpt.ChatGPTThread;
1212
import com.logicaldoc.gui.frontend.client.menu.MainMenu;
1313
import com.smartgwt.client.types.Alignment;
1414
import com.smartgwt.client.types.HeaderControls;
@@ -158,7 +158,7 @@ public void run() {
158158
}
159159

160160
private String robotName() {
161-
if (robot.getLabel() == null || robot.getLabel().isBlank())
161+
if (robot.getLabel() == null || robot.getLabel().trim().isEmpty())
162162
return robot.getName();
163163
else
164164
return robot.getLabel();
@@ -179,7 +179,7 @@ public void onSuccess(String answer) {
179179

180180
@Override
181181
public boolean equals(Object obj) {
182-
if (obj instanceof ThreadWindow)
182+
if (obj instanceof ChatGPTThread)
183183
return super.equals(obj);
184184
else
185185
return false;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.logicaldoc.gui.frontend.client.ai.robot;
2+
3+
import com.logicaldoc.gui.common.client.DefaultAsyncCallback;
4+
import com.logicaldoc.gui.common.client.util.AwesomeFactory;
5+
import com.logicaldoc.gui.common.client.util.ItemFactory;
6+
import com.logicaldoc.gui.frontend.client.menu.MenuTray;
7+
import com.smartgwt.client.types.Alignment;
8+
import com.smartgwt.client.widgets.form.fields.FormItemIcon;
9+
import com.smartgwt.client.widgets.form.fields.TextItem;
10+
11+
/**
12+
* A tray to interact with the Robots
13+
*
14+
* @author Marco Meschieri - LogicalDOC
15+
* @since 9.2
16+
*/
17+
public class RobotTray extends MenuTray {
18+
19+
public RobotTray() {
20+
TextItem question = ItemFactory.newTextItem("question", "");
21+
question.setShowTitle(false);
22+
question.setWidth(200);
23+
question.addKeyPressHandler(event -> {
24+
if (event.getKeyName() != null && "enter".equalsIgnoreCase(event.getKeyName()))
25+
onAsk(question.getValueAsString());
26+
});
27+
28+
FormItemIcon ask = new FormItemIcon();
29+
ask.setInline(true);
30+
ask.setInlineIconAlign(Alignment.RIGHT);
31+
ask.setText(AwesomeFactory.getIconHtml("paper-plane"));
32+
question.setIcons(ask);
33+
ask.addFormItemClickHandler(click -> onAsk(question.getValueAsString()));
34+
35+
RobotSelector robot = new RobotSelector();
36+
robot.setDefaultToFirstOption(true);
37+
robot.setWidth(100);
38+
39+
setNumCols(3);
40+
41+
setItems(robot, question);
42+
}
43+
44+
private void onAsk(String question) {
45+
if (validate()) {
46+
RobotService.Instance.get().get(Long.parseLong(getValueAsString("robot")), new DefaultAsyncCallback<>() {
47+
48+
@Override
49+
public void onSuccess(GUIRobot rbt) {
50+
RobotThread.get(rbt).open(getValueAsString("question"));
51+
}
52+
});
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)