156 changed files with 5501 additions and 1443 deletions
@ -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; |
||||
} |
||||
} |
@ -0,0 +1,301 @@
|
||||
package com.fr.design.data.datapane.connect; |
||||
|
||||
import com.fr.data.impl.JDBCDatabaseConnection; |
||||
import com.fr.data.security.ssh.BaseSsh; |
||||
import com.fr.data.security.ssh.Ssh; |
||||
import com.fr.data.security.ssh.SshException; |
||||
import com.fr.data.security.ssh.SshType; |
||||
import com.fr.data.security.ssh.impl.KeyVerifySsh; |
||||
import com.fr.data.security.ssh.impl.NormalSsh; |
||||
import com.fr.design.border.UITitledBorder; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.editor.editor.NotNegativeIntegerEditor; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.file.FILE; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.project.ProjectConstants; |
||||
import com.fr.third.guava.collect.HashBiMap; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JPasswordField; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
import static com.fr.design.i18n.Toolkit.i18nText; |
||||
|
||||
/** |
||||
* @author xiqiu |
||||
* @date 2021/12/23 |
||||
* @description |
||||
*/ |
||||
public class SshPane extends BasicPane { |
||||
private static HashBiMap<String, SshType> typeMap; |
||||
|
||||
static { |
||||
typeMap = HashBiMap.create(); |
||||
typeMap.put(Toolkit.i18nText("Fine-Design_Basic_Password"), SshType.NORMAL); |
||||
typeMap.put(Toolkit.i18nText("Fine-Design_Basic_Ssh_Public_Key"), SshType.KEY); |
||||
} |
||||
|
||||
private UICheckBox usingSsh = new UICheckBox(i18nText("Fine-Design_Basic_Ssh_Using")); |
||||
private NotNegativeIntegerEditor port = new NotNegativeIntegerEditor(20); |
||||
private UITextField ip = new UITextField(20); |
||||
private UIComboBox type = new UIComboBox(); |
||||
private UITextField user = new UITextField(20); |
||||
private JPasswordField password = new UIPasswordFieldWithFixedLength(20); |
||||
private JPasswordField secret = new UIPasswordFieldWithFixedLength(20); |
||||
private KeyFileUITextField keyPath = new KeyFileUITextField(18); |
||||
private JPanel contextPane; |
||||
private Component[][] passwordComps; |
||||
private Component[][] keyComps; |
||||
private double p = TableLayout.PREFERRED; |
||||
private double f = TableLayout.FILL; |
||||
private JPanel jPanel; |
||||
private UIButton fileChooserButton = new UIButton(); |
||||
private double[] columnSize = new double[]{195, p}; |
||||
|
||||
public SshPane() { |
||||
fileChooserButton.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); |
||||
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Ssh_Settings"))); |
||||
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
||||
typeMap.keySet().forEach(key -> type.addItem(key)); |
||||
type.setSelectedItem(typeMap.inverse().get(SshType.KEY)); |
||||
jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
fileChooserButton.setPreferredSize(new Dimension(20, 20)); |
||||
type.setEditable(false); |
||||
type.setSelectedItem(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key")); |
||||
JPanel filePanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPath, fileChooserButton}}, new double[]{p}, new double[]{f, 20}, 0); |
||||
Component[] compIp = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Host") + ":", SwingConstants.RIGHT), ip}; |
||||
Component[] compPort = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Port") + ":", SwingConstants.RIGHT), port}; |
||||
Component[] compUserName = {new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName") + ":", SwingConstants.RIGHT), user}; |
||||
Component[] compMethod = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Verify_Method") + ":", SwingConstants.RIGHT), type}; |
||||
Component[] compPassword = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":", SwingConstants.RIGHT), password}; |
||||
Component[] compKey = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Private_Key") + ":", SwingConstants.RIGHT), filePanel}; |
||||
Component[] comSecret = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssh_Secret") + ":", SwingConstants.RIGHT), secret}; |
||||
|
||||
passwordComps = new Component[][]{ |
||||
compIp, |
||||
compPort, |
||||
compUserName, |
||||
compMethod, |
||||
compPassword |
||||
}; |
||||
keyComps = new Component[][]{ |
||||
compIp, |
||||
compPort, |
||||
compUserName, |
||||
compMethod, |
||||
compKey, |
||||
comSecret |
||||
}; |
||||
usingSsh.setSelected(true); |
||||
contextPane = TableLayoutHelper.createGapTableLayoutPane(keyComps, new double[]{p, p, p, p, p, p}, columnSize, 11, 11); |
||||
jPanel.add(usingSsh, BorderLayout.NORTH); |
||||
jPanel.add(contextPane, BorderLayout.CENTER); |
||||
this.add(jPanel); |
||||
|
||||
usingSsh.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
changePane(); |
||||
} |
||||
}); |
||||
|
||||
type.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
changePaneForType(); |
||||
} |
||||
}); |
||||
fileChooserButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(true)); |
||||
int type = fileChooser.showOpenDialog(SshPane.this, StringUtils.EMPTY); |
||||
if (type == FILEChooserPane.OK_OPTION) { |
||||
final FILE file = fileChooser.getSelectedFILE(); |
||||
if (file == null) { |
||||
keyPath.setText(StringUtils.EMPTY); |
||||
} else { |
||||
keyPath.setText(file.getPath()); |
||||
} |
||||
} |
||||
fileChooser.removeAllFilter(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
private void changePane() { |
||||
contextPane.setVisible(usingSsh.isSelected()); |
||||
} |
||||
|
||||
private void changePaneForType() { |
||||
contextPane.removeAll(); |
||||
switch (typeMap.get(type.getSelectedItem())) { |
||||
case NORMAL: |
||||
TableLayoutHelper.addComponent2ResultPane(passwordComps, new double[]{p, p, p, p, p}, columnSize, contextPane); |
||||
break; |
||||
case KEY: |
||||
TableLayoutHelper.addComponent2ResultPane(keyComps, new double[]{p, p, p, p, p, p}, columnSize, contextPane); |
||||
break; |
||||
default: |
||||
throw new SshException("un support ssh type"); |
||||
} |
||||
jPanel.revalidate(); |
||||
jPanel.repaint(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Basic_Ssh_Settings"); |
||||
} |
||||
|
||||
|
||||
public void populate(JDBCDatabaseConnection jdbcDatabase) { |
||||
if (jdbcDatabase.getSsh() == null) { |
||||
jdbcDatabase.setSsh(new NormalSsh()); |
||||
} |
||||
Ssh ssh = jdbcDatabase.getSsh(); |
||||
switch (ssh.getSshType()) { |
||||
case KEY: |
||||
type.setSelectedItem(typeMap.inverse().get(ssh.getSshType())); |
||||
KeyVerifySsh keyVerifySsh = (KeyVerifySsh) ssh; |
||||
keyPath.setText(keyVerifySsh.getPrivateKeyPath()); |
||||
secret.setText(keyVerifySsh.getSecret()); |
||||
password.setText(StringUtils.EMPTY); |
||||
setCommonConfig(keyVerifySsh); |
||||
break; |
||||
case NORMAL: |
||||
type.setSelectedItem(typeMap.inverse().get(ssh.getSshType())); |
||||
NormalSsh normalSsh = (NormalSsh) ssh; |
||||
password.setText(normalSsh.getSecret()); |
||||
keyPath.setText(StringUtils.EMPTY); |
||||
secret.setText(StringUtils.EMPTY); |
||||
setCommonConfig(normalSsh); |
||||
break; |
||||
default: |
||||
throw new SshException("un support ssh type"); |
||||
} |
||||
usingSsh.setSelected(ssh.isUsingSsh()); |
||||
changePane(); |
||||
} |
||||
|
||||
private void setCommonConfig(BaseSsh baseSsh) { |
||||
ip.setText(baseSsh.getIp()); |
||||
port.setValue(baseSsh.getPort()); |
||||
user.setText(baseSsh.getUser()); |
||||
} |
||||
|
||||
public void update(JDBCDatabaseConnection jdbcDatabase) { |
||||
Ssh ssh; |
||||
switch (typeMap.get(type.getSelectedItem())) { |
||||
case NORMAL: |
||||
NormalSsh normalSsh = new NormalSsh(); |
||||
normalSsh.setSecret(new String(password.getPassword()).trim()); |
||||
getCommonConfig(normalSsh); |
||||
ssh = normalSsh; |
||||
break; |
||||
case KEY: |
||||
KeyVerifySsh keyVerifySsh = new KeyVerifySsh(); |
||||
keyVerifySsh.setPrivateKeyPath(keyPath.getText().trim()); |
||||
keyVerifySsh.setSecret(new String(secret.getPassword()).trim()); |
||||
getCommonConfig(keyVerifySsh); |
||||
ssh = keyVerifySsh; |
||||
break; |
||||
default: |
||||
throw new SshException("un support ssh type"); |
||||
} |
||||
jdbcDatabase.setSsh(ssh); |
||||
} |
||||
|
||||
private void getCommonConfig(BaseSsh baseSsh) { |
||||
baseSsh.setUsingSsh(usingSsh.isSelected()); |
||||
baseSsh.setIp(ip.getText().trim()); |
||||
baseSsh.setPort(port.getValue()); |
||||
baseSsh.setUser(user.getText().trim()); |
||||
} |
||||
|
||||
public static class KeyFileUITextField extends UITextField { |
||||
private static final Pattern ERROR_START = Pattern.compile("^([/\\\\.]+).*"); |
||||
private static final Pattern MUTI_DOT = Pattern.compile("\\.+"); |
||||
private static final String PREFIX = ProjectConstants.RESOURCES_NAME + "/"; |
||||
private static final String UPPER = ".."; |
||||
|
||||
public KeyFileUITextField(int columns) { |
||||
this(); |
||||
this.setColumns(columns); |
||||
} |
||||
|
||||
|
||||
public KeyFileUITextField() { |
||||
super(); |
||||
this.addKeyListener(new KeyAdapter() { |
||||
@Override |
||||
public void keyReleased(KeyEvent e) { |
||||
String text = KeyFileUITextField.this.getTextOrigin(); |
||||
if (!StringUtils.isEmpty(text)) { |
||||
if (text.contains(UPPER)) { |
||||
text = MUTI_DOT.matcher(text).replaceAll("."); |
||||
KeyFileUITextField.this.setTextOrigin(text); |
||||
} |
||||
Matcher matcher = ERROR_START.matcher(text); |
||||
if (matcher.matches()) { |
||||
text = text.substring(matcher.group(1).length()); |
||||
KeyFileUITextField.this.setTextOrigin(text); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public String getTextOrigin() { |
||||
return super.getText(); |
||||
} |
||||
|
||||
public void setTextOrigin(String text) { |
||||
super.setText(text); |
||||
} |
||||
|
||||
@Override |
||||
public String getText() { |
||||
// 获取的时候,不为空,给他加上前缀就好了,否则还是空
|
||||
if (!StringUtils.isEmpty(super.getText())) { |
||||
return PREFIX + super.getText(); |
||||
} |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public void setText(String text) { |
||||
// 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀
|
||||
if (!StringUtils.isEmpty(text) && text.startsWith(PREFIX)) { |
||||
super.setText(text.replaceFirst(PREFIX, "")); |
||||
} else { |
||||
super.setText(text); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,164 @@
|
||||
package com.fr.design.data.datapane.connect; |
||||
|
||||
import com.fr.data.impl.JDBCDatabaseConnection; |
||||
import com.fr.data.security.ssl.Ssl; |
||||
import com.fr.data.security.ssl.SslException; |
||||
import com.fr.data.security.ssl.SslType; |
||||
import com.fr.data.security.ssl.impl.NormalSsl; |
||||
import com.fr.design.border.UITitledBorder; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.data.datapane.connect.SshPane.KeyFileUITextField; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.file.FILE; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.project.ProjectConstants; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
import static com.fr.design.i18n.Toolkit.i18nText; |
||||
|
||||
/** |
||||
* @author xiqiu |
||||
* @date 2022/1/4 |
||||
* @description |
||||
*/ |
||||
public class SslPane extends BasicPane { |
||||
UICheckBox usingSsl = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Using")); |
||||
private KeyFileUITextField keyPathCa = new KeyFileUITextField(18); |
||||
private UIButton fileChooserButtonCa = new UIButton(); |
||||
private KeyFileUITextField keyPathClientCert = new KeyFileUITextField(18); |
||||
private UIButton fileChooserButtonClientCert = new UIButton(); |
||||
private KeyFileUITextField keyPathClientKey = new KeyFileUITextField(18); |
||||
private UIButton fileChooserButtonClientKey = new UIButton(); |
||||
private UICheckBox verifyCa = new UICheckBox(i18nText("Fine-Design_Basic_Ssl_Verify_Ca")); |
||||
// private UITextField cipher = new UITextField(20);
|
||||
private JPanel jPanel; |
||||
private Component[][] usingComps; |
||||
private double p = TableLayout.PREFERRED; |
||||
private double f = TableLayout.FILL; |
||||
private JPanel contextPane; |
||||
private double[] columnSize = new double[]{195, p}; |
||||
|
||||
public SslPane() { |
||||
fileChooserButtonCa.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); |
||||
fileChooserButtonClientCert.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); |
||||
fileChooserButtonClientKey.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT)); |
||||
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Basic_Ssl_Settings"))); |
||||
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
||||
jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
Dimension dimension = new Dimension(20, 20); |
||||
fileChooserButtonCa.setPreferredSize(dimension); |
||||
fileChooserButtonClientCert.setPreferredSize(dimension); |
||||
fileChooserButtonClientKey.setPreferredSize(dimension); |
||||
JPanel filePanelCa = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathCa, fileChooserButtonCa}}, new double[]{p}, new double[]{f, 20}, 0); |
||||
Component[] compCa = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Ca") + ":", SwingConstants.RIGHT), filePanelCa}; |
||||
Component[] compVerifyCa = {null, verifyCa}; |
||||
JPanel filePanelClientCert = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathClientCert, fileChooserButtonClientCert}}, new double[]{p}, new double[]{f, 20}, 0); |
||||
Component[] compClientCert = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Cert") + ":", SwingConstants.RIGHT), filePanelClientCert}; |
||||
JPanel filePanelClientKey = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{{keyPathClientKey, fileChooserButtonClientKey}}, new double[]{p}, new double[]{f, 20}, 0); |
||||
Component[] compClientKey = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Client_Key") + ":", SwingConstants.RIGHT), filePanelClientKey}; |
||||
// Component[] comCipher = {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Ssl_Cipher") + ":", SwingConstants.RIGHT), cipher};
|
||||
usingComps = new Component[][]{ |
||||
compCa, |
||||
compVerifyCa, |
||||
compClientCert, |
||||
compClientKey, |
||||
// comCipher
|
||||
}; |
||||
usingSsl.setSelected(true); |
||||
contextPane = TableLayoutHelper.createGapTableLayoutPane(usingComps, new double[]{p, p, p, p}, columnSize, 11, 11); |
||||
jPanel.add(usingSsl, BorderLayout.NORTH); |
||||
jPanel.add(contextPane, BorderLayout.CENTER); |
||||
this.add(jPanel); |
||||
usingSsl.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
changePane(); |
||||
} |
||||
}); |
||||
fileChooserButtonCa.addActionListener(new TextFieldActionListener(keyPathCa)); |
||||
fileChooserButtonClientCert.addActionListener(new TextFieldActionListener(keyPathClientCert)); |
||||
fileChooserButtonClientKey.addActionListener(new TextFieldActionListener(keyPathClientKey)); |
||||
} |
||||
|
||||
private void changePane() { |
||||
contextPane.setVisible(usingSsl.isSelected()); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Basic_Ssl_Settings"); |
||||
} |
||||
|
||||
public void populate(JDBCDatabaseConnection jdbcDatabase) { |
||||
Ssl ssl = jdbcDatabase.getSsl(); |
||||
if (ssl == null) { |
||||
ssl = new NormalSsl(); |
||||
jdbcDatabase.setSsl(ssl); |
||||
} |
||||
if (ssl.getSslType() == SslType.NORMAL) { |
||||
NormalSsl normalSsl = (NormalSsl) ssl; |
||||
keyPathCa.setText(normalSsl.getCaCertificate()); |
||||
keyPathClientCert.setText(normalSsl.getClientCertificate()); |
||||
keyPathClientKey.setText(normalSsl.getClientPrivateKey()); |
||||
verifyCa.setSelected(normalSsl.isVerifyCa()); |
||||
// cipher.setText(normalSsl.getCipher());
|
||||
} else { |
||||
throw new SslException("un support ssl type"); |
||||
} |
||||
usingSsl.setSelected(ssl.isUsingSsl()); |
||||
changePane(); |
||||
} |
||||
|
||||
public void update(JDBCDatabaseConnection jdbcDatabase) { |
||||
NormalSsl normalSsl = new NormalSsl(); |
||||
// normalSsl.setCipher(cipher.getText().trim());
|
||||
normalSsl.setVerifyCa(verifyCa.isSelected()); |
||||
normalSsl.setCaCertificate(keyPathCa.getText().trim()); |
||||
normalSsl.setClientCertificate(keyPathClientCert.getText().trim()); |
||||
normalSsl.setClientPrivateKey(keyPathClientKey.getText().trim()); |
||||
normalSsl.setUsingSsl(usingSsl.isSelected()); |
||||
jdbcDatabase.setSsl(normalSsl); |
||||
} |
||||
|
||||
private class TextFieldActionListener implements ActionListener { |
||||
private UITextField textField; |
||||
|
||||
public TextFieldActionListener(UITextField textField) { |
||||
this.textField = textField; |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(true)); |
||||
int type = fileChooser.showOpenDialog(SslPane.this, StringUtils.EMPTY); |
||||
if (type == FILEChooserPane.OK_OPTION) { |
||||
final FILE file = fileChooser.getSelectedFILE(); |
||||
if (file == null) { |
||||
textField.setText(StringUtils.EMPTY); |
||||
} else { |
||||
textField.setText(file.getPath()); |
||||
} |
||||
} |
||||
fileChooser.removeAllFilter(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.design.deeplink; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/6 |
||||
*/ |
||||
public abstract class DeepLink { |
||||
|
||||
public abstract boolean accept(String url, String host, String path, Map<String, Object> params); |
||||
|
||||
public abstract void run(String url, String host, String path, Map<String, Object> params); |
||||
} |
@ -0,0 +1,184 @@
|
||||
package com.fr.design.deeplink; |
||||
|
||||
import com.fr.design.constants.DesignerLaunchStatus; |
||||
import com.fr.design.startup.FineStartupNotificationFactory; |
||||
import com.fr.design.startup.FineStartupNotificationProvider; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Listener; |
||||
import com.fr.event.Null; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
import com.fr.third.org.apache.http.NameValuePair; |
||||
import com.fr.web.URLUtils; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Color; |
||||
import java.awt.Frame; |
||||
import java.awt.event.WindowAdapter; |
||||
import java.awt.event.WindowEvent; |
||||
import java.io.IOException; |
||||
import java.net.MalformedURLException; |
||||
import java.net.URL; |
||||
import java.net.URLConnection; |
||||
import java.net.URLStreamHandler; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/6 |
||||
*/ |
||||
public class DeepLinkCore { |
||||
|
||||
protected DeepLinkCore(){} |
||||
private static final DeepLinkCore instance = new DeepLinkCore(); |
||||
public static DeepLinkCore getInstance(){ |
||||
return instance; |
||||
} |
||||
|
||||
private String pendingURL; |
||||
|
||||
private final List<DeepLink> deepLinkList = new ArrayList<>(); |
||||
|
||||
private boolean isDesignerStartupCompleted = false; |
||||
|
||||
public void register(DeepLink deepLink) { |
||||
if (deepLink != null) { |
||||
deepLinkList.add(deepLink); |
||||
} |
||||
} |
||||
|
||||
public void start(String[] args) { |
||||
if (OperatingSystem.isWindows()) { |
||||
if (args.length > 0) { |
||||
receiveDeeplink(args[0]); |
||||
} |
||||
} |
||||
|
||||
if (OperatingSystem.isWindows() && args.length > 0) { |
||||
receiveDeeplink(args[0]); |
||||
} |
||||
|
||||
FineStartupNotificationFactory.getNotification() |
||||
.registerStartupListener(new FineStartupNotificationProvider.Listener() { |
||||
@Override |
||||
public void startupPerformed(String parameters) { |
||||
receiveDeeplink(parameters); |
||||
} |
||||
}); |
||||
|
||||
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { |
||||
@Override |
||||
public void on(Event event, Null param) { |
||||
EventDispatcher.stopListen(this); |
||||
isDesignerStartupCompleted = true; |
||||
if (canConsumePendingURL()) { |
||||
consumePendingURL(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public void receiveDeeplink(String url) { |
||||
if (canAcceptNewURL()) { |
||||
acceptNewURL(url); |
||||
if (canConsumePendingURL()) { |
||||
consumePendingURL(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void receiveDeeplink2(String url) { |
||||
if (canAcceptNewURL()) { |
||||
acceptNewURL(url); |
||||
if (canConsumePendingURL()) { |
||||
consumePendingURL(); |
||||
} else { |
||||
Frame frame = new Frame("can not ConsumePendingURL"); |
||||
frame.setSize(400, 400); |
||||
frame.setBackground(Color.BLACK); |
||||
frame.addWindowListener(new WindowAdapter() { |
||||
public void windowClosing(WindowEvent windowEvent){ |
||||
frame.dispose(); |
||||
} |
||||
}); |
||||
frame.setVisible(true); |
||||
} |
||||
} else { |
||||
Frame frame = new Frame("can not AcceptNewURL"); |
||||
frame.setSize(400, 400); |
||||
frame.setBackground(Color.BLACK); |
||||
frame.addWindowListener(new WindowAdapter() { |
||||
public void windowClosing(WindowEvent windowEvent){ |
||||
frame.dispose(); |
||||
} |
||||
}); |
||||
frame.setVisible(true); |
||||
} |
||||
} |
||||
|
||||
private boolean canAcceptNewURL() { |
||||
return StringUtils.isEmpty(this.pendingURL); |
||||
} |
||||
|
||||
private void acceptNewURL(String url) { |
||||
this.pendingURL = url; |
||||
} |
||||
|
||||
private boolean canConsumePendingURL() { |
||||
return StringUtils.isNotEmpty(this.pendingURL) && isDesignerStartupCompleted; |
||||
} |
||||
|
||||
private void consumePendingURL() { |
||||
String host = null; |
||||
String path = null; |
||||
Map<String, Object> params = new HashMap<>(); |
||||
|
||||
URL url = null; |
||||
try { |
||||
url = new URL(null, this.pendingURL, new URLStreamHandler() { |
||||
@Override |
||||
protected URLConnection openConnection(URL u) throws IOException { |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (MalformedURLException ignored) {} |
||||
|
||||
if (url != null) { |
||||
host = url.getHost(); |
||||
path = url.getPath(); |
||||
|
||||
List<NameValuePair> pairs = URLUtils.parse(url.getQuery()); |
||||
for (NameValuePair pair: pairs) { |
||||
params.put(pair.getName(), pair.getValue()); |
||||
} |
||||
} |
||||
|
||||
FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL); |
||||
performDeepLinks(this.pendingURL, host, path, params); |
||||
|
||||
markPendingURLConsumed(); |
||||
} |
||||
|
||||
private void performDeepLinks(String url, String host, String path, Map<String, Object> params) { |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
for (DeepLink deepLink: deepLinkList) { |
||||
if (deepLink.accept(url, host, path, params)) { |
||||
deepLink.run(url, host, path, params); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void markPendingURLConsumed() { |
||||
this.pendingURL = null; |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.editor.editor; |
||||
|
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
|
||||
/** |
||||
* @author xiqiu |
||||
* @date 2022/1/10 |
||||
* @description 一个简单的非负整数框 |
||||
*/ |
||||
public class NotNegativeIntegerEditor extends IntegerEditor { |
||||
private static final String NEG = "-"; |
||||
|
||||
public NotNegativeIntegerEditor(int columns) { |
||||
this(); |
||||
this.setColumns(columns); |
||||
} |
||||
|
||||
public NotNegativeIntegerEditor() { |
||||
super(); |
||||
this.numberField.addKeyListener(new KeyAdapter() { |
||||
|
||||
@Override |
||||
public void keyReleased(KeyEvent evt) { |
||||
char keyChar = evt.getKeyChar(); |
||||
if (NEG.equals(keyChar + "")) { |
||||
numberField.setText(numberField.getTextValue().replace(NEG, "")); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,10 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/3/1 |
||||
*/ |
||||
public interface JDashboard { |
||||
void switchToDashBoardEditor(); |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.design.mainframe.share.mini; |
||||
|
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/8 |
||||
*/ |
||||
public class MiniShopDisposingChecker { |
||||
|
||||
public static boolean check() { |
||||
return check(DesignerContext.getDesignerFrame()); |
||||
} |
||||
|
||||
public static boolean check(Component optionParentComponent) { |
||||
if (MiniShopNativeTaskManager.getInstance().hasExecutingTasks()) { |
||||
int result = FineJOptionPane.showConfirmDialog( |
||||
optionParentComponent, |
||||
Toolkit.i18nText("Fine-Design_Share_Online_Mini_Shop_Close_Tip"), |
||||
"", |
||||
FineJOptionPane.YES_NO_OPTION |
||||
); |
||||
if (result == JOptionPane.YES_OPTION) { |
||||
MiniShopNativeTaskManager.getInstance().cancelAllExecutingTasks(); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fr.design.mainframe.share.mini; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/8 |
||||
*/ |
||||
public interface MiniShopNativeTask { |
||||
void execute(); |
||||
void cancel(); |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.design.mainframe.share.mini; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/8 |
||||
*/ |
||||
public class MiniShopNativeTaskManager { |
||||
private MiniShopNativeTaskManager() { |
||||
} |
||||
private static class HOLDER { |
||||
private static final MiniShopNativeTaskManager singleton = new MiniShopNativeTaskManager(); |
||||
} |
||||
public static MiniShopNativeTaskManager getInstance() { |
||||
return MiniShopNativeTaskManager.HOLDER.singleton; |
||||
} |
||||
|
||||
|
||||
private static final Set<MiniShopNativeTask> executingTasks = new HashSet<>(); |
||||
|
||||
public void addStartedTask(MiniShopNativeTask task) { |
||||
executingTasks.add(task); |
||||
} |
||||
|
||||
public void removeCompletedTask(MiniShopNativeTask task) { |
||||
executingTasks.remove(task); |
||||
} |
||||
|
||||
public boolean hasExecutingTasks() { |
||||
return !executingTasks.isEmpty(); |
||||
} |
||||
|
||||
public void cancelAllExecutingTasks() { |
||||
for (MiniShopNativeTask executingTask: executingTasks) { |
||||
executingTask.cancel(); |
||||
} |
||||
executingTasks.clear(); |
||||
} |
||||
} |
@ -1,25 +1,29 @@
|
||||
package com.fr.design.selection; |
||||
|
||||
import com.fr.base.TRL; |
||||
|
||||
/** |
||||
* |
||||
* @author zhou |
||||
* @since 2012-7-26上午10:20:32 |
||||
*/ |
||||
public interface Selectedable<S extends SelectableElement> { |
||||
|
||||
public S getSelection(); |
||||
S getSelection(); |
||||
|
||||
void setSelection(S selectElement); |
||||
|
||||
public void setSelection(S selectElement); |
||||
/** |
||||
* Adds a <code>ChangeListener</code> to the listener list. |
||||
*/ |
||||
void addSelectionChangeListener(SelectionListener selectionListener); |
||||
|
||||
/** |
||||
* Adds a <code>ChangeListener</code> to the listener list. |
||||
*/ |
||||
public void addSelectionChangeListener(SelectionListener selectionListener); |
||||
/** |
||||
* removes a <code>ChangeListener</code> from the listener list. |
||||
*/ |
||||
void removeSelectionChangeListener(SelectionListener selectionListener); |
||||
|
||||
/** |
||||
* removes a <code>ChangeListener</code> from the listener list. |
||||
*/ |
||||
public void removeSelectionChangeListener(SelectionListener selectionListener); |
||||
// august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用!
|
||||
default void navigate(TRL trl) { |
||||
|
||||
// august:这儿就不要加fireSelectionChangeListener方法了。因为这个方法一般要定义成私有的,不然外部随即的调用!
|
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.startup; |
||||
|
||||
import org.jetbrains.annotations.NotNull; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/11 |
||||
*/ |
||||
public class FineStartupNotificationFactory { |
||||
private static final FineStartupNotificationProvider DEFAULT = Install4jStartupNotificationProvider.getInstance(); |
||||
private static FineStartupNotificationProvider provider; |
||||
|
||||
public FineStartupNotificationFactory() { |
||||
} |
||||
|
||||
public static FineStartupNotificationProvider getNotification() { |
||||
return provider; |
||||
} |
||||
|
||||
public static void setLogger(@NotNull FineStartupNotificationProvider provider) { |
||||
FineStartupNotificationFactory.provider = provider; |
||||
} |
||||
|
||||
public static void reset() { |
||||
provider = DEFAULT; |
||||
} |
||||
|
||||
|
||||
static { |
||||
provider = DEFAULT; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.design.startup; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/11 |
||||
*/ |
||||
public interface FineStartupNotificationProvider { |
||||
void registerStartupListener(Listener listener); |
||||
|
||||
interface Listener { |
||||
void startupPerformed(String parameters); |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.fr.design.startup; |
||||
|
||||
import com.install4j.api.launcher.StartupNotification; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2022/1/11 |
||||
*/ |
||||
public class Install4jStartupNotificationProvider implements FineStartupNotificationProvider { |
||||
|
||||
private Install4jStartupNotificationProvider() { |
||||
} |
||||
private static final Install4jStartupNotificationProvider INSTANCE = new Install4jStartupNotificationProvider(); |
||||
public static Install4jStartupNotificationProvider getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public void registerStartupListener(Listener listener) { |
||||
boolean supported = false; |
||||
try { |
||||
supported = Class.forName("com.install4j.api.launcher.StartupNotification") != null; |
||||
} catch (Throwable ignored) {} |
||||
|
||||
if (supported) { |
||||
StartupNotification.registerStartupListener(new StartupNotification.Listener() { |
||||
@Override |
||||
public void startupPerformed(String parameters) { |
||||
listener.startupPerformed(parameters); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.mainframe.loghandler; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* @author vito |
||||
* @version 10.0 |
||||
* Created by vito on 2022/1/25 |
||||
*/ |
||||
public class DesignerLogHandlerTest { |
||||
|
||||
@Test |
||||
public void findTplLink() { |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)", "(公式定位测试/单sheet2(2).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1),出错公式(公式定位测试/单sheet2(2).cpt:0:A1),的飞机啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).frm:0:A1)", "(公式定位测试/单sheet2(2).frm:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).frm:0:A1),出错公式(公式定位测试/单sheet2(2).frm:0:A1),的飞机啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式(计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式)计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机)啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机(啊") |
||||
); |
||||
Assert.assertArrayEquals( |
||||
new String[]{"(公式定位测试/单sheet2(1).cpt:0:A1)"}, |
||||
DesignerLogHandler.findTplLink("错误代码:11300310 公式(0fdasf)计算错误:(公式定位测试/单sheet2(1).cpt:0:A1)的飞机啊") |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,117 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.design.gui.frpane.UINumberDragPaneWithPercent; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; |
||||
import com.fr.plugin.chart.gantt.VanChartGanttPlot; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
|
||||
public class VanChartGanttTimeLinePane extends JPanel { |
||||
private UIButtonGroup<String> switchButton; |
||||
private ColorSelectBoxWithOutTransparent colorSelect; |
||||
private UINumberDragPaneWithPercent opacity; |
||||
|
||||
private JPanel centerPane; |
||||
|
||||
public VanChartGanttTimeLinePane() { |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(createSwitchButtonPane(), BorderLayout.NORTH); |
||||
this.add(createCenterPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
private JPanel createSwitchButtonPane() { |
||||
double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL}; |
||||
double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED}; |
||||
String[] array = new String[]{Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Not_Show"), Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Show")}; |
||||
switchButton = new UIButtonGroup<>(array); |
||||
switchButton.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
setCenterPaneVisibility(); |
||||
} |
||||
}); |
||||
UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Guide_Line_Current_Line"), SwingConstants.LEFT); |
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(new Component[][] { |
||||
new Component[]{null, null}, |
||||
new Component[] {text, switchButton} |
||||
}, rowSize, columnSize); |
||||
} |
||||
|
||||
private JPanel createCenterPane() { |
||||
double[] columnSize = {TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; |
||||
double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; |
||||
|
||||
colorSelect = new ColorSelectBoxWithOutTransparent(100); |
||||
opacity = new UINumberDragPaneWithPercent(0, 100); |
||||
|
||||
centerPane = TableLayout4VanChartHelper.createGapTableLayoutPane(new Component[][] { |
||||
new Component[]{null, null}, |
||||
new Component[] {new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), colorSelect}, |
||||
new Component[] {new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")), opacity} |
||||
}, rowSize, columnSize); |
||||
|
||||
centerPane.setVisible(false); |
||||
|
||||
return centerPane; |
||||
} |
||||
|
||||
public void populateBean(Plot plot) { |
||||
if (plot instanceof VanChartGanttPlot) { |
||||
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot; |
||||
setShowTimeLine(ganttPlot.isShowTimeLine()); |
||||
setTimeLineColor(ganttPlot.getTimeLineColor()); |
||||
setTimeLineOpacity(ganttPlot.getTimeLineOpacity()); |
||||
|
||||
centerPane.setVisible(ganttPlot.isShowTimeLine()); |
||||
} |
||||
} |
||||
|
||||
public void updateBean(Plot plot) { |
||||
if (plot instanceof VanChartGanttPlot) { |
||||
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot; |
||||
ganttPlot.setShowTimeLine(isShowTimeLine()); |
||||
ganttPlot.setTimeLineColor(getTimeLineColor()); |
||||
ganttPlot.setTimeLineOpacity(getTimeLineOpacity()); |
||||
} |
||||
} |
||||
|
||||
private void setCenterPaneVisibility() { |
||||
centerPane.setVisible(switchButton.getSelectedIndex() == 1); |
||||
} |
||||
|
||||
public boolean isShowTimeLine() { |
||||
return switchButton.getSelectedIndex() == 1; |
||||
} |
||||
|
||||
public void setShowTimeLine(boolean showTimeLine) { |
||||
switchButton.setSelectedIndex(showTimeLine ? 1 : 0); |
||||
} |
||||
|
||||
public Color getTimeLineColor() { |
||||
return colorSelect.getSelectObject(); |
||||
} |
||||
|
||||
public void setTimeLineColor(Color timeLineColor) { |
||||
colorSelect.setSelectObject(timeLineColor); |
||||
} |
||||
|
||||
public double getTimeLineOpacity() { |
||||
return opacity.updateBean(); |
||||
} |
||||
|
||||
public void setTimeLineOpacity(double timeLineOpacity) { |
||||
opacity.populateBean(timeLineOpacity); |
||||
} |
||||
} |
@ -1,4 +0,0 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
public class VanChartGuideLinesPane { |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.van.chart.designer.style.axis; |
||||
|
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; |
||||
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; |
||||
import com.fr.design.mainframe.chart.mode.ChartEditContext; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
public class VanChartAxisPaneHelper { |
||||
public static ChartTextAttrPane createAxisTextAttrPane() { |
||||
return ChartEditContext.supportTheme() ? new ChartTextAttrPaneWithThemeStyle() { |
||||
protected double getEdithAreaWidth() { |
||||
return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; |
||||
} |
||||
} : new ChartTextAttrPane() { |
||||
@Override |
||||
protected JPanel getContentPane(JPanel buttonPane) { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; |
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p, p}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), rowSize, columnSize); |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,166 @@
|
||||
package com.fr.van.chart.designer.style.axis; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.chart.base.TextAttr; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.frpane.UINumberDragPane; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
import com.fr.design.widget.FRWidgetFactory; |
||||
import com.fr.plugin.chart.attr.axis.VanChartAxisLabelStyle; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
import com.fr.van.chart.designer.style.axis.component.AxisLabelDisplayComboBox; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartAxisStyleSettingPane extends BasicBeanPane<VanChartAxisLabelStyle> { |
||||
private static final double ROTATION_MAX = 90.0; |
||||
|
||||
private AxisLabelDisplayComboBox labelDisplayComboBox; |
||||
private JPanel labelDisplayPane; |
||||
private ChartTextAttrPane labelTextAttrPane; |
||||
private UINumberDragPane labelTextRotation; |
||||
private UIButtonGroup<Integer> labelGapStyle; |
||||
private UITextField labelGapValue; |
||||
private JPanel labelGapPane; |
||||
private JPanel labelGapValuePane; |
||||
private JPanel contentPane; |
||||
|
||||
private boolean showLabelDisplayPane = true; |
||||
|
||||
public VanChartAxisStyleSettingPane(boolean showLabelDisplayPane, ChartTextAttrPane textAttrPane) { |
||||
this.showLabelDisplayPane = showLabelDisplayPane; |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; |
||||
double[] column = {f, s}; |
||||
double[] row = {p, p, p}; |
||||
|
||||
labelDisplayComboBox = new AxisLabelDisplayComboBox(); |
||||
labelDisplayPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Show"), labelDisplayComboBox, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); |
||||
labelDisplayPane.setVisible(showLabelDisplayPane); |
||||
|
||||
labelTextAttrPane = textAttrPane; |
||||
labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); |
||||
|
||||
labelGapStyle = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")}); |
||||
labelGapValue = new UITextField(); |
||||
labelGapPane = createLabelGapPane(row, column); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
contentPane = new JPanel(new BorderLayout()); |
||||
contentPane.add(labelDisplayPane, BorderLayout.NORTH); |
||||
contentPane.add(labelTextAttrPane, BorderLayout.CENTER); |
||||
contentPane.add(labelGapPane, BorderLayout.SOUTH); |
||||
this.add(contentPane, BorderLayout.NORTH); |
||||
initListner(); |
||||
} |
||||
|
||||
public VanChartAxisStyleSettingPane(ChartTextAttrPane textAttrPane) { |
||||
this(true, textAttrPane); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension defaultSize = super.getPreferredSize(); |
||||
return new Dimension(defaultSize.width, contentPane.getPreferredSize().height); |
||||
} |
||||
|
||||
private void initListner() { |
||||
labelDisplayComboBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkLabelGapPane(); |
||||
} |
||||
}); |
||||
|
||||
labelGapStyle.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkLabelGapValuePane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkLabelGapPane() { |
||||
if (labelGapPane != null) { |
||||
boolean visible = true; |
||||
|
||||
if (showLabelDisplayPane && labelDisplayPane != null && labelDisplayComboBox != null) { |
||||
visible = labelDisplayComboBox.getSelectedIndex() == 0; |
||||
} |
||||
|
||||
labelGapPane.setVisible(visible); |
||||
} |
||||
} |
||||
|
||||
private void checkLabelGapValuePane() { |
||||
if (labelGapValuePane != null && labelGapStyle != null) { |
||||
labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(VanChartAxisLabelStyle style) { |
||||
labelDisplayComboBox.populateBean(style.getLabelDisplay()); |
||||
labelTextAttrPane.populate(style.getTextAttr()); |
||||
labelTextRotation.populateBean((double) style.getTextAttr().getRotation()); |
||||
labelGapStyle.setSelectedIndex(style.isAutoLabelGap() ? 0 : 1); |
||||
labelGapValue.setText(style.getLabelIntervalNumber().getContent()); |
||||
|
||||
checkLabelGapPane(); |
||||
checkLabelGapValuePane(); |
||||
} |
||||
|
||||
@Override |
||||
public VanChartAxisLabelStyle updateBean() { |
||||
VanChartAxisLabelStyle style = new VanChartAxisLabelStyle(); |
||||
style.setLabelDisplay(labelDisplayComboBox.updateBean()); |
||||
TextAttr textAttr = style.getTextAttr(); |
||||
labelTextAttrPane.update(textAttr); |
||||
textAttr.setRotation(labelTextRotation.updateBean().intValue()); |
||||
style.setTextAttr(textAttr); |
||||
style.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0); |
||||
if (style.isAutoLabelGap()) { |
||||
style.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("0")); |
||||
} else { |
||||
style.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText())); |
||||
} |
||||
return style; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
private JPanel createLabelGapPane(double[] row, double[] col) { |
||||
Component[][] gapComponents = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{ |
||||
FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_TextRotation")), |
||||
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation) |
||||
}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle} |
||||
}; |
||||
|
||||
JPanel gapDetailPane = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col); |
||||
labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); |
||||
|
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
panel.add(gapDetailPane, BorderLayout.CENTER); |
||||
panel.add(labelGapValuePane, BorderLayout.SOUTH); |
||||
|
||||
return panel; |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.fr.van.chart.designer.style.axis.component; |
||||
|
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.frpane.UIBubbleFloatPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.plugin.chart.attr.axis.VanChartAxisLabelStyle; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.van.chart.designer.style.axis.VanChartAxisPaneHelper; |
||||
import com.fr.van.chart.designer.style.axis.VanChartAxisStyleSettingPane; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.Point; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
public class VanChartCategoryStylePaneWithCheckBox extends JPanel { |
||||
private UICheckBox checkBox; // 复选框
|
||||
private UIButton settingButton; // 设置按钮
|
||||
private VanChartAxisStyleSettingPane settingPane; // 设置弹窗面板
|
||||
|
||||
private JPanel showOnPane; |
||||
private AbstractAttrNoScrollPane parent; |
||||
|
||||
private VanChartAxisLabelStyle axis; |
||||
|
||||
public VanChartCategoryStylePaneWithCheckBox(AbstractAttrNoScrollPane parent, JPanel showOnPane, String checkBoxName) { |
||||
this.parent = parent; |
||||
this.showOnPane = showOnPane; |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
checkBox = new UICheckBox(checkBoxName); |
||||
checkBox.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); |
||||
checkBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
/* 为什么需要这句话呢?因为这个checkBox是动态加上去的,没有走最上层父组件ChartStylePane的initAllListener方法, |
||||
* 所以不会触发update监听,下面的bubble弹窗则是不属于ChartStylePane的单独悬浮组件,也只能这样触发update监听 |
||||
*/ |
||||
if(parent != null){ |
||||
parent.attributeChanged(); |
||||
} |
||||
} |
||||
}); |
||||
settingButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Axis_Style_Setting")); |
||||
|
||||
this.add(checkBox, BorderLayout.CENTER); |
||||
this.add(settingButton, BorderLayout.EAST); |
||||
|
||||
initListener(); |
||||
} |
||||
|
||||
private void initListener() { |
||||
if(settingButton != null) { |
||||
settingButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseReleased(MouseEvent e) { |
||||
if (settingPane == null) { |
||||
settingPane = new VanChartAxisStyleSettingPane(VanChartAxisPaneHelper.createAxisTextAttrPane()); |
||||
} |
||||
|
||||
Point comPoint = settingButton.getLocationOnScreen(); |
||||
Point arrowPoint = new Point(comPoint.x +settingButton.getWidth() - 25, comPoint.y + settingButton.getHeight()); |
||||
Dimension size = settingPane.getPreferredSize(); |
||||
UIBubbleFloatPane<VanChartAxisLabelStyle> pane = new UIBubbleFloatPane(Constants.LEFT, arrowPoint, settingPane, size.width, 230) { |
||||
|
||||
@Override |
||||
public void updateContentPane() { |
||||
axis = settingPane.updateBean(); |
||||
if(parent != null){//条件属性没有parent
|
||||
parent.attributeChanged(); |
||||
} |
||||
} |
||||
}; |
||||
pane.show(showOnPane, axis); |
||||
super.mouseReleased(e); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
public void populate(VanChartAxisLabelStyle style) { |
||||
this.axis = style; |
||||
checkBox.setSelected(axis.isShowLabel()); |
||||
} |
||||
|
||||
public VanChartAxisLabelStyle update() { |
||||
axis.setShowLabel(checkBox.isSelected()); |
||||
return axis; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.van.chart.designer.style.background; |
||||
|
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||
|
||||
public class VanChartGantAreaPane extends VanChartAreaPane { |
||||
public VanChartGantAreaPane(Plot plot, VanChartStylePane parent) { |
||||
super(plot, parent); |
||||
} |
||||
|
||||
protected void initPlotPane(boolean b, AbstractAttrNoScrollPane parent) { |
||||
plotPane = new VanChartGantPlotAreaBackgroundPane(parent); |
||||
} |
||||
} |
@ -0,0 +1,102 @@
|
||||
package com.fr.van.chart.designer.style.background; |
||||
|
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; |
||||
import com.fr.plugin.chart.gantt.VanChartGanttPlot; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
|
||||
public class VanChartGantPlotAreaBackgroundPane extends VanChartAreaBackgroundPane { |
||||
private ColorSelectBoxWithOutTransparent axisColorPane; |
||||
private ColorSelectBoxWithOutTransparent contentColorPane; |
||||
|
||||
public VanChartGantPlotAreaBackgroundPane(AbstractAttrNoScrollPane parent) { |
||||
super(true, parent); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
JPanel contentPane = new JPanel(new BorderLayout()); |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {f}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{createAxisBorderPane()}, |
||||
new Component[]{createContentBorderPane()} |
||||
}; |
||||
|
||||
contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); |
||||
return contentPane; |
||||
} |
||||
|
||||
@Override |
||||
public void updateBean(Chart chart) { |
||||
if (chart == null) { |
||||
chart = new Chart(); |
||||
} |
||||
|
||||
Plot plot = chart.getPlot(); |
||||
if (plot instanceof VanChartGanttPlot) { |
||||
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot; |
||||
ganttPlot.setAxisBorderColor(axisColorPane.getSelectObject()); |
||||
ganttPlot.setContentBorderColor(contentColorPane.getSelectObject()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Chart chart) { |
||||
if (chart == null) { |
||||
chart = new Chart(); |
||||
} |
||||
|
||||
Plot plot = chart.getPlot(); |
||||
if (plot instanceof VanChartGanttPlot) { |
||||
VanChartGanttPlot ganttPlot = (VanChartGanttPlot) plot; |
||||
axisColorPane.setSelectObject(ganttPlot.getAxisBorderColor()); |
||||
contentColorPane.setSelectObject(ganttPlot.getContentBorderColor()); |
||||
} |
||||
} |
||||
|
||||
private JPanel createAxisBorderPane() { |
||||
axisColorPane = new ColorSelectBoxWithOutTransparent(100); |
||||
return TableLayout4VanChartHelper.createExpandablePaneWithTitle( |
||||
Toolkit.i18nText("Fine-Design_Chart_Gant_Axis_Border"), |
||||
createBorderPane(axisColorPane) |
||||
); |
||||
} |
||||
|
||||
private JPanel createContentBorderPane() { |
||||
contentColorPane = new ColorSelectBoxWithOutTransparent(100); |
||||
return TableLayout4VanChartHelper.createExpandablePaneWithTitle( |
||||
Toolkit.i18nText("Fine-Design_Chart_Gant_Content_Border"), |
||||
createBorderPane(contentColorPane) |
||||
); |
||||
} |
||||
|
||||
private JPanel createBorderPane(ColorSelectBoxWithOutTransparent colorPane) { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; |
||||
double[] rowSize = {p, p}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{ |
||||
new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), |
||||
colorPane |
||||
} |
||||
}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue