|
|
@ -4,7 +4,6 @@ import com.fr.base.FRContext; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
import com.fr.design.RestartHelper; |
|
|
|
import com.fr.design.RestartHelper; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.gui.frpane.UITabbedPane; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
@ -12,12 +11,12 @@ import com.fr.general.SiteCenter; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
import com.fr.plugin.PluginVerifyException; |
|
|
|
import com.fr.plugin.PluginVerifyException; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
|
|
|
import javafx.embed.swing.JFXPanel; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -31,21 +30,18 @@ import java.util.concurrent.ExecutionException; |
|
|
|
* 因为如果直接嵌入WebView,和设计器的交互就需要预先设定好,这样灵活性会差很多,而如果使用JavaScript引擎, |
|
|
|
* 因为如果直接嵌入WebView,和设计器的交互就需要预先设定好,这样灵活性会差很多,而如果使用JavaScript引擎, |
|
|
|
* 就可以直接在JavaScript中和WebView组件做交互,而同时JavaScript中可以调用任何的设计器API. |
|
|
|
* 就可以直接在JavaScript中和WebView组件做交互,而同时JavaScript中可以调用任何的设计器API. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class PluginManagerPane extends BasicPane { |
|
|
|
public class ShopManagerPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
private static final String LATEST = "latest"; |
|
|
|
private static final String LATEST = "latest"; |
|
|
|
|
|
|
|
private ShopPaneConfig shopPaneConfig; |
|
|
|
|
|
|
|
|
|
|
|
public PluginManagerPane() { |
|
|
|
public ShopManagerPane(ShopPaneConfig shopPaneConfig) { |
|
|
|
|
|
|
|
this.shopPaneConfig = shopPaneConfig; |
|
|
|
setLayout(new BorderLayout()); |
|
|
|
setLayout(new BorderLayout()); |
|
|
|
if (StableUtils.getMajorJavaVersion() == 8) { |
|
|
|
|
|
|
|
String installHome; |
|
|
|
|
|
|
|
if (StableUtils.isDebug()) { |
|
|
|
if (StableUtils.isDebug()) { |
|
|
|
URL url = ClassLoader.getSystemResource(""); |
|
|
|
addPane(); |
|
|
|
installHome = url.getPath(); |
|
|
|
|
|
|
|
addPane(installHome); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
installHome = StableUtils.getInstallHome(); |
|
|
|
File file = new File(shopPaneConfig.getMainJS()); |
|
|
|
File file = new File(StableUtils.pathJoin(installHome, "scripts")); |
|
|
|
|
|
|
|
if (!file.exists()) { |
|
|
|
if (!file.exists()) { |
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
this, |
|
|
|
this, |
|
|
@ -58,55 +54,31 @@ public class PluginManagerPane extends BasicPane { |
|
|
|
downloadShopScripts(); |
|
|
|
downloadShopScripts(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
addPane(installHome); |
|
|
|
addPane(); |
|
|
|
updateShopScripts(); |
|
|
|
updateShopScripts(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
initTraditionalStore(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
private void addPane() { |
|
|
|
* 以关键词打开设计器商店 |
|
|
|
JFXPanel webPane = shopPaneConfig.getWebPane(); |
|
|
|
* |
|
|
|
|
|
|
|
* @param keyword 关键词 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public PluginManagerPane(String keyword) { |
|
|
|
|
|
|
|
this(); |
|
|
|
|
|
|
|
PluginWebBridge.getHelper().openWithSearch(keyword); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void addPane(String installHome) { |
|
|
|
|
|
|
|
PluginWebPane webPane = new PluginWebPane(new File(installHome).getAbsolutePath()); |
|
|
|
|
|
|
|
add(webPane, BorderLayout.CENTER); |
|
|
|
add(webPane, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initTraditionalStore() { |
|
|
|
|
|
|
|
UITabbedPane tabbedPane = new UITabbedPane(); |
|
|
|
|
|
|
|
add(tabbedPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void downloadShopScripts() { |
|
|
|
private void downloadShopScripts() { |
|
|
|
new SwingWorker<Boolean, Void>() { |
|
|
|
new SwingWorker<Boolean, Void>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Boolean doInBackground() throws Exception { |
|
|
|
protected Boolean doInBackground() throws Exception { |
|
|
|
String id = "shop_scripts"; |
|
|
|
|
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
|
|
|
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() { |
|
|
|
PluginHelper.downloadPluginFile(shopPaneConfig.getScriptsId(), username, password, new Process<Double>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void process(Double integer) { |
|
|
|
public void process(Double integer) { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (PluginVerifyException e) { |
|
|
|
} catch (PluginVerifyException e) { |
|
|
|
JOptionPane.showMessageDialog(PluginManagerPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
JOptionPane.showMessageDialog(ShopManagerPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
@ -122,7 +94,7 @@ public class PluginManagerPane extends BasicPane { |
|
|
|
if (get()) { |
|
|
|
if (get()) { |
|
|
|
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); |
|
|
|
IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); |
|
|
|
int rv = JOptionPane.showOptionDialog( |
|
|
|
int rv = JOptionPane.showOptionDialog( |
|
|
|
PluginManagerPane.this, |
|
|
|
ShopManagerPane.this, |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
@ -151,7 +123,7 @@ public class PluginManagerPane extends BasicPane { |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
|
|
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { |
|
|
|
if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { |
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
int rv = JOptionPane.showConfirmDialog( |
|
|
|
PluginManagerPane.this, |
|
|
|
ShopManagerPane.this, |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
JOptionPane.OK_CANCEL_OPTION, |
|
|
|
JOptionPane.OK_CANCEL_OPTION, |