Browse Source

Pull request #4598: REPORT-51360 设计器消息提醒 & REPORT-53706 关闭按钮样式调整

Merge in DESIGN/design from ~LANLAN/design:feature/10.0 to feature/10.0

* commit '1af829055b777332899b50bb164f37a4972b81f9':
  fix
  修改延迟时间
  REPORT-51360 设计器消息提醒
  REPORT-53706 关闭按钮样式调整
feature/10.0
Lanlan 3 years ago
parent
commit
8bf55b1952
  1. 120
      designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java
  2. 69
      designer-base/src/main/java/com/fr/design/login/message/DesignerModuleClickType.java
  3. 31
      designer-base/src/main/java/com/fr/design/login/message/NotificationJumpType.java
  4. 11
      designer-base/src/main/resources/com/fr/design/login/guide.css
  5. 2
      designer-base/src/main/resources/com/fr/design/login/guide.js
  6. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_install_normal.png
  7. 44
      designer-base/src/main/resources/com/fr/design/login/login.css
  8. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

120
designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java

@ -0,0 +1,120 @@
package com.fr.design.login.message;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.NotificationDialog;
import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/11
*/
public class DesignerMessageHelper {
private static final long DELAY = 7L;
private static final String STATUS = "status";
private static final String DATA = "data";
private static final String SUCCESS = "success";
private static final String MESSAGE_ID = "messageId";
private static final String TITLE = "title";
private static final String BODY = "body";
private static final String JUMP_TYPE = "jumpType";
private static final String JUMP_TO = "jumpTo";
private static DesignerMessageHelper instance;
private DesignerMessageHelper() {
}
public static DesignerMessageHelper getInstance() {
if (instance == null) {
instance = new DesignerMessageHelper();
}
return instance;
}
public void prepareShowMessage() {
DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("DesignerMessageHelper"));
service.schedule(new Runnable() {
@Override
public void run() {
try {
pullLatestMessageAndShow();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}, DELAY, TimeUnit.MINUTES);
service.shutdown();
}
});
}
private void pullLatestMessageAndShow() throws Exception {
String url = CloudCenter.getInstance().acquireUrlByKind("designer.message.push", "https://market.fanruan.com/api/v1/message/designer");
Map<String, String> params = new HashMap<>();
params.put("designerId", DesignerEnvManager.getEnvManager().getUUID());
String result = HttpToolbox.post(url, params);
JSONObject response = JSONFactory.createJSON(JSON.OBJECT, result);
String status = response.optString(STATUS);
if (SUCCESS.equals(status)) {
JSONObject data = response.optJSONObject(DATA);
String messageId = data.optString(MESSAGE_ID);
String title = data.optString(TITLE);
String body = data.optString(BODY);
int jumpType = data.optInt(JUMP_TYPE);
String jumpTo = data.optString(JUMP_TO);
if (StringUtils.isNotEmpty(messageId) && StringUtils.isNotEmpty(title) && StringUtils.isNotEmpty(body) && jumpType > 0 && StringUtils.isNotEmpty(jumpTo)) {
NotificationJumpType notificationJumpType = NotificationJumpType.valueOf(jumpType);
if (notificationJumpType == NotificationJumpType.WEB_URL) {
NotificationDialog.Builder()
.owner(DesignerContext.getDesignerFrame())
.title(title)
.modal(true)
.messageType(NotificationDialog.NEW_MESSAGE)
.message(body)
.notificationDialogAction(new NotificationDialogAction() {
@Override
public void doClick() {
String ssoUrl = DesignerLoginUtils.generateDesignerSSOUrl(jumpTo);
BrowseUtils.browser(ssoUrl);
}
})
.build()
.setVisible(true);
} else if (notificationJumpType == NotificationJumpType.DESIGNER_MODULE) {
DesignerModuleClickType designerModuleClickType = DesignerModuleClickType.valueOf(jumpTo);
NotificationDialog.Builder()
.owner(DesignerContext.getDesignerFrame())
.title(title)
.modal(true)
.messageType(NotificationDialog.NEW_MESSAGE)
.message(body)
.notificationDialogAction(designerModuleClickType.getAction())
.build()
.setVisible(true);
}
}
}
}
}

69
designer-base/src/main/java/com/fr/design/login/message/DesignerModuleClickType.java

@ -0,0 +1,69 @@
package com.fr.design.login.message;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.upm.UpmFinder;
import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.stable.os.Arch;
import com.fr.stable.os.OperatingSystem;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/11
*/
public enum DesignerModuleClickType {
PLUGIN("PLUGIN", new NotificationDialogAction() {
@Override
public void doClick() {
try {
if (Arch.getArch() == Arch.ARM || OperatingSystem.isLinux() || SupportOSImpl.MACOS_WEB_PLUGIN_MANAGEMENT.support()) {
DesignUtils.visitEnvServerByParameters("#management/plugin", null, null);
return;
}
if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() || SupportOSImpl.MACOS_NEW_PLUGIN_MANAGEMENT.support()) {
UpmFinder.showUPMDialog();
} else {
WebViewDlgHelper.createPluginDialog();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}),
REUSE("REUSE", new NotificationDialogAction() {
@Override
public void doClick() {
try {
// TODO
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}),
UNKNOWN(StringUtils.EMPTY, new NotificationDialogAction() {
@Override
public void doClick() {
}
});
private String jumpTo;
private NotificationDialogAction action;
DesignerModuleClickType(String jumpTo, NotificationDialogAction action) {
this.jumpTo = jumpTo;
this.action = action;
}
public String getJumpTo() {
return jumpTo;
}
public NotificationDialogAction getAction() {
return action;
}
}

31
designer-base/src/main/java/com/fr/design/login/message/NotificationJumpType.java

@ -0,0 +1,31 @@
package com.fr.design.login.message;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/11
*/
public enum NotificationJumpType {
WEB_URL(1),
DESIGNER_MODULE(2),
UNKNOWN(-1);
private int jumpType;
NotificationJumpType(int jumpType) {
this.jumpType = jumpType;
}
public int getJumpType() {
return jumpType;
}
public static NotificationJumpType valueOf(int jumpType) {
for(NotificationJumpType value : NotificationJumpType.values()) {
if(value.getJumpType() == jumpType) {
return value;
}
}
return UNKNOWN;
}
}

11
designer-base/src/main/resources/com/fr/design/login/guide.css

@ -4,9 +4,14 @@
font-size: 14px;
}
.background-guide-close {
color: black !important;
font-weight: bold;
font-size: 16px;
background: url(./img/icon_install_normal.png) no-repeat center center;
background-size: cover;
width: 20px;
height: 20px;
cursor: pointer;
}
.background-guide-close:hover {
background-color: #E8E8E9;
}
.background-login-loading {
background: url(./img/login_loading.gif) no-repeat center center;

2
designer-base/src/main/resources/com/fr/design/login/guide.js

File diff suppressed because one or more lines are too long

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_install_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

44
designer-base/src/main/resources/com/fr/design/login/login.css

@ -4,9 +4,14 @@
font-size: 14px;
}
.background-guide-close {
color: black !important;
font-weight: bold;
font-size: 16px;
background: url(./img/icon_install_normal.png) no-repeat center center;
background-size: cover;
width: 20px;
height: 20px;
cursor: pointer;
}
.background-guide-close:hover {
background-color: #E8E8E9;
}
.background-login-loading {
background: url(./img/login_loading.gif) no-repeat center center;
@ -50,9 +55,14 @@
font-size: 14px;
}
.background-guide-close {
color: black !important;
font-weight: bold;
font-size: 16px;
background: url(./img/icon_install_normal.png) no-repeat center center;
background-size: cover;
width: 20px;
height: 20px;
cursor: pointer;
}
.background-guide-close:hover {
background-color: #E8E8E9;
}
.background-login-loading {
background: url(./img/login_loading.gif) no-repeat center center;
@ -136,9 +146,14 @@
font-size: 14px;
}
.background-guide-close {
color: black !important;
font-weight: bold;
font-size: 16px;
background: url(./img/icon_install_normal.png) no-repeat center center;
background-size: cover;
width: 20px;
height: 20px;
cursor: pointer;
}
.background-guide-close:hover {
background-color: #E8E8E9;
}
.background-login-loading {
background: url(./img/login_loading.gif) no-repeat center center;
@ -186,9 +201,14 @@
font-size: 14px;
}
.background-guide-close {
color: black !important;
font-weight: bold;
font-size: 16px;
background: url(./img/icon_install_normal.png) no-repeat center center;
background-size: cover;
width: 20px;
height: 20px;
cursor: pointer;
}
.background-guide-close:hover {
background-color: #E8E8E9;
}
.background-login-loading {
background: url(./img/login_loading.gif) no-repeat center center;

2
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -41,6 +41,7 @@ import com.fr.design.javascript.ParameterJavaScriptPane;
import com.fr.design.javascript.ProcessTransitionAdapter;
import com.fr.design.login.DesignerLoginType;
import com.fr.design.login.guide.DesignerGuideHelper;
import com.fr.design.login.message.DesignerMessageHelper;
import com.fr.design.login.socketio.LoginAuthServer;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.FormHierarchyTreePane;
@ -141,6 +142,7 @@ public class DesignerActivator extends Activator implements Prepare {
public void run() {
DesignerPushUpdateManager.getInstance().preparePushUpdate();
DesignerGuideHelper.prepareShowGuideDialog();
DesignerMessageHelper.getInstance().prepareShowMessage();
}
});

Loading…
Cancel
Save