plough
7 years ago
109 changed files with 1451 additions and 700 deletions
@ -0,0 +1,31 @@
|
||||
package com.fr.design.bbs; |
||||
|
||||
import com.fr.base.ConfigManager; |
||||
import com.fr.base.FRContext; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/8/21. |
||||
*/ |
||||
public class BBSLoginUtils { |
||||
|
||||
public static void bbsLogin(String username, String password){ |
||||
try{ |
||||
ConfigManager.getProviderInstance().setBbsUsername(username); |
||||
ConfigManager.getProviderInstance().setBbsPassword(password); |
||||
FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance()); |
||||
}catch (Exception e){ |
||||
FRContext.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
public static void bbsLogout(){ |
||||
try{ |
||||
ConfigManager.getProviderInstance().setBbsUsername(StringUtils.EMPTY); |
||||
ConfigManager.getProviderInstance().setBbsPassword(StringUtils.EMPTY); |
||||
FRContext.getCurrentEnv().writeResource(ConfigManager.getProviderInstance()); |
||||
}catch (Exception e){ |
||||
FRContext.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,224 @@
|
||||
package com.fr.design.gui.chart; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.RestartHelper; |
||||
import com.fr.design.extra.PluginConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.WindowAdapter; |
||||
import java.awt.event.WindowEvent; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.InputStream; |
||||
import java.net.HttpURLConnection; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2017/8/21. |
||||
*/ |
||||
public class DownLoadOnLineSourcesHelper { |
||||
// 定义加载窗口大小
|
||||
private static final int LOAD_WIDTH = 455; |
||||
private static final int INCIDENT_HEIGHT = 15; |
||||
private static final int LOAD_HEIGHT = 295; |
||||
private static final int PERCENT = 100; |
||||
|
||||
//进度显示界面
|
||||
private JDialog dialog; |
||||
//进度条
|
||||
private JProgressBar progressbar; |
||||
|
||||
private List<SiteInfo> list = new ArrayList<>(); |
||||
//安装结果
|
||||
private boolean result = true; |
||||
//链接服务器的客户端
|
||||
private HttpClient httpClient; |
||||
|
||||
//总共字节数
|
||||
private double totalBytes = 0; |
||||
|
||||
|
||||
private static final double PHANTOM_MB = 96.1 * 1024 * 1024; |
||||
|
||||
public void addPhantomSiteInfo() { |
||||
this.addSiteInfo("plugin.phantomjs", "/assist/phantomjs", PHANTOM_MB); |
||||
} |
||||
|
||||
private static final double MAP_JSON_MB = 3.8 * 1024 * 1024; |
||||
|
||||
public void addMapJSONSiteInfo() { |
||||
this.addSiteInfo("map.json", "/assets/map", MAP_JSON_MB); |
||||
} |
||||
|
||||
public void addSiteInfo(String siteKind, String localDir, double megaBits) { |
||||
if (new File(FRContext.getCurrentEnv().getPath() + localDir).exists()) { |
||||
//本地有这个资源,不下载
|
||||
return; |
||||
} |
||||
httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(siteKind)); |
||||
if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK) { |
||||
//服务器连不上,不下载
|
||||
return; |
||||
} |
||||
totalBytes += megaBits; |
||||
list.add(new SiteInfo(siteKind, localDir)); |
||||
} |
||||
|
||||
public void installOnline() { |
||||
|
||||
int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer-Download_Online_Sources"), null, JOptionPane.YES_NO_OPTION); |
||||
|
||||
if (choose == JOptionPane.OK_OPTION) { |
||||
initDialog(); |
||||
|
||||
dialog.addWindowListener(new WindowAdapter() { |
||||
public void windowClosing(WindowEvent e) { |
||||
//取消下载
|
||||
result = false; |
||||
exitDialog(); |
||||
} |
||||
|
||||
public void windowOpened(WindowEvent e) { |
||||
downloadAndInstallPluginDependenceFile(); |
||||
exitDialog(); |
||||
} |
||||
|
||||
}); |
||||
|
||||
dialog.setVisible(true); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 下载和安装不分开是因为,本地如果只安装好了一个依赖,下次就不需要重复下载了 |
||||
* 如果下载依赖后不安装,则后面的插件会把前面的插件覆盖,故而下载好了一个安装一个 |
||||
* |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private void downloadAndInstallPluginDependenceFile() { |
||||
try { |
||||
double currentBytesRead = 0; |
||||
|
||||
for (int i = 0; i < list.size(); i++) { |
||||
SiteInfo siteInfo = list.get(i); |
||||
|
||||
httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); |
||||
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { |
||||
InputStream reader = httpClient.getResponseStream(); |
||||
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); |
||||
File file = new File(temp); |
||||
StableUtils.makesureFileExist(file); |
||||
FileOutputStream writer = new FileOutputStream(temp); |
||||
byte[] buffer = new byte[PluginConstants.BYTES_NUM]; |
||||
int bytesRead; |
||||
while ((bytesRead = reader.read(buffer)) > 0 && result) { |
||||
writer.write(buffer, 0, bytesRead); |
||||
buffer = new byte[PluginConstants.BYTES_NUM]; |
||||
|
||||
currentBytesRead += bytesRead; |
||||
setProgress(currentBytesRead); |
||||
} |
||||
reader.close(); |
||||
writer.flush(); |
||||
writer.close(); |
||||
|
||||
|
||||
if (result) { |
||||
//安装文件
|
||||
IOUtils.unZipFilesGBK(temp, FRContext.getCurrentEnv().getPath() + siteInfo.localDir); |
||||
} |
||||
} else { |
||||
result = false; |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
result = false; |
||||
} |
||||
} |
||||
|
||||
|
||||
private void initDialog() { |
||||
|
||||
// 创建标签,并在标签上放置一张图片
|
||||
BufferedImage image = IOUtils.readImage("/com/fr/design/gui/chart/background.png"); |
||||
ImageIcon imageIcon = new ImageIcon(image); |
||||
UILabel label = new UILabel(imageIcon); |
||||
label.setBounds(0, 0, LOAD_WIDTH, LOAD_HEIGHT); |
||||
|
||||
progressbar = new JProgressBar(); |
||||
// 显示当前进度值信息
|
||||
progressbar.setStringPainted(true); |
||||
// 设置进度条边框不显示
|
||||
progressbar.setBorderPainted(false); |
||||
// 设置进度条的前景色
|
||||
progressbar.setForeground(new Color(0x38aef5)); |
||||
// 设置进度条的背景色
|
||||
progressbar.setBackground(new Color(188, 190, 194)); |
||||
progressbar.setBounds(0, LOAD_HEIGHT, LOAD_WIDTH, INCIDENT_HEIGHT); |
||||
progressbar.setMinimum(0); |
||||
progressbar.setMaximum((int) totalBytes); |
||||
setProgress(0); |
||||
|
||||
dialog = new JDialog(); |
||||
dialog.setTitle(Inter.getLocText("FR-Designer-Dependence_Install_Online")); |
||||
|
||||
JPanel contentPane = new JPanel(new BorderLayout()); |
||||
contentPane.add(label, BorderLayout.CENTER); |
||||
contentPane.add(progressbar, BorderLayout.SOUTH); |
||||
dialog.getContentPane().add(contentPane); |
||||
|
||||
|
||||
dialog.setModal(true); |
||||
dialog.setResizable(true); |
||||
dialog.setSize(LOAD_WIDTH, LOAD_HEIGHT + INCIDENT_HEIGHT); |
||||
dialog.setResizable(false); |
||||
GUICoreUtils.centerWindow(dialog); |
||||
|
||||
dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); |
||||
} |
||||
|
||||
private void setProgress(double current) { |
||||
progressbar.setValue((int) current); |
||||
progressbar.setString(current / totalBytes * PERCENT + "%"); |
||||
progressbar.paintImmediately(new Rectangle(0, 0, LOAD_WIDTH, INCIDENT_HEIGHT * 2)); |
||||
} |
||||
|
||||
|
||||
private void exitDialog() { |
||||
dialog.dispose(); |
||||
|
||||
if (result) { |
||||
int choose = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_Work_After_Restart_Designer"), null, JOptionPane.YES_NO_OPTION); |
||||
|
||||
if (choose == JOptionPane.OK_OPTION) { |
||||
RestartHelper.restart(); |
||||
} |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Dependence_Install_Failed")); |
||||
} |
||||
} |
||||
|
||||
private class SiteInfo { |
||||
String siteKind; |
||||
String localDir; |
||||
|
||||
SiteInfo(String siteKind, String localDir) { |
||||
this.siteKind = siteKind; |
||||
this.localDir = localDir; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
After Width: | Height: | Size: 105 KiB |
@ -0,0 +1,84 @@
|
||||
package com.fr.plugin.chart.designer.other; |
||||
|
||||
import com.fr.base.chart.BasePlot; |
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.chart.chartglyph.ConditionAttr; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.controlpane.NameObjectCreator; |
||||
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; |
||||
import com.fr.design.gui.ilist.ListModelElement; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.plugin.chart.designer.component.ConditionUIMenuNameableCreator; |
||||
import com.fr.stable.Nameable; |
||||
|
||||
import java.lang.reflect.Constructor; |
||||
import java.lang.reflect.InvocationTargetException; |
||||
|
||||
/** |
||||
* Created by mengao on 2017/8/18. |
||||
*/ |
||||
public class ChartConditionNameObjectCreator extends NameObjectCreator { |
||||
private BasePlot plot; |
||||
private ConditionUIMenuNameableCreator conditionUIMenuNameableCreator; |
||||
|
||||
public ChartConditionNameObjectCreator(BasePlot plot, String menuName, Class clazz, Class<? extends BasicBeanPane> updatePane) { |
||||
super(menuName, clazz, updatePane); |
||||
this.plot = plot; |
||||
} |
||||
|
||||
/** |
||||
* create Nameable |
||||
* |
||||
* @param helper |
||||
* @return |
||||
*/ |
||||
public Nameable createNameable(UnrepeatedNameHelper helper) { |
||||
Constructor<? extends ConditionUIMenuNameableCreator> constructor = null; |
||||
try { |
||||
constructor = clazzOfInitCase.getConstructor(Plot.class, String.class, Object.class, Class.class); |
||||
ConditionUIMenuNameableCreator conditionUIMenuNameableCreator = constructor.newInstance(plot, Inter.getLocText("Chart-Condition_Attributes"), new ConditionAttr(), getUpdatePane()); |
||||
return new NameObject(helper.createUnrepeatedName(this.menuName()), conditionUIMenuNameableCreator); |
||||
|
||||
} catch (NoSuchMethodException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} catch (InstantiationException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvocationTargetException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* @param ob |
||||
* @return |
||||
*/ |
||||
public Object acceptObject2Populate(Object ob) { |
||||
if (ob instanceof NameObject) { |
||||
ob = ((NameObject) ob).getObject(); |
||||
} |
||||
if (clazzOfObject != null && clazzOfObject.isInstance(ob)) { |
||||
doSthChanged4Icon(ob); |
||||
conditionUIMenuNameableCreator = (ConditionUIMenuNameableCreator) ((ConditionUIMenuNameableCreator) ob).clone(); |
||||
return ob; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* save update bean |
||||
* |
||||
* @param wrapper |
||||
* @param bean |
||||
*/ |
||||
public void saveUpdatedBean(ListModelElement wrapper, Object bean) { |
||||
conditionUIMenuNameableCreator.setObj(bean); |
||||
((NameObject) wrapper.wrapper).setObject(conditionUIMenuNameableCreator); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,84 @@
|
||||
package com.fr.plugin.chart.designer.other; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.controlpane.NameObjectCreator; |
||||
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; |
||||
import com.fr.design.gui.ilist.ListModelElement; |
||||
import com.fr.design.gui.imenutable.UIMenuNameableCreator; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.stable.Nameable; |
||||
|
||||
import java.lang.reflect.Constructor; |
||||
import java.lang.reflect.InvocationTargetException; |
||||
|
||||
/** |
||||
* Created by mengao on 2017/8/21. |
||||
*/ |
||||
public class ChartHyperlinkNameObjectCreartor extends NameObjectCreator { |
||||
private Object object; |
||||
private UIMenuNameableCreator uIMenuNameableCreator; |
||||
|
||||
|
||||
public ChartHyperlinkNameObjectCreartor(Object object, String menuName, Class clazz, Class<? extends BasicBeanPane> updatePane) { |
||||
super(menuName, clazz, updatePane); |
||||
this.object = object; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* create Nameable |
||||
* |
||||
* @param helper |
||||
* @return |
||||
*/ |
||||
public Nameable createNameable(UnrepeatedNameHelper helper) { |
||||
Constructor<? extends UIMenuNameableCreator> constructor = null; |
||||
try { |
||||
constructor = clazzOfInitCase.getConstructor(String.class, Object.class, Class.class); |
||||
UIMenuNameableCreator uIMenuNameableCreator = constructor.newInstance(menuName, object, getUpdatePane()); |
||||
return new NameObject(helper.createUnrepeatedName(this.menuName()), uIMenuNameableCreator); |
||||
|
||||
} catch (NoSuchMethodException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} catch (InstantiationException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvocationTargetException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* @param ob |
||||
* @return |
||||
*/ |
||||
public Object acceptObject2Populate(Object ob) { |
||||
if (ob instanceof NameObject) { |
||||
ob = ((NameObject) ob).getObject(); |
||||
} |
||||
if (clazzOfObject != null && clazzOfObject.isInstance(ob)) { |
||||
doSthChanged4Icon(ob); |
||||
uIMenuNameableCreator = ((UIMenuNameableCreator) ob).clone(); |
||||
if (uIMenuNameableCreator.getObj() != null && object.getClass().isInstance(uIMenuNameableCreator.getObj())) { |
||||
return ob; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* save update bean |
||||
* |
||||
* @param wrapper |
||||
* @param bean |
||||
*/ |
||||
public void saveUpdatedBean(ListModelElement wrapper, Object bean) { |
||||
uIMenuNameableCreator.setObj(bean); |
||||
((NameObject) wrapper.wrapper).setObject(uIMenuNameableCreator); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,102 @@
|
||||
package com.fr.plugin.chart.designer.other; |
||||
|
||||
import com.fr.base.chart.BasePlot; |
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.chart.chartglyph.ConditionAttr; |
||||
import com.fr.chart.chartglyph.ConditionCollection; |
||||
import com.fr.design.ChartTypeInterfaceManager; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.controlpane.NameableCreator; |
||||
import com.fr.design.gui.controlpane.UIListControlPane; |
||||
import com.fr.design.gui.imenutable.UIMenuNameableCreator; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.plugin.chart.attr.plot.VanChartPlot; |
||||
import com.fr.plugin.chart.designer.component.ConditionUIMenuNameableCreator; |
||||
import com.fr.stable.Nameable; |
||||
|
||||
import java.lang.reflect.Constructor; |
||||
import java.lang.reflect.InvocationTargetException; |
||||
|
||||
/** |
||||
* Created by mengao on 2017/8/18. |
||||
*/ |
||||
public class VanChartListControlPane extends UIListControlPane { |
||||
|
||||
public VanChartListControlPane(BasePlot plot) { |
||||
super(plot); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(Nameable[] nameableArray) { |
||||
initComponentPane(); |
||||
super.populate(nameableArray); |
||||
} |
||||
|
||||
@Override |
||||
public NameableCreator[] createNameableCreators() { |
||||
return new ChartConditionNameObjectCreator[]{new ChartConditionNameObjectCreator(this.plot, Inter.getLocText("Condition_Attributes"), ConditionUIMenuNameableCreator.class, ChartTypeInterfaceManager.getInstance().getPlotConditionPane((Plot) plot).getClass())}; |
||||
} |
||||
|
||||
|
||||
protected BasicBeanPane createPaneByCreators(NameableCreator creator) { |
||||
Constructor<? extends BasicBeanPane> constructor = null; |
||||
try { |
||||
constructor = creator.getUpdatePane().getConstructor(Plot.class); |
||||
return constructor.newInstance(plot); |
||||
|
||||
} catch (InstantiationException e) { |
||||
throw new RuntimeException(e); |
||||
} catch (IllegalAccessException e) { |
||||
throw new RuntimeException(e); |
||||
} catch (NoSuchMethodException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvocationTargetException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void saveSettings() { |
||||
if (isPopulating) { |
||||
return; |
||||
} |
||||
updateConditionCollection(((VanChartPlot) plot).getConditionCollection()); |
||||
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); |
||||
} |
||||
|
||||
@Override |
||||
public String getAddItemText() { |
||||
return Inter.getLocText("FR-Designer_Add_Condition"); |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText("Condition_Attributes"); |
||||
} |
||||
|
||||
protected Object getob2Populate(Object ob2Populate) { |
||||
return ((ConditionUIMenuNameableCreator) ob2Populate).getObj(); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Update. |
||||
*/ |
||||
public void updateConditionCollection(ConditionCollection cc) { |
||||
Nameable[] nameables = this.update(); |
||||
|
||||
cc.clearConditionAttr(); |
||||
|
||||
for (int i = 0; i < nameables.length; i++) { |
||||
UIMenuNameableCreator uiMenuNameableCreator = (UIMenuNameableCreator) ((NameObject) nameables[i]).getObject(); |
||||
ConditionAttr ca = (ConditionAttr) uiMenuNameableCreator.getObj(); |
||||
ca.setName(nameables[i].getName()); |
||||
cc.addConditionAttr(ca); |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
@ -1,13 +1,13 @@
|
||||
package com.fr.plugin.chart.map.designer.other; |
||||
|
||||
import com.fr.plugin.chart.designer.other.AbstractConditionAttrContentPane; |
||||
import com.fr.plugin.chart.designer.other.VanChartConditionAttrContentPane; |
||||
import com.fr.plugin.chart.designer.other.VanChartConditionAttrPane; |
||||
|
||||
/** |
||||
* Created by Mitisky on 16/5/20. |
||||
*/ |
||||
public class VanChartMapConditionAttrPane extends VanChartConditionAttrPane{ |
||||
protected AbstractConditionAttrContentPane createConditionAttrContentPane() { |
||||
protected VanChartConditionAttrContentPane createConditionAttrContentPane() { |
||||
return new VanChartMapConditionAttrContentPane(); |
||||
} |
||||
} |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue