Browse Source
* commit '57116cff094005f8928439b215a303e2f092026b': KERNEL-442 配合测试新版本插件商店bugfix/10.0
richie
6 years ago
9 changed files with 238 additions and 6 deletions
@ -0,0 +1,63 @@
|
||||
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 UPM { |
||||
|
||||
private static final String MAIN_RESOURCE_PATH = "/upm/plugin.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 void showUPMDialog() { |
||||
UPMPane upmPane = new UPMPane(); |
||||
if (dialog == null) { |
||||
dialog = new UPMDialog(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,31 @@
|
||||
package com.fr.design.upm; |
||||
|
||||
import com.fr.design.upm.event.DownloadEvent; |
||||
import com.fr.event.EventDispatcher; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-12 |
||||
* 桥接Java和JavaScript的类 |
||||
*/ |
||||
public class UPMBridge { |
||||
|
||||
private static UPMBridge bridge = new UPMBridge(); |
||||
|
||||
public static UPMBridge getBridge() { |
||||
return bridge; |
||||
} |
||||
|
||||
public void startDownload() { |
||||
// do something.....
|
||||
EventDispatcher.fire(DownloadEvent.FINISH, "start"); |
||||
} |
||||
|
||||
|
||||
|
||||
public void closeWindow() { |
||||
UPM.closeWindow(); |
||||
} |
||||
|
||||
} |
@ -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 UPMDialog extends UIDialog { |
||||
|
||||
private static final Dimension DEFAULT_SHOP = new Dimension(900, 700); |
||||
|
||||
public UPMDialog(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 { |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.upm; |
||||
|
||||
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; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-12 |
||||
*/ |
||||
public class WarnComponent extends AssembleComponent { |
||||
|
||||
public static final WarnComponent KEY = new WarnComponent(); |
||||
|
||||
private WarnComponent() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public ScriptPath script(RequestClient req) { |
||||
return ScriptPath.build("com/fr/design/upm/warn.js"); |
||||
} |
||||
|
||||
@Override |
||||
public Atom[] refer() { |
||||
return new Atom[]{ |
||||
FineUI.KEY |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.design.upm.event; |
||||
|
||||
import com.fr.event.Event; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-12 |
||||
*/ |
||||
public enum DownloadEvent implements Event<String> { |
||||
|
||||
FINISH |
||||
} |
@ -0,0 +1,20 @@
|
||||
window.onload = function () { |
||||
let button = BI.createWidget({ |
||||
type : "bi.button", |
||||
text : "点击我跳转到插件商店", |
||||
level: 'common', |
||||
height: 30, |
||||
handler : function () { |
||||
PluginBridgeTest.startDownload(); |
||||
} |
||||
}); |
||||
BI.createWidget({ |
||||
type:"bi.absolute", |
||||
element: "body", |
||||
items: [{ |
||||
el: button, |
||||
left: 100, |
||||
top: 100 |
||||
}] |
||||
}); |
||||
}; |
Loading…
Reference in new issue