|
|
|
@ -1,10 +1,17 @@
|
|
|
|
|
package com.fr.design.extra; |
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.design.RestartHelper; |
|
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
|
import com.fr.design.gui.frpane.UITabbedPane; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -24,10 +31,29 @@ public class PluginManagerPane extends BasicPane {
|
|
|
|
|
public PluginManagerPane() { |
|
|
|
|
setLayout(new BorderLayout()); |
|
|
|
|
if (System.getProperty("java.version").startsWith("1.8")) { |
|
|
|
|
URL url = ClassLoader.getSystemResource(""); |
|
|
|
|
String installHome = url.getPath(); |
|
|
|
|
PluginWebPane webPane = new PluginWebPane(installHome); |
|
|
|
|
String installHome; |
|
|
|
|
if(StableUtils.isDebug()){ |
|
|
|
|
URL url = ClassLoader.getSystemResource(""); |
|
|
|
|
installHome = url.getPath() + "scripts"; |
|
|
|
|
}else{ |
|
|
|
|
installHome = StableUtils.getInstallHome() + File.separator + "scripts"; |
|
|
|
|
File file = new File(installHome); |
|
|
|
|
if (!file.exists()) { |
|
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
|
null, |
|
|
|
|
"您还没有插件商店的资源,是否下载?", |
|
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
|
JOptionPane.OK_CANCEL_OPTION, |
|
|
|
|
JOptionPane.INFORMATION_MESSAGE |
|
|
|
|
); |
|
|
|
|
if (rv == JOptionPane.OK_OPTION) { |
|
|
|
|
downloadShopScripts(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
PluginWebPane webPane = new PluginWebPane(new File(installHome).getAbsolutePath()); |
|
|
|
|
add(webPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
initTraditionalStore(); |
|
|
|
|
} |
|
|
|
@ -42,6 +68,45 @@ public class PluginManagerPane extends BasicPane {
|
|
|
|
|
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void downloadShopScripts() { |
|
|
|
|
new SwingWorker<Void, Void>() { |
|
|
|
|
@Override |
|
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
|
String id = "shop_scripts"; |
|
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
|
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
|
|
|
|
try { |
|
|
|
|
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() { |
|
|
|
|
@Override |
|
|
|
|
public void process(Double integer) { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void done() { |
|
|
|
|
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); |
|
|
|
|
int rv = JOptionPane.showOptionDialog( |
|
|
|
|
null, |
|
|
|
|
"商店安装完毕,是否立刻启动?", |
|
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
|
JOptionPane.INFORMATION_MESSAGE, |
|
|
|
|
null, |
|
|
|
|
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later")}, |
|
|
|
|
null |
|
|
|
|
); |
|
|
|
|
if (rv == JOptionPane.OK_OPTION) { |
|
|
|
|
RestartHelper.restart(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}.execute(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return Inter.getLocText("FR-Designer-Plugin_Manager"); |
|
|
|
|