|
|
@ -10,6 +10,7 @@ import com.fr.design.extra.Process; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.plugin.Plugin; |
|
|
|
import com.fr.plugin.Plugin; |
|
|
|
import com.fr.plugin.PluginLoader; |
|
|
|
import com.fr.plugin.PluginLoader; |
|
|
|
|
|
|
|
import com.fr.plugin.PluginVerifyException; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
@ -43,44 +44,50 @@ public class UpdateOnlineExecutor implements Executor { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run(Process<String> process) { |
|
|
|
public void run(Process<String> process) { |
|
|
|
if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){ |
|
|
|
if (StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())) { |
|
|
|
LoginCheckContext.fireLoginCheckListener(); |
|
|
|
LoginCheckContext.fireLoginCheckListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
if(StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())){ |
|
|
|
if (StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())) { |
|
|
|
for (int i = 0; i < pluginIDs.length; i++) { |
|
|
|
try { |
|
|
|
Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); |
|
|
|
for (int i = 0; i < pluginIDs.length; i++) { |
|
|
|
String id = null; |
|
|
|
try { |
|
|
|
if (plugin != null) { |
|
|
|
Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); |
|
|
|
id = plugin.getId(); |
|
|
|
String id = null; |
|
|
|
} |
|
|
|
if (plugin != null) { |
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
id = plugin.getId(); |
|
|
|
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void process(Double integer) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
updateFileFromDisk(PluginHelper.getDownloadTempFile()); |
|
|
|
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
|
|
|
process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); |
|
|
|
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() { |
|
|
|
} catch (Exception e) { |
|
|
|
@Override |
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
public void process(Double integer) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
updateFileFromDisk(PluginHelper.getDownloadTempFile()); |
|
|
|
|
|
|
|
process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); |
|
|
|
|
|
|
|
} catch (PluginVerifyException e) { |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FRContext.getLogger().error(e.getMessage(), e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
int rv = JOptionPane.showOptionDialog( |
|
|
|
int rv = JOptionPane.showOptionDialog( |
|
|
|
null, |
|
|
|
null, |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Update_Successful"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Update_Successful"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
Inter.getLocText("FR-Designer-Plugin_Warning"), |
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
JOptionPane.INFORMATION_MESSAGE, |
|
|
|
JOptionPane.INFORMATION_MESSAGE, |
|
|
|
null, |
|
|
|
null, |
|
|
|
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), |
|
|
|
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), |
|
|
|
Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") |
|
|
|
Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") |
|
|
|
}, |
|
|
|
}, |
|
|
|
null |
|
|
|
null |
|
|
|
); |
|
|
|
); |
|
|
|
if (rv == JOptionPane.OK_OPTION) { |
|
|
|
if (rv == JOptionPane.OK_OPTION) { |
|
|
|
RestartHelper.restart(); |
|
|
|
RestartHelper.restart(); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (PluginVerifyException e) { |
|
|
|
|
|
|
|
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -88,26 +95,22 @@ public class UpdateOnlineExecutor implements Executor { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateFileFromDisk(File fileOnDisk) { |
|
|
|
private void updateFileFromDisk(File fileOnDisk) throws Exception { |
|
|
|
try { |
|
|
|
Plugin plugin = PluginHelper.readPlugin(fileOnDisk); |
|
|
|
Plugin plugin = PluginHelper.readPlugin(fileOnDisk); |
|
|
|
if (plugin == null) { |
|
|
|
if (plugin == null) { |
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); |
|
|
|
Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); |
|
|
|
if (oldPlugin != null) { |
|
|
|
if (oldPlugin != null) { |
|
|
|
String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); |
|
|
|
String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); |
|
|
|
PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { |
|
|
|
PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void done() { |
|
|
|
public void done() { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e1) { |
|
|
|
|
|
|
|
JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|