forked from fanruan/design
Browse Source
* commit '857bc45f43fdd8b686202eb260f2d0a97961a1ec': (152 commits) REPORT-60163 公式编辑器优化2.0 1.优化错误提示 2.修改埋点逻辑 REPORT-63524 【组件可更新提醒】组件复用-埋点,现在设计器端弹出可更新弹窗时没有触发埋点记录 REPORT-63192 【组件可更新提醒】组件复用-设计器端生成组件弹窗的类型改为必填 REPORT-63192 【组件可更新提醒】组件复用-设计器端生成组件弹窗的类型改为必填 REPORT-63311【接触点优化】轮播期间切换组件设置页面,轮播停住了 REPORT-62672【接触点优化】部分埋点无法模拟对应埋点数据 CHART-22060 fix:fvs图表第一个不是跟随主题default 是normal REPORT-63308【接触点优化】轮播期间在组件上右键的交互问题 REPORT-62175 && REPORT-63204 1.埋点适配 2.针对sum(1,)等此类公式进行合法性判断 CHART-22038 决策报表,安装ECharts后,图表块插入图表区域不显示echarts的图标 REPORT-63305 设计器获取父容器,需要对拓展的布局插件兼容处理下 REPORT-63196 && REPORT-63186 1.在双击之后使搜索框消失; 2.模拟计算在计算错误的时候提示计算异常 REPORT-62672【接触点优化】部分埋点无法模拟对应埋点数据 REPORT-63250 组件可更新视觉验收 REPORT-63190【接触点优化】轮播过程中切换组件包,再回来发现显示有问题 REPORT-63194 【组件可更新提醒】组件复用-适配设计器字段输入框输入时会出现字符消失的情况 REPORT-63192 【组件可更新提醒】组件复用-设计器端生成组件弹窗的类型改为必填 REPORT-63102 公式编辑器优化,多行函数错误返回值异常 1.定制一个没有newline的frformulalexer REPORT-62477 组件复用-10设计器在线组件预期不能看到11组件 REPORT-62808 公式编辑器优化,辅助框内选择函数后,函数名没有正确跳转 1.修复单击实现偶然失效的bug; 2.修复上下键不生效的bug。 ...persist/11.0
superman
3 years ago
186 changed files with 10419 additions and 1979 deletions
@ -0,0 +1,193 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.CloudCenterConfig; |
||||
import com.fr.general.http.HttpToolbox; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.ProductConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLReaderHelper; |
||||
import com.fr.stable.xml.XMLTools; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.third.javax.xml.stream.XMLStreamException; |
||||
import com.fr.third.org.apache.commons.io.FileUtils; |
||||
|
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.HashMap; |
||||
import java.util.Iterator; |
||||
import java.util.Map; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
/** |
||||
* Created by kerry on 2021/10/22 |
||||
*/ |
||||
public class DesignerCloudURLManager implements XMLable { |
||||
private static final String CLOUD_URL_INFO = "cloudUrl.info"; |
||||
private static final String ROOT_XML_TAG = "CloudUrlInfoList"; |
||||
private static final String CHILD_XML_TAG = "CloudUrlInfo"; |
||||
private final Map<String, String> urlMap = new HashMap<>(); |
||||
|
||||
public static DesignerCloudURLManager getInstance() { |
||||
return DesignerCloudURLManager.HOLDER.singleton; |
||||
} |
||||
|
||||
private final ExecutorService executorService = Executors.newSingleThreadExecutor(new NamedThreadFactory("TestCloudConnectThread")); |
||||
|
||||
private volatile boolean testResult; |
||||
|
||||
|
||||
private static class HOLDER { |
||||
private static final DesignerCloudURLManager singleton = new DesignerCloudURLManager(); |
||||
} |
||||
|
||||
private DesignerCloudURLManager() { |
||||
loadURLXMLFile(); |
||||
} |
||||
|
||||
public String acquireUrlByKind(String key) { |
||||
String url = urlMap.getOrDefault(key, StringUtils.EMPTY); |
||||
if (StringUtils.isEmpty(url)) { |
||||
//本地缓存中为空时,直接从云中心获取,获取完成后异步更新本地缓存文件
|
||||
String latestUrl = CloudCenter.getInstance().acquireConf(key, StringUtils.EMPTY); |
||||
executorService.submit(() -> { |
||||
updateURLXMLFile(key, latestUrl); |
||||
}); |
||||
return latestUrl; |
||||
} |
||||
//本地缓存不为空时,直接返回对应 url,同时异步更新
|
||||
executorService.submit(() -> { |
||||
String latestUrl = CloudCenter.getInstance().acquireConf(key, StringUtils.EMPTY); |
||||
updateURLXMLFile(key, latestUrl); |
||||
}); |
||||
return url; |
||||
} |
||||
|
||||
private synchronized void updateURLXMLFile(String key, String url) { |
||||
if (StringUtils.isNotEmpty(url) && (!urlMap.containsKey(key) || !url.equals(urlMap.get(key)))) { |
||||
urlMap.put(key, url); |
||||
saveURLXMLFile(); |
||||
} |
||||
} |
||||
|
||||
|
||||
public void testConnect() { |
||||
executorService.submit(() -> { |
||||
testResult = isOnline(); |
||||
}); |
||||
} |
||||
|
||||
public boolean isConnected() { |
||||
return testResult; |
||||
} |
||||
|
||||
public boolean isOnline() { |
||||
if (CloudCenterConfig.getInstance().isOnline()) { |
||||
String ping = acquireUrlByKind("ping"); |
||||
if (StringUtils.isNotEmpty(ping)) { |
||||
try { |
||||
return StringUtils.isEmpty(HttpToolbox.get(ping)); |
||||
} catch (Exception ignore) { |
||||
} |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 加载本地 url 管理文件 |
||||
*/ |
||||
private void loadURLXMLFile() { |
||||
if (!getInfoFile().exists()) { |
||||
return; |
||||
} |
||||
XMLableReader reader = null; |
||||
try (InputStream in = new FileInputStream(getInfoFile())) { |
||||
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
|
||||
reader = XMLReaderHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER); |
||||
if (reader == null) { |
||||
return; |
||||
} |
||||
reader.readXMLObject(this); |
||||
} catch (FileNotFoundException e) { |
||||
// do nothing
|
||||
} catch (XMLStreamException | IOException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} finally { |
||||
try { |
||||
if (reader != null) { |
||||
reader.close(); |
||||
} |
||||
} catch (XMLStreamException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private File getInfoFile() { |
||||
|
||||
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), CLOUD_URL_INFO)); |
||||
try { |
||||
if (!file.exists()) { |
||||
file.createNewFile(); |
||||
} |
||||
} catch (Exception ex) { |
||||
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
||||
} |
||||
return file; |
||||
} |
||||
|
||||
/** |
||||
* 保存到本地 URL 管理文件中,存放在 .Finereport110 中 |
||||
*/ |
||||
void saveURLXMLFile() { |
||||
try { |
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
XMLTools.writeOutputStreamXML(this, out); |
||||
out.flush(); |
||||
out.close(); |
||||
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); |
||||
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8); |
||||
} catch (Exception ex) { |
||||
FineLoggerFactory.getLogger().error(ex.getMessage()); |
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
String tagName = reader.getTagName(); |
||||
if (tagName.equals(CHILD_XML_TAG)) { |
||||
String key = reader.getAttrAsString("key", StringUtils.EMPTY); |
||||
String value = reader.getAttrAsString("url", StringUtils.EMPTY); |
||||
this.urlMap.put(key, value); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter xmlPrintWriter) { |
||||
xmlPrintWriter.startTAG(ROOT_XML_TAG); |
||||
Iterator<Map.Entry<String, String>> iterable = urlMap.entrySet().iterator(); |
||||
while (iterable.hasNext()) { |
||||
Map.Entry<String, String> entry = iterable.next(); |
||||
xmlPrintWriter.startTAG(CHILD_XML_TAG).attr("key", entry.getKey()).attr("url", entry.getValue()).end(); |
||||
} |
||||
xmlPrintWriter.end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
return null; |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,91 +1,48 @@
|
||||
package com.fr.design.formula; |
||||
|
||||
import com.fr.design.formula.exception.FormulaExceptionTipsProcessor; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.parser.FRLexer; |
||||
import com.fr.parser.FRParser; |
||||
import com.fr.script.checker.FunctionCheckerDispatcher; |
||||
import com.fr.script.checker.exception.ConditionCheckWrongException; |
||||
import com.fr.script.checker.exception.FunctionCheckWrongException; |
||||
import com.fr.script.rules.FunctionParameterType; |
||||
import com.fr.script.rules.FunctionRule; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.script.Expression; |
||||
import com.fr.stable.script.Node; |
||||
import com.fr.third.antlr.TokenStreamRecognitionException; |
||||
|
||||
import java.io.StringReader; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/9/28 |
||||
*/ |
||||
public class FormulaChecker { |
||||
private static final String VALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula"); |
||||
private static final String INVALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula"); |
||||
public static final String COLON = ":"; |
||||
public static final String VALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula"); |
||||
public static final String INVALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula"); |
||||
private static FormulaExceptionTipsProcessor processor = FormulaExceptionTipsProcessor.getProcessor(); |
||||
|
||||
public static String check(String formulaText) throws FormulaCheckerException { |
||||
public static FormulaCheckResult check(String formulaText) { |
||||
if (StringUtils.isEmpty(formulaText) || formulaText.equals(Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Tips"))) { |
||||
return new FormulaCheckResult(true, VALID_FORMULA, FormulaCoordinates.INVALID, true); |
||||
} |
||||
//过滤一些空格等符号
|
||||
StringReader in = new StringReader(formulaText); |
||||
|
||||
FRLexer lexer = new FRLexer(in); |
||||
//此lexer为公式校验定制
|
||||
FRFormulaLexer lexer = new FRFormulaLexer(in); |
||||
FRParser parser = new FRParser(lexer); |
||||
|
||||
try { |
||||
Expression expression = parser.parse(); |
||||
Node node = expression.getConditionalExpression(); |
||||
boolean valid = FunctionCheckerDispatcher.getInstance().getFunctionChecker(node).checkFunction(node); |
||||
if (valid) { |
||||
return VALID_FORMULA; |
||||
} else { |
||||
throw new FormulaCheckerException(INVALID_FORMULA); |
||||
} |
||||
} catch (ConditionCheckWrongException cce) { |
||||
String functionName = cce.getFunctionName(); |
||||
throw new FormulaCheckerException(functionName + Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + COLON); |
||||
} catch (FunctionCheckWrongException ce) { |
||||
List<FunctionRule> rules = ce.getRules(); |
||||
String functionName = ce.getFunctionName(); |
||||
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Error_Tips") + COLON); |
||||
for (int i = 0; i < rules.size(); i++) { |
||||
errorMsg.append("("); |
||||
if (rules.get(i).getParameterList().isEmpty()) { |
||||
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_No_Param")); |
||||
} |
||||
for (FunctionParameterType functionParameterType : rules.get(i).getParameterList()) { |
||||
errorMsg.append(getTypeString(functionParameterType)).append(","); |
||||
} |
||||
if (",".equals(errorMsg.charAt(errorMsg.length() - 1) + "")) { |
||||
errorMsg.deleteCharAt(errorMsg.length() - 1); |
||||
} |
||||
errorMsg.append(")"); |
||||
if (i != rules.size() - 1) { |
||||
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or")); |
||||
} |
||||
} |
||||
throw new FormulaCheckerException(errorMsg.toString()); |
||||
boolean valid = FunctionCheckerDispatcher.getInstance().getFunctionChecker(node).checkFunction(formulaText, node); |
||||
return new FormulaCheckResult(valid, valid ? Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") : |
||||
Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula"), FormulaCoordinates.INVALID, true); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
throw new FormulaCheckerException(INVALID_FORMULA); |
||||
// alex:继续往下面走,expression为null时告知不合法公式
|
||||
if (e instanceof TokenStreamRecognitionException) { |
||||
return processor.getExceptionTips(((TokenStreamRecognitionException) e).recog); |
||||
} |
||||
return processor.getExceptionTips(e); |
||||
} |
||||
|
||||
private static String getTypeString(FunctionParameterType type) { |
||||
switch (type) { |
||||
case NUMBER: |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Number"); |
||||
case STRING: |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_String"); |
||||
case ANY: |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Any"); |
||||
case DATE: |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Date"); |
||||
case BOOLEAN: |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Boolean"); |
||||
case ARRAY: |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Array"); |
||||
} |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,48 @@
|
||||
package com.fr.design.formula.exception; |
||||
|
||||
import com.fr.design.formula.FormulaChecker; |
||||
import com.fr.design.formula.exception.function.FormulaCheckWrongFunction; |
||||
import com.fr.design.formula.exception.function.MismatchedCharFunction; |
||||
import com.fr.design.formula.exception.function.MismatchedTokenFunction; |
||||
import com.fr.design.formula.exception.function.NoViableAltForCharFunction; |
||||
import com.fr.design.formula.exception.function.NoViableAltFunction; |
||||
import com.fr.script.checker.exception.FunctionCheckWrongException; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.third.antlr.MismatchedCharException; |
||||
import com.fr.third.antlr.MismatchedTokenException; |
||||
import com.fr.third.antlr.NoViableAltException; |
||||
import com.fr.third.antlr.NoViableAltForCharException; |
||||
|
||||
import java.util.Map; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/26 |
||||
*/ |
||||
public class FormulaExceptionTipsProcessor { |
||||
private static final Map<Class, Function<Exception, FormulaCheckResult>> EXCEPTION_TIPS = new ConcurrentHashMap<>(); |
||||
|
||||
private static final FormulaExceptionTipsProcessor PROCESSOR = new FormulaExceptionTipsProcessor(); |
||||
|
||||
static { |
||||
EXCEPTION_TIPS.put(FunctionCheckWrongException.class, FormulaCheckWrongFunction.getFunction()); |
||||
EXCEPTION_TIPS.put(MismatchedCharException.class, MismatchedCharFunction.getFunction()); |
||||
EXCEPTION_TIPS.put(MismatchedTokenException.class, MismatchedTokenFunction.getFunction()); |
||||
EXCEPTION_TIPS.put(NoViableAltException.class, NoViableAltFunction.getFunction()); |
||||
EXCEPTION_TIPS.put(NoViableAltForCharException.class, NoViableAltForCharFunction.getFunction()); |
||||
|
||||
} |
||||
|
||||
public FormulaCheckResult getExceptionTips(Exception e) { |
||||
return EXCEPTION_TIPS.getOrDefault(e.getClass(), |
||||
e1 -> new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false)) |
||||
.apply(e); |
||||
} |
||||
|
||||
public static FormulaExceptionTipsProcessor getProcessor() { |
||||
return PROCESSOR; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/28 |
||||
*/ |
||||
public class FormulaCheckConstants { |
||||
public static final String COLON = ":"; |
||||
public static final String LEFT = "("; |
||||
public static final String COMMON = ","; |
||||
public static final String RIGHT = ")"; |
||||
public static final String BLANK = " "; |
||||
public static final String SINGLE_QUOTES = "'"; |
||||
} |
@ -0,0 +1,78 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.script.checker.exception.FunctionCheckWrongException; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.script.rules.FunctionParameterType; |
||||
import com.fr.script.rules.FunctionRule; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.util.List; |
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/26 |
||||
*/ |
||||
public class FormulaCheckWrongFunction implements Function<Exception, FormulaCheckResult> { |
||||
private final static FormulaCheckWrongFunction FUNCTION = new FormulaCheckWrongFunction(); |
||||
|
||||
@Override |
||||
public FormulaCheckResult apply(Exception e) { |
||||
if (e instanceof FunctionCheckWrongException) { |
||||
FunctionCheckWrongException ce = (FunctionCheckWrongException) e; |
||||
List<FunctionRule> rules = ce.getRules(); |
||||
String functionName = ce.getFunctionName(); |
||||
StringBuilder errorMsg = new StringBuilder(functionName + Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Error_Tips") + FormulaCheckConstants.COLON); |
||||
for (int i = 0; i < rules.size(); i++) { |
||||
errorMsg.append(FormulaCheckConstants.LEFT); |
||||
if (rules.get(i).getParameterList().isEmpty()) { |
||||
errorMsg.append(Toolkit.i18nText("Fine-Design_Basic_Formula_No_Param")); |
||||
} |
||||
for (FunctionParameterType functionParameterType : rules.get(i).getParameterList()) { |
||||
errorMsg.append(getTypeString(functionParameterType)).append(FormulaCheckConstants.COMMON); |
||||
} |
||||
if (FormulaCheckConstants.COMMON.equals(errorMsg.charAt(errorMsg.length() - 1) + StringUtils.EMPTY)) { |
||||
errorMsg.deleteCharAt(errorMsg.length() - 1); |
||||
} |
||||
errorMsg.append(FormulaCheckConstants.RIGHT); |
||||
if (i != rules.size() - 1) { |
||||
errorMsg.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or")); |
||||
} |
||||
} |
||||
return new FormulaCheckResult(false, errorMsg.toString(), new FormulaCoordinates(1, indexPosition(ce.getFormulaText(), ce.getNode().toString())), true); |
||||
} |
||||
return new FormulaCheckResult(false, StringUtils.EMPTY, new FormulaCoordinates(-1, -1), true); |
||||
} |
||||
|
||||
private static String getTypeString(FunctionParameterType type) { |
||||
switch (type) { |
||||
case NUMBER: |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Number"); |
||||
case STRING: |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_String"); |
||||
case ANY: |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Any"); |
||||
case DATE: |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Date"); |
||||
case BOOLEAN: |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Boolean"); |
||||
case ARRAY: |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Array"); |
||||
} |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
public static Function<Exception, FormulaCheckResult> getFunction() { |
||||
return FUNCTION; |
||||
} |
||||
|
||||
private int indexPosition(String formulaText, String invalidFormula) { |
||||
//处理一下自己FunctionCall自己拼的逗号逻辑
|
||||
if (invalidFormula.contains(",")) { |
||||
invalidFormula = invalidFormula.substring(0, invalidFormula.indexOf(",")); |
||||
} |
||||
return formulaText.indexOf(invalidFormula); |
||||
} |
||||
} |
@ -0,0 +1,95 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
import com.fr.design.formula.FormulaChecker; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.third.antlr.MismatchedCharException; |
||||
|
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/28 |
||||
*/ |
||||
public class MismatchedCharFunction implements Function<Exception, FormulaCheckResult> { |
||||
private final static MismatchedCharFunction FUNCTION = new MismatchedCharFunction(); |
||||
|
||||
@Override |
||||
public FormulaCheckResult apply(Exception e) { |
||||
if (e instanceof MismatchedCharException) { |
||||
MismatchedCharException charException = (MismatchedCharException) e; |
||||
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1); |
||||
return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates, false); |
||||
} |
||||
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false); |
||||
} |
||||
|
||||
public static Function<Exception, FormulaCheckResult> getFunction() { |
||||
return FUNCTION; |
||||
} |
||||
|
||||
private String getMessage(MismatchedCharException charException) { |
||||
StringBuffer sb = new StringBuffer(); |
||||
switch (charException.mismatchType) { |
||||
case 1: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": "); |
||||
appendCharName(sb, charException.expecting); |
||||
break; |
||||
case 2: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting_Anything") + ": ") |
||||
.append(FormulaCheckConstants.BLANK) |
||||
.append(FormulaCheckConstants.SINGLE_QUOTES); |
||||
appendCharName(sb, charException.expecting); |
||||
sb.append("';").append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_GotItAnyway")); |
||||
break; |
||||
case 3: |
||||
case 4: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ").append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Token")); |
||||
if (charException.mismatchType == 4) { |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Not")); |
||||
} |
||||
|
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_In_Range")).append(": "); |
||||
appendCharName(sb, charException.expecting); |
||||
sb.append(".."); |
||||
appendCharName(sb, charException.upper); |
||||
break; |
||||
case 5: |
||||
case 6: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ") |
||||
.append(charException.mismatchType == 6 ? Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Not") : FormulaCheckConstants.BLANK) |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ONE_OF")).append(" ("); |
||||
int[] elems = charException.set.toArray(); |
||||
|
||||
for (int i = 0; i < elems.length; ++i) { |
||||
appendCharName(sb, elems[i]); |
||||
} |
||||
break; |
||||
default: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_Char")); |
||||
} |
||||
|
||||
return sb.toString(); |
||||
} |
||||
|
||||
private void appendCharName(StringBuffer sb, int c) { |
||||
switch (c) { |
||||
case 9: |
||||
sb.append("'\\t'"); |
||||
break; |
||||
case 10: |
||||
sb.append("'\\n'"); |
||||
break; |
||||
case 13: |
||||
sb.append("'\\r'"); |
||||
break; |
||||
case 65535: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_EOF")); |
||||
break; |
||||
default: |
||||
sb.append((char) c); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,110 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
import com.fr.design.formula.FormulaChecker; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.antlr.MismatchedTokenException; |
||||
|
||||
import java.lang.reflect.Field; |
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/28 |
||||
*/ |
||||
public class MismatchedTokenFunction implements Function<Exception, FormulaCheckResult> { |
||||
private final static MismatchedTokenFunction FUNCTION = new MismatchedTokenFunction(); |
||||
public static final String NULL_STRING = "null"; |
||||
|
||||
@Override |
||||
public FormulaCheckResult apply(Exception e) { |
||||
if (e instanceof MismatchedTokenException) { |
||||
MismatchedTokenException charException = (MismatchedTokenException) e; |
||||
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1); |
||||
return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates, false); |
||||
} |
||||
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false); |
||||
} |
||||
|
||||
public static Function<Exception, FormulaCheckResult> getFunction() { |
||||
return FUNCTION; |
||||
} |
||||
|
||||
public String getMessage(MismatchedTokenException exception) { |
||||
StringBuilder sb = new StringBuilder(); |
||||
Object fieldValue = getFieldValue(exception, "tokenText"); |
||||
String tokenText = fieldValue == null ? NULL_STRING : fieldValue.toString(); |
||||
switch (exception.mismatchType) { |
||||
case 1: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ") |
||||
.append(tokenName(exception.expecting, exception)); |
||||
break; |
||||
case 2: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting_Anything") + ": ") |
||||
.append(tokenName(exception.expecting, exception)) |
||||
.append("; ") |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_GotItAnyway")); |
||||
break; |
||||
case 3: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ") |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Token")) |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_In_Range")) |
||||
.append(": ") |
||||
.append(tokenName(exception.expecting, exception)) |
||||
.append("..") |
||||
.append(tokenName(exception.upper, exception)); |
||||
break; |
||||
case 4: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ") |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Token")) |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Not")) |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_In_Range")) |
||||
.append(": ") |
||||
.append(tokenName(exception.expecting, exception)) |
||||
.append("..") |
||||
.append(tokenName(exception.upper, exception)); |
||||
break; |
||||
case 5: |
||||
case 6: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Expecting") + ": ") |
||||
.append(exception.mismatchType == 6 ? Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Not") : FormulaCheckConstants.BLANK) |
||||
.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ONE_OF")).append("("); |
||||
int[] elms = exception.set.toArray(); |
||||
|
||||
for (int i = 0; i < elms.length; ++i) { |
||||
sb.append(' '); |
||||
sb.append(tokenName(elms[i], exception)); |
||||
} |
||||
|
||||
break; |
||||
default: |
||||
sb.append(Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_Token")); |
||||
} |
||||
|
||||
return sb.toString(); |
||||
} |
||||
|
||||
private String tokenName(int tokenType, MismatchedTokenException exception) { |
||||
if (tokenType == 0) { |
||||
return "<Set of tokens>"; |
||||
} else { |
||||
String[] tokenNames = (String[]) getFieldValue(exception, "tokenNames"); |
||||
return tokenType >= 0 && tokenType < tokenNames.length ? TranslateTokenUtils.translateToken(tokenNames[tokenType]) : "<" + tokenType + ">"; |
||||
} |
||||
} |
||||
|
||||
|
||||
private Object getFieldValue(Object object, String fieldName) { |
||||
try { |
||||
Field field = object.getClass().getDeclaredField(fieldName); |
||||
field.setAccessible(true); |
||||
return field.get(object); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().warn(e.getMessage(), e); |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
import com.fr.design.formula.FormulaChecker; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.third.antlr.NoViableAltForCharException; |
||||
|
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/28 |
||||
*/ |
||||
public class NoViableAltForCharFunction implements Function<Exception, FormulaCheckResult> { |
||||
private final static NoViableAltForCharFunction FUNCTION = new NoViableAltForCharFunction(); |
||||
|
||||
@Override |
||||
public FormulaCheckResult apply(Exception e) { |
||||
if (e instanceof NoViableAltForCharException) { |
||||
NoViableAltForCharException charException = (NoViableAltForCharException) e; |
||||
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(charException.line, charException.column - 1); |
||||
return new FormulaCheckResult(false, getMessage(charException), formulaCoordinates, false); |
||||
} |
||||
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false); |
||||
} |
||||
|
||||
public static Function<Exception, FormulaCheckResult> getFunction() { |
||||
return FUNCTION; |
||||
} |
||||
|
||||
public String getMessage(NoViableAltForCharException exception) { |
||||
String mesg = Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Unexpected_Char") + ": "; |
||||
if (exception.foundChar >= ' ' && exception.foundChar <= '~') { |
||||
mesg = mesg + '\''; |
||||
mesg = mesg + exception.foundChar; |
||||
mesg = mesg + '\''; |
||||
} else { |
||||
mesg = mesg + exception.foundChar; |
||||
} |
||||
|
||||
return mesg; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
import com.fr.design.formula.FormulaChecker; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.script.checker.result.FormulaCheckResult; |
||||
import com.fr.script.checker.result.FormulaCoordinates; |
||||
import com.fr.third.antlr.NoViableAltException; |
||||
import com.fr.third.antlr.TreeParser; |
||||
|
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/10/28 |
||||
*/ |
||||
public class NoViableAltFunction implements Function<Exception, FormulaCheckResult> { |
||||
private final static NoViableAltFunction FUNCTION = new NoViableAltFunction(); |
||||
|
||||
@Override |
||||
public FormulaCheckResult apply(Exception e) { |
||||
if (e instanceof NoViableAltException) { |
||||
NoViableAltException altException = (NoViableAltException) e; |
||||
FormulaCoordinates formulaCoordinates = new FormulaCoordinates(altException.line, altException.column - 1); |
||||
return new FormulaCheckResult(false, getMessage(altException), formulaCoordinates, false); |
||||
} |
||||
return new FormulaCheckResult(false, FormulaChecker.INVALID_FORMULA, FormulaCoordinates.INVALID, false); |
||||
} |
||||
|
||||
public static Function<Exception, FormulaCheckResult> getFunction() { |
||||
return FUNCTION; |
||||
} |
||||
|
||||
public String getMessage(NoViableAltException exception) { |
||||
if (exception.token != null) { |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Unexpected_Token") + ": " + exception.token.getText(); |
||||
} else { |
||||
return exception.node == TreeParser.ASTNULL ? Toolkit.i18nText("Fine-Design_Basic_Formula_Check_End_Of_Subtree") : |
||||
Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Unexpected_AST_Node") + ": " + exception.node.toString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
package com.fr.design.formula.exception.function; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/11/30 |
||||
*/ |
||||
public class TranslateTokenUtils { |
||||
public static String translateToken(String token) { |
||||
switch (token) { |
||||
case ("RPAREN"): |
||||
return ")"; |
||||
case ("LPAREN"): |
||||
return "("; |
||||
case ("COMMA"): |
||||
return ","; |
||||
case ("COLON"): |
||||
return ":"; |
||||
case ("EOF"): |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Mismatched_EOF"); |
||||
case ("DOT"): |
||||
return "."; |
||||
case ("FLOT_NUM"): |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Float_Number"); |
||||
case ("LOR"): |
||||
return "||"; |
||||
case ("LAND"): |
||||
return "&&"; |
||||
case ("EQUAL"): |
||||
return "="; |
||||
case ("EQUAL2"): |
||||
return "="; |
||||
case ("NOT_EQUAL"): |
||||
return "!="; |
||||
case ("NOT_EQUAL2"): |
||||
return "!="; |
||||
case ("GE"): |
||||
return ">="; |
||||
case ("LE"): |
||||
return "<="; |
||||
case ("LT"): |
||||
return "<"; |
||||
case ("PLUS"): |
||||
return "+"; |
||||
case ("MINUS"): |
||||
return "-"; |
||||
case ("STAR"): |
||||
return "*"; |
||||
case ("DIV"): |
||||
return "/"; |
||||
case ("MOD"): |
||||
return "%"; |
||||
case ("POWER"): |
||||
return "^"; |
||||
case ("LNOT"): |
||||
return "!"; |
||||
case ("WAVE"): |
||||
return "~"; |
||||
case ("LBRACK"): |
||||
return "["; |
||||
case ("SEMI"): |
||||
return ";"; |
||||
case ("RBRACK"): |
||||
return "]"; |
||||
case ("LCURLY"): |
||||
return "{"; |
||||
case ("RCURLY"): |
||||
return "}"; |
||||
case ("DCOLON"): |
||||
return ";"; |
||||
case ("INT_NUM"): |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Integer"); |
||||
case ("CR_ADRESS"): |
||||
return "\n"; |
||||
case ("SHARP"): |
||||
return "#"; |
||||
case ("AT"): |
||||
return "@"; |
||||
case ("QUESTION"): |
||||
return "?"; |
||||
case ("BOR"): |
||||
return "||"; |
||||
case ("BAND"): |
||||
return "&&"; |
||||
case ("Char"): |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Character"); |
||||
case ("DIGIT"): |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Digital"); |
||||
case ("XDIGIT"): |
||||
return Toolkit.i18nText("Fine-Design_Basic_Formula_Hexadecimal_Digital"); |
||||
default: |
||||
return token; |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
package com.fr.design.gui.autocomplete; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Hoky |
||||
* @date 2021/11/5 |
||||
*/ |
||||
public class FormulaCompletion extends BasicCompletion { |
||||
private Icon icon; |
||||
|
||||
public FormulaCompletion(CompletionProvider provider, String replacementText, Icon icon) { |
||||
super(provider, replacementText); |
||||
this.icon = icon; |
||||
} |
||||
|
||||
@Override |
||||
public Icon getIcon() { |
||||
return icon; |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@
|
||||
package com.fr.design.icon; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.gui.itree.filetree.FileTreeIcon; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
|
||||
/** |
||||
* Created by kerry on 2021/11/11 |
||||
*/ |
||||
public class LocalFileIcon implements Icon { |
||||
private static final Icon FILE_LOCKED_ICON = BaseUtils.readIcon(FileTreeIcon.FILE_LOCKED_ICON_PATH); |
||||
private static final int OFFSET_X = 9; |
||||
private static final int OFFSET_Y = 8; |
||||
private final Icon mainIcon; |
||||
private final boolean showLock; |
||||
|
||||
public LocalFileIcon(Icon mainIcon, boolean showLock) { |
||||
this.mainIcon = mainIcon; |
||||
this.showLock = showLock; |
||||
} |
||||
|
||||
@Override |
||||
public void paintIcon(Component c, Graphics g, int x, int y) { |
||||
mainIcon.paintIcon(c, g, x, y); |
||||
if (showLock) { |
||||
FILE_LOCKED_ICON.paintIcon(c, g, OFFSET_X, OFFSET_Y); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int getIconWidth() { |
||||
return mainIcon.getIconWidth(); |
||||
} |
||||
|
||||
@Override |
||||
public int getIconHeight() { |
||||
return mainIcon.getIconHeight(); |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
public class ShowOnlineWidgetMark implements LocaleMark<Boolean> { |
||||
private Map<Locale, Boolean> map = new HashMap<>(); |
||||
|
||||
public ShowOnlineWidgetMark() { |
||||
map.put(Locale.CHINA, true); |
||||
map.put(Locale.TAIWAN, true); |
||||
map.put(Locale.US, false); |
||||
map.put(Locale.KOREA, false); |
||||
map.put(Locale.JAPAN, false); |
||||
} |
||||
|
||||
@Override |
||||
public Boolean getValue() { |
||||
Boolean result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? false : result; |
||||
} |
||||
} |
@ -1,169 +0,0 @@
|
||||
package com.fr.design.mainframe.reuse; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.PromptWindow; |
||||
import com.fr.design.mainframe.share.collect.ComponentCollector; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Dialog; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Font; |
||||
import java.awt.Frame; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Image; |
||||
import java.awt.RenderingHints; |
||||
import java.awt.geom.RoundRectangle2D; |
||||
|
||||
public class ReuseGuideDialog extends UIDialog implements PromptWindow { |
||||
InnerDialog innerDialog; |
||||
private static final Dimension DEFAULT = new Dimension(735, 510); |
||||
|
||||
public ReuseGuideDialog(Frame parent) { |
||||
super(parent); |
||||
} |
||||
|
||||
@Override |
||||
public void showWindow() { |
||||
innerDialog = new InnerDialog(this); |
||||
JPanel backGroundPane = new JPanel() { |
||||
@Override |
||||
protected void paintComponent(Graphics g) { |
||||
Image icon = IOUtils.readImage("com/fr/base/images/share/background.png");// 003.jpg是测试图片在项目的根目录下
|
||||
g.drawImage(icon, 0, 0, getSize().width, getSize().height, this);// 图片会自动缩放
|
||||
} |
||||
}; |
||||
add(backGroundPane, BorderLayout.CENTER); |
||||
initStyle(); |
||||
innerDialog.showWindow(); |
||||
} |
||||
|
||||
private void initStyle() { |
||||
setSize(DEFAULT); |
||||
setUndecorated(true); |
||||
setBackground(new Color(0, 0, 0, 0)); |
||||
GUICoreUtils.centerWindow(this); |
||||
} |
||||
|
||||
@Override |
||||
public void hideWindow() { |
||||
ComponentReuseNotificationInfo.getInstance().updateLastGuidePopUpTime(); |
||||
this.setVisible(false); |
||||
if (innerDialog != null) { |
||||
innerDialog.setVisible(false); |
||||
innerDialog.dispose(); |
||||
innerDialog = null; |
||||
} |
||||
this.dispose(); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() { |
||||
|
||||
} |
||||
|
||||
class InnerDialog extends UIDialog { |
||||
private final Dimension DEFAULT = new Dimension(700, 475); |
||||
private static final int TITLE_FONT_SIZE = 20; |
||||
|
||||
public InnerDialog(Dialog dialog) { |
||||
super(dialog); |
||||
} |
||||
|
||||
public void showWindow() { |
||||
add(createCenterPanel(), BorderLayout.CENTER); |
||||
add(createSouthPanel(), BorderLayout.SOUTH); |
||||
add(createNorthPanel(), BorderLayout.NORTH); |
||||
showDialog(); |
||||
} |
||||
|
||||
private JPanel createNorthPanel() { |
||||
JPanel northPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
||||
|
||||
//右上角关闭按钮
|
||||
JButton button = new JButton(new ImageIcon(IOUtils.readImage("/com/fr/base/images/share/close.png").getScaledInstance(15, 15, Image.SCALE_SMOOTH))); |
||||
button.setBorder(null); |
||||
button.setOpaque(false); |
||||
button.addActionListener(e -> ReuseGuideDialog.this.hideWindow()); |
||||
|
||||
northPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 15)); |
||||
northPanel.setOpaque(false); |
||||
northPanel.add(button); |
||||
return northPanel; |
||||
} |
||||
|
||||
private JPanel createCenterPanel() { |
||||
JPanel centerPanel = new JPanel(new BorderLayout()); |
||||
|
||||
UILabel titleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Component")); |
||||
UILabel imageLabel = new UILabel(new ImageIcon(IOUtils.readImage("com/fr/design/images/dashboard/guide.png").getScaledInstance(DEFAULT.width, DEFAULT.height, Image.SCALE_SMOOTH))); |
||||
titleLabel.setFont(new Font(titleLabel.getFont().getName(), Font.BOLD, TITLE_FONT_SIZE)); |
||||
titleLabel.setBorder(BorderFactory.createEmptyBorder()); |
||||
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); |
||||
panel.setOpaque(false); |
||||
panel.add(titleLabel); |
||||
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); |
||||
centerPanel.setOpaque(false); |
||||
centerPanel.add(imageLabel, BorderLayout.CENTER); |
||||
centerPanel.add(panel, BorderLayout.NORTH); |
||||
return centerPanel; |
||||
} |
||||
|
||||
private JPanel createSouthPanel() { |
||||
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
|
||||
JButton button = new JButton(Toolkit.i18nText("Fine-Design_Share_Try_Drag")) { |
||||
@Override |
||||
public void paint(Graphics g) { |
||||
ColorBackground buttonBackground = ColorBackground.getInstance(Color.decode("#419BF9")); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
||||
buttonBackground.paint(g2d, new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 8, 8)); |
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
||||
super.paint(g); |
||||
} |
||||
}; |
||||
button.setBorder(null); |
||||
button.setForeground(Color.WHITE); |
||||
button.setOpaque(false); |
||||
button.addActionListener(e -> ReuseGuideDialog.this.hideWindow()); |
||||
|
||||
southPanel.setBorder(BorderFactory.createEmptyBorder(0, 290, 19, 290)); |
||||
southPanel.setPreferredSize(new Dimension(DEFAULT.width, 51)); |
||||
southPanel.setOpaque(false); |
||||
southPanel.add(button); |
||||
return southPanel; |
||||
} |
||||
|
||||
/** |
||||
* 显示窗口 |
||||
*/ |
||||
private void showDialog() { |
||||
setSize(DEFAULT); |
||||
setUndecorated(true); |
||||
GUICoreUtils.centerWindow(this); |
||||
setModalityType(ModalityType.APPLICATION_MODAL); |
||||
ReuseGuideDialog.this.setVisible(true); |
||||
setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() { |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,99 @@
|
||||
package com.fr.design.mainframe.share; |
||||
|
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; |
||||
import com.fr.form.share.constants.ComponentPath; |
||||
import com.fr.form.share.group.filter.ReuFilter; |
||||
import com.fr.design.DesignerCloudURLManager; |
||||
import com.fr.workspace.WorkContext; |
||||
|
||||
/** |
||||
* Created by kerry on 2021/10/27 |
||||
*/ |
||||
public class ComponentShareUtil { |
||||
private ComponentShareUtil() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 判断是否需要切换到在线组件库 |
||||
* |
||||
* @return |
||||
*/ |
||||
public static boolean needSwitch2OnlineTab() { |
||||
return DesignerCloudURLManager.getInstance().isConnected() && !hasTouched() && isCurrentTplNewCreate(); |
||||
} |
||||
|
||||
/** |
||||
* 判断是否可触达 |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
public static boolean hasTouched() { |
||||
String sharePath = ComponentPath.SHARE_PATH.path(); |
||||
String[] components = WorkContext.getWorkResource().list(sharePath, new ReuFilter()); |
||||
return components != null && components.length > 6; |
||||
} |
||||
|
||||
/** |
||||
* 判断当前模板是否是新建模板 |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
public static boolean isCurrentTplNewCreate() { |
||||
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
return jTemplate.isNewCreateTpl(); |
||||
} |
||||
|
||||
/** |
||||
* 判断是否在需要展示组件库界面 |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
public static boolean needShowEmbedFilterPane() { |
||||
return !ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter() && !hasTouched() && isCurrentTplNewCreate(); |
||||
} |
||||
|
||||
public static boolean needShowComponentLib() { |
||||
return !ComponentReuseNotificationInfo.getInstance().isCompleteFirstShowComponentLib() && !hasTouched() && isCurrentTplNewCreate(); |
||||
} |
||||
|
||||
/** |
||||
* 判断是否需要展示首次拖拽动效 |
||||
* |
||||
* @return boolean |
||||
*/ |
||||
public static boolean needShowFirstDragAnimate() { |
||||
return ComponentReuseNotificationInfo.getInstance().isFirstDrag(); |
||||
} |
||||
|
||||
/** |
||||
* 完成嵌入式筛选 |
||||
*/ |
||||
public static void completeEmbedFilter() { |
||||
boolean changed = false; |
||||
if (!ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) { |
||||
ComponentReuseNotificationInfo.getInstance().setWidgetLibHasRefreshed(true); |
||||
changed = true; |
||||
} |
||||
if (!ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter()) { |
||||
ComponentReuseNotificationInfo.getInstance().setCompleteEmbedFilter(true); |
||||
changed = true; |
||||
} |
||||
if (changed) { |
||||
DesignerEnvManager.getEnvManager().saveXMLFile(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 记录组件库刷新 |
||||
*/ |
||||
public static void recordWidgetLibHasRefreshed() { |
||||
if (!ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) { |
||||
ComponentReuseNotificationInfo.getInstance().setWidgetLibHasRefreshed(true); |
||||
DesignerEnvManager.getEnvManager().saveXMLFile(); |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 279 B |
After Width: | Height: | Size: 383 B |
@ -0,0 +1,91 @@
|
||||
package com.fr.van.chart.config; |
||||
|
||||
import com.fr.base.ChartPreStyleConfig; |
||||
import com.fr.chart.base.ChartBaseUtils; |
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.general.Background; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.stable.CodeUtils; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Font; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/6/25 |
||||
*/ |
||||
public class DefaultStyleConstants { |
||||
static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 14, new Color(241, 246, 255)); |
||||
static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); |
||||
|
||||
static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); |
||||
static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(200, 211, 228)); |
||||
static final Color AXIS_LINE = new Color(46, 75, 102); |
||||
static final Color GRID_LINE = new Color(30, 55, 78); |
||||
|
||||
static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(255, 0, 0)); |
||||
|
||||
static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); |
||||
static final Color DATA_SHEET_BORDER = new Color(46, 75, 102); |
||||
|
||||
static final Color BORDER = Color.BLACK; |
||||
static final int BORDER_WIDTH = Constants.LINE_NONE; |
||||
static final int SPECIAL_BORDER_WIDTH = Constants.LINE_THIN; |
||||
|
||||
static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 10, new Color(232, 232, 232)); |
||||
|
||||
static final Color GAUGE_PANE_BACK_COLOR = null; |
||||
static final Color GAUGE_HINGE = null; |
||||
static final Color GAUGE_PANE_BACK_COLOR_4_RING = new Color(72, 73, 79); |
||||
static final Color GAUGE_SLOT_BACKGROUND_COLOR = new Color(72, 73, 79); |
||||
private static final String FONT_NAME = ChartBaseUtils.getLocalDefaultFont("verdana"); |
||||
static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 9, new Color(232, 232, 232));//试管仪表盘标签的默认样式
|
||||
static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 8, new Color(159, 173, 191)); |
||||
static final FRFont RING_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//百分比圆环仪表盘值标签的默认样式
|
||||
static final FRFont POINTER_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//多指针仪表盘值标签的默认样式
|
||||
static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 10, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式
|
||||
|
||||
static final Color MAP_NULL_VALUE_COLOR = new Color(168, 168, 168); |
||||
static final Color MAP_BORDER = Color.BLACK; |
||||
static final Color MAP_LEGEND_BACK = Color.BLACK; |
||||
static final Color MAP_TITLE_BACK = Color.BLACK; |
||||
|
||||
static final Color DRILL_MAP_DRILL_TOOLS_BACK = Color.BLACK; |
||||
static final float DRILL_MAP_DRILL_TOOLS_BACK_OPACITY = 0.8f; |
||||
|
||||
//todo vancharts
|
||||
private static final Color GANTT_OUT_LINE = GRID_LINE; |
||||
private static final FRFont GANTT_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 8, new Color(217, 217, 217)); |
||||
private static final Color GANTT_BORDER_LINE = new Color(30, 36, 58); |
||||
private static final Color GAUGE_TICK = new Color(39, 49, 71); |
||||
|
||||
static final Background BACK = null; |
||||
|
||||
static String COLORS = null; |
||||
|
||||
static { |
||||
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); |
||||
try { |
||||
DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u7ecf\u5178\u9ad8\u4eae"); |
||||
// 没有经典高亮, 用新特性
|
||||
if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) { |
||||
DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u65b0\u7279\u6027"); |
||||
} |
||||
// 没有新特性, 用第一个配色
|
||||
if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) { |
||||
if (config.names().hasNext()) { |
||||
|
||||
String name = GeneralUtils.objectToString(config.names().next()); |
||||
if (config.getPreStyle(name) != null) { |
||||
DefaultStyleConstants.COLORS = name; |
||||
} |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,186 @@
|
||||
package com.fr.van.chart.config; |
||||
|
||||
import com.fr.chart.base.AttrBorder; |
||||
import com.fr.chart.base.AttrFillStyle; |
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.chart.chartglyph.ConditionAttr; |
||||
import com.fr.chart.chartglyph.DataSheet; |
||||
import com.fr.config.predefined.ColorFillStyle; |
||||
import com.fr.design.mainframe.chart.mode.ChartEditContext; |
||||
import com.fr.plugin.chart.PiePlot4VanChart; |
||||
import com.fr.plugin.chart.attr.axis.VanChartAlertValue; |
||||
import com.fr.plugin.chart.attr.axis.VanChartAxis; |
||||
import com.fr.plugin.chart.attr.plot.VanChartPlot; |
||||
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; |
||||
import com.fr.plugin.chart.base.AttrLabel; |
||||
import com.fr.plugin.chart.base.AttrLabelDetail; |
||||
import com.fr.plugin.chart.custom.type.CustomPlotType; |
||||
import com.fr.plugin.chart.gauge.VanChartGaugePlot; |
||||
import com.fr.plugin.chart.map.VanChartMapPlot; |
||||
import com.fr.plugin.chart.type.GaugeStyle; |
||||
|
||||
/** |
||||
* @author shine |
||||
* @version 10.0 |
||||
* Created by shine on 2021/10/22 |
||||
* vanchart的抽出来,因为主体代码 新增y轴 组合图新增图表都要用 |
||||
*/ |
||||
public class DefaultStyleHelper4Van { |
||||
|
||||
public static void dealVanPlot4Custom(VanChartPlot plot, CustomPlotType customPlotType) { |
||||
if (!ChartEditContext.duchampMode()) { |
||||
return; |
||||
} |
||||
dealVanPlotCommonAttr(plot); |
||||
switch (customPlotType) { |
||||
case PIE: |
||||
case DIFFERENT_PIE: |
||||
case SAME_PIE: |
||||
dealPie(plot); |
||||
break; |
||||
case SLOT: |
||||
case POINTER_360: |
||||
case POINTER_180: |
||||
case CUVETTE: |
||||
case RING: |
||||
dealGauge(plot); |
||||
break; |
||||
case COLUMN: |
||||
case LINE: |
||||
case AREA: |
||||
case BUBBLE: |
||||
case RADAR: |
||||
case STACK_RADAR: |
||||
case SCATTER: |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
public static VanChartAxis dealAxisDefault(VanChartAxis axis) { |
||||
if (!ChartEditContext.duchampMode()) { |
||||
return axis; |
||||
} |
||||
axis.getTitle().getTextAttr().setFRFont(DefaultStyleConstants.AXIS_TITLE); |
||||
axis.getTextAttr().setFRFont(DefaultStyleConstants.AXIS_LABEL); |
||||
axis.setAxisColor(DefaultStyleConstants.AXIS_LINE); |
||||
axis.setMainGridColor(DefaultStyleConstants.GRID_LINE); |
||||
return axis; |
||||
} |
||||
|
||||
public static void dealAxisAlert(VanChartAlertValue vanChartAlertValue) { |
||||
if (!ChartEditContext.duchampMode()) { |
||||
return; |
||||
} |
||||
vanChartAlertValue.setAlertFont(DefaultStyleConstants.ALERT_FONT); |
||||
} |
||||
|
||||
static void dealVanPlotCommonAttr(Plot plot) { |
||||
if (!ChartEditContext.duchampMode()) { |
||||
return; |
||||
} |
||||
if (plot instanceof VanChartPlot) { |
||||
VanChartPlot vanChartPlot = (VanChartPlot) plot; |
||||
|
||||
ColorFillStyle colorFillStyle = new ColorFillStyle(); |
||||
colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC); |
||||
colorFillStyle.setFillStyleName(DefaultStyleConstants.COLORS); |
||||
AttrFillStyle plotFillStyle = vanChartPlot.getPlotFillStyle(); |
||||
if (plotFillStyle == null) { |
||||
plotFillStyle = new AttrFillStyle(); |
||||
vanChartPlot.setPlotFillStyle(plotFillStyle); |
||||
} |
||||
plotFillStyle.setColorFillStyle(colorFillStyle); |
||||
|
||||
if (vanChartPlot.getLegend() != null) { |
||||
vanChartPlot.getLegend().setFRFont(DefaultStyleConstants.LEGEND); |
||||
} |
||||
|
||||
if (vanChartPlot instanceof VanChartRectanglePlot) { |
||||
VanChartRectanglePlot vanChartRectanglePlot = (VanChartRectanglePlot) vanChartPlot; |
||||
|
||||
for (VanChartAxis axis : vanChartRectanglePlot.getXAxisList()) { |
||||
dealAxisDefault(axis); |
||||
} |
||||
for (VanChartAxis axis : vanChartRectanglePlot.getYAxisList()) { |
||||
dealAxisDefault(axis); |
||||
} |
||||
} |
||||
|
||||
dealBorder(vanChartPlot); |
||||
|
||||
DataSheet dataSheet = vanChartPlot.getDataSheet(); |
||||
dataSheet.getTextAttr().setFRFont(DefaultStyleConstants.DATA_SHEET); |
||||
dataSheet.setBorderColor(DefaultStyleConstants.DATA_SHEET_BORDER); |
||||
} |
||||
|
||||
} |
||||
|
||||
private static void dealBorder(VanChartPlot vanChartPlot) { |
||||
ConditionAttr defaultAttr = vanChartPlot.getConditionCollection().getDefaultAttr(); |
||||
AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class); |
||||
if (attrBorder != null) { |
||||
attrBorder.setBorderColor(DefaultStyleConstants.BORDER); |
||||
attrBorder.setBorderStyle(defaultBorderWidth(vanChartPlot)); |
||||
} |
||||
} |
||||
|
||||
private static int defaultBorderWidth(VanChartPlot vanChartPlot) { |
||||
//pie multipie treemap map drillmap heatmap
|
||||
if (vanChartPlot instanceof PiePlot4VanChart |
||||
|| vanChartPlot instanceof VanChartMapPlot) { |
||||
return DefaultStyleConstants.SPECIAL_BORDER_WIDTH; |
||||
} |
||||
return DefaultStyleConstants.BORDER_WIDTH; |
||||
} |
||||
|
||||
static void dealPie(Plot plot) { |
||||
if (plot instanceof PiePlot4VanChart) { |
||||
ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); |
||||
AttrLabel attrLabel = defaultAttr.getExisted(AttrLabel.class); |
||||
if (attrLabel == null) { |
||||
attrLabel = ((PiePlot4VanChart) plot).getDefaultAttrLabel(); |
||||
defaultAttr.addDataSeriesCondition(attrLabel); |
||||
} |
||||
attrLabel.getSecondLabelDetail().getTextAttr().setFRFont(DefaultStyleConstants.PIE_CATEGORY_LABEL); |
||||
} |
||||
} |
||||
|
||||
static void dealGauge(Plot param) { |
||||
if (!(param instanceof VanChartGaugePlot)) { |
||||
return; |
||||
} |
||||
VanChartGaugePlot plot = (VanChartGaugePlot) param; |
||||
plot.getGaugeDetailStyle().setPaneBackgroundColor(plot.getGaugeStyle() == GaugeStyle.RING ? DefaultStyleConstants.GAUGE_PANE_BACK_COLOR_4_RING : DefaultStyleConstants.GAUGE_PANE_BACK_COLOR); |
||||
plot.getGaugeDetailStyle().setSlotBackgroundColor(DefaultStyleConstants.GAUGE_SLOT_BACKGROUND_COLOR); |
||||
plot.getGaugeDetailStyle().setHingeColor(DefaultStyleConstants.GAUGE_HINGE); |
||||
|
||||
ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); |
||||
AttrLabel attrLabel = defaultAttr.getExisted(AttrLabel.class); |
||||
if (attrLabel != null) { |
||||
AttrLabelDetail detail = attrLabel.getAttrLabelDetail(); |
||||
AttrLabelDetail valueDetail = attrLabel.getGaugeValueLabelDetail(); |
||||
|
||||
switch (plot.getGaugeStyle()) { |
||||
case POINTER: |
||||
case POINTER_SEMI: |
||||
detail.getContent().getCategoryFormat().setEnable(false); |
||||
detail.getTextAttr().setFRFont(DefaultStyleConstants.POINTER_CATE_LABEL_FONT); |
||||
valueDetail.getTextAttr().setFRFont(DefaultStyleConstants.POINTER_VALUE_LABEL_FONT); |
||||
break; |
||||
case RING: |
||||
case SLOT: |
||||
valueDetail.getTextAttr().setFRFont(DefaultStyleConstants.RING_VALUE_LABEL_FONT); |
||||
break; |
||||
case THERMOMETER: |
||||
detail.getTextAttr().setFRFont(DefaultStyleConstants.THERMOMETER_LABEL_FONT); |
||||
valueDetail.getTextAttr().setFRFont(DefaultStyleConstants.THERMOMETER_LABEL_FONT); |
||||
plot.getGaugeAxis().getTextAttr().setFRFont(DefaultStyleConstants.THERMOMETER_AXIS_LABEL); |
||||
break; |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.designer.ui; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 把弹窗统一管理起来 防止出现异常情况下游离的弹窗 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/11/02 |
||||
*/ |
||||
public class PopupDialogContext { |
||||
|
||||
private static List<SelectedPopupDialog> dialogs = new ArrayList<>(); |
||||
|
||||
public static void add(SelectedPopupDialog selectedPopupDialog) { |
||||
if (dialogs.contains(selectedPopupDialog)) { |
||||
return; |
||||
} |
||||
dialogs.add(selectedPopupDialog); |
||||
} |
||||
|
||||
public static void remove(SelectedPopupDialog selectedPopupDialog) { |
||||
dialogs.remove(selectedPopupDialog); |
||||
} |
||||
|
||||
public static void checkSelectedPop(XCreator creator) { |
||||
Iterator<SelectedPopupDialog> iterator = dialogs.iterator(); |
||||
List<SelectedPopupDialog> removedDialog = new ArrayList<>(); |
||||
while (iterator.hasNext()) { |
||||
SelectedPopupDialog dialog = iterator.next(); |
||||
if (dialog.isVisible() && creator != dialog.getCreator()) { |
||||
iterator.remove(); |
||||
removedDialog.add(dialog); |
||||
} |
||||
} |
||||
for (SelectedPopupDialog dialog : removedDialog) { |
||||
dialog.setVisible(false); |
||||
} |
||||
} |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue