Compare commits
No commits in common. 'persist/10.0' and '设计器' have entirely different histories.
persist/10
...
设计器
3140 changed files with 50284 additions and 188951 deletions
@ -1,88 +0,0 @@
|
||||
import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel |
||||
|
||||
plugins { |
||||
id 'java' |
||||
id 'java-library' |
||||
id 'com.fr.common' version '1.0-SNAPSHOT' |
||||
} |
||||
|
||||
// 模块参数 |
||||
ext { |
||||
frVersion = "" |
||||
outputPath = "build" |
||||
ignoreTestFailureSetting = true |
||||
languageLevelSetting = 1.8 |
||||
} |
||||
|
||||
applyGlobalConfigPathIfExist() |
||||
|
||||
if (versions.frVersion) { |
||||
frVersion = versions.frVersion |
||||
} |
||||
def frDevVersion = "DEV" + frVersion |
||||
|
||||
dependencies { |
||||
api project(':designer-base') |
||||
api project(':designer-chart') |
||||
api project(':designer-form') |
||||
api project(':designer-realize') |
||||
} |
||||
|
||||
allprojects { |
||||
apply plugin: 'java' |
||||
apply plugin: 'java-library' |
||||
apply plugin: 'idea' |
||||
|
||||
group 'com.fr.design' |
||||
version frDevVersion |
||||
sourceCompatibility = languageLevelSetting |
||||
targetCompatibility = languageLevelSetting |
||||
|
||||
tasks.withType(JavaCompile) { |
||||
options.encoding = "UTF-8" |
||||
} |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
} |
||||
|
||||
idea { |
||||
module { |
||||
inheritOutputDirs = false |
||||
outputDir = file(outputPath +"/classes") |
||||
testOutputDir = file(outputPath +"/test-classes") |
||||
languageLevel = new IdeaLanguageLevel(sourceCompatibility) |
||||
targetBytecodeVersion = targetCompatibility |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
implementation 'com.fr.third:jxbrowser:6.23' |
||||
implementation 'com.fr.third:jxbrowser-mac:6.23' |
||||
implementation 'com.fr.third:jxbrowser-win64:6.23' |
||||
implementation 'com.fr.third:jxbrowser-v7:7.15' |
||||
implementation 'com.fr.third:jxbrowser-mac-v7:7.15' |
||||
implementation 'com.fr.third:jxbrowser-win64-v7:7.15' |
||||
implementation 'com.fr.third:jxbrowser-swing-v7:7.15' |
||||
implementation 'com.fr.third.server:servlet-api:3.0' |
||||
implementation 'org.swingexplorer:swexpl:2.0.1' |
||||
implementation 'org.swingexplorer:swag:1.0' |
||||
implementation 'net.java.dev.jna:jna:5.4.0' |
||||
implementation 'org.apache.tomcat:tomcat-catalina:8.5.72' |
||||
implementation 'io.socket:socket.io-client:0.7.0' |
||||
implementation 'com.fr.third:fine-third:' + frVersion |
||||
implementation 'com.fr.core:fine-core:' + frDevVersion |
||||
implementation 'com.fr.activator:fine-activator:' + frVersion |
||||
implementation 'com.fr.datasource:fine-datasource:' + frVersion |
||||
implementation 'com.fr.decision:fine-decision:' + frVersion |
||||
implementation 'com.fr.schedule:fine-schedule:' + frVersion |
||||
implementation 'com.fr.report:engine-report:' + frDevVersion |
||||
implementation 'com.fr.report:engine-chart:' + frDevVersion |
||||
implementation 'com.fr.report:engine-i18n:' + frDevVersion |
||||
implementation 'com.fr.design:design-i18n:' + frDevVersion |
||||
testImplementation 'org.easymock:easymock:3.5.1' |
||||
testImplementation 'org.powermock:powermock-module-junit4:1.7.1' |
||||
testImplementation 'org.powermock:powermock-api-easymock:1.7.1' |
||||
testImplementation 'junit:junit:4.12' |
||||
} |
||||
} |
@ -1,148 +0,0 @@
|
||||
package com.fr.base.svg; |
||||
|
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.bridge.StableFactory; |
||||
import com.fr.stable.fun.ResourcePathTransformer; |
||||
import com.fr.stable.plugin.ExtraClassManagerProvider; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.ImageIcon; |
||||
import java.util.Arrays; |
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* 主要是用来读取svgIcon的工具类 |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2020/12/23 |
||||
*/ |
||||
public class IconUtils { |
||||
|
||||
private static final String ICON_SUFFIX_SVG = ".svg"; |
||||
private static final String ICON_SUFFIX_PNG = ".png"; |
||||
private static final String ICON_SUFFIX_GIF = ".gif"; |
||||
private static final String SUFFIX_SEPARATOR = "."; |
||||
|
||||
public static final String ICON_TYPE_NORMAL= "_normal.svg"; |
||||
public static final String ICON_TYPE_DISABLED= "_disabled.svg"; |
||||
public static final String ICON_TYPE_PRESSED= "_pressed.svg"; |
||||
|
||||
|
||||
/** |
||||
* 可以读取SVG图标或者普通图标,并且可以读取不带扩展名的文件 |
||||
* 不带扩展名时以svg优先、其次png,最后gif |
||||
* @param resource 图片路径 |
||||
* @return 图标 |
||||
*/ |
||||
public static Icon readIcon(String resource) { |
||||
// 判断是否有.XXX文件后缀
|
||||
if (resource.contains(SUFFIX_SEPARATOR)) { |
||||
// 判断是否以.svg结尾
|
||||
if (resource.endsWith(ICON_SUFFIX_SVG)) { |
||||
if (IOUtils.readResource(resource) != null) { |
||||
return SVGIcon.readSVGIcon(transformPath(resource)); |
||||
} |
||||
// 适配插件
|
||||
return adjustPluginsPng(resource); |
||||
} |
||||
return IOUtils.readIcon(resource); |
||||
} |
||||
// 文件无后缀时
|
||||
return readNoSuffixResource(resource, ICON_TYPE_NORMAL); |
||||
} |
||||
|
||||
/** |
||||
* 适配插件中使用_normal.png、_selected.png、_disabled.png的情况 |
||||
* @param resource 图片路径 |
||||
* @return Icon |
||||
*/ |
||||
private static Icon adjustPluginsPng(String resource) { |
||||
String pngResource = resource.replace(ICON_SUFFIX_SVG, ICON_SUFFIX_PNG); |
||||
// 考虑到某些插件可能只会使用三种图标中的一部分,这里做个判断,不然就会因为资源不存在而报错
|
||||
return IOUtils.readResource(pngResource) == null ? new ImageIcon() : IOUtils.readIcon(pngResource); |
||||
} |
||||
|
||||
/** |
||||
* 尝试读取不带扩展名的图标,svg优先,其次png,最后gif,都没读到就打印错误日志,返回空白Icon |
||||
* @param resource 图片路径 |
||||
* @param svgIconType 针对svg来说的图标类型 |
||||
* 取值为:ICON_TYPE_NORMAL、ICON_TYPE_DISABLED、ICON_TYPE_PRESSED |
||||
* @return 图标 |
||||
*/ |
||||
private static Icon readNoSuffixResource(String resource, String svgIconType) { |
||||
String svgPath = resource + svgIconType; |
||||
if (IOUtils.readResource(svgPath) != null) { |
||||
return SVGIcon.readSVGIcon(transformPath(svgPath)); |
||||
} |
||||
String pngPath = resource + ICON_SUFFIX_PNG; |
||||
if (IOUtils.readResource(pngPath) != null) { |
||||
return IOUtils.readIcon(transformPath(pngPath)); |
||||
} |
||||
String gifPath = resource + ICON_SUFFIX_GIF; |
||||
if (IOUtils.readResource(gifPath) != null) { |
||||
return IOUtils.readIcon(transformPath(gifPath)); |
||||
} |
||||
FineLoggerFactory.getLogger().error("File not exists:{}", resource); |
||||
return new ImageIcon(); |
||||
} |
||||
|
||||
/** |
||||
* 读取指定类型的svgIcon |
||||
* @param resource |
||||
* @param svgIconType |
||||
* @return |
||||
*/ |
||||
public static Icon readSVGIcon(String resource, String svgIconType) { |
||||
// 判断下是否有后缀
|
||||
if (!resource.contains(SUFFIX_SEPARATOR)) { |
||||
return readNoSuffixResource(resource, svgIconType); |
||||
} |
||||
// 如果是".png"后缀,就替换为传入的svgIconType,然后读取图标
|
||||
if (resource.endsWith(ICON_SUFFIX_PNG)) { |
||||
return readSpecifiedTypeIcon(resource, ICON_SUFFIX_PNG, svgIconType); |
||||
} |
||||
// 如果是"_XXXXXX.svg"后缀
|
||||
if (resource.endsWith(ICON_TYPE_NORMAL)) { |
||||
return readSpecifiedTypeIcon(resource, ICON_TYPE_NORMAL, svgIconType); |
||||
} |
||||
if (resource.endsWith(ICON_TYPE_DISABLED)) { |
||||
return readSpecifiedTypeIcon(resource, ICON_TYPE_DISABLED, svgIconType); |
||||
} |
||||
if (resource.endsWith(ICON_TYPE_PRESSED)) { |
||||
return readSpecifiedTypeIcon(resource, ICON_TYPE_PRESSED, svgIconType); |
||||
} |
||||
return readIcon(resource); |
||||
} |
||||
|
||||
private static Icon readSpecifiedTypeIcon(String resource, String oldSuffix, String newSuffix) { |
||||
String iconPath = resource.replace(oldSuffix, newSuffix); |
||||
if (IOUtils.readResource(iconPath) != null) { |
||||
return SVGIcon.readSVGIcon(transformPath(iconPath)); |
||||
} |
||||
return readIcon(resource); |
||||
} |
||||
|
||||
private static String transformPath(String path) { |
||||
Set<ResourcePathTransformer> set = getResourcePathTransformers(); |
||||
for (ResourcePathTransformer transformer : set) { |
||||
if (transformer.accept(path)) { |
||||
return transformer.transform(path); |
||||
} |
||||
} |
||||
return path; |
||||
} |
||||
|
||||
private static Set<ResourcePathTransformer> getResourcePathTransformers() { |
||||
Set<ResourcePathTransformer> set = new HashSet<ResourcePathTransformer>(); |
||||
ExtraClassManagerProvider provider = StableFactory.getExtraClassManager(); |
||||
if (provider != null) { |
||||
Set<ResourcePathTransformer> pluginProvided = provider.getArray(ResourcePathTransformer.MARK_STRING); |
||||
set.addAll(pluginProvided); |
||||
} |
||||
ResourcePathTransformer[] oemSet = StableFactory.getMarkedObjectsFromCollection(ResourcePathTransformer.MARK_STRING, ResourcePathTransformer.class); |
||||
set.addAll(Arrays.asList(oemSet)); |
||||
return set; |
||||
} |
||||
} |
@ -1,101 +0,0 @@
|
||||
package com.fr.base.svg; |
||||
|
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.image.BufferedImage; |
||||
import java.util.Map; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* SVG转化而来的Icon |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2020/12/17 |
||||
*/ |
||||
public class SVGIcon implements Icon { |
||||
|
||||
private BufferedImage image; |
||||
|
||||
private static final boolean HI_DPI_SURPORT = SystemScaleUtils.isJreHiDPIEnabled(); |
||||
|
||||
public static final float SYSTEM_SCALE = SystemScaleUtils.sysScale(); |
||||
|
||||
private static final String ICON_PREFIX = "/"; |
||||
|
||||
public SVGIcon(BufferedImage image) { |
||||
this.image = image; |
||||
} |
||||
|
||||
private static Map<String, Icon> iconCache = new ConcurrentHashMap<>(); |
||||
|
||||
@Override |
||||
public void paintIcon(Component c, Graphics g, int x, int y) { |
||||
if (HI_DPI_SURPORT) { |
||||
Graphics2D graphics = (Graphics2D) g.create(x, y, image.getWidth(null), image.getHeight(null)); |
||||
float scale = SYSTEM_SCALE; |
||||
graphics.scale(1 / scale, 1 / scale); |
||||
graphics.drawImage(image, 0, 0, null); |
||||
graphics.scale(1.0D, 1.0D); |
||||
graphics.dispose(); |
||||
} else { |
||||
g.drawImage(image, x, y, null); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int getIconWidth() { |
||||
return HI_DPI_SURPORT ? (int) (image.getWidth() / SYSTEM_SCALE) : image.getWidth(); |
||||
} |
||||
|
||||
@Override |
||||
public int getIconHeight() { |
||||
return HI_DPI_SURPORT ? (int) (image.getHeight() / SYSTEM_SCALE) : image.getHeight(); |
||||
} |
||||
|
||||
/** |
||||
* 读取高清图标 |
||||
* @param url |
||||
* @return |
||||
*/ |
||||
public static Icon readSVGIcon(String url) { |
||||
return readSVGIconWithCache(url, true); |
||||
} |
||||
|
||||
public static Icon readSVGIconWithCache(String url, boolean cacheRead) { |
||||
Icon icon = null; |
||||
if (cacheRead) { |
||||
icon = iconCache.get(url); |
||||
} |
||||
if (icon == null) { |
||||
if (!url.startsWith(ICON_PREFIX)) { |
||||
url = ICON_PREFIX + url; |
||||
} |
||||
BufferedImage image = (BufferedImage) SVGLoader.load(url); |
||||
icon = image == null ? IOUtils.readIcon(url) : new SVGIcon(image); |
||||
//只缓存svg图标
|
||||
if (image != null){ |
||||
iconCache.put(url, icon); |
||||
} |
||||
} |
||||
return icon; |
||||
} |
||||
|
||||
/** |
||||
* 读取指定尺寸的图标 |
||||
* @param url 资源路径 |
||||
* @param width 宽度 |
||||
* @param height 高度 |
||||
* @return |
||||
*/ |
||||
public static Icon readSVGIcon(String url, float width, float height) { |
||||
if (!url.startsWith(ICON_PREFIX)) { |
||||
url = ICON_PREFIX + url; |
||||
} |
||||
BufferedImage image = (BufferedImage) SVGLoader.load(url, width, height); |
||||
return image == null ? IOUtils.readIcon(url) : new SVGIcon(image); |
||||
} |
||||
} |
@ -1,92 +0,0 @@
|
||||
package com.fr.base.svg; |
||||
|
||||
import com.fr.general.IOUtils; |
||||
import org.apache.batik.transcoder.TranscoderException; |
||||
import org.apache.batik.transcoder.TranscoderInput; |
||||
import org.apache.xmlgraphics.java2d.Dimension2DDouble; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import java.awt.Image; |
||||
import java.io.IOException; |
||||
import java.net.URL; |
||||
|
||||
/** |
||||
* SVG图标加载器 |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2020/12/17 |
||||
*/ |
||||
public class SVGLoader { |
||||
public static final int ICON_DEFAULT_SIZE = 16; |
||||
|
||||
public SVGLoader() { |
||||
} |
||||
|
||||
@Nullable |
||||
public static Image load(@NotNull String url) { |
||||
try { |
||||
URL resource = IOUtils.getResource(url, SVGLoader.class); |
||||
if (resource == null) { |
||||
return null; |
||||
} |
||||
return load(resource, SVGIcon.SYSTEM_SCALE); |
||||
} catch (IOException ignore) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@Nullable |
||||
public static Image load(@NotNull URL url) throws IOException { |
||||
return load(url, SVGIcon.SYSTEM_SCALE); |
||||
} |
||||
|
||||
@Nullable |
||||
public static Image load(@NotNull URL url, double scale) throws IOException { |
||||
try { |
||||
String svgUri = url.toString(); |
||||
TranscoderInput input = new TranscoderInput(svgUri); |
||||
return SVGTranscoder.createImage(scale, input).getImage(); |
||||
} catch (TranscoderException ignore) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@Nullable |
||||
public static Image load(@NotNull URL url, double scale, Dimension2DDouble dimension) throws IOException { |
||||
try { |
||||
String svgUri = url.toString(); |
||||
TranscoderInput input = new TranscoderInput(svgUri); |
||||
return SVGTranscoder.createImage(scale, input, |
||||
(float) (dimension.getWidth() * scale), (float) (dimension.getHeight() * scale)).getImage(); |
||||
} catch (TranscoderException ignore) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
|
||||
@Nullable |
||||
public static Image load(@NotNull URL url, double scale, double overriddenWidth, double overriddenHeight) throws IOException { |
||||
try { |
||||
String svgUri = url.toString(); |
||||
TranscoderInput input = new TranscoderInput(svgUri); |
||||
return SVGTranscoder.createImage(scale, input, (float) (overriddenWidth * scale), (float) (overriddenHeight * scale)).getImage(); |
||||
} catch (TranscoderException ignore) { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@Nullable |
||||
public static Image load(@NotNull String url, float width, float height) { |
||||
try { |
||||
URL resource = IOUtils.getResource(url, SVGLoader.class); |
||||
if (resource == null) { |
||||
return null; |
||||
} |
||||
TranscoderInput input = new TranscoderInput(resource.toString()); |
||||
return SVGTranscoder.createImage(SVGIcon.SYSTEM_SCALE, input, -1, -1, width, height).getImage(); |
||||
} catch (TranscoderException ignore) { |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -1,181 +0,0 @@
|
||||
package com.fr.base.svg; |
||||
|
||||
import com.fr.stable.AssistUtils; |
||||
import com.fr.value.AtomicNotNullLazyValue; |
||||
import org.apache.batik.anim.dom.SAXSVGDocumentFactory; |
||||
import org.apache.batik.anim.dom.SVGOMDocument; |
||||
import org.apache.batik.bridge.BridgeContext; |
||||
import org.apache.batik.bridge.UserAgent; |
||||
import org.apache.batik.transcoder.SVGAbstractTranscoder; |
||||
import org.apache.batik.transcoder.TranscoderException; |
||||
import org.apache.batik.transcoder.TranscoderInput; |
||||
import org.apache.batik.transcoder.TranscoderOutput; |
||||
import org.apache.batik.transcoder.image.ImageTranscoder; |
||||
import org.apache.batik.util.XMLResourceDescriptor; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import org.jetbrains.annotations.Nullable; |
||||
import org.w3c.dom.Element; |
||||
import org.w3c.dom.svg.SVGDocument; |
||||
|
||||
import java.awt.GraphicsDevice; |
||||
import java.awt.GraphicsEnvironment; |
||||
import java.awt.Rectangle; |
||||
import java.awt.geom.AffineTransform; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.IOException; |
||||
import java.io.StringReader; |
||||
|
||||
/** |
||||
* 可以根据某个缩放倍数scale,将SVG图片转化为Image对象 |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2020/12/17 |
||||
*/ |
||||
public class SVGTranscoder extends ImageTranscoder { |
||||
|
||||
private static final float DEFAULT_VALUE = -1.0F; |
||||
public static final float ICON_DEFAULT_SIZE = 16F; |
||||
private float origDocWidth; |
||||
private float origDocHeight; |
||||
@Nullable |
||||
private BufferedImage image; |
||||
private final double scale; |
||||
|
||||
@NotNull |
||||
private static AtomicNotNullLazyValue<Double> iconMaxSize = new AtomicNotNullLazyValue<Double>() { |
||||
@NotNull |
||||
@Override |
||||
protected Double compute() { |
||||
double maxSize = Double.MAX_VALUE; |
||||
if (!GraphicsEnvironment.isHeadless()) { |
||||
GraphicsDevice defaultScreenDevice = GraphicsEnvironment |
||||
.getLocalGraphicsEnvironment() |
||||
.getDefaultScreenDevice(); |
||||
Rectangle bounds = defaultScreenDevice.getDefaultConfiguration().getBounds(); |
||||
AffineTransform tx = defaultScreenDevice |
||||
.getDefaultConfiguration() |
||||
.getDefaultTransform(); |
||||
maxSize = Math.max(bounds.width * tx.getScaleX(), bounds.height * tx.getScaleY()); |
||||
} |
||||
return maxSize; |
||||
} |
||||
}; |
||||
|
||||
public SVGTranscoder(double scale) { |
||||
this.scale = scale; |
||||
this.width = ICON_DEFAULT_SIZE; |
||||
this.height = ICON_DEFAULT_SIZE; |
||||
} |
||||
|
||||
public SVGTranscoder(double scale, float width, float height) { |
||||
this.scale = scale; |
||||
this.width = width; |
||||
this.height = height; |
||||
} |
||||
|
||||
public final float getOrigDocWidth() { |
||||
return this.origDocWidth; |
||||
} |
||||
|
||||
public final void setOrigDocWidth(float origDocWidth) { |
||||
this.origDocWidth = origDocWidth; |
||||
} |
||||
|
||||
public final float getOrigDocHeight() { |
||||
return this.origDocHeight; |
||||
} |
||||
|
||||
public final void setOrigDocHeight(float origDocHeight) { |
||||
this.origDocHeight = origDocHeight; |
||||
} |
||||
|
||||
public static double getIconMaxSize() { |
||||
return iconMaxSize.getValue(); |
||||
} |
||||
|
||||
@Nullable |
||||
public final BufferedImage getImage() { |
||||
return this.image; |
||||
} |
||||
|
||||
@NotNull |
||||
public static SVGTranscoder createImage(double scale, @NotNull TranscoderInput input) throws TranscoderException { |
||||
return createImage(scale, input, -1, -1); |
||||
} |
||||
|
||||
@NotNull |
||||
public static SVGTranscoder createImage(double scale, @NotNull TranscoderInput input, float overriddenWidth, float overriddenHeight) throws TranscoderException { |
||||
return createImage(scale, input, overriddenWidth, overriddenHeight, ICON_DEFAULT_SIZE, ICON_DEFAULT_SIZE); |
||||
} |
||||
|
||||
@NotNull |
||||
public static SVGTranscoder createImage(double scale, @NotNull TranscoderInput input, float overriddenWidth, float overriddenHeight, float width, float height) throws TranscoderException { |
||||
SVGTranscoder transcoder = new SVGTranscoder(scale, width, height); |
||||
if (!AssistUtils.equals(overriddenWidth, DEFAULT_VALUE)) { |
||||
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, overriddenWidth); |
||||
} |
||||
|
||||
if (!AssistUtils.equals(overriddenHeight, DEFAULT_VALUE)) { |
||||
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, overriddenHeight); |
||||
} |
||||
|
||||
double iconMaxSize = SVGTranscoder.iconMaxSize.getValue(); |
||||
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_WIDTH, (float) iconMaxSize); |
||||
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_HEIGHT, (float) iconMaxSize); |
||||
transcoder.transcode(input, null); |
||||
return transcoder; |
||||
} |
||||
|
||||
private static SVGDocument createFallbackPlaceholder() { |
||||
try { |
||||
String fallbackIcon = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n" + |
||||
" <rect x=\"1\" y=\"1\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"red\" stroke-width=\"2\"/>\n" + |
||||
" <line x1=\"1\" y1=\"1\" x2=\"15\" y2=\"15\" stroke=\"red\" stroke-width=\"2\"/>\n" + |
||||
" <line x1=\"1\" y1=\"15\" x2=\"15\" y2=\"1\" stroke=\"red\" stroke-width=\"2\"/>\n" + |
||||
"</svg>\n"; |
||||
|
||||
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName()); |
||||
return (SVGDocument) factory.createDocument(null, new StringReader(fallbackIcon)); |
||||
} catch (IOException e) { |
||||
throw new IllegalStateException(e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void setImageSize(float docWidth, float docHeight) { |
||||
super.setImageSize((float) (docWidth * this.scale), (float) (docHeight * this.scale)); |
||||
this.origDocWidth = docWidth; |
||||
this.origDocHeight = docHeight; |
||||
} |
||||
|
||||
@Override |
||||
@NotNull |
||||
public BufferedImage createImage(int width, int height) { |
||||
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
||||
} |
||||
|
||||
@Override |
||||
public void writeImage(@NotNull BufferedImage image, @Nullable TranscoderOutput output) { |
||||
this.image = image; |
||||
} |
||||
|
||||
@Override |
||||
@NotNull |
||||
protected UserAgent createUserAgent() { |
||||
return new SVGAbstractTranscoderUserAgent() { |
||||
@Override |
||||
@NotNull |
||||
public SVGDocument getBrokenLinkDocument(@NotNull Element e, @NotNull String url, @NotNull String message) { |
||||
return createFallbackPlaceholder(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 开放访问权限 |
||||
*/ |
||||
@Override |
||||
public BridgeContext createBridgeContext(SVGOMDocument doc) { |
||||
return super.createBridgeContext(doc); |
||||
} |
||||
} |
@ -1,101 +0,0 @@
|
||||
package com.fr.base.svg; |
||||
|
||||
import com.bulenkov.iconloader.util.UIUtil; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
import java.awt.GraphicsConfiguration; |
||||
import java.awt.GraphicsDevice; |
||||
import java.awt.GraphicsEnvironment; |
||||
import java.lang.reflect.Method; |
||||
import java.util.concurrent.atomic.AtomicReference; |
||||
|
||||
/** |
||||
* 获取系统Scale相关的工具类 |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2020/12/17 |
||||
*/ |
||||
public class SystemScaleUtils { |
||||
|
||||
private static final AtomicReference<Boolean> JRE_HIDPI = new AtomicReference<>(); |
||||
|
||||
private static final String HI_DPI = "hidpi"; |
||||
|
||||
/** |
||||
* 判断是否支持高清 |
||||
* @return |
||||
*/ |
||||
public static boolean isJreHiDPIEnabled() { |
||||
if (JRE_HIDPI.get() != null) { |
||||
return JRE_HIDPI.get(); |
||||
} |
||||
if (OperatingSystem.isMacos()) { |
||||
// 如果是mac os系统,直接返回true
|
||||
return true; |
||||
} |
||||
if (OperatingSystem.isWindows() && StableUtils.getMajorJavaVersion() <= 8) { |
||||
// 如果是jdk8 + Windows系统,直接返回false
|
||||
return false; |
||||
} |
||||
synchronized (JRE_HIDPI) { |
||||
if (JRE_HIDPI.get() != null) { |
||||
return JRE_HIDPI.get(); |
||||
} |
||||
boolean result = false; |
||||
if (getBooleanProperty(HI_DPI, true)) { |
||||
try { |
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
||||
Class<?> sunGraphicsEnvironmentClass = Class.forName("sun.java2d.SunGraphicsEnvironment"); |
||||
if (sunGraphicsEnvironmentClass.isInstance(ge)) { |
||||
try { |
||||
Method method = sunGraphicsEnvironmentClass.getDeclaredMethod("isUIScaleEnabled"); |
||||
method.setAccessible(true); |
||||
result = (Boolean)method.invoke(ge); |
||||
} |
||||
catch (NoSuchMethodException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
catch (Throwable ignore) { |
||||
} |
||||
} |
||||
JRE_HIDPI.set(result); |
||||
return result; |
||||
} |
||||
} |
||||
|
||||
public static boolean getBooleanProperty(@NotNull final String key, final boolean defaultValue) { |
||||
final String value = System.getProperty(key); |
||||
return value == null ? defaultValue : Boolean.parseBoolean(value); |
||||
} |
||||
|
||||
/** |
||||
* 获取系统Scale |
||||
* @return |
||||
*/ |
||||
public static float sysScale() { |
||||
// 如果检测到是retina,直接返回2
|
||||
if (UIUtil.isRetina()) { |
||||
return 2.0f; |
||||
} |
||||
float scale = 1.0f; |
||||
// 先判断是否支持高清,不支持代表此时是Windows + jdk8 的设计器,返回的scale值为1.0
|
||||
if (isJreHiDPIEnabled()) { |
||||
// 获取屏幕图形设备对象
|
||||
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); |
||||
if (graphicsDevice != null) { |
||||
// 获取图形配置对象
|
||||
GraphicsConfiguration configuration = graphicsDevice.getDefaultConfiguration(); |
||||
if (configuration != null && configuration.getDevice().getType() != GraphicsDevice.TYPE_PRINTER) { |
||||
// 获取屏幕缩放率,Windows+jdk11环境下会得到用户设置的dpi值
|
||||
scale = (float) configuration.getDefaultTransform().getScaleX(); |
||||
} |
||||
} |
||||
} |
||||
return scale; |
||||
} |
||||
} |
@ -1,83 +0,0 @@
|
||||
package com.fr.base.vcs; |
||||
|
||||
import com.fr.design.base.mode.DesignModeContext; |
||||
|
||||
/** |
||||
* 兼容 |
||||
* |
||||
* @deprecated user {@link com.fr.design.base.mode.DesignerMode} and {@link DesignModeContext} instead |
||||
*/ |
||||
@Deprecated |
||||
public enum DesignerMode { |
||||
|
||||
NORMAL() { |
||||
@Override |
||||
public void doSwitch() { |
||||
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); |
||||
} |
||||
}, |
||||
VCS() { |
||||
@Override |
||||
public void doSwitch() { |
||||
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.VCS); |
||||
} |
||||
}, |
||||
AUTHORITY() { |
||||
@Override |
||||
public void doSwitch() { |
||||
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.AUTHORITY); |
||||
} |
||||
}; |
||||
|
||||
abstract void doSwitch(); |
||||
|
||||
|
||||
/** |
||||
* @return 是否时版本控制模式 |
||||
* @deprecated use {@link DesignModeContext#isVcsMode()} instead |
||||
*/ |
||||
@Deprecated |
||||
public static boolean isVcsMode() { |
||||
return DesignModeContext.isVcsMode(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 切换设计器模式 |
||||
* |
||||
* @param mode mode |
||||
* @deprecated use {@link DesignModeContext#switchTo(com.fr.design.base.mode.DesignerMode)} instead |
||||
*/ |
||||
@Deprecated |
||||
public static void setMode(DesignerMode mode) { |
||||
mode.doSwitch(); |
||||
} |
||||
|
||||
/** |
||||
* @return 获取当前设计器模式 |
||||
* @deprecated use {@link DesignModeContext#getMode()} instead |
||||
*/ |
||||
@Deprecated |
||||
public static DesignerMode getMode() { |
||||
switch (DesignModeContext.getMode()) { |
||||
case VCS: |
||||
return VCS; |
||||
case AUTHORITY: |
||||
return AUTHORITY; |
||||
case NORMAL: |
||||
default: |
||||
return NORMAL; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 是否为权限编辑 |
||||
* |
||||
* @return 是否为权限编辑 |
||||
* @deprecated use {@link DesignModeContext#isAuthorityEditing()} instead |
||||
*/ |
||||
@Deprecated |
||||
public static boolean isAuthorityEditing() { |
||||
return DesignModeContext.isAuthorityEditing(); |
||||
} |
||||
} |
@ -1,59 +0,0 @@
|
||||
package com.fr.common.detect; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.module.ModuleContext; |
||||
import com.fr.web.WebSocketConfig; |
||||
|
||||
import java.net.Socket; |
||||
import java.util.concurrent.ExecutorService; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/10 |
||||
*/ |
||||
public class CommonPortDetector { |
||||
|
||||
private static final CommonPortDetector INSTANCE = new CommonPortDetector(); |
||||
private ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(new NamedThreadFactory("CommonPortDetector")); |
||||
|
||||
public static CommonPortDetector getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
public void execute() { |
||||
service.submit(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
detectTomcatPort(); |
||||
detectWebSocketPort(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void detectTomcatPort() { |
||||
int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); |
||||
if (checkPort(port)) { |
||||
FineLoggerFactory.getLogger().error("EmbedTomcat Port: {} is not available, maybe occupied by other programs, please check it!", port); |
||||
} |
||||
} |
||||
|
||||
private void detectWebSocketPort() { |
||||
Integer[] ports = WebSocketConfig.getInstance().getPort(); |
||||
for (int port : ports) { |
||||
if (checkPort(port)) { |
||||
FineLoggerFactory.getLogger().error("WebSocKet Port: {} is not available, maybe occupied by other programs, please check it!", port); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private boolean checkPort(int port) { |
||||
try (Socket socket = new Socket("localhost", port)) { |
||||
return true; |
||||
} catch (Exception e) { |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -1,12 +0,0 @@
|
||||
package com.fr.common.exception; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/27 |
||||
*/ |
||||
public interface ThrowableHandler { |
||||
|
||||
boolean process(Throwable e); |
||||
|
||||
} |
@ -1,51 +0,0 @@
|
||||
package com.fr.common.listener; |
||||
|
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import javax.swing.event.AncestorEvent; |
||||
import javax.swing.event.AncestorListener; |
||||
import javax.swing.event.ChangeListener; |
||||
|
||||
/** |
||||
* 管理数据集相关监听的注册 |
||||
* |
||||
* 原本的监听生命周期注册与销毁: |
||||
* |
||||
* 创建时组件时进行注册,在模板关闭时进行销毁 |
||||
* 但是在模板未关闭的这段时间,如果不断的打开和关闭某些弹窗,次数达到一定程度,会导致出现大量内存占用,除非此时关闭模板 |
||||
* |
||||
* 改成以下模式: |
||||
* |
||||
* 当组件可见或者被添加到某个大组件 注册相关监听 |
||||
* 当组件不可见或者被移除时 立即移除相关监听 |
||||
* 及时清理无效监听,减少实时内存占用 |
||||
* |
||||
* |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/2/14 |
||||
*/ |
||||
public class ManageDsListenerRegisterListener implements AncestorListener { |
||||
|
||||
private ChangeListener changeListener; |
||||
|
||||
public ManageDsListenerRegisterListener(ChangeListener changeListener) { |
||||
this.changeListener = changeListener; |
||||
} |
||||
|
||||
@Override |
||||
public void ancestorAdded(AncestorEvent event) { |
||||
DesignTableDataManager.addDsChangeListener(changeListener); |
||||
// 添加后 fire一下 更新数据
|
||||
changeListener.stateChanged(null); |
||||
} |
||||
|
||||
@Override |
||||
public void ancestorRemoved(AncestorEvent event) { |
||||
DesignTableDataManager.removeDsChangeLister(changeListener); |
||||
} |
||||
|
||||
@Override |
||||
public void ancestorMoved(AncestorEvent event) { |
||||
// do nothing
|
||||
} |
||||
} |
@ -1,21 +0,0 @@
|
||||
package com.fr.common.report; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/27 |
||||
*/ |
||||
public enum ReportState { |
||||
|
||||
STOP("stop"), ACTIVE("active"); |
||||
|
||||
private String value; |
||||
|
||||
ReportState(String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
public String getValue() { |
||||
return this.value; |
||||
} |
||||
} |
@ -1,103 +0,0 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.design.constants.DesignerLaunchStatus; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.fun.HyperlinkProvider; |
||||
import com.fr.design.fun.TableDataDefineProvider; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.ui.util.UIUtil; |
||||
import com.fr.plugin.observer.PluginEvent; |
||||
import com.fr.plugin.observer.PluginEventListener; |
||||
import com.fr.plugin.observer.PluginEventType; |
||||
import com.fr.plugin.observer.PluginListenerRegistration; |
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/12/17 |
||||
*/ |
||||
public class PluginClassRefreshManager { |
||||
|
||||
|
||||
private static final PluginClassRefreshManager INSTANCE = new PluginClassRefreshManager(); |
||||
|
||||
private final Set<String> context = new HashSet<>(); |
||||
|
||||
private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
// 重载模版之前 触发下hide
|
||||
fireTabChange(); |
||||
// 兼容之前版本特性
|
||||
for (String tag : context) { |
||||
if (event.getContext().contain(tag)) { |
||||
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); |
||||
return; |
||||
} |
||||
} |
||||
// 重新载入模板xml内容 到 Workbook/Form对象中
|
||||
HistoryTemplateListCache.getInstance().reloadAllEditingTemplateByPlugin(event.getContext()); |
||||
} |
||||
}; |
||||
|
||||
private final PluginEventListener beforeAllPluginActive = new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
PluginListenerRegistration.getInstance().stopListen(pluginAfterRunEventListener); |
||||
} |
||||
}; |
||||
|
||||
private final PluginEventListener afterAllPluginsActive = new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); |
||||
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { |
||||
fireTabChange(); |
||||
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
public void fireTabChange() { |
||||
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (template != null) { |
||||
UIUtil.invokeLaterIfNeeded(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
template.fireTabChange(); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
|
||||
public static PluginClassRefreshManager getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
public void load() { |
||||
context.add(TableDataDefineProvider.XML_TAG); |
||||
context.add(HyperlinkProvider.XML_TAG); |
||||
} |
||||
|
||||
private PluginClassRefreshManager() { |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllActive, beforeAllPluginActive); |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterAllActive, afterAllPluginsActive); |
||||
} |
||||
|
||||
public void removePluginListener() { |
||||
PluginListenerRegistration.getInstance().stopListen(this.pluginAfterRunEventListener); |
||||
PluginListenerRegistration.getInstance().stopListen(this.beforeAllPluginActive); |
||||
PluginListenerRegistration.getInstance().stopListen(this.afterAllPluginsActive); |
||||
} |
||||
|
||||
public void addPluginListener() { |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginAfterRunEventListener); |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllActive, beforeAllPluginActive); |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterAllActive, afterAllPluginsActive); |
||||
} |
||||
|
||||
} |
@ -1,26 +0,0 @@
|
||||
package com.fr.design.actions; |
||||
|
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIForbiddenButton; |
||||
import javax.swing.AbstractButton; |
||||
import javax.swing.JComponent; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/4/12 |
||||
*/ |
||||
public abstract class ForbiddenUpdateAction extends UpdateAction { |
||||
|
||||
@Override |
||||
public JComponent createToolBarComponent() { |
||||
Object object = this.getValue(UIForbiddenButton.class.getName()); |
||||
if (!(object instanceof AbstractButton)) { |
||||
UIButton button = null; |
||||
button = new UIForbiddenButton(); |
||||
object = initButton(button, UIForbiddenButton.class.getName()); |
||||
} |
||||
|
||||
return (JComponent) object; |
||||
} |
||||
} |
@ -1,48 +0,0 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.locale.impl.BugNeedMark; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.design.utils.BrowseUtils; |
||||
import com.fr.general.locale.LocaleCenter; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* @Author: Yuan.Wang |
||||
* @Date: 2020/7/28 |
||||
*/ |
||||
public class BugNeedAction extends UpdateAction { |
||||
public BugNeedAction() { |
||||
this.setMenuKeySet(BugAndNeed); |
||||
this.setName(getMenuKeySet().getMenuName()); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon("/com/fr/design/images/bbs/need"); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
LocaleMark<String> localeMark = LocaleCenter.getMark(BugNeedMark.class); |
||||
BrowseUtils.browser(localeMark.getValue()); |
||||
} |
||||
|
||||
public static final MenuKeySet BugAndNeed = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_BugAndNeed"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
} |
@ -1,40 +0,0 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.design.utils.BrowseUtils; |
||||
import com.fr.general.CloudCenter; |
||||
import javax.swing.KeyStroke; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
public class FacebookFansAction extends UpAction { |
||||
|
||||
public FacebookFansAction() { |
||||
this.setMenuKeySet(FACEBOOKFANS); |
||||
this.setName(getMenuKeySet().getMenuName()); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon("/com/fr/design/images/bbs/facebook"); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent arg0) { |
||||
BrowseUtils.browser(CloudCenter.getInstance().acquireUrlByKind("facebook.fans.tw", "https://www.facebook.com/twfinereport")); |
||||
} |
||||
|
||||
public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 'F'; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_FaceBook_Fans"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
} |
@ -1,17 +0,0 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.login.AbstractDesignerSSO; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
public class StudyPlanAction extends AbstractDesignerSSO { |
||||
public StudyPlanAction() { |
||||
this.setName(Toolkit.i18nText("Fine-Design_Study_Plan")); |
||||
this.setSmallIcon("/com/fr/design/images/bbs/studyPlan"); |
||||
} |
||||
|
||||
@Override |
||||
public String getJumpUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind("bbs.studyPlan", "https://edu.fanruan.com/studypath/finereport"); |
||||
} |
||||
} |
@ -1,49 +0,0 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.locale.impl.TechSupportMark; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.design.utils.BrowseUtils; |
||||
import com.fr.general.locale.LocaleCenter; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* @Author: Yuan.Wang |
||||
* @Date: 2020/7/28 |
||||
*/ |
||||
public class TechSupportAction extends UpdateAction { |
||||
public TechSupportAction() { |
||||
this.setMenuKeySet(TechSupport); |
||||
this.setName(getMenuKeySet().getMenuName()); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/support.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
LocaleMark<String> localeMark = LocaleCenter.getMark(TechSupportMark.class); |
||||
String str=localeMark.getValue(); |
||||
BrowseUtils.browser(localeMark.getValue()); |
||||
} |
||||
|
||||
public static final MenuKeySet TechSupport = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_TechSupport"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
} |
@ -1,52 +0,0 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.login.AbstractDesignerSSO; |
||||
import com.fr.design.mainframe.share.collect.ComponentCollector; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.design.utils.BrowseUtils; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
import javax.swing.KeyStroke; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/03/24 |
||||
**/ |
||||
public class TemplateStoreAction extends AbstractDesignerSSO { |
||||
|
||||
public TemplateStoreAction() { |
||||
|
||||
this.setMenuKeySet(TEMPLATE); |
||||
this.setName(getMenuKeySet().getMenuName()); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/share/template_store.png")); |
||||
} |
||||
|
||||
public static final MenuKeySet TEMPLATE = new MenuKeySet() { |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
|
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Share_Template_Store"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public char getMnemonic() { |
||||
|
||||
return 'T'; |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
public String getJumpUrl() { |
||||
ComponentCollector.getInstance().collectTepMenuEnterClick(); |
||||
return CloudCenter.getInstance().acquireUrlByKind("design.market.template", "https://market.fanruan.com/template"); |
||||
} |
||||
} |
@ -1,21 +0,0 @@
|
||||
package com.fr.design.actions.community; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.general.CloudCenter; |
||||
|
||||
/** |
||||
* @Description 工单中心 |
||||
* @Author Henry.Wang |
||||
* @Date 2021/3/8 14:02 |
||||
**/ |
||||
public class WorkOrderCenterAction extends UpAction { |
||||
public WorkOrderCenterAction() { |
||||
this.setSmallIcon("/com/fr/design/images/bbs/workOrderCenter"); |
||||
this.setName(Toolkit.i18nText("Fine-Design_Basic_Commuinity_Work_Order_Center")); |
||||
} |
||||
|
||||
@Override |
||||
public String getJumpUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind("bbs.work.order.center", "https://service.fanruan.com/ticket"); |
||||
} |
||||
} |
@ -1,44 +1 @@
|
||||
package com.fr.design.actions.file; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.file.MutilTempalteTabPane; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.menu.KeySetUtils; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* Author : daisy |
||||
* Date: 13-8-16 |
||||
* Time: 下午3:23 |
||||
*/ |
||||
public class CloseCurrentTemplateAction extends UpdateAction { |
||||
|
||||
public CloseCurrentTemplateAction() { |
||||
this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); |
||||
this.setName(getMenuKeySet().getMenuKeySetName()); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setAccelerator(getMenuKeySet().getKeyStroke()); |
||||
} |
||||
|
||||
/** |
||||
* 动作 |
||||
* @param e 事件 |
||||
*/ |
||||
public void actionPerformed(ActionEvent e) { |
||||
MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); |
||||
MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); |
||||
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
super.update(); |
||||
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
if (template != null) { |
||||
this.setEnabled(!template.isSaving()); |
||||
} |
||||
} |
||||
} |
||||
package com.fr.design.actions.file;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.menu.KeySetUtils;
import java.awt.event.ActionEvent;
/**
* Author : daisy
* Date: 13-8-16
* Time: 下午3:23
*/
public class CloseCurrentTemplateAction extends UpdateAction {
public CloseCurrentTemplateAction() {
this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
MutilTempalteTabPane.getInstance().setIsCloseCurrent(true);
MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
}
} |
@ -1,235 +0,0 @@
|
||||
package com.fr.design.actions.file.export; |
||||
|
||||
import com.fr.design.actions.JTemplateAction; |
||||
import com.fr.design.base.mode.DesignModeContext; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.gui.iprogressbar.FRProgressBar; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.exception.RemoteDesignPermissionDeniedException; |
||||
import com.fr.file.FILE; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.file.RenameExportFILE; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.io.exporter.DesignExportType; |
||||
import com.fr.io.exporter.ExporterKey; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.ProductConstants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.jodd.io.FileNameUtil; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.exporter.TemplateExportOperator; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingWorker; |
||||
import javax.swing.UIManager; |
||||
import java.awt.event.ActionEvent; |
||||
import java.io.OutputStream; |
||||
import java.util.Map; |
||||
|
||||
public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JTemplateAction<E> { |
||||
|
||||
private FRProgressBar progressbar; |
||||
|
||||
public AbstractExportAction(E t) { |
||||
super(t); |
||||
} |
||||
|
||||
/** |
||||
* 导出接口名 |
||||
* |
||||
* @return String scopeName |
||||
*/ |
||||
public abstract ExporterKey exportKey(); |
||||
|
||||
/** |
||||
* 导出类型 |
||||
* |
||||
* @return DesignExportType tyoe |
||||
*/ |
||||
public abstract DesignExportType exportType(); |
||||
|
||||
/** |
||||
* 目标文件过滤器 |
||||
* |
||||
* @return ChooseFileFilter filter |
||||
*/ |
||||
protected abstract ChooseFileFilter getChooseFileFilter(); |
||||
|
||||
/** |
||||
* 目标文件扩展名 |
||||
* |
||||
* @return String extensionName |
||||
*/ |
||||
protected abstract String getDefaultExtension(); |
||||
|
||||
/** |
||||
* 处理参数 |
||||
* |
||||
* @return Map para |
||||
*/ |
||||
protected abstract Map<String, Object> processParameter(); |
||||
|
||||
|
||||
/** |
||||
* 执行方法 |
||||
*/ |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
|
||||
if (!processNotSaved()) { |
||||
return; |
||||
} |
||||
|
||||
Map<String, Object> para = processParameter(); |
||||
|
||||
// 选择输入的文件
|
||||
FILEChooserPane fileChooserPane = FILEChooserPane.getMultiEnvInstance(true, false); |
||||
fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter()); |
||||
|
||||
|
||||
String fileName = getTargetFileName(); |
||||
fileChooserPane.setFileNameTextField(fileName, "." + this.getDefaultExtension()); |
||||
int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), "." + this.getDefaultExtension()); |
||||
if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) { |
||||
FILE target = fileChooserPane.getSelectedFILE(); |
||||
//rename 方式导出
|
||||
target = RenameExportFILE.create(target); |
||||
try { |
||||
target.mkfile(); |
||||
} catch (Exception exp) { |
||||
FineLoggerFactory.getLogger().error("Error In Make New File", exp); |
||||
} |
||||
FineLoggerFactory.getLogger().info( |
||||
"\"" + RenameExportFILE.recoverFileName(target.getName()) + "\"" + |
||||
Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!" |
||||
); |
||||
|
||||
progressbar = new FRProgressBar( |
||||
createExportWork(getSource(), target, para), |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Report_Exporting"), |
||||
StringUtils.EMPTY, |
||||
0, |
||||
100); |
||||
|
||||
progressbar.start(); |
||||
} |
||||
} |
||||
|
||||
private FILE getSource() { |
||||
return this.getEditingComponent().getEditingFILE(); |
||||
} |
||||
|
||||
private String getTargetFileName() { |
||||
FILE source = getSource(); |
||||
String fileName = source.getName(); |
||||
return FileNameUtil.removeExtension(fileName); |
||||
} |
||||
|
||||
private boolean processNotSaved() { |
||||
//当前编辑的模板
|
||||
E e = getEditingComponent(); |
||||
if (!e.isALLSaved() && !DesignModeContext.isVcsMode()) { |
||||
e.stopEditing(); |
||||
int returnVal = FineJOptionPane.showConfirmDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + e.getEditingFILE() + "\" ?", |
||||
Toolkit.i18nText("Fine-Design_Basic_Confirm"), |
||||
JOptionPane.YES_NO_CANCEL_OPTION, |
||||
JOptionPane.QUESTION_MESSAGE |
||||
); |
||||
if (returnVal == JOptionPane.YES_OPTION) { |
||||
e.saveTemplate(); |
||||
FineLoggerFactory.getLogger().info( |
||||
Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", e.getEditingFILE().getName()) |
||||
); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
private SwingWorker createExportWork(final FILE source, final FILE target, final Map<String, Object> parameterMap) { |
||||
final String path = source.getPath(); |
||||
final String name = RenameExportFILE.recoverFileName(target.getName()); |
||||
|
||||
return new SwingWorker<Void, Void>() { |
||||
|
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
//bug 10516
|
||||
Thread.sleep(100); |
||||
try (OutputStream outputStream = target.asOutputStream()) { |
||||
this.setProgress(10); |
||||
dealExporter(outputStream, path, parameterMap); |
||||
this.setProgress(80); |
||||
outputStream.flush(); |
||||
this.setProgress(100); |
||||
|
||||
FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!"); |
||||
FineJOptionPane.showMessageDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + name); |
||||
|
||||
|
||||
} catch (RemoteDesignPermissionDeniedException exp) { |
||||
this.setProgress(100); |
||||
target.closeTemplate(); |
||||
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); |
||||
FineJOptionPane.showMessageDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), |
||||
JOptionPane.ERROR_MESSAGE, |
||||
UIManager.getIcon("OptionPane.errorIcon") |
||||
); |
||||
} catch (Exception exp) { |
||||
this.setProgress(100); |
||||
target.closeTemplate(); |
||||
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); |
||||
FineJOptionPane.showMessageDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), |
||||
JOptionPane.ERROR_MESSAGE, |
||||
UIManager.getIcon("OptionPane.errorIcon") |
||||
); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void done() { |
||||
progressbar.close(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void dealExporter(OutputStream outputStream, String path, final Map<String, Object> para) throws Exception { |
||||
|
||||
// 没有办法处理这个 isLocal 判断,因为一个是修改参数传递结果,一个是返回值做结果
|
||||
// todo 后续想想办法
|
||||
if (WorkContext.getCurrent().isLocal()) { |
||||
WorkContext.getCurrent().get(TemplateExportOperator.class) |
||||
.export(exportKey(), exportType(), outputStream, path, para); |
||||
} else { |
||||
byte[] contents = |
||||
WorkContext.getCurrent().get(TemplateExportOperator.class) |
||||
.export(exportKey(), exportType(), null, path, para); |
||||
|
||||
outputStream.write(contents); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
super.update(); |
||||
this.setEnabled(this.getEditingComponent().checkEnable()); |
||||
} |
||||
|
||||
} |
@ -1,67 +0,0 @@
|
||||
package com.fr.design.actions.help; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import com.fr.web.struct.AssembleComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.impl.FineUI; |
||||
|
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-03-08 |
||||
*/ |
||||
public class FineUIAction extends UpdateAction { |
||||
|
||||
public FineUIAction() { |
||||
setName("FineUI"); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(final ActionEvent e) { |
||||
ModernUIPane<?> pane = new ModernUIPane.Builder<>() |
||||
// .prepare(new ScriptContextAdapter() {
|
||||
// @Override
|
||||
// public void onScriptContextCreated(ScriptContextEvent event) {
|
||||
// JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool");
|
||||
// pool.asObject().setProperty("i18n", new I18n());
|
||||
// }
|
||||
// })
|
||||
.withComponent(new AssembleComponent() { |
||||
|
||||
@Override |
||||
public ScriptPath script(RequestClient req) { |
||||
return ScriptPath.build("/com/fr/design/ui/help/demo.js"); |
||||
} |
||||
|
||||
@Override |
||||
public Atom[] refer() { |
||||
return new Atom[] {FineUI.KEY}; |
||||
} |
||||
}) |
||||
.build(); |
||||
BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
// Do nothing
|
||||
} |
||||
}); |
||||
dialog.setVisible(true); |
||||
|
||||
} |
||||
|
||||
public static class I18n { |
||||
|
||||
public String i18nText(String key) { |
||||
return InterProviderFactory.getProvider().getLocText(key); |
||||
} |
||||
} |
||||
} |
@ -1,200 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.json.JSONArray; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 云端变量统一管理 |
||||
* |
||||
* @author Link |
||||
* @version 11.0 |
||||
* Created by Link on 2022/9/28 |
||||
*/ |
||||
public class AlphaFineCloudConstants { |
||||
|
||||
private static final String PLUGIN_SEARCH_API = "plugin.searchAPI"; |
||||
private static final String PLUGIN_ALL_SEARCH_API = "plugin.all.searchAPI"; |
||||
private static final String AF_PLUGIN_INFO = "af.pluginInfo"; |
||||
private static final String AF_REUSE_INFO = "af.reuseInfo"; |
||||
private static final String AF_DOC_VIEW = "af.doc_view"; |
||||
private static final String AF_DOC_SEARCH = "af.doc_search"; |
||||
private static final String AF_DOC_INFO = "af.doc_info"; |
||||
private static final String AF_PLUGIN_IMAGE = "af.plugin_image"; |
||||
private static final String AF_RECORD = "af.record"; |
||||
private static final String AF_CLOUD_SEARCH = "af.cloud_search"; |
||||
private static final String AF_SIMILAR_SEARCH = "af.similar_search"; |
||||
private static final String AF_ADVICE_SEARCH = "af.advice_search"; |
||||
private static final String AF_HOT_SEARCH = "af.hot_search"; |
||||
private static final String AF_GO_FORUM = "af.go_fourm"; |
||||
private static final String AF_GO_WEB = "af.go_web"; |
||||
private static final String AF_PREVIEW = "af.preview"; |
||||
private static final String AF_CID_NEW = "af.cid.new"; |
||||
private static final String AF_CID_USER_GROUP_INFO = "af.cid.user.group.info"; |
||||
private static final String AF_HELP_QUICK_START = "af.help.quick.start"; |
||||
private static final String AF_HELP_REPORT_LEARNING_PATH = "af.help.report.learning.path"; |
||||
private static final String AF_HELP_PARAM_LEARNING_PATH = "af.help.param.learning.path"; |
||||
private static final String AF_HELP_FILL_LEARNING_PATH = "af.help.fill.learning.path"; |
||||
private static final String AF_HELP_API_SUMMARY = "af.help.api.summary"; |
||||
private static final String AF_HELP_MONTHLY_DOCUMENT = "af.help.monthly.document"; |
||||
private static final String AF_RECOMMEND = "af.recommend"; |
||||
|
||||
private static final String LINK_NAME = "name"; |
||||
private static final String LINK_URL = "link"; |
||||
|
||||
/** |
||||
* 获取插件搜索api |
||||
*/ |
||||
public static String getPluginSearchUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_SEARCH_API); |
||||
}; |
||||
|
||||
/** |
||||
* 帆软市场里全部插件api |
||||
*/ |
||||
public static String getSearchAllPluginUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_ALL_SEARCH_API); |
||||
} |
||||
|
||||
/** |
||||
* 获取插件信息api |
||||
*/ |
||||
public static String getPluginUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_INFO); |
||||
} |
||||
|
||||
/** |
||||
* 获取组件信息api |
||||
*/ |
||||
public static String getReuseUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_REUSE_INFO); |
||||
} |
||||
|
||||
/** |
||||
* 获取帮助文档url |
||||
*/ |
||||
public static String getDocumentDocUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_VIEW); |
||||
} |
||||
|
||||
/** |
||||
* 帮助文档搜索api |
||||
*/ |
||||
public static String getDocumentSearchUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_SEARCH); |
||||
} |
||||
|
||||
/** |
||||
* 帮助文档信息api |
||||
*/ |
||||
public static String getDocumentInformationUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_INFO); |
||||
} |
||||
|
||||
/** |
||||
* 插件图片api |
||||
*/ |
||||
public static String getPluginImageUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_IMAGE); |
||||
} |
||||
|
||||
/** |
||||
* 获取云端接口,用于上传alphafine搜索记录 |
||||
*/ |
||||
public static String getCloudServerUrl() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_RECORD); |
||||
} |
||||
|
||||
/** |
||||
* 获取搜索api,输入搜索词,返回fr的相关功能 |
||||
*/ |
||||
public static String getSearchApi() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_CLOUD_SEARCH); |
||||
} |
||||
|
||||
/** |
||||
* 获取模糊搜索api前缀,输入搜索词,返回alphaFine相关内容,插件,文档,功能等 |
||||
*/ |
||||
public static String getSimilarSearchUrlPrefix() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_SIMILAR_SEARCH); |
||||
} |
||||
|
||||
/** |
||||
* 补全建议搜索结果 api,与AF_SIMILAR_SEARCH接口类似,但是返回的信息更全 |
||||
*/ |
||||
public static String getComplementAdviceSearchUrlPrefix() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_ADVICE_SEARCH); |
||||
} |
||||
|
||||
/** |
||||
* 获取热门问题 |
||||
*/ |
||||
public static String getAlphaHotSearch() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_HOT_SEARCH); |
||||
} |
||||
|
||||
/** |
||||
* 跳转论坛url |
||||
*/ |
||||
public static String getAlphaGoToForum() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_GO_FORUM); |
||||
} |
||||
|
||||
/** |
||||
* 推荐搜索api,输入搜索词,返回猜你想搜的内容(html格式) |
||||
*/ |
||||
public static String getAlphaGoToWeb() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_GO_WEB); |
||||
} |
||||
|
||||
/** |
||||
* 帆软智能客服页面url |
||||
*/ |
||||
public static String getAlphaPreview() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_PREVIEW); |
||||
} |
||||
|
||||
/** |
||||
* cid系统的产品动态api |
||||
*/ |
||||
public static String getAlphaCid() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_CID_NEW); |
||||
} |
||||
|
||||
/** |
||||
* cid系统的 用户组信息api |
||||
*/ |
||||
public static String getAlphaCidUserGroupInfo() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_CID_USER_GROUP_INFO); |
||||
} |
||||
|
||||
private static String getDefaultRecommend() { |
||||
String[][] links = new String[][]{ |
||||
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Quick_Start"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_QUICK_START)}, |
||||
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Report_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_REPORT_LEARNING_PATH)}, |
||||
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Parameter_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_PARAM_LEARNING_PATH)}, |
||||
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Fill_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_FILL_LEARNING_PATH)}, |
||||
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Api_Summary"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_API_SUMMARY)}, |
||||
{Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Monthly_Document"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_MONTHLY_DOCUMENT)} |
||||
}; |
||||
JSONArray jsonArray = new JSONArray(); |
||||
for (String[] link : links) { |
||||
Map<String, String> map = new HashMap<>(); |
||||
map.put(LINK_NAME, link[0]); |
||||
map.put(LINK_URL, link[1]); |
||||
jsonArray.put(map); |
||||
} |
||||
|
||||
return jsonArray.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 获取默认推荐帮助文档url |
||||
*/ |
||||
public static String getAlphaHelpRecommend() { |
||||
return CloudCenter.getInstance().acquireUrlByKind(AF_RECOMMEND, getDefaultRecommend()); |
||||
} |
||||
} |
@ -1,199 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
import com.fr.base.extension.FileExtension; |
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.utils.DesignUtils; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.Font; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.LinkedHashSet; |
||||
import java.util.Set; |
||||
|
||||
|
||||
/** |
||||
* Created by XiaXiang on 2017/5/10. |
||||
*/ |
||||
public class AlphaFineConstants { |
||||
|
||||
|
||||
public static final String FUNCTION = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Function"); |
||||
|
||||
public static final String MY_TEMPLATES = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_My_Templates"); |
||||
|
||||
public static final String PRODUCT_NEWS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_News"); |
||||
|
||||
public static final String HELP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"); |
||||
|
||||
public static final String PLUGIN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Plugin_Addon"); |
||||
|
||||
public static final String TEMPLATE_SHOP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop"); |
||||
|
||||
public static final int SHOW_SIZE = 5; |
||||
|
||||
public static final int MAX_FILE_SIZE = 1000; |
||||
|
||||
public static final int LATEST_SHOW_SIZE = 3; |
||||
|
||||
public static final int HEIGHT = 680; |
||||
|
||||
public static final int WIDTH = 460; |
||||
|
||||
public static final int LEFT_WIDTH = 300; |
||||
|
||||
public static final int RIGHT_WIDTH = 380; |
||||
|
||||
public static final int FIELD_HEIGHT = 55; |
||||
|
||||
public static final int CONTENT_HEIGHT = 405; |
||||
|
||||
public static final int CELL_HEIGHT = 29; |
||||
|
||||
public static final int CELL_TITLE_HEIGHT = 24; |
||||
|
||||
public static final int HOT_ICON_LABEL_HEIGHT = 36; |
||||
|
||||
public static final int HOT_ITEMS = 6; |
||||
|
||||
/** |
||||
* 限制搜索字符长度 |
||||
*/ |
||||
public static final int LEN_LIMIT = 50; |
||||
|
||||
/** |
||||
* 帮助文档搜索间隔(ms) api限制了1s之内只能搜索一次 |
||||
*/ |
||||
public static final long DOCUMENT_SEARCH_GAP = 1000; |
||||
|
||||
public static final Dimension FULL_SIZE = new Dimension(680, 460); |
||||
|
||||
public static final Dimension CONTENT_SIZE = new Dimension(680, 405); |
||||
|
||||
public static final Dimension FIELD_SIZE = new Dimension(680, 55); |
||||
|
||||
public static final Dimension ICON_LABEL_SIZE = new Dimension(64, 64); |
||||
|
||||
public static final Dimension HOT_ICON_LABEL_SIZE = new Dimension(36, 36); |
||||
|
||||
public static final Dimension HOT_ISSUES_JAPNEL_SIZE = new Dimension(213, 182); |
||||
|
||||
/** |
||||
* 展示面板的尺寸 |
||||
*/ |
||||
public static final Dimension PREVIEW_SIZE = new Dimension(680, 305); |
||||
|
||||
public static final Dimension CLOSE_BUTTON_SIZE = new Dimension(40, 40); |
||||
|
||||
public static final Color WHITE = new Color(0xf9f9f9); |
||||
|
||||
public static final Color LABEL_SELECTED = new Color(0x419bf9); |
||||
|
||||
public static final Color GRAY = new Color(0xd2d2d2); |
||||
|
||||
public static final Color LIGHT_GRAY = new Color(0xcccccc); |
||||
|
||||
public static final Color MEDIUM_GRAY = new Color(0x999999); |
||||
|
||||
public static final Color BLUE = new Color(0x3394f0); |
||||
|
||||
public static final Color BLACK = new Color(0x222222); |
||||
|
||||
public static final Color DARK_GRAY = new Color(0x666666); |
||||
|
||||
public static final Color RED = new Color(0xf46c4c); |
||||
|
||||
public static final String HIGH_LIGHT_COLOR = "rgb(51,148,240)"; |
||||
|
||||
public static final Font SMALL_FONT = DesignUtils.getDefaultGUIFont().applySize(10); |
||||
|
||||
public static final Font MEDIUM_FONT = DesignUtils.getDefaultGUIFont().applySize(12); |
||||
|
||||
public static final Font MEDIUM_FONT_ANOTHER = new Font("HiraginoSansGB-W3", 0, 12); |
||||
|
||||
public static final Font LARGE_FONT = DesignUtils.getDefaultGUIFont().applySize(18); |
||||
|
||||
public static final Font GREATER_FONT = DesignUtils.getDefaultGUIFont().applySize(20); |
||||
|
||||
public static final String IMAGE_URL = "/com/fr/design/mainframe/alphafine/images/"; |
||||
|
||||
public static final String ALPHA_HOT_IMAGE_NAME = "alphafine_hot"; |
||||
|
||||
public static final String SPECIAL_CHARACTER_REGEX = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]"; |
||||
|
||||
public static final String BOTTOM_REGEX_FIRST = "<div class=\"bang\">([\\s\\S]*?)class=\"jiaoyes\">YES</a><br/>"; |
||||
|
||||
public static final String BOTTOM_REGEX_SECOND = "<div class=\"yes_([\\s\\S]*?)帮助</a></div></div>"; |
||||
|
||||
public static final String LINK_REGEX = "javascript:;\"([\\s\\S]*?)','"; |
||||
|
||||
public static final String LINK_REGEX_ANOTHER = "javascript:([\\s\\S]*?)url=\""; |
||||
|
||||
public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs"; |
||||
|
||||
public static final String SEARCH_BY_ID = "?id="; |
||||
|
||||
public static final String JAVASCRIPT_PREFIX = "javascript:SendJava"; |
||||
|
||||
public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]"; |
||||
|
||||
public static final String FIRST_PAGE = "-1"; |
||||
|
||||
public static final FileExtension[] FILE_EXTENSIONS = new FileExtension[]{FileExtension.CPT, FileExtension.FRM}; |
||||
|
||||
public static final int RECOMMEND_MAX_ITEM_NUM = 3; |
||||
|
||||
public static final String BACK_ICON_NAME = "back@1x.png"; |
||||
|
||||
public static final Icon NO_RESULT_ICON = IOUtils.readIcon(AlphaFineConstants.IMAGE_URL + "noresult.png"); |
||||
|
||||
public static final Color SUSPENDED_COLOR = new Color(84, 165, 249); |
||||
|
||||
public static final Color FOREGROUND_COLOR = new Color(51, 51, 52); |
||||
|
||||
/** |
||||
* 后面数字代表透明度 80% |
||||
*/ |
||||
public static final Color FOREGROUND_COLOR_8 = new Color(51, 51, 52, 204); |
||||
|
||||
public static final Color FOREGROUND_COLOR_6 = new Color(51, 51, 52, 153); |
||||
|
||||
public static final Color FOREGROUND_COLOR_5 = new Color(51, 51, 52, 128); |
||||
|
||||
public static final Color BACKGROUND_COLOR = new Color(245, 245, 247); |
||||
|
||||
public static final Icon BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bulb.svg"); |
||||
|
||||
public static final Icon YELLOW_BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/yellow_bulb.svg"); |
||||
|
||||
public static final Icon LIGHT_YELLOW_BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg"); |
||||
|
||||
public static final String HOT_SEARCH = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search"); |
||||
|
||||
public static final Set<String> HOT_SEARCH_SET = new LinkedHashSet<>( |
||||
Arrays.asList( |
||||
Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search_TOP_ONE"), |
||||
Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search_TOP_TWO"), |
||||
Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search_TOP_THREE") |
||||
) |
||||
); |
||||
|
||||
|
||||
public static final ArrayList<String> CONJUNCTION = new ArrayList<String>() {{ |
||||
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_HE")); |
||||
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_YU")); |
||||
add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Conjunction_DE")); |
||||
}}; |
||||
|
||||
public static final String LOADING = "loading"; |
||||
|
||||
public static final String NETWORK_ERROR = "network error"; |
||||
|
||||
public static final String TITLE = "AlphaFine"; |
||||
|
||||
public static final int DEFAULT_CLICK_COUNT = 1; |
||||
} |
@ -1,44 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/4/26 |
||||
*/ |
||||
public class AlphaFineShortCutUtil { |
||||
|
||||
private static final String TYPE = "pressed"; |
||||
private static final String DISPLAY_TYPE = "+"; |
||||
private static final String BACK_SLASH = "BACK_SLASH"; |
||||
private static final String DISPLAY_BACK_SLASH = "\\"; |
||||
private static final String SLASH = "SLASH"; |
||||
private static final String DISPLAY_SLASH = "/"; |
||||
private static final String CONTROL = "CONTROL"; |
||||
private static final String DISPLAY_CONTROL = "ctrl"; |
||||
private static final String OPEN_BRACKET = "OPEN_BRACKET"; |
||||
private static final String DISPLAY_OPEN_BRACKET = "{"; |
||||
private static final String CLOSE_BRACKET = "CLOSE_BRACKET"; |
||||
private static final String DISPLAY_CLOSE_BRACKET = "}"; |
||||
private static final String COMMA = "COMMA"; |
||||
private static final String DISPLAY_COMMA = ","; |
||||
private static final String PERIOD = "PERIOD"; |
||||
private static final String DISPLAY_PERIOD = "."; |
||||
private static final String SEMICOLON = "SEMICOLON"; |
||||
private static final String DISPLAY_SEMICOLON = ";"; |
||||
private static final String QUOTE = "QUOTE"; |
||||
private static final String DISPLAY_QUOTE = "'"; |
||||
private static final String EQUALS = "EQUALS"; |
||||
private static final String DISPLAY_EQUALS = "+"; |
||||
private static final String MINUS = "MINUS"; |
||||
private static final String DISPLAY_MINUS = "-"; |
||||
private static final String COMMAND = "META"; |
||||
private static final String SMALL_COMMAND = "meta"; |
||||
private static final String DISPLAY_COMMAND = "\u2318"; |
||||
|
||||
public static String getDisplayShortCut(String shortCut) { |
||||
return shortCut.replace(TYPE, DISPLAY_TYPE).replace(BACK_SLASH, DISPLAY_BACK_SLASH).replace(SLASH, DISPLAY_SLASH) |
||||
.replace(CONTROL, DISPLAY_CONTROL).replace(OPEN_BRACKET, DISPLAY_OPEN_BRACKET).replace(CLOSE_BRACKET, DISPLAY_CLOSE_BRACKET) |
||||
.replace(COMMA, DISPLAY_COMMA).replace(PERIOD, DISPLAY_PERIOD).replace(SEMICOLON, DISPLAY_SEMICOLON).replace(QUOTE, DISPLAY_QUOTE) |
||||
.replace(EQUALS, DISPLAY_EQUALS).replace(MINUS, DISPLAY_MINUS).replace(COMMAND, DISPLAY_COMMAND).replace(SMALL_COMMAND, DISPLAY_COMMAND); |
||||
} |
||||
} |
@ -1,30 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine; |
||||
|
||||
import java.util.Stack; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 11.0 |
||||
* Created by hades on 2022/4/23 |
||||
*/ |
||||
public class SizedStack<T> extends Stack<T> { |
||||
|
||||
private final int maxSize; |
||||
|
||||
public SizedStack(int size) { |
||||
super(); |
||||
this.maxSize = size; |
||||
} |
||||
|
||||
@Override |
||||
public T push(T object) { |
||||
while (this.size() >= maxSize) { |
||||
this.remove(0); |
||||
} |
||||
// 不重复
|
||||
if (this.contains(object)) { |
||||
return object; |
||||
} |
||||
return super.push(object); |
||||
} |
||||
} |
@ -1,229 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine.component; |
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.actions.help.alphafine.AlphaFineConfigPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.plaf.PanelUI; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.util.ArrayList; |
||||
import java.util.Comparator; |
||||
import java.util.HashMap; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* alphafine设置 - 搜索范围 - 自定义排序 - 弹出面板 |
||||
* |
||||
* @author Link |
||||
* @version 11.0 |
||||
* Created by Link on 2022/9/18 |
||||
*/ |
||||
public class CustomSortPane extends JPanel { |
||||
|
||||
|
||||
private static final int WIDTH = 147; |
||||
private static final int ITEM_HEIGHT = 23; |
||||
private static final int GAP = 1; |
||||
private static final Color BACKGROUND_COLOR = new Color(0xdadadd); |
||||
|
||||
private UIButton top; |
||||
private UIButton bottom; |
||||
private UIButton up; |
||||
private UIButton down; |
||||
private JPanel toolbarPane; |
||||
private MenuLabelPane sortItemPane; |
||||
private List<UICheckBox> sortItems; |
||||
private MenuLabel selectedLabel; |
||||
private AlphaFineConfigPane parentPane; |
||||
|
||||
public CustomSortPane(List<UICheckBox> items, AlphaFineConfigPane parentPane) { |
||||
this.sortItems = items; |
||||
this.parentPane = parentPane; |
||||
setLayout(new BorderLayout(GAP, GAP)); |
||||
int height = (sortItems.size() + 1) * (ITEM_HEIGHT + GAP) + GAP; |
||||
setPreferredSize(new Dimension(WIDTH, height)); |
||||
initComponent(); |
||||
add(toolbarPane, BorderLayout.NORTH); |
||||
add(sortItemPane, BorderLayout.CENTER); |
||||
revalidate(); |
||||
this.setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
public void setUI(PanelUI ui) { |
||||
super.setUI(ui); |
||||
setBackground(BACKGROUND_COLOR); |
||||
|
||||
} |
||||
|
||||
private void initComponent() { |
||||
createToolbarPane(); |
||||
createSortItemPane(); |
||||
} |
||||
|
||||
private void createToolbarPane() { |
||||
top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg"), false); |
||||
bottom = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom.svg"), false); |
||||
up = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up.svg"), false); |
||||
down = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down.svg"), false); |
||||
top.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top_disable.svg")); |
||||
bottom.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom_disable.svg")); |
||||
up.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up_disable.svg")); |
||||
down.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down_disable.svg")); |
||||
top.addActionListener(e -> { |
||||
SwingUtilities.invokeLater(() -> { |
||||
sortItemPane.setComponentZOrder(selectedLabel, 0); |
||||
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); |
||||
CustomSortPane.this.revalidate(); |
||||
CustomSortPane.this.repaint(); |
||||
refreshCurrentOrder(); |
||||
}); |
||||
|
||||
}); |
||||
bottom.addActionListener(e -> { |
||||
SwingUtilities.invokeLater(() -> { |
||||
sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentCount() - 1); |
||||
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); |
||||
CustomSortPane.this.revalidate(); |
||||
CustomSortPane.this.repaint(); |
||||
refreshCurrentOrder(); |
||||
}); |
||||
|
||||
}); |
||||
up.addActionListener(e -> { |
||||
SwingUtilities.invokeLater(() -> { |
||||
sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) - 1); |
||||
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); |
||||
CustomSortPane.this.revalidate(); |
||||
CustomSortPane.this.repaint(); |
||||
refreshCurrentOrder(); |
||||
}); |
||||
|
||||
}); |
||||
down.addActionListener(e -> { |
||||
SwingUtilities.invokeLater(() -> { |
||||
sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) + 1); |
||||
setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); |
||||
CustomSortPane.this.revalidate(); |
||||
CustomSortPane.this.repaint(); |
||||
refreshCurrentOrder(); |
||||
}); |
||||
|
||||
}); |
||||
toolbarPane = new JPanel(new FlowLayout(FlowLayout.TRAILING, GAP, GAP)); |
||||
toolbarPane.setBorder(BorderFactory.createEmptyBorder()); |
||||
toolbarPane.add(top); |
||||
toolbarPane.add(bottom); |
||||
toolbarPane.add(up); |
||||
toolbarPane.add(down); |
||||
} |
||||
|
||||
private void createSortItemPane() { |
||||
String[] currentTabOrder = parentPane.getCurrentOrder(); |
||||
Map<String, Integer> sortMap = new HashMap<>(); |
||||
for (int i = 0; i < currentTabOrder.length; i++) { |
||||
sortMap.put(currentTabOrder[i], i); |
||||
} |
||||
List<MenuLabel> sortLabels = new ArrayList<>(); |
||||
for (UICheckBox item : sortItems) { |
||||
MenuLabel label = new MenuLabel(item.getText(), (Function<MenuLabel, Object>) o -> { |
||||
selectedLabel = o; |
||||
disableButton(); |
||||
return null; |
||||
}); |
||||
sortLabels.add(label); |
||||
} |
||||
sortLabels.sort(Comparator.comparingInt(tab -> sortMap.get(tab.getText()))); |
||||
sortItemPane = new MenuLabelPane(sortLabels); |
||||
} |
||||
|
||||
/** |
||||
* 如果选中第一个和最后一个,则置灰向上和向下的按钮 |
||||
*/ |
||||
private void disableButton() { |
||||
int order = sortItemPane.getComponentZOrder(selectedLabel); |
||||
if (order == 0) { |
||||
setToolbarEnable(false, false, true, true); |
||||
} else if (order == sortItemPane.getComponentCount() - 1) { |
||||
setToolbarEnable(true, true, false, false); |
||||
} else { |
||||
setToolbarEnable(true, true, true, true); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置 置顶,上移,下移,置底 按钮的状态 |
||||
* true:启用 |
||||
* false:关闭 |
||||
*/ |
||||
private void setToolbarEnable(boolean top, boolean up, boolean down, boolean bottom) { |
||||
this.top.setEnabled(top); |
||||
this.up.setEnabled(up); |
||||
this.down.setEnabled(down); |
||||
this.bottom.setEnabled(bottom); |
||||
} |
||||
|
||||
/** |
||||
* 根据选项当前位置以及菜单大小设置 置顶,上移,下移,置底 按钮的状态 |
||||
*/ |
||||
private void setToolbarEnable(int order, int maxOrder) { |
||||
this.top.setEnabled(true); |
||||
this.up.setEnabled(true); |
||||
this.down.setEnabled(true); |
||||
this.bottom.setEnabled(true); |
||||
// 选项处于顶端,则置灰上移和置顶按钮
|
||||
if (order == 0) { |
||||
this.top.setEnabled(false); |
||||
this.up.setEnabled(false); |
||||
} |
||||
// 选项处于底端,则置灰下移和置底按钮
|
||||
if (order == maxOrder - 1) { |
||||
this.down.setEnabled(false); |
||||
this.bottom.setEnabled(false); |
||||
} |
||||
} |
||||
|
||||
private void refreshCurrentOrder() { |
||||
String[] currentTabOrder = parentPane.getCurrentOrder(); |
||||
HashSet<String> selectedTab = new HashSet<>(); |
||||
for (UICheckBox item : sortItems) { |
||||
selectedTab.add(item.getText()); |
||||
} |
||||
|
||||
// 未选中的tab,保持原排序不变
|
||||
Map<String, Integer> exTab = new HashMap<>(); |
||||
for (int i = 0; i < currentTabOrder.length; i++) { |
||||
if (!selectedTab.contains(currentTabOrder[i])) { |
||||
exTab.put(currentTabOrder[i], i); |
||||
} |
||||
} |
||||
|
||||
// 计算当前排序
|
||||
String[] newOrder = new String[currentTabOrder.length]; |
||||
Component[] components = sortItemPane.getComponents(); |
||||
for (String s : exTab.keySet()) { |
||||
newOrder[exTab.get(s)] = s; |
||||
} |
||||
|
||||
int t = 0; |
||||
for (int i = 0; i < newOrder.length; i++) { |
||||
if (StringUtils.isEmpty(newOrder[i])) { |
||||
newOrder[i] = ((MenuLabel) components[t++]).getText(); |
||||
} |
||||
} |
||||
parentPane.setCurrentOrder(newOrder); |
||||
} |
||||
|
||||
} |
@ -1,96 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine.component; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.utils.DesignUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.plaf.LabelUI; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.util.function.Function; |
||||
|
||||
/** |
||||
* 菜单选项label |
||||
* |
||||
* @author Link |
||||
* @version 11.0 |
||||
* Created by Link on 2022/9/18 |
||||
*/ |
||||
public class MenuLabel extends UILabel { |
||||
|
||||
private static final Color BACKGROUND_COLOR = Color.white; |
||||
private static final Color SELECTED_COLOR = new Color(0x419BF9); |
||||
private static final Color HOVERED_COLOR = new Color(0xd9ebfe); |
||||
private static final int HEIGHT = 23; |
||||
private static final int WIDTH = 147; |
||||
|
||||
private MenuLabelPane parentMenu; |
||||
private final Function function; |
||||
private boolean selected; |
||||
|
||||
public MenuLabel(String text, Function function) { |
||||
super(text); |
||||
this.function = function; |
||||
setOpaque(true); |
||||
addMouseListener(createMouseListener()); |
||||
} |
||||
|
||||
public void setParentMenu(MenuLabelPane menu) { |
||||
this.parentMenu = menu; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void setUI(LabelUI ui) { |
||||
super.setUI(ui); |
||||
this.setBackground(BACKGROUND_COLOR); |
||||
this.setBorder(BorderFactory.createEmptyBorder(2, 10, 1, 10)); |
||||
this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); |
||||
this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); |
||||
} |
||||
|
||||
public boolean isSelected() { |
||||
return selected; |
||||
} |
||||
|
||||
public void setSelected(boolean selected) { |
||||
if (selected) { |
||||
parentMenu.setNoneSelected(); |
||||
setBackground(SELECTED_COLOR); |
||||
function.apply(this); |
||||
this.selected = true; |
||||
} else { |
||||
setBackground(BACKGROUND_COLOR); |
||||
this.selected = false; |
||||
} |
||||
} |
||||
|
||||
MouseListener createMouseListener() { |
||||
return new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
super.mouseClicked(e); |
||||
setSelected(true); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
super.mouseEntered(e); |
||||
if (!selected) { |
||||
setBackground(HOVERED_COLOR); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
super.mouseExited(e); |
||||
if (!selected) { |
||||
setBackground(BACKGROUND_COLOR); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,34 +0,0 @@
|
||||
package com.fr.design.actions.help.alphafine.component; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.FlowLayout; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 简单菜单面板 |
||||
* |
||||
* @author Link |
||||
* @version 11.0 |
||||
* Created by Link on 2022/9/18 |
||||
*/ |
||||
public class MenuLabelPane extends JPanel { |
||||
|
||||
private static final int GAP = 1; |
||||
|
||||
private List<MenuLabel> labels; |
||||
|
||||
public MenuLabelPane(List<MenuLabel> labels) { |
||||
this.labels = labels; |
||||
setLayout(new FlowLayout(FlowLayout.CENTER, GAP, GAP)); |
||||
for (MenuLabel label : labels) { |
||||
label.setParentMenu(this); |
||||
add(label); |
||||
} |
||||
} |
||||
|
||||
public void setNoneSelected() { |
||||
for (MenuLabel label : labels) { |
||||
label.setSelected(false); |
||||
} |
||||
} |
||||
} |
@ -1,71 +0,0 @@
|
||||
package com.fr.design.base.clipboard; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.fun.ClipboardHandlerProvider; |
||||
import com.fr.plugin.injectable.PluginModule; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/05/14 |
||||
**/ |
||||
@SuppressWarnings({"rawtypes", "unchecked"}) |
||||
public abstract class ClipboardFilter { |
||||
public static Set<ClipboardHandlerProvider> clipboardHandlerProviders = new HashSet(); |
||||
|
||||
public static void registerClipboardHandler(ClipboardHandlerProvider provider) { |
||||
if (!clipboardHandlerProviders.contains(provider)) { |
||||
clipboardHandlerProviders.add(provider); |
||||
} |
||||
} |
||||
|
||||
public static void removeClipboardHandler(ClipboardHandlerProvider provider) { |
||||
if (clipboardHandlerProviders.contains(provider)) { |
||||
clipboardHandlerProviders.remove(provider); |
||||
} |
||||
} |
||||
|
||||
public static <T> T cut(T selection) { |
||||
for (ClipboardHandlerProvider provider : getClipboardHandlerProviders()) { |
||||
if (provider.support(selection)) { |
||||
selection = ((ClipboardHandlerProvider<T>) provider).cut(selection); |
||||
} |
||||
} |
||||
return selection; |
||||
} |
||||
|
||||
public static <T> T copy(T selection) { |
||||
for (ClipboardHandlerProvider provider : getClipboardHandlerProviders()) { |
||||
if (provider.support(selection)) { |
||||
selection = ((ClipboardHandlerProvider<T>) provider).copy(selection); |
||||
} |
||||
} |
||||
return selection; |
||||
} |
||||
|
||||
public static <T> T paste(T selection) { |
||||
for (ClipboardHandlerProvider provider : getClipboardHandlerProviders()) { |
||||
if (provider.support(selection)) { |
||||
selection = ((ClipboardHandlerProvider<T>) provider).paste(selection); |
||||
} |
||||
} |
||||
return selection; |
||||
} |
||||
|
||||
private static Set<ClipboardHandlerProvider> getClipboardHandlerProviders() { |
||||
Set<ClipboardHandlerProvider> providers = new HashSet<>(); |
||||
|
||||
for (ClipboardHandlerProvider clipboardHandlerProvider : clipboardHandlerProviders) { |
||||
providers.add(clipboardHandlerProvider); |
||||
} |
||||
|
||||
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); |
||||
Set<ClipboardHandlerProvider> pluginProviders = manager.getArray(ClipboardHandlerProvider.XML_TAG); |
||||
for (ClipboardHandlerProvider clipboardHandlerProvider : pluginProviders) { |
||||
providers.add(clipboardHandlerProvider); |
||||
} |
||||
|
||||
return providers; |
||||
} |
||||
} |
@ -1,35 +0,0 @@
|
||||
package com.fr.design.base.clipboard; |
||||
|
||||
public interface ClipboardHandler<T> { |
||||
/** |
||||
* 剪切 |
||||
* |
||||
* @param selection 选中 |
||||
* @return 处理后的内容 |
||||
*/ |
||||
T cut(T selection); |
||||
|
||||
/** |
||||
* 复制 |
||||
* |
||||
* @param selection 选中 |
||||
* @return 处理后的内容 |
||||
*/ |
||||
T copy(T selection); |
||||
|
||||
/** |
||||
* 粘贴 |
||||
* |
||||
* @param selection 选中 |
||||
* @return 处理后的内容 |
||||
*/ |
||||
T paste(T selection); |
||||
|
||||
/** |
||||
* 支持的类型 |
||||
* |
||||
* @param selection 内容 |
||||
* @return 是否 |
||||
*/ |
||||
boolean support(Object selection); |
||||
} |
@ -1,24 +0,0 @@
|
||||
package com.fr.design.base.clipboard; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class ClipboardHelper { |
||||
public static String formatExcelString(List<List<Object>> table) { |
||||
StringBuffer stringBuffer = new StringBuffer(); |
||||
|
||||
for (int row = 0; row < table.size(); row++) { |
||||
List<Object> rowValue = table.get(row); |
||||
for (int col = 0; col < rowValue.size(); col++) { |
||||
Object cell = rowValue.get(col); |
||||
stringBuffer.append(cell); |
||||
if (col != rowValue.size() - 1) { |
||||
stringBuffer.append("\t"); |
||||
} |
||||
} |
||||
if (row != table.size() - 1) { |
||||
stringBuffer.append("\n"); |
||||
} |
||||
} |
||||
return stringBuffer.toString(); |
||||
} |
||||
} |
@ -1,68 +0,0 @@
|
||||
package com.fr.design.base.clipboard; |
||||
|
||||
import java.awt.datatransfer.Clipboard; |
||||
import java.awt.datatransfer.ClipboardOwner; |
||||
import java.awt.datatransfer.DataFlavor; |
||||
import java.awt.datatransfer.FlavorListener; |
||||
import java.awt.datatransfer.Transferable; |
||||
import java.awt.datatransfer.UnsupportedFlavorException; |
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/05/11 |
||||
**/ |
||||
public class DesignerClipboard extends Clipboard { |
||||
|
||||
private Clipboard clipboard; |
||||
|
||||
public DesignerClipboard(Clipboard clipboard) { |
||||
super(clipboard.getName()); |
||||
this.clipboard = clipboard; |
||||
} |
||||
|
||||
@Override |
||||
public synchronized void setContents(Transferable contents, ClipboardOwner owner) { |
||||
//处理 contents/owner
|
||||
Transferable filtered = ClipboardFilter.copy(contents); |
||||
clipboard.setContents(filtered, owner); |
||||
} |
||||
|
||||
@Override |
||||
public synchronized Transferable getContents(Object requestor) { |
||||
Transferable contents = clipboard.getContents(requestor); |
||||
//处理 contents
|
||||
Transferable filtered = ClipboardFilter.paste(contents); |
||||
return filtered; |
||||
} |
||||
|
||||
@Override |
||||
public DataFlavor[] getAvailableDataFlavors() { |
||||
return clipboard.getAvailableDataFlavors(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isDataFlavorAvailable(DataFlavor flavor) { |
||||
return clipboard.isDataFlavorAvailable(flavor); |
||||
} |
||||
|
||||
@Override |
||||
public Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { |
||||
return clipboard.getData(flavor); |
||||
} |
||||
|
||||
@Override |
||||
public synchronized void addFlavorListener(FlavorListener listener) { |
||||
clipboard.addFlavorListener(listener); |
||||
} |
||||
|
||||
@Override |
||||
public synchronized void removeFlavorListener(FlavorListener listener) { |
||||
clipboard.removeFlavorListener(listener); |
||||
} |
||||
|
||||
@Override |
||||
public synchronized FlavorListener[] getFlavorListeners() { |
||||
return clipboard.getFlavorListeners(); |
||||
} |
||||
|
||||
} |
@ -1,78 +0,0 @@
|
||||
package com.fr.design.base.mode; |
||||
|
||||
import com.fr.design.designer.TargetComponent; |
||||
|
||||
import static com.fr.design.base.mode.DesignerMode.AUTHORITY; |
||||
import static com.fr.design.base.mode.DesignerMode.DUCHAMP; |
||||
|
||||
public class DesignModeContext { |
||||
|
||||
private static DesignerMode mode = DesignerMode.NORMAL; |
||||
|
||||
public static void switchTo(DesignerMode mode) { |
||||
changeMode(DesignModeContext.mode, mode); |
||||
} |
||||
|
||||
private static void changeMode(DesignerMode oldMode, DesignerMode newMode) { |
||||
if (oldMode != newMode) { |
||||
DesignModeContext.mode = newMode; |
||||
oldMode.closeMode(); |
||||
newMode.openMode(); |
||||
} |
||||
} |
||||
|
||||
public static DesignerMode getMode() { |
||||
return mode; |
||||
} |
||||
|
||||
/** |
||||
* 是否是版本控制模式 |
||||
* |
||||
* @return 是否是版本控制模式 |
||||
*/ |
||||
public static boolean isVcsMode() { |
||||
return mode == DesignerMode.VCS; |
||||
} |
||||
|
||||
/** |
||||
* @return 是否是禁止拷贝剪切模式 |
||||
*/ |
||||
public static boolean isBanCopyAndCut() { |
||||
return mode == DesignerMode.BAN_COPY_AND_CUT; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 是否为权限编辑 |
||||
* |
||||
* @return 是否为权限编辑 |
||||
*/ |
||||
public static boolean isAuthorityEditing() { |
||||
return mode == AUTHORITY; |
||||
} |
||||
|
||||
public static boolean isDuchampMode() { |
||||
return mode == DUCHAMP; |
||||
} |
||||
|
||||
public static void doCopy(TargetComponent principal) { |
||||
if (isBanCopyAndCut() || principal == null) { |
||||
return; |
||||
} |
||||
principal.copy(); |
||||
} |
||||
|
||||
public static boolean doPaste(TargetComponent principal) { |
||||
if (principal == null) { |
||||
return false; |
||||
} |
||||
return principal.paste(); |
||||
} |
||||
|
||||
public static boolean doCut(TargetComponent principal) { |
||||
if (isBanCopyAndCut() || principal == null) { |
||||
return false; |
||||
} |
||||
return principal.cut(); |
||||
} |
||||
} |
@ -1,25 +0,0 @@
|
||||
package com.fr.design.base.mode; |
||||
|
||||
|
||||
import com.fr.design.mainframe.DesignerContext; |
||||
|
||||
public enum DesignerMode { |
||||
NORMAL, |
||||
BAN_COPY_AND_CUT, |
||||
VCS, |
||||
AUTHORITY { |
||||
@Override |
||||
public void closeMode() { |
||||
DesignerContext.getDesignerFrame().closeAuthorityMode(); |
||||
} |
||||
}, |
||||
DUCHAMP; |
||||
|
||||
public void openMode() { |
||||
|
||||
} |
||||
|
||||
public void closeMode() { |
||||
} |
||||
|
||||
} |
@ -1,23 +0,0 @@
|
||||
package com.fr.design.beans; |
||||
|
||||
import com.fr.common.annotations.Open; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/9/24 |
||||
* 数据存取视图界面 |
||||
*/ |
||||
@Open |
||||
public abstract class BasicStorePane<T> extends BasicBeanPane<T> { |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
return null; |
||||
} |
||||
|
||||
public abstract void populateBean(T t); |
||||
|
||||
@Override |
||||
public abstract void updateBean(T t); |
||||
} |
@ -1,11 +0,0 @@
|
||||
package com.fr.design.beans; |
||||
|
||||
import javax.swing.JComponent; |
||||
|
||||
public interface ErrorMsgTextFieldAdapter { |
||||
void setText(String str); |
||||
|
||||
String getText(); |
||||
|
||||
JComponent getErrorMsgTextField(); |
||||
} |
@ -1,46 +0,0 @@
|
||||
package com.fr.design.beans; |
||||
|
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
|
||||
public class UITextFieldAdapter implements ErrorMsgTextFieldAdapter { |
||||
private final UITextField uiTextField = new UITextField(); |
||||
|
||||
public UITextFieldAdapter(){ |
||||
addDocumentListener(); |
||||
} |
||||
@Override |
||||
public void setText(String str) { |
||||
uiTextField.setText(str); |
||||
} |
||||
|
||||
@Override |
||||
public String getText() { |
||||
return uiTextField.getText(); |
||||
} |
||||
|
||||
public void addDocumentListener() { |
||||
uiTextField.getDocument().addDocumentListener(new DocumentListener() { |
||||
|
||||
public void changedUpdate(DocumentEvent e) { |
||||
uiTextField.setToolTipText(uiTextField.getText()); |
||||
} |
||||
|
||||
public void insertUpdate(DocumentEvent e) { |
||||
uiTextField.setToolTipText(uiTextField.getText()); |
||||
} |
||||
|
||||
public void removeUpdate(DocumentEvent e) { |
||||
uiTextField.setToolTipText(uiTextField.getText()); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public JComponent getErrorMsgTextField() { |
||||
return uiTextField; |
||||
} |
||||
} |
@ -1,17 +0,0 @@
|
||||
package com.fr.design.bridge.exec; |
||||
|
||||
import java.lang.annotation.ElementType; |
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
import java.lang.annotation.Target; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-18 |
||||
* 用于标记一个方法是用于和JS做桥接的,避免被误删除 |
||||
*/ |
||||
@Target(ElementType.METHOD) |
||||
@Retention(RetentionPolicy.SOURCE) |
||||
public @interface JSBridge { |
||||
} |
@ -1,18 +0,0 @@
|
||||
package com.fr.design.bridge.exec; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/5/27. |
||||
*/ |
||||
public class JSCallback { |
||||
|
||||
private JSExecutor executeScript; |
||||
|
||||
public JSCallback(JSExecutor jsExecutor) { |
||||
this.executeScript = jsExecutor; |
||||
} |
||||
|
||||
public void execute(String newValue) { |
||||
executeScript.executor(newValue); |
||||
} |
||||
} |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue