Browse Source

REPORT-9061 记住历史颜色功能bug

master
Mata.Li 6 years ago
parent
commit
44aac62eb8
  1. 20
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 85
      designer-base/src/com/fr/design/style/color/ColorSelectConfigManager.java

20
designer-base/src/com/fr/design/DesignerEnvManager.java

@ -13,6 +13,7 @@ import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter; import com.fr.general.FRLogFormatter;
@ -127,7 +128,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
//记录当前激活码的在线激活状态. //记录当前激活码的在线激活状态.
private int activeKeyStatus = -1; private int activeKeyStatus = -1;
private boolean joinProductImprove = true; private boolean joinProductImprove = true;
//最近使用的颜色
private ColorSelectConfigManager configManager = ColorSelectConfigManager.getInstance();
/** /**
* alphafine * alphafine
*/ */
@ -1293,6 +1295,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
private void readRecentColor(XMLableReader reader){
reader.readXMLObject(this.configManager);
}
/** /**
* Read XML.<br> * Read XML.<br>
* The method will be invoked when read data from XML file.<br> * The method will be invoked when read data from XML file.<br>
@ -1344,7 +1350,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readHttpsParas(reader); readHttpsParas(reader);
} else if (name.equals("AlphaFineConfigManager")) { } else if (name.equals("AlphaFineConfigManager")) {
readAlphaFineAttr(reader); readAlphaFineAttr(reader);
} else { } else if (name.equals("RecentColors")) {
readRecentColor(reader);
}
else {
readLayout(reader, name); readLayout(reader, name);
} }
} }
@ -1536,6 +1545,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeActiveStatus(writer); writeActiveStatus(writer);
writeHttpsParas(writer); writeHttpsParas(writer);
writeAlphaFineAttr(writer); writeAlphaFineAttr(writer);
writeRecentColor(writer);
writer.end(); writer.end();
} }
@ -1545,6 +1555,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
private void writeRecentColor(XMLPrintWriter writer) {
if (this.configManager != null) {
this.configManager.writeXML(writer);
}
}
public String getUUID() { public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid; return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
} }

85
designer-base/src/com/fr/design/style/color/ColorSelectConfigManager.java

@ -1,16 +1,12 @@
package com.fr.design.style.color; package com.fr.design.style.color;
import com.fr.base.FRContext;
import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.awt.*; import java.awt.*;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -19,12 +15,11 @@ import java.util.List;
* *
* @author focus * @author focus
*/ */
public class ColorSelectConfigManager extends XMLFileManager implements ColorSelectConfigManagerProvider { public class ColorSelectConfigManager implements XMLReadable {
// 最近使用的颜色个数 // 最近使用的颜色个数
private int colorNums = 20; private int colorNums = 20;
private static ColorSelectConfigManagerProvider configManager = null;
private static ColorSelectConfigManager colorSelectConfigManager = null; private static ColorSelectConfigManager colorSelectConfigManager = null;
private boolean init = true; private boolean init = true;
// 最近使用颜色 // 最近使用颜色
@ -32,29 +27,9 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
private static final String RECENT_COLOR_TAG = "RecentColors"; private static final String RECENT_COLOR_TAG = "RecentColors";
private static final String COLOR_TAG = "Color"; private static final String COLOR_TAG = "Color";
static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() {
ColorSelectConfigManager.envChanged();
}
});
}
private static void envChanged() {
configManager = null;
}
public Color[] getColors() { public Color[] getColors() {
//初次打开软件时从xml文件中获取历史颜色信息
if (init) {
ColorSelectConfigManagerProvider manager = ColorSelectConfigManager.getProviderInstance();
this.colors = manager.getColorsFromFile();
init = false;
}
if (colors == null) {
colors = new ArrayList<Color>();
}
return colors.toArray(new Color[colors.size()]); return colors.toArray(new Color[colors.size()]);
} }
@ -91,52 +66,25 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
/*@author yaohwu*/ /*@author yaohwu*/
//将历史颜色信息保存到xml文件中去 //将历史颜色信息保存到xml文件中去
ColorSelectConfigManagerProvider manager = ColorSelectConfigManager.getProviderInstance(); ColorSelectConfigManager manager = ColorSelectConfigManager.getInstance();
if (colors != null && !colors.isEmpty()) { if (colors != null && !colors.isEmpty()) {
manager.setColorsToFile(colors); manager.setColorsToFile(colors);
} }
} }
/**
* 读取配置文件流
*
* @param input
* @throws Exception 异常
*/
@Override
public void readFromInputStream(InputStream input) throws Exception {
ColorSelectConfigManager manager = new ColorSelectConfigManager();
XMLTools.readInputStreamXML(manager, input);
configManager = manager;
}
/**
* 获取配置管理接口
*
* @return 配置管理接口ConfigManagerProvider
*/
public synchronized static ColorSelectConfigManagerProvider getProviderInstance() {
if (configManager == null) {
configManager = new ColorSelectConfigManager();
configManager.readXMLFile();
}
return configManager;
}
public String fileName() {
return "recentcolors.xml";
}
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
String name = reader.getTagName(); reader.readXMLObject(new XMLReadable() {
if (reader.isChildNode()) { @Override
if (ComparatorUtils.equals(COLOR_TAG, name)) { public void readXML(XMLableReader reader) {
Color color = null; String tagName = reader.getTagName();
colors.add(reader.getAttrAsColor("colors", color)); if (reader.isChildNode()) {
if (ComparatorUtils.equals(COLOR_TAG, tagName)) {
Color color = null;
colors.add(reader.getAttrAsColor("colors", color));
}
}
} }
} });
} }
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
@ -151,9 +99,6 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
writer.end(); writer.end();
} }
public List<Color> getColorsFromFile() {
return this.colors;
}
public void setColorsToFile(List<Color> colors) { public void setColorsToFile(List<Color> colors) {
this.colors = colors; this.colors = colors;

Loading…
Cancel
Save