vito
8 years ago
13 changed files with 347 additions and 500 deletions
@ -0,0 +1,32 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by vito on 2017/5/5. |
||||
*/ |
||||
public class LoginDialog extends UIDialog { |
||||
private static final Dimension DEFAULT_SHOP = new Dimension(401, 201); |
||||
|
||||
public LoginDialog(Frame frame, Component pane) { |
||||
super(frame); |
||||
if (StableUtils.getMajorJavaVersion() == 8) { |
||||
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 { |
||||
} |
||||
} |
@ -1,140 +0,0 @@
|
||||
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.general.ComparatorUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.plugin.PluginVerifyException; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.io.File; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* Created by zhaohehe on 16/7/27. |
||||
*/ |
||||
public class LoginPane extends BasicPane { |
||||
private static final String LATEST = "latest"; |
||||
|
||||
public LoginPane() { |
||||
setLayout(new BorderLayout()); |
||||
if (StableUtils.getMajorJavaVersion() == 8) { |
||||
String installHome; |
||||
if (StableUtils.isDebug()) { |
||||
URL url = ClassLoader.getSystemResource(""); |
||||
installHome = url.getPath(); |
||||
addPane(installHome); |
||||
} else { |
||||
installHome = StableUtils.getInstallHome(); |
||||
File file = new File(StableUtils.pathJoin(installHome, "scripts")); |
||||
if (!file.exists()) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
this, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(); |
||||
} |
||||
} else { |
||||
addPane(installHome); |
||||
updateShopScripts(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void addPane(String installHome) { |
||||
LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath(),LoginPane.this); |
||||
add(webPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Manager"); |
||||
} |
||||
|
||||
private void downloadShopScripts() { |
||||
new SwingWorker<Boolean, Void>() { |
||||
@Override |
||||
protected Boolean 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 (PluginVerifyException e) { |
||||
JOptionPane.showMessageDialog(LoginPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
try { |
||||
if (get()) { |
||||
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); |
||||
int rv = JOptionPane.showOptionDialog( |
||||
LoginPane.this, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), |
||||
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(); |
||||
} |
||||
} |
||||
} catch (InterruptedException | ExecutionException e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
private void updateShopScripts() { |
||||
new SwingWorker<Void, Void>() { |
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION); |
||||
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
||||
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
LoginPane.this, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(); |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
}.execute(); |
||||
} |
||||
} |
@ -1,145 +0,0 @@
|
||||
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.general.ComparatorUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.plugin.PluginVerifyException; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.io.File; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* Created by zhaohehe on 16/7/28. |
||||
*/ |
||||
public class QQLoginPane extends BasicPane { |
||||
private static final String LATEST = "latest"; |
||||
|
||||
public QQLoginPane() { |
||||
setLayout(new BorderLayout()); |
||||
if (StableUtils.getMajorJavaVersion() == 8) { |
||||
String installHome; |
||||
if (StableUtils.isDebug()) { |
||||
URL url = ClassLoader.getSystemResource(""); |
||||
installHome = url.getPath(); |
||||
addPane(installHome); |
||||
} else { |
||||
installHome = StableUtils.getInstallHome(); |
||||
File file = new File(StableUtils.pathJoin(installHome, "scripts")); |
||||
if (!file.exists()) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
this, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(); |
||||
} |
||||
} else { |
||||
addPane(installHome); |
||||
updateShopScripts(); |
||||
} |
||||
} |
||||
} else { |
||||
} |
||||
} |
||||
|
||||
private void addPane(String installHome) { |
||||
QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath()); |
||||
add(webPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Manager"); |
||||
} |
||||
|
||||
|
||||
private void downloadShopScripts() { |
||||
new SwingWorker<Boolean, Void>() { |
||||
@Override |
||||
protected Boolean 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 (PluginVerifyException e) { |
||||
JOptionPane.showMessageDialog(QQLoginPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
|
||||
try { |
||||
if (get()) { |
||||
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); |
||||
int rv = JOptionPane.showOptionDialog( |
||||
QQLoginPane.this, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), |
||||
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(); |
||||
} |
||||
} |
||||
} catch (InterruptedException | ExecutionException e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
private void updateShopScripts() { |
||||
new SwingWorker<Void, Void>() { |
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION); |
||||
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
||||
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
QQLoginPane.this, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(); |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
}.execute(); |
||||
} |
||||
} |
@ -1,132 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.general.SiteCenter; |
||||
import javafx.scene.web.WebEngine; |
||||
import netscape.javascript.JSObject; |
||||
import org.json.JSONObject; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.net.URI; |
||||
|
||||
/** |
||||
* Created by lp on 2016/8/10. |
||||
*/ |
||||
public class QQLoginWebBridge { |
||||
|
||||
private static com.fr.design.extra.QQLoginWebBridge helper; |
||||
private WebEngine webEngine; |
||||
private static String LOGINSUCCESS = "ok"; |
||||
private static String LOGINFAILED = "failed"; |
||||
private UIDialog uiDialog; |
||||
private UILabel uiLabel; |
||||
private UILabel pluginuiLabel; |
||||
private UIDialog qqDialog; |
||||
private String username; |
||||
|
||||
|
||||
private QQLoginWebBridge() { |
||||
} |
||||
|
||||
public static com.fr.design.extra.QQLoginWebBridge getHelper() { |
||||
if (helper != null) { |
||||
return helper; |
||||
} |
||||
synchronized (com.fr.design.extra.QQLoginWebBridge.class) { |
||||
if (helper == null) { |
||||
helper = new com.fr.design.extra.QQLoginWebBridge(); |
||||
} |
||||
return helper; |
||||
} |
||||
} |
||||
|
||||
public void setEngine(WebEngine webEngine) { |
||||
this.webEngine = webEngine; |
||||
} |
||||
|
||||
public void setDialogHandle(UIDialog uiDialog) { |
||||
closeParentWindow(); |
||||
this.uiDialog = uiDialog; |
||||
} |
||||
|
||||
public void setQQDialogHandle(UIDialog uiDialog) { |
||||
closeQQWindow(); |
||||
this.qqDialog = uiDialog; |
||||
} |
||||
|
||||
public void setUILabel(UILabel uiLabel) { |
||||
this.uiLabel = uiLabel; |
||||
} |
||||
|
||||
public void setUILabelInPlugin(UILabel uiLabel) { |
||||
this.pluginuiLabel = uiLabel; |
||||
} |
||||
|
||||
public void setLoginlabel() { |
||||
username = DesignerEnvManager.getEnvManager().getBBSName(); |
||||
} |
||||
|
||||
private static JSObject window; |
||||
|
||||
public static com.fr.design.extra.QQLoginWebBridge getHelper(WebEngine webEngine) { |
||||
getHelper(); |
||||
helper.setEngine(webEngine); |
||||
return helper; |
||||
} |
||||
|
||||
/** |
||||
* 关闭QQ授权窗口 |
||||
*/ |
||||
public void closeQQWindow() { |
||||
if (qqDialog != null) { |
||||
qqDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
||||
qqDialog.setVisible(false); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 关闭父窗口 |
||||
*/ |
||||
public void closeParentWindow() { |
||||
if (uiDialog != null) { |
||||
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
||||
uiDialog.setVisible(false); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取用户信息 |
||||
* |
||||
* @param userInfo |
||||
*/ |
||||
public void getLoginInfo(String userInfo) { |
||||
JSONObject jo = new JSONObject(userInfo); |
||||
String status = jo.get("status").toString(); |
||||
if (status.equals(LOGINSUCCESS)) { |
||||
String username = jo.get("username").toString(); |
||||
int uid = Integer.parseInt(jo.get("uid") == null ? "" : jo.get("uid").toString()); |
||||
closeQQWindow(); |
||||
closeParentWindow(); |
||||
pluginuiLabel.setText(username); |
||||
DesignerEnvManager.getEnvManager().setBBSName(username); |
||||
DesignerEnvManager.getEnvManager().setBbsUid(uid); |
||||
DesignerEnvManager.getEnvManager().setInShowBBsName(username); |
||||
} else if (status.equals(LOGINFAILED)) { |
||||
//账号没有QQ授权
|
||||
closeQQWindow(); |
||||
try { |
||||
Desktop.getDesktop().browse(new URI(SiteCenter.getInstance().acquireUrlByKind("QQ_binding"))); |
||||
} catch (Exception exp) { |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { |
||||
if (url.indexOf("qqLogin.html") > 0) { |
||||
return; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,203 @@
|
||||
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.dialog.UIDialog; |
||||
import com.fr.design.gui.frpane.UITabbedPane; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.plugin.PluginVerifyException; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.io.File; |
||||
import java.net.HttpURLConnection; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* Created by vito on 2016/9/28. |
||||
*/ |
||||
public class WebViewDlgHelper { |
||||
private static final String LATEST = "latest"; |
||||
private static final String SHOP_SCRIPTS = "shop_scripts"; |
||||
private static final int VERSION_8 = 8; |
||||
// 调试时,使用installHome = ClassLoader.getSystemResource("").getPath()代替下面
|
||||
private static String installHome = StableUtils.getInstallHome(); |
||||
|
||||
public static void createPluginDialog() { |
||||
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { |
||||
String relativePath = "/scripts/store/web/index.html"; |
||||
String mainJsPath = StableUtils.pathJoin(new File(installHome).getAbsolutePath(), relativePath); |
||||
File file = new File(mainJsPath); |
||||
if (!file.exists()) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
null, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
} else { |
||||
updateShopScripts(SHOP_SCRIPTS); |
||||
showPluginDlg(mainJsPath); |
||||
} |
||||
} else { |
||||
BasicPane traditionalStorePane = new BasicPane() { |
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Manager"); |
||||
} |
||||
}; |
||||
traditionalStorePane.setLayout(new BorderLayout()); |
||||
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER); |
||||
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane); |
||||
dlg.setVisible(true); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 以关键词打开设计器商店 |
||||
* |
||||
* @param keyword 关键词 |
||||
*/ |
||||
public static void createPluginDialog(String keyword) { |
||||
PluginWebBridge.getHelper().openWithSearch(keyword); |
||||
createPluginDialog(); |
||||
} |
||||
|
||||
public static void createLoginDialog() { |
||||
if (StableUtils.getMajorJavaVersion() == 8) { |
||||
File file = new File(StableUtils.pathJoin(installHome, "scripts")); |
||||
if (!file.exists()) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
null, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
} else { |
||||
showLoginDlg(); |
||||
updateShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void createQQLoginDialog() { |
||||
QQLoginWebPane webPane = new QQLoginWebPane(new File(installHome).getAbsolutePath()); |
||||
UIDialog qqlog = new QQLoginDialog(DesignerContext.getDesignerFrame(), webPane); |
||||
LoginWebBridge.getHelper().setQqDialog(qqlog); |
||||
qqlog.setVisible(true); |
||||
} |
||||
|
||||
private static void showPluginDlg(String mainJsPath) { |
||||
BasicPane managerPane = new ShopManagerPane(new PluginWebPane(mainJsPath)); |
||||
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); |
||||
PluginWebBridge.getHelper().setDialogHandle(dlg); |
||||
dlg.setVisible(true); |
||||
} |
||||
|
||||
private static void showLoginDlg() { |
||||
LoginWebPane webPane = new LoginWebPane(new File(installHome).getAbsolutePath()); |
||||
UIDialog qqdlg = new LoginDialog(DesignerContext.getDesignerFrame(), webPane); |
||||
LoginWebBridge.getHelper().setDialogHandle(qqdlg); |
||||
qqdlg.setVisible(true); |
||||
} |
||||
|
||||
private static Component initTraditionalStore() { |
||||
UITabbedPane tabbedPane = new UITabbedPane(); |
||||
PluginInstalledPane installedPane = new PluginInstalledPane(); |
||||
tabbedPane.addTab(installedPane.tabTitle(), installedPane); |
||||
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_Update"), new PluginUpdatePane(tabbedPane)); |
||||
tabbedPane.addTab(Inter.getLocText("FR-Designer-Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane)); |
||||
return tabbedPane; |
||||
} |
||||
|
||||
private static void downloadShopScripts(final String scriptsId) { |
||||
new SwingWorker<Boolean, Void>() { |
||||
@Override |
||||
protected Boolean doInBackground() throws Exception { |
||||
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
||||
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
||||
try { |
||||
PluginHelper.downloadPluginFile(scriptsId, username, password, new Process<Double>() { |
||||
@Override |
||||
public void process(Double integer) { |
||||
} |
||||
}); |
||||
} catch (PluginVerifyException e) { |
||||
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
return false; |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
|
||||
try { |
||||
if (get()) { |
||||
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); |
||||
int rv = JOptionPane.showOptionDialog( |
||||
null, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), |
||||
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(); |
||||
} |
||||
} |
||||
} catch (InterruptedException | ExecutionException e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
private static void updateShopScripts(final String scriptsId) { |
||||
new SwingWorker<Void, Void>() { |
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("store.version") + "&version=" + PluginStoreConstants.VERSION); |
||||
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
||||
String text = httpClient.getResponseText(); |
||||
if (!ComparatorUtils.equals(text, LATEST)) { |
||||
int rv = JOptionPane.showConfirmDialog( |
||||
null, |
||||
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(scriptsId); |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
}.execute(); |
||||
} |
||||
} |
Loading…
Reference in new issue