|
|
@ -12,12 +12,16 @@ import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.SiteCenter; |
|
|
|
import com.fr.general.SiteCenter; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
import com.fr.plugin.PluginVerifyException; |
|
|
|
import com.fr.plugin.PluginVerifyException; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
|
|
|
|
|
|
|
@ -30,26 +34,30 @@ public class WebViewDlgHelper { |
|
|
|
private static final int VERSION_8 = 8; |
|
|
|
private static final int VERSION_8 = 8; |
|
|
|
// 调试时,使用installHome = ClassLoader.getSystemResource("").getPath()代替下面
|
|
|
|
// 调试时,使用installHome = ClassLoader.getSystemResource("").getPath()代替下面
|
|
|
|
private static String installHome = StableUtils.getInstallHome(); |
|
|
|
private static String installHome = StableUtils.getInstallHome(); |
|
|
|
|
|
|
|
private static final int BYTES_NUM = 1024; |
|
|
|
|
|
|
|
|
|
|
|
public static void createPluginDialog() { |
|
|
|
public static void createPluginDialog() { |
|
|
|
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { |
|
|
|
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { |
|
|
|
String relativePath = "index.html"; |
|
|
|
String relativePath = "/scripts/store/web/index.html"; |
|
|
|
String mainJsPath = StableUtils.pathJoin(FRContext.getCurrentEnv().getWebReportPath(), relativePath); |
|
|
|
String mainJsPath = StableUtils.pathJoin(FRContext.getCurrentEnv().getWebReportPath(), relativePath); |
|
|
|
File file = new File(mainJsPath); |
|
|
|
File file = new File(mainJsPath); |
|
|
|
if (!file.exists()) { |
|
|
|
if (!file.exists()) { |
|
|
|
// int rv = JOptionPane.showConfirmDialog(
|
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
// null,
|
|
|
|
null, |
|
|
|
// Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"),
|
|
|
|
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), |
|
|
|
// Inter.getLocText("FR-Designer-Plugin_Warning"),
|
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
// JOptionPane.OK_CANCEL_OPTION,
|
|
|
|
JOptionPane.OK_CANCEL_OPTION, |
|
|
|
// JOptionPane.INFORMATION_MESSAGE
|
|
|
|
JOptionPane.INFORMATION_MESSAGE |
|
|
|
// );
|
|
|
|
); |
|
|
|
// if (rv == JOptionPane.OK_OPTION) {
|
|
|
|
if (rv == JOptionPane.OK_OPTION) { |
|
|
|
// downloadShopScripts(SHOP_SCRIPTS);
|
|
|
|
downloadShopScripts(SHOP_SCRIPTS); |
|
|
|
// }
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
String indexPath = "index.html"; |
|
|
|
|
|
|
|
String mainIndexPath = StableUtils.pathJoin(FRContext.getCurrentEnv().getWebReportPath(), indexPath); |
|
|
|
|
|
|
|
checkAndCopyMainFile(mainIndexPath, mainJsPath); |
|
|
|
updateShopScripts(SHOP_SCRIPTS); |
|
|
|
updateShopScripts(SHOP_SCRIPTS); |
|
|
|
showPluginDlg(mainJsPath); |
|
|
|
showPluginDlg(mainIndexPath); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
BasicPane traditionalStorePane = new BasicPane() { |
|
|
|
BasicPane traditionalStorePane = new BasicPane() { |
|
|
@ -65,6 +73,31 @@ public class WebViewDlgHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 检查script文件夹中的index.html文件 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static void checkAndCopyMainFile(String indexPath, String mainJsPath){ |
|
|
|
|
|
|
|
File file = new File(indexPath); |
|
|
|
|
|
|
|
if (!file.exists()) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
File mainJsFile = new File(mainJsPath); |
|
|
|
|
|
|
|
int byteread = 0; |
|
|
|
|
|
|
|
if (mainJsFile.exists()) { |
|
|
|
|
|
|
|
InputStream inStream = new FileInputStream(mainJsPath); |
|
|
|
|
|
|
|
FileOutputStream fs = new FileOutputStream(indexPath); |
|
|
|
|
|
|
|
byte[] buffer = new byte[BYTES_NUM]; |
|
|
|
|
|
|
|
while ((byteread = inStream.read(buffer)) != -1) { |
|
|
|
|
|
|
|
fs.write(buffer, 0, byteread); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
inStream.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FRContext.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 以关键词打开设计器商店 |
|
|
|
* 以关键词打开设计器商店 |
|
|
|
* |
|
|
|
* |
|
|
@ -181,20 +214,23 @@ public class WebViewDlgHelper { |
|
|
|
new SwingWorker<Void, Void>() { |
|
|
|
new SwingWorker<Void, Void>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION); |
|
|
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("shop.plugin.cv") + "&version=" + PluginStoreConstants.VERSION); |
|
|
|
|
|
|
|
httpClient.asGet(); |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
String text = httpClient.getResponseText(); |
|
|
|
String text = httpClient.getResponseText(); |
|
|
|
if (!ComparatorUtils.equals(text, LATEST)) { |
|
|
|
JSONObject resultJSONObject = new JSONObject(text); |
|
|
|
// int rv = JOptionPane.showConfirmDialog(
|
|
|
|
String isLatest = resultJSONObject.optString("result"); |
|
|
|
// null,
|
|
|
|
if (!ComparatorUtils.equals(isLatest, LATEST)) { |
|
|
|
// Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"),
|
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
// Inter.getLocText("FR-Designer-Plugin_Warning"),
|
|
|
|
null, |
|
|
|
// JOptionPane.OK_CANCEL_OPTION,
|
|
|
|
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), |
|
|
|
// JOptionPane.INFORMATION_MESSAGE
|
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
// );
|
|
|
|
JOptionPane.OK_CANCEL_OPTION, |
|
|
|
// if (rv == JOptionPane.OK_OPTION) {
|
|
|
|
JOptionPane.INFORMATION_MESSAGE |
|
|
|
// downloadShopScripts(scriptsId);
|
|
|
|
); |
|
|
|
// }
|
|
|
|
if (rv == JOptionPane.OK_OPTION) { |
|
|
|
|
|
|
|
downloadShopScripts(scriptsId); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|