Browse Source

update

master
Fangjie Hu 9 years ago
parent
commit
dfa8ef6c53
  1. 6
      designer_base/src/com/fr/design/extra/PluginManagerPane.java
  2. 53
      designer_base/src/com/fr/design/extra/pre4plugin/PhantomJs4VanChartPlugin.java
  3. 2
      designer_base/src/com/fr/design/extra/pre4plugin/PluginFactory.java

6
designer_base/src/com/fr/design/extra/PluginManagerPane.java

@ -39,11 +39,11 @@ public class PluginManagerPane extends BasicPane {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
if (StableUtils.getMajorJavaVersion() == 8) { if (StableUtils.getMajorJavaVersion() == 8) {
String installHome; String installHome;
if (StableUtils.isDebug()) { /*if (StableUtils.isDebug()) {
URL url = ClassLoader.getSystemResource(""); URL url = ClassLoader.getSystemResource("");
installHome = url.getPath(); installHome = url.getPath();
addPane(installHome); addPane(installHome);
} else { } else {*/
installHome = StableUtils.getInstallHome(); installHome = StableUtils.getInstallHome();
File file = new File(StableUtils.pathJoin(installHome, "scripts")); File file = new File(StableUtils.pathJoin(installHome, "scripts"));
if (!file.exists()) { if (!file.exists()) {
@ -61,7 +61,7 @@ public class PluginManagerPane extends BasicPane {
addPane(installHome); addPane(installHome);
updateShopScripts(); updateShopScripts();
} }
} /*}*/
} else { } else {
initTraditionalStore(); initTraditionalStore();
} }

53
designer_base/src/com/fr/design/extra/pre4plugin/InstallPhantomJs.java → designer_base/src/com/fr/design/extra/pre4plugin/PhantomJs4VanChartPlugin.java

@ -34,36 +34,28 @@ import javax.swing.event.ChangeListener;
public class InstallPhantomJs implements ActionListener, ChangeListener, PreEnv4Plugin { public class PhantomJs4VanChartPlugin implements ActionListener, ChangeListener, PreEnv4Plugin {
//七牛云服务器下载地址
private static final String PHANTOM_PATH = "http://ocrpz63ed.bkt.clouddn.com/phantomjs.zip"; private static final String PHANTOM_PATH = "http://ocrpz63ed.bkt.clouddn.com/phantomjs.zip";
//链接服务器的客户端 //链接服务器的客户端
private HttpClient httpClient; private HttpClient httpClient;
//已读文件字节数 //已读文件字节数
private int totalBytesRead = 0; private int totalBytesRead = 0;
//文件总长度 //文件总长度
private int totalSize = 0; private int totalSize = 0;
//进度显示界面 //进度显示界面
private JDialog frame = null; private JDialog frame = null;
//进度条 //进度条
private JProgressBar progressbar; private JProgressBar progressbar;
//进度信息
private JLabel label; private JLabel label;
//进度条更新时钟 //进度条更新时钟
private Timer timer; private Timer timer;
//文件路径 //文件路径
private String filePath = StringUtils.EMPTY; private String filePath = StringUtils.EMPTY;
//是否继续下载 //是否继续下载
private boolean flag = true; private boolean flag = true;
//安装结果 //安装结果
boolean result = false; boolean result = false;
@ -75,11 +67,12 @@ public class InstallPhantomJs implements ActionListener, ChangeListener, PreEnv4
return filePath; return filePath;
} }
public InstallPhantomJs() { public PhantomJs4VanChartPlugin() {
} }
//是否可以连接服务器 //是否可以连接服务器
public boolean serverReached(){ private boolean serverReached(){
connectToServer();
return totalSize != -1; return totalSize != -1;
} }
@ -119,21 +112,29 @@ public class InstallPhantomJs implements ActionListener, ChangeListener, PreEnv4
contentPanel.add(progressbar, BorderLayout.SOUTH); contentPanel.add(progressbar, BorderLayout.SOUTH);
} }
private int connectToServer(){ private void connectToServer(){
httpClient = new HttpClient(PHANTOM_PATH);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
totalSize = httpClient.getContentLength();
}else {
totalSize = -1;
}
}
private int getFileLength(){
httpClient = new HttpClient(PHANTOM_PATH); httpClient = new HttpClient(PHANTOM_PATH);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
return httpClient.getContentLength(); return httpClient.getContentLength();
} }
return -1; return -1;
} }
//安装 //安装
public boolean install() { private boolean install() {
//连接服务器
connectToServer();
//初始化安装进度界面 //初始化安装进度界面
init(); init();
//连接服务器
totalSize = connectToServer();
//开始时钟 //开始时钟
timer.start(); timer.start();
//开始下载 //开始下载
@ -226,31 +227,25 @@ public class InstallPhantomJs implements ActionListener, ChangeListener, PreEnv4
public void stateChanged(ChangeEvent e1) { public void stateChanged(ChangeEvent e1) {
double value = (double)progressbar.getValue() / 1000000.0; double value = (double)progressbar.getValue() / 1000000.0;
if (e1.getSource() == progressbar) { if (e1.getSource() == progressbar) {
label.setText("已下载:" + Double.toString(value) + " m"); label.setText("已下载:" + Double.toString(value) + " m");
label.setForeground(Color.blue); label.setForeground(Color.blue);
} }
} }
@Override @Override
public boolean preOnline() { public boolean preOnline() {
int choose = JOptionPane.showConfirmDialog(null, "新图表需要phantomjs支持。是否需要安装phantomjs(" + totalSize/1000000 + " m)?", "install tooltip", JOptionPane.YES_NO_OPTION); int fileLength = getFileLength();
int choose = JOptionPane.showConfirmDialog(null, "新图表需要phantomjs支持。是否需要安装phantomjs(" + fileLength/1000000 + " m)?", "install tooltip", JOptionPane.YES_NO_OPTION);
if (choose == 0){//下载安装 if (choose == 0){//下载安装
InstallPhantomJs installPhantomJs = new InstallPhantomJs(); if (!serverReached()){
if (!installPhantomJs.serverReached()){
JOptionPane.showMessageDialog(null, "无法连接远程服务器!!", "警告", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "无法连接远程服务器!!", "警告", JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
//安装phantomJs //安装phantomJs
if (installPhantomJs.install()){ if (install()){
JOptionPane.showMessageDialog(null, "安装成功!!"); JOptionPane.showMessageDialog(null, "安装成功!!");
return true; return true;
}else { }else {

2
designer_base/src/com/fr/design/extra/pre4plugin/PluginFactory.java

@ -16,7 +16,7 @@ public class PluginFactory {
*/ */
private static Map<String, Class<? extends PreEnv4Plugin>> pluginMap = new HashMap<String, Class<? extends PreEnv4Plugin>>(); private static Map<String, Class<? extends PreEnv4Plugin>> pluginMap = new HashMap<String, Class<? extends PreEnv4Plugin>>();
static { static {
pluginMap.put("com.fr.plugin.chart.vancharts", InstallPhantomJs.class); pluginMap.put("com.fr.plugin.chart.vancharts", PhantomJs4VanChartPlugin.class);
} }
public static PreEnv4Plugin createPreEnv(String pluginID) { public static PreEnv4Plugin createPreEnv(String pluginID) {

Loading…
Cancel
Save