forked from fanruan/design
alex.sung
6 years ago
326 changed files with 12538 additions and 3109 deletions
@ -0,0 +1,41 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.design.utils.BrowseUtils; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.KeyStroke; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
public class FacebookFansAction extends UpAction { |
||||
|
||||
public FacebookFansAction() { |
||||
this.setMenuKeySet(FACEBOOKFANS); |
||||
this.setName(getMenuKeySet().getMenuName()); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/facebook.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent arg0) { |
||||
BrowseUtils.browser(CloudCenter.getInstance().acquireUrlByKind("facebook.fans.tw")); |
||||
} |
||||
|
||||
public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 'F'; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_FaceBook_Fans"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.fr.design.actions.help; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import com.fr.web.struct.AssembleComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.impl.FineUI; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-03-08 |
||||
*/ |
||||
public class FineUIAction extends UpdateAction { |
||||
|
||||
public FineUIAction() { |
||||
setName("FineUI"); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(final ActionEvent e) { |
||||
ModernUIPane<?> pane = new ModernUIPane.Builder<>() |
||||
// .prepare(new ScriptContextAdapter() {
|
||||
// @Override
|
||||
// public void onScriptContextCreated(ScriptContextEvent event) {
|
||||
// JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool");
|
||||
// pool.asObject().setProperty("i18n", new I18n());
|
||||
// }
|
||||
// })
|
||||
.withComponent(new AssembleComponent() { |
||||
|
||||
@Override |
||||
public ScriptPath script(RequestClient req) { |
||||
return ScriptPath.build("/com/fr/design/ui/help/demo.js"); |
||||
} |
||||
|
||||
@Override |
||||
public Atom[] refer() { |
||||
return new Atom[] {FineUI.KEY}; |
||||
} |
||||
}) |
||||
.build(); |
||||
BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
|
||||
} |
||||
}); |
||||
dialog.setVisible(true); |
||||
|
||||
} |
||||
|
||||
public static class I18n { |
||||
|
||||
public String i18nText(String key) { |
||||
return InterProviderFactory.getProvider().getLocText(key); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.design.bridge.exec; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-18 |
||||
* 用于标记一个方法是用于和JS做桥接的,避免被误删除 |
||||
*/ |
||||
@Target(ElementType.METHOD) |
||||
@Retention(RetentionPolicy.SOURCE) |
||||
public @interface JSBridge { |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.design.bridge.exec; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/5/27. |
||||
*/ |
||||
public class JSCallback { |
||||
|
||||
private JSExecutor executeScript; |
||||
|
||||
public JSCallback(JSExecutor jsExecutor) { |
||||
this.executeScript = jsExecutor; |
||||
} |
||||
|
||||
public void execute(String newValue) { |
||||
executeScript.executor(newValue); |
||||
} |
||||
} |
||||
|
@ -1,4 +1,4 @@
|
||||
package com.fr.design.extra.exe.callback; |
||||
package com.fr.design.bridge.exec; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/6/21. |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.constants; |
||||
|
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Null; |
||||
|
||||
/** |
||||
* 设计器启动事件类型 |
||||
* |
||||
* @author vito |
||||
* @date 2019-06-18 |
||||
*/ |
||||
public enum DesignerLaunchStatus implements Event<Null> { |
||||
/** |
||||
* 初始化环境完成 |
||||
*/ |
||||
WORKSPACE_INIT_COMPLETE, |
||||
|
||||
/** |
||||
* 设计器模块启动完成 |
||||
*/ |
||||
DESIGNER_INIT_COMPLETE, |
||||
|
||||
/** |
||||
* 启动完成 |
||||
*/ |
||||
OPEN_LAST_FILE_COMPLETE; |
||||
|
||||
private static DesignerLaunchStatus status; |
||||
|
||||
public static DesignerLaunchStatus getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public static void setStatus(DesignerLaunchStatus state) { |
||||
status = state; |
||||
EventDispatcher.asyncFire(DesignerLaunchStatus.getStatus()); |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.dcm; |
||||
|
||||
import com.fr.web.struct.AssembleComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
import com.fr.web.struct.impl.FineUI; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-05-16 |
||||
*/ |
||||
public class UniversalDatabaseComponent extends AssembleComponent { |
||||
|
||||
public static final UniversalDatabaseComponent KEY = new UniversalDatabaseComponent(); |
||||
|
||||
private UniversalDatabaseComponent() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public ScriptPath script(RequestClient req) { |
||||
return ScriptPath.build("/com/fr/design/dcm/index.js"); |
||||
} |
||||
|
||||
@Override |
||||
public StylePath style(RequestClient req) { |
||||
return StylePath.build("/com/fr/design/dcm/style.css"); |
||||
} |
||||
|
||||
@Override |
||||
public Atom[] refer() { |
||||
return new Atom[]{ |
||||
FineUI.KEY |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.dcm; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-05-16 |
||||
*/ |
||||
public class UniversalDatabaseDialog extends UIDialog { |
||||
|
||||
public UniversalDatabaseDialog(Frame frame, BasicPane pane) { |
||||
super(frame); |
||||
setUndecorated(true); |
||||
JPanel panel = (JPanel) getContentPane(); |
||||
panel.setLayout(new BorderLayout()); |
||||
add(pane, BorderLayout.CENTER); |
||||
setSize(new Dimension(1000, 600)); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.dcm; |
||||
|
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-05-16 |
||||
*/ |
||||
public class UniversalDatabaseOpener { |
||||
|
||||
private static UIDialog dialog = null; |
||||
|
||||
public static UIDialog getDialog() { |
||||
return dialog; |
||||
} |
||||
|
||||
public static void showUniverseDatabaseDialog() { |
||||
UniversalDatabasePane upmPane = new UniversalDatabasePane(); |
||||
if (dialog == null) { |
||||
dialog = new UniversalDatabaseDialog(DesignerContext.getDesignerFrame(), upmPane); |
||||
} |
||||
dialog.setVisible(true); |
||||
} |
||||
|
||||
public static void closeWindow() { |
||||
if (dialog != null) { |
||||
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); |
||||
dialog.setVisible(false); |
||||
dialog = null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.dcm; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.teamdev.jxbrowser.chromium.JSValue; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-05-16 |
||||
*/ |
||||
public class UniversalDatabasePane extends BasicPane { |
||||
|
||||
private ModernUIPane<Object> modernUIPane; |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Database"; |
||||
} |
||||
|
||||
public UniversalDatabasePane() { |
||||
setLayout(new BorderLayout()); |
||||
modernUIPane = new ModernUIPane.Builder<>() |
||||
.withComponent(UniversalDatabaseComponent.KEY) |
||||
.prepare(new ScriptContextAdapter() { |
||||
@Override |
||||
public void onScriptContextCreated(ScriptContextEvent event) { |
||||
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); |
||||
window.asObject().setProperty("DcmHelper", UniversalDcmBridge.getBridge(event.getBrowser())); |
||||
} |
||||
}) |
||||
.build(); |
||||
add(modernUIPane, BorderLayout.CENTER); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.design.dcm; |
||||
|
||||
import com.fr.decision.webservice.bean.BaseBean; |
||||
import com.fr.design.bridge.exec.JSBridge; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.JSObject; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-05-17 |
||||
* 桥接Java和JavaScript的类 |
||||
*/ |
||||
public class UniversalDcmBridge { |
||||
|
||||
public static UniversalDcmBridge getBridge(Browser browser) { |
||||
return new UniversalDcmBridge(browser); |
||||
} |
||||
|
||||
private JSObject window; |
||||
|
||||
private UniversalDcmBridge(Browser browser) { |
||||
this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); |
||||
} |
||||
|
||||
/** |
||||
* 获取所有的数据连接 |
||||
* @return 数据连接集合 |
||||
*/ |
||||
@JSBridge |
||||
public BaseBean getConnections() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.bridge.exec.JSExecutor; |
||||
import com.fr.design.bridge.exec.JSUtils; |
||||
import javafx.application.Platform; |
||||
import javafx.scene.web.WebEngine; |
||||
import netscape.javascript.JSObject; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-18 |
||||
*/ |
||||
public class PluginJavaFxExecutor implements JSExecutor { |
||||
|
||||
public static PluginJavaFxExecutor create(WebEngine webEngine, JSObject callback) { |
||||
return new PluginJavaFxExecutor(webEngine, callback); |
||||
} |
||||
|
||||
private WebEngine webEngine; |
||||
private JSObject callback; |
||||
|
||||
private PluginJavaFxExecutor(WebEngine webEngine, JSObject callback) { |
||||
this.webEngine = webEngine; |
||||
this.callback = callback; |
||||
} |
||||
|
||||
@Override |
||||
public void executor(final String newValue) { |
||||
Platform.runLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
String fun = "(" + callback + ")(\"" + JSUtils.trimText(newValue) + "\")"; |
||||
try { |
||||
webEngine.executeScript(fun); |
||||
} catch (Exception e) { |
||||
webEngine.executeScript("alert(\"" + e.getMessage() + "\")"); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.menu.MenuDef; |
||||
import com.fr.start.SplashStrategy; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 设计器Oem接口 |
||||
*/ |
||||
public interface OemProcessor { |
||||
public static final String MARK_STRING = "OemProcessor"; |
||||
|
||||
/** |
||||
* 启动动画,如果不替换则返回null |
||||
* |
||||
* @return |
||||
*/ |
||||
SplashStrategy createSplashStrategy(); |
||||
|
||||
/** |
||||
* 替换标题图标--DesignerFrame.initTitleIcon |
||||
* 如果不替换则返回null |
||||
* |
||||
* @return |
||||
*/ |
||||
List<BufferedImage> createTitleIcon(); |
||||
|
||||
/** |
||||
* 处理设计器菜单(增删改) |
||||
* |
||||
* @param menuDefs 已加载的菜单 |
||||
* @return 新的菜单数组 |
||||
*/ |
||||
MenuDef[] dealWithMenuDef(MenuDef[] menuDefs); |
||||
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.OemProcessor; |
||||
import com.fr.design.menu.MenuDef; |
||||
import com.fr.start.SplashStrategy; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
import java.util.List; |
||||
|
||||
public abstract class AbstractOemProcessor implements OemProcessor{ |
||||
@Override |
||||
public MenuDef[] dealWithMenuDef(MenuDef[] menuDefs) { |
||||
return menuDefs; |
||||
} |
||||
|
||||
@Override |
||||
public List<BufferedImage> createTitleIcon() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public SplashStrategy createSplashStrategy() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Hades |
||||
* @date 2019/6/24 |
||||
*/ |
||||
public class ProductImproveMark implements LocaleMark<Boolean> { |
||||
|
||||
private Map<Locale, Boolean> map = new HashMap<>(); |
||||
|
||||
public ProductImproveMark() { |
||||
map.put(Locale.CHINA, true); |
||||
map.put(Locale.TAIWAN, false); |
||||
map.put(Locale.US, false); |
||||
map.put(Locale.KOREA, false); |
||||
map.put(Locale.JAPAN, false); |
||||
} |
||||
|
||||
@Override |
||||
public Boolean getValue() { |
||||
Boolean result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? false : result; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Hades |
||||
* @date 2019/6/24 |
||||
*/ |
||||
public class SplashMark implements LocaleMark<String> { |
||||
|
||||
private Map<Locale, String> map = new HashMap<Locale, String>(); |
||||
private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; |
||||
private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.gif"; |
||||
private static final String SPLASH_JP_PATH = "/com/fr/design/images/splash_10_jp.gif"; |
||||
|
||||
public SplashMark() { |
||||
map.put(Locale.CHINA, SPLASH_PATH); |
||||
map.put(Locale.KOREA, SPLASH_EN_PATH); |
||||
map.put(Locale.JAPAN, SPLASH_JP_PATH); |
||||
map.put(Locale.US, SPLASH_EN_PATH); |
||||
map.put(Locale.TAIWAN, SPLASH_EN_PATH); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(DesignerEnvManager.getEnvManager().getLanguage()); |
||||
return result == null ? SPLASH_EN_PATH : result; |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.locale.SupportLocale; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Locale; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* 某些国际化环境支持的操作 |
||||
* 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码 |
||||
* 后续有新的不同语言下的差异操作 添加新的枚举 |
||||
* @author Hades |
||||
* @date 2019/6/24 |
||||
*/ |
||||
public enum SupportLocaleImpl implements SupportLocale { |
||||
|
||||
/** |
||||
* 社区菜单支持的国际化环境 |
||||
*/ |
||||
COMMUNITY { |
||||
@Override |
||||
public Set<Locale> support() { |
||||
Set<Locale> set = new HashSet<Locale>(); |
||||
set.add(Locale.CHINA); |
||||
set.add(Locale.TAIWAN); |
||||
return set; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* Facebook支持的国际化环境 |
||||
*/ |
||||
FACEBOOK { |
||||
@Override |
||||
public Set<Locale> support() { |
||||
Set<Locale> set = new HashSet<Locale>(); |
||||
set.add(Locale.TAIWAN); |
||||
return set; |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Hades |
||||
* @date 2019/6/24 |
||||
*/ |
||||
public class UserInfoMark implements LocaleMark<String> { |
||||
|
||||
private Map<Locale, String> map = new HashMap<>(); |
||||
private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn"); |
||||
private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en"); |
||||
private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw"); |
||||
private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp"); |
||||
|
||||
public UserInfoMark() { |
||||
map.put(Locale.CHINA, CN_LOGIN_HTML); |
||||
map.put(Locale.KOREA, EN_LOGIN_HTML); |
||||
map.put(Locale.JAPAN, JP_LOGIN_HTML); |
||||
map.put(Locale.US, EN_LOGIN_HTML); |
||||
map.put(Locale.TAIWAN, TW_LOGIN_HTML); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? EN_LOGIN_HTML : result; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Hades |
||||
* @date 2019/6/24 |
||||
*/ |
||||
public class VideoMark implements LocaleMark<String> { |
||||
|
||||
private Map<Locale, String> map = new HashMap<>(); |
||||
private static final String VIDEO_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); |
||||
private static final String VIDEO_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); |
||||
private static final String VIDEO_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw"); |
||||
|
||||
public VideoMark() { |
||||
map.put(Locale.CHINA, VIDEO_CN); |
||||
map.put(Locale.KOREA, VIDEO_EN); |
||||
map.put(Locale.JAPAN, VIDEO_EN); |
||||
map.put(Locale.US, VIDEO_EN); |
||||
map.put(Locale.TAIWAN, VIDEO_TW); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? VIDEO_EN : result; |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.event.Event; |
||||
|
||||
public enum DesignAuthorityEventType implements Event<DesignerFrame> { |
||||
|
||||
// 退出权限编辑
|
||||
StartEdit, |
||||
// 进入权限编辑
|
||||
StopEdit; |
||||
} |
@ -0,0 +1,82 @@
|
||||
package com.fr.design.mainframe.loghandler; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.third.apache.log4j.Level; |
||||
import com.fr.third.apache.log4j.spi.LoggingEvent; |
||||
import com.fr.third.apache.log4j.spi.ThrowableInformation; |
||||
|
||||
/** |
||||
* 设计器日志记录 |
||||
*/ |
||||
public class DesignerLogger { |
||||
public static final int INFO_INT = Level.INFO.toInt(); |
||||
|
||||
public static final int ERROR_INT = Level.ERROR.toInt(); |
||||
|
||||
public static final int WARN_INT = Level.WARN.toInt(); |
||||
|
||||
/** |
||||
* 记录LoggingEvent对象 |
||||
* |
||||
* @param event |
||||
*/ |
||||
public static void log(LoggingEvent event) { |
||||
if (event == null) { |
||||
return; |
||||
} |
||||
LogParser.parse(event).log(event); |
||||
} |
||||
|
||||
public enum LogParser { |
||||
DEFAULT(-1) { |
||||
@Override |
||||
public void log(LoggingEvent event) { |
||||
|
||||
} |
||||
}, |
||||
INFO(Level.INFO.toInt()) { |
||||
@Override |
||||
public void log(LoggingEvent event) { |
||||
FineLoggerFactory.getLogger().info(event.getRenderedMessage()); |
||||
} |
||||
}, |
||||
WARN(Level.WARN.toInt()) { |
||||
@Override |
||||
public void log(LoggingEvent event) { |
||||
ThrowableInformation information = event.getThrowableInformation(); |
||||
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable()); |
||||
} |
||||
}, |
||||
|
||||
ERROR(Level.ERROR.toInt()) { |
||||
@Override |
||||
public void log(LoggingEvent event) { |
||||
ThrowableInformation information = event.getThrowableInformation(); |
||||
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable()); |
||||
} |
||||
}; |
||||
private int level; |
||||
|
||||
LogParser(int level) { |
||||
this.level = level; |
||||
} |
||||
|
||||
public int getLevel() { |
||||
return level; |
||||
} |
||||
|
||||
public static LogParser parse(LoggingEvent event) { |
||||
int intLevel = event.getLevel().toInt(); |
||||
for (LogParser logParser : values()) { |
||||
if (logParser.getLevel() == intLevel) { |
||||
return logParser; |
||||
} |
||||
} |
||||
return DEFAULT; |
||||
|
||||
} |
||||
|
||||
public void log(LoggingEvent event) { |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.design.mainframe.vcs.ui; |
||||
|
||||
import com.fr.design.editor.editor.DateEditor; |
||||
import com.fr.log.FineLoggerFactory; |
||||
|
||||
import java.text.ParseException; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* Created by XiaXiang on 2019/5/14. |
||||
*/ |
||||
public class VcsDateEditor extends DateEditor { |
||||
private Date tempValue; |
||||
|
||||
public VcsDateEditor(Date value, boolean format, String name, int dateFormat) { |
||||
super(value, format, name, dateFormat); |
||||
this.tempValue = value; |
||||
} |
||||
|
||||
@Override |
||||
public Date getValue() { |
||||
if (tempValue == null) { |
||||
return null; |
||||
} |
||||
return super.getValue(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(Date value) { |
||||
this.tempValue = value; |
||||
try { |
||||
getUiDatePicker().setSelectedDate(value); |
||||
} catch (ParseException parseException) { |
||||
FineLoggerFactory.getLogger().error(parseException.getMessage(), parseException); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.mainframe.vcs.ui; |
||||
|
||||
|
||||
import com.fr.design.gui.ilable.ActionLabel; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
|
||||
/** |
||||
* Created by XiaXiang on 2019/5/15. |
||||
*/ |
||||
public class VcsLabel extends ActionLabel { |
||||
|
||||
|
||||
public VcsLabel(String text, Color color) { |
||||
super(text); |
||||
this.setForeground(color); |
||||
} |
||||
|
||||
public void paintComponent(Graphics g) { |
||||
if (ui != null) { |
||||
Graphics scratchGraphics = (g == null) ? null : g.create(); |
||||
try { |
||||
ui.update(scratchGraphics, this); |
||||
} |
||||
finally { |
||||
scratchGraphics.dispose(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,468 @@
|
||||
package com.fr.design.upm; |
||||
|
||||
import com.fr.base.passport.FinePassportManager; |
||||
import com.fr.config.MarketConfig; |
||||
import com.fr.config.ServerPreferenceConfig; |
||||
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; |
||||
import com.fr.design.bridge.exec.JSBridge; |
||||
import com.fr.design.bridge.exec.JSCallback; |
||||
import com.fr.design.extra.PluginOperateUtils; |
||||
import com.fr.design.extra.PluginUtils; |
||||
import com.fr.design.extra.exe.GetInstalledPluginsExecutor; |
||||
import com.fr.design.extra.exe.GetPluginCategoriesExecutor; |
||||
import com.fr.design.extra.exe.GetPluginFromStoreExecutor; |
||||
import com.fr.design.extra.exe.GetPluginPrefixExecutor; |
||||
import com.fr.design.extra.exe.PluginLoginExecutor; |
||||
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; |
||||
import com.fr.design.extra.exe.SearchOnlineExecutor; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.upm.event.CertificateEvent; |
||||
import com.fr.design.upm.event.DownloadEvent; |
||||
import com.fr.design.upm.exec.UpmBrowserExecutor; |
||||
import com.fr.design.upm.task.UpmTaskWorker; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.JSArray; |
||||
import com.teamdev.jxbrowser.chromium.JSFunction; |
||||
import com.teamdev.jxbrowser.chromium.JSObject; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.filechooser.FileNameExtensionFilter; |
||||
import java.awt.*; |
||||
import java.io.File; |
||||
import java.net.URI; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.concurrent.Callable; |
||||
import java.util.concurrent.FutureTask; |
||||
import java.util.concurrent.RunnableFuture; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-12 |
||||
* 桥接Java和JavaScript的类 |
||||
*/ |
||||
public class UpmBridge { |
||||
|
||||
public static UpmBridge getBridge(Browser browser) { |
||||
return new UpmBridge(browser); |
||||
} |
||||
|
||||
private JSObject window; |
||||
|
||||
private UpmBridge(Browser browser) { |
||||
this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); |
||||
} |
||||
|
||||
/** |
||||
* 更新插件管理中心资源文件,这个方法仅仅是为了语义上的作用(更新) |
||||
* @param callback 安装完成后的回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void update(final JSFunction callback) { |
||||
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); |
||||
try { |
||||
UpmResourceLoader.INSTANCE.download(); |
||||
UpmResourceLoader.INSTANCE.install(); |
||||
callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); |
||||
EventDispatcher.fire(DownloadEvent.UPDATE, "success"); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 下载并安装插件管理中心的资源文件 |
||||
* @param callback 安装完成后的回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void startDownload(final JSFunction callback) { |
||||
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); |
||||
new SwingWorker<Void, Void>(){ |
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
UpmResourceLoader.INSTANCE.download(); |
||||
UpmResourceLoader.INSTANCE.install(); |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
try { |
||||
get(); |
||||
callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); |
||||
EventDispatcher.fire(DownloadEvent.SUCCESS, "success"); |
||||
} catch (Exception e) { |
||||
callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
EventDispatcher.fire(DownloadEvent.ERROR, "error"); |
||||
} |
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 获取upm的版本信息 |
||||
* @return 版本信息 |
||||
*/ |
||||
@JSBridge |
||||
public String getVersion() { |
||||
return ServerPreferenceConfig.getInstance().getOptimizedUPMVersion(); |
||||
} |
||||
|
||||
@JSBridge |
||||
public String i18nText(String key) { |
||||
return Toolkit.i18nText(key); |
||||
} |
||||
|
||||
@JSBridge |
||||
public void closeWindow() { |
||||
UpmFinder.closeWindow(); |
||||
} |
||||
|
||||
|
||||
@JSBridge |
||||
public boolean isDesigner() { |
||||
return true; |
||||
} |
||||
|
||||
@JSBridge |
||||
public void getPackInfo(final JSFunction callback) { |
||||
callback.invoke(window, StringUtils.EMPTY); |
||||
} |
||||
|
||||
@JSBridge |
||||
public void getPluginPrefix(final JSFunction callback) { |
||||
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginPrefixExecutor()); |
||||
task.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 在线获取插件分类 |
||||
* |
||||
* @param callback 回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void getPluginCategories(final JSFunction callback) { |
||||
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginCategoriesExecutor()); |
||||
task.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 根据条件获取在线插件 |
||||
* |
||||
* @param info 插件信息 |
||||
* @param callback 回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void getPluginFromStoreNew(String info, final JSFunction callback) { |
||||
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginFromStoreExecutor(new JSONObject(info))); |
||||
task.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 已安装插件检查更新 |
||||
*/ |
||||
@JSBridge |
||||
public void readUpdateOnline(final JSFunction callback) { |
||||
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new ReadUpdateOnlineExecutor()); |
||||
task.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 获取已经安装的插件的数组 |
||||
*/ |
||||
@JSBridge |
||||
public void getInstalledPlugins(final JSFunction callback) { |
||||
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetInstalledPluginsExecutor()); |
||||
task.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 从插件服务器上更新选中的插件 |
||||
* |
||||
* @param pluginIDs 插件集合 |
||||
*/ |
||||
@JSBridge |
||||
public void updatePluginOnline(Object pluginIDs, final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
List<PluginMarker> pluginMarkerList = new ArrayList<>(); |
||||
if (pluginIDs instanceof String) { |
||||
pluginMarkerList.add(PluginUtils.createPluginMarker(pluginIDs.toString())); |
||||
} else if (pluginIDs instanceof JSArray) { |
||||
JSArray pluginInfos = (JSArray) pluginIDs; |
||||
for (int i = 0, len = pluginInfos.length(); i < len; i++) { |
||||
String value = pluginInfos.get(i).asString().getValue(); |
||||
pluginMarkerList.add(PluginUtils.createPluginMarker(value)); |
||||
} |
||||
} |
||||
PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 搜索在线插件 |
||||
* |
||||
* @param keyword 关键字 |
||||
*/ |
||||
@JSBridge |
||||
public void searchPlugin(String keyword, final JSFunction callback) { |
||||
UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new SearchOnlineExecutor(keyword)); |
||||
worker.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 从磁盘上选择插件安装包进行安装 |
||||
* |
||||
* @param filePath 插件包的路径 |
||||
*/ |
||||
@JSBridge |
||||
public void installPluginFromDisk(final String filePath, final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
File file = new File(filePath); |
||||
PluginOperateUtils.installPluginFromDisk(file, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 卸载当前选中的插件 |
||||
* |
||||
* @param pluginInfo 插件信息 |
||||
*/ |
||||
@JSBridge |
||||
public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 从插件服务器上安装插件 |
||||
* |
||||
* @param pluginInfo 插件的ID |
||||
* @param callback 回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void installPluginOnline(final String pluginInfo, final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); |
||||
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 从磁盘上选择插件安装包进行插件升级 |
||||
* |
||||
* @param filePath 插件包的路径 |
||||
*/ |
||||
public void updatePluginFromDisk(String filePath, final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
File file = new File(filePath); |
||||
PluginOperateUtils.updatePluginFromDisk(file, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 修改选中的插件的活跃状态 |
||||
* |
||||
* @param pluginID 插件ID |
||||
*/ |
||||
@JSBridge |
||||
public void setPluginActive(String pluginID, final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
PluginOperateUtils.setPluginActive(pluginID, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 选择文件对话框 |
||||
* |
||||
* @return 选择的文件的路径 |
||||
*/ |
||||
@JSBridge |
||||
public String showFileChooser() { |
||||
return showFileChooserWithFilter(StringUtils.EMPTY, StringUtils.EMPTY); |
||||
} |
||||
|
||||
/** |
||||
* 选择文件对话框 |
||||
* |
||||
* @param des 过滤文件描述 |
||||
* @param filter 文件的后缀 |
||||
* @return 选择的文件的路径 |
||||
* 这里换用JFileChooser会卡死,不知道为什么 |
||||
*/ |
||||
@JSBridge |
||||
public String showFileChooserWithFilter(final String des, final String filter) { |
||||
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() { |
||||
@Override |
||||
public String call() { |
||||
JFileChooser fileChooser = new JFileChooser(); |
||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); |
||||
|
||||
if (StringUtils.isNotEmpty(filter)) { |
||||
fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter))); |
||||
} |
||||
|
||||
int result = fileChooser.showOpenDialog(UpmFinder.getDialog()); |
||||
if (result == JFileChooser.APPROVE_OPTION) { |
||||
return fileChooser.getSelectedFile().getAbsolutePath(); |
||||
} |
||||
return null; |
||||
} |
||||
}); |
||||
SwingUtilities.invokeLater(future); |
||||
try { |
||||
return future.get(); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 选择文件对话框 |
||||
* |
||||
* @param des 过滤文件描述 |
||||
* @param args 文件的后缀 |
||||
* @return 选择的文件的路径 |
||||
*/ |
||||
@JSBridge |
||||
public String showFileChooserWithFilters(final String des, final Object args) { |
||||
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() { |
||||
@Override |
||||
public String call() { |
||||
JFileChooser fileChooser = new JFileChooser(); |
||||
List<String> filterList = new ArrayList<>(); |
||||
if (args instanceof String) { |
||||
filterList.add(GeneralUtils.objectToString(args)); |
||||
} else if (args instanceof JSArray) { |
||||
JSArray array = (JSArray)args; |
||||
for (int i = 0, len = array.length(); i < len; i ++) { |
||||
filterList.add(array.get(i).getStringValue()); |
||||
} |
||||
} |
||||
String[] filters = filterList.toArray(new String[0]); |
||||
if (ArrayUtils.isNotEmpty(filters)) { |
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filters)); |
||||
fileChooser.setFileFilter(filter); |
||||
} |
||||
int result = fileChooser.showOpenDialog(UpmFinder.getDialog()); |
||||
if (result == JFileChooser.APPROVE_OPTION) { |
||||
return fileChooser.getSelectedFile().getAbsolutePath(); |
||||
} |
||||
return null; |
||||
} |
||||
}); |
||||
SwingUtilities.invokeLater(future); |
||||
try { |
||||
return future.get(); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
////////登录相关///////
|
||||
|
||||
/** |
||||
* 获取系统登录的用户名 |
||||
*/ |
||||
@JSBridge |
||||
public String getLoginInfo(final JSFunction callback) { |
||||
registerLoginInfo(callback); |
||||
return MarketConfig.getInstance().getBbsUsername(); |
||||
} |
||||
|
||||
/** |
||||
* 系统登录注册 |
||||
* |
||||
* @param callback 回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void registerLoginInfo(final JSFunction callback) { |
||||
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); |
||||
String username = MarketConfig.getInstance().getBbsUsername(); |
||||
if (StringUtils.isEmpty(username)) { |
||||
jsCallback.execute(StringUtils.EMPTY); |
||||
EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY); |
||||
} else { |
||||
jsCallback.execute(username); |
||||
EventDispatcher.fire(CertificateEvent.LOGIN, username); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 设计器端的用户登录 |
||||
* |
||||
* @param username 用户名 |
||||
* @param password 密码 |
||||
* @param callback 回调函数 |
||||
*/ |
||||
@JSBridge |
||||
public void defaultLogin(String username, String password, final JSFunction callback) { |
||||
UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new PluginLoginExecutor(username, password)); |
||||
worker.execute(); |
||||
} |
||||
|
||||
/** |
||||
* 清除用户信息 |
||||
*/ |
||||
public void clearUserInfo() { |
||||
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); |
||||
FinePassportManager.getInstance().logout(); |
||||
EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY); |
||||
} |
||||
|
||||
/** |
||||
* 打开论坛消息界面 |
||||
*/ |
||||
@JSBridge |
||||
public void getPriviteMessage() { |
||||
try { |
||||
String loginUrl = CloudCenter.getInstance().acquireUrlByKind("bbs.default"); |
||||
Desktop.getDesktop().browse(new URI(loginUrl)); |
||||
} catch (Exception exp) { |
||||
FineLoggerFactory.getLogger().info(exp.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 忘记密码 |
||||
*/ |
||||
@JSBridge |
||||
public void forgetHref() { |
||||
try { |
||||
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset"))); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 使用系统浏览器打开网页 |
||||
* @param url 要打开的网页 |
||||
*/ |
||||
@JSBridge |
||||
public void openShopUrlAtWebBrowser(String url) { |
||||
if (Desktop.isDesktopSupported()) { |
||||
try { |
||||
//创建一个URI实例,注意不是URL
|
||||
URI uri = URI.create(url); |
||||
//获取当前系统桌面扩展
|
||||
Desktop desktop = Desktop.getDesktop(); |
||||
//判断系统桌面是否支持要执行的功能
|
||||
if (desktop.isSupported(Desktop.Action.BROWSE)) { |
||||
//获取系统默认浏览器打开链接
|
||||
desktop.browse(uri); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,68 @@
|
||||
package com.fr.design.upm; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Listener; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.workspace.Workspace; |
||||
import com.fr.workspace.WorkspaceEvent; |
||||
|
||||
import javax.swing.*; |
||||
import java.io.File; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-12 |
||||
*/ |
||||
public class UpmFinder { |
||||
|
||||
private static final String UPM_DIR = "/upm"; |
||||
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; |
||||
|
||||
public static String installHome = FRContext.getCommonOperator().getWebRootPath(); |
||||
|
||||
private static UIDialog dialog = null; |
||||
|
||||
static { |
||||
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() { |
||||
@Override |
||||
public void on(Event event, Workspace param) { |
||||
installHome = FRContext.getCommonOperator().getWebRootPath(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static boolean checkUPMResourcesExist() { |
||||
String mainJsPath = StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); |
||||
File file = new File(mainJsPath); |
||||
return file.exists(); |
||||
} |
||||
|
||||
public static String getMainResourcePath() { |
||||
return "file:///" + StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); |
||||
} |
||||
|
||||
public static UIDialog getDialog() { |
||||
return dialog; |
||||
} |
||||
|
||||
public static void showUPMDialog() { |
||||
UpmShowPane upmPane = new UpmShowPane(); |
||||
if (dialog == null) { |
||||
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); |
||||
} |
||||
dialog.setVisible(true); |
||||
} |
||||
|
||||
public static void closeWindow() { |
||||
if (dialog != null) { |
||||
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); |
||||
dialog.setVisible(false); |
||||
dialog = null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.design.upm; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-12 |
||||
*/ |
||||
public class UpmShowDialog extends UIDialog { |
||||
|
||||
private static final Dimension DEFAULT_SHOP = new Dimension(900, 700); |
||||
|
||||
public UpmShowDialog(Frame frame, BasicPane pane) { |
||||
super(frame); |
||||
setUndecorated(true); |
||||
JPanel panel = (JPanel) getContentPane(); |
||||
panel.setLayout(new BorderLayout()); |
||||
add(pane, BorderLayout.CENTER); |
||||
setSize(DEFAULT_SHOP); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue