Browse Source

Merge pull request #206 in DESIGN/design from ~MATA.LI/designrel:release/10.0 to release/10.0

* commit '636edef2730d0184e6095d804ec2ca05c7c70886':
  REPORT-9061 记住历史颜色功能bug
  REPORT-9061 记住历史颜色功能bug
  REPORT-9061 记住历史颜色功能bug
master
Mata.Li 6 years ago
parent
commit
eb1588b81e
  1. 24
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 3
      designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java
  3. 93
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectConfigManager.java
  4. 3
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java
  5. 3
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  6. 5
      designer-base/src/main/java/com/fr/design/style/color/UsedColorPane.java
  7. 3
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartAccColorPane.java
  8. 7
      designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java

24
designer-base/src/main/java/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.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter;
@ -129,7 +130,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
//记录当前激活码的在线激活状态.
private int activeKeyStatus = -1;
private boolean joinProductImprove = true;
//最近使用的颜色
private ColorSelectConfigManager configManager = new ColorSelectConfigManager();
/**
* alphafine
*/
@ -190,6 +192,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return designerEnvManager;
}
public ColorSelectConfigManager getColorConfigManager(){
return this.configManager;
}
public static void checkNameEnvMap() {
if (designerEnvManager == null || designerEnvManager.nameEnvMap.size() > 0) {
return;
@ -1299,6 +1305,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
private void readRecentColor(XMLableReader reader){
reader.readXMLObject(this.configManager);
}
/**
* Read XML.<br>
* The method will be invoked when read data from XML file.<br>
@ -1350,7 +1360,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readHttpsParas(reader);
} else if (name.equals("AlphaFineConfigManager")) {
readAlphaFineAttr(reader);
} else {
} else if (name.equals("RecentColors")) {
readRecentColor(reader);
}
else {
readLayout(reader, name);
}
}
@ -1542,6 +1555,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeActiveStatus(writer);
writeHttpsParas(writer);
writeAlphaFineAttr(writer);
writeRecentColor(writer);
writer.end();
}
@ -1551,6 +1565,12 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
private void writeRecentColor(XMLPrintWriter writer) {
if (this.configManager != null) {
this.configManager.writeXML(writer);
}
}
public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid;
}

3
designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java

@ -19,6 +19,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.design.DesignerEnvManager;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.itextfield.UINumberField;
@ -104,7 +105,7 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, GradientBar.this);
Color color = GradientBar.this.getColor();
if (color != null) {
ColorSelectConfigManager.getInstance().addToColorQueue(color);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
list.get(select).setColorInner(color);
stateChanged();
GradientBar.this.repaint();

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

@ -1,16 +1,12 @@
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.GeneralContext;
import com.fr.stable.EnvChangedListener;
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 java.awt.*;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@ -19,42 +15,20 @@ import java.util.List;
*
* @author focus
*/
public class ColorSelectConfigManager extends XMLFileManager implements ColorSelectConfigManagerProvider {
public class ColorSelectConfigManager implements XMLReadable {
// 最近使用的颜色个数
private int colorNums = 20;
private static ColorSelectConfigManagerProvider configManager = null;
private static ColorSelectConfigManager colorSelectConfigManager = null;
private boolean init = true;
// 最近使用颜色
private List<Color> colors = new ArrayList<Color>();
private static final String RECENT_COLOR_TAG = "RecentColors";
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() {
//初次打开软件时从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()]);
}
@ -66,12 +40,6 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
this.colorNums = colorNums;
}
public synchronized static ColorSelectConfigManager getInstance() {
if (colorSelectConfigManager == null) {
colorSelectConfigManager = new ColorSelectConfigManager();
}
return colorSelectConfigManager;
}
/**
* 添加颜色到最近使用队列中
@ -91,52 +59,24 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
/*@author yaohwu*/
//将历史颜色信息保存到xml文件中去
ColorSelectConfigManagerProvider manager = ColorSelectConfigManager.getProviderInstance();
if (colors != null && !colors.isEmpty()) {
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();
this.setColorsToFile(colors);
}
return configManager;
}
public String fileName() {
return "recentcolors.xml";
}
public void readXML(XMLableReader reader) {
String name = reader.getTagName();
if (reader.isChildNode()) {
if (ComparatorUtils.equals(COLOR_TAG, name)) {
Color color = null;
colors.add(reader.getAttrAsColor("colors", color));
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
String tagName = reader.getTagName();
if (reader.isChildNode()) {
if (ComparatorUtils.equals(COLOR_TAG, tagName)) {
Color color = null;
colors.add(reader.getAttrAsColor("colors", color));
}
}
}
}
});
}
public void writeXML(XMLPrintWriter writer) {
@ -151,9 +91,6 @@ public class ColorSelectConfigManager extends XMLFileManager implements ColorSel
writer.end();
}
public List<Color> getColorsFromFile() {
return this.colors;
}
public void setColorsToFile(List<Color> colors) {
this.colors = colors;

3
designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java

@ -3,6 +3,7 @@
*/
package com.fr.design.style.color;
import com.fr.design.DesignerEnvManager;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
@ -159,7 +160,7 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
}
}
ColorSelectConfigManager.getInstance().addToColorQueue(color);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
this.repaint();
}

3
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -1,5 +1,6 @@
package com.fr.design.style.color;
import com.fr.design.DesignerEnvManager;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
@ -163,7 +164,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
this.colorChangeListenerList.get(i).stateChanged(evt);
}
}
ColorSelectConfigManager.getInstance().addToColorQueue(color);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
this.repaint();
}

5
designer-base/src/main/java/com/fr/design/style/color/UsedColorPane.java

@ -1,5 +1,6 @@
package com.fr.design.style.color;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.SpecialUIButton;
@ -66,7 +67,7 @@ public class UsedColorPane extends BasicPane {
panel.setLayout(new GridLayout(rows, columns, 1, 1));
panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
//最近使用颜色
Color[] colors = ColorSelectConfigManager.getInstance().getColors();
Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors();
int size = colors.length;
int i = 0;
if (needPickColorButton) {
@ -96,7 +97,7 @@ public class UsedColorPane extends BasicPane {
*/
public void updateUsedColor() {
int total = columns * rows;
Color[] colors = ColorSelectConfigManager.getInstance().getColors();
Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors();
int size = colors.length;
for (int i = this.reserveCells; i < total; i++) {
ColorCell cell = (ColorCell) this.pane.getComponent(i);

3
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartAccColorPane.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.chart.gui.style;
import com.fr.chart.base.ChartConstants;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
@ -122,7 +123,7 @@ public class ChartAccColorPane extends BasicPane implements MouseListener, UIObs
Color choosedColor = this.getColor();
if (choosedColor != null) {
colors[currentIndex] = choosedColor;
ColorSelectConfigManager.getInstance().addToColorQueue(choosedColor);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(choosedColor);
ChartAccColorPane.this.stateChanged();
}
ChartAccColorPane.this.repaint();

7
designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java

@ -1,6 +1,7 @@
package com.fr.van.chart.range.component;
import com.fr.chart.base.ChartBaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.mainframe.DesignerContext;
@ -263,7 +264,7 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this);
Color color = LegendGradientBar.this.getColor();
if (color != null) {
ColorSelectConfigManager.getInstance().addToColorQueue(color);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
selectColorPointBtnList.get(select).setColorInner(color);
LegendGradientBar.this.repaint();
@ -276,7 +277,7 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this);
Color color = LegendGradientBar.this.getColor();
if (color != null) {
ColorSelectConfigManager.getInstance().addToColorQueue(color);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
selectColorSlotBtnStart.setColorInner(color);
//stateChanged();
LegendGradientBar.this.repaint();
@ -286,7 +287,7 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this);
Color color = LegendGradientBar.this.getColor();
if (color != null) {
ColorSelectConfigManager.getInstance().addToColorQueue(color);
DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color);
selectColorSlotBtnEnd.setColorInner(color);
//stateChanged();
LegendGradientBar.this.repaint();

Loading…
Cancel
Save