forked from fanruan/design
Browse Source
Merge in DESIGN/design from ~NEIL/design:feature/10.0 to feature/10.0 * commit 'e4679bbb8ea55a4f7e866b7cd39e8fa91a2eb793': (384 commits) 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 合代码冲突 REPORT-32162 替换 ui 的时候,需要在事件分发线程中 ...persist/11.0
ju.ju
5 years ago
415 changed files with 11045 additions and 2942 deletions
@ -0,0 +1,59 @@
|
||||
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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
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; |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
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.Set; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/05/14 |
||||
**/ |
||||
@SuppressWarnings({"rawtypes", "unchecked"}) |
||||
public abstract class ClipboardFilter { |
||||
|
||||
public static <T> T cut(T selection) { |
||||
|
||||
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); |
||||
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); |
||||
for (ClipboardHandlerProvider provider : providers) { |
||||
if (provider.support(selection)) { |
||||
selection = ((ClipboardHandlerProvider<T>) provider).cut(selection); |
||||
} |
||||
} |
||||
return selection; |
||||
} |
||||
|
||||
public static <T> T copy(T selection) { |
||||
|
||||
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); |
||||
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); |
||||
for (ClipboardHandlerProvider provider : providers) { |
||||
if (provider.support(selection)) { |
||||
selection = ((ClipboardHandlerProvider<T>) provider).copy(selection); |
||||
} |
||||
} |
||||
return selection; |
||||
} |
||||
|
||||
public static <T> T paste(T selection) { |
||||
|
||||
ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); |
||||
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); |
||||
for (ClipboardHandlerProvider provider : providers) { |
||||
if (provider.support(selection)) { |
||||
selection = ((ClipboardHandlerProvider<T>) provider).paste(selection); |
||||
} |
||||
} |
||||
return selection; |
||||
} |
||||
} |
@ -0,0 +1,68 @@
|
||||
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(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.data; |
||||
|
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/4/27 |
||||
*/ |
||||
public abstract class BasicTableDataUtils { |
||||
|
||||
private static final int LEN = 2; |
||||
|
||||
|
||||
public static boolean checkName(String name) { |
||||
if (isInValidName(name)) { |
||||
FineJOptionPane.showMessageDialog(null, |
||||
Toolkit.i18nText("Fine-Design_Basic_DataSet_Rename_Warning", name), |
||||
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
||||
FineJOptionPane.WARNING_MESSAGE); |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public static boolean isInValidName(String name) { |
||||
String[] values = name.split("\\."); |
||||
if (values.length == LEN) { |
||||
return (StringUtils.isNotEmpty(values[0]) && StringUtils.isNotEmpty(values[1])) |
||||
|| (StringUtils.isEmpty(values[0]) && StringUtils.isNotEmpty(values[1])); |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fr.design.event; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/19 |
||||
*/ |
||||
public interface RemoveListener { |
||||
|
||||
void doRemoveAction(); |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* @author yaohwu |
||||
* created by yaohwu at 2020/4/26 15:50 |
||||
*/ |
||||
public interface CellExpandAttrPanelProvider extends Mutable { |
||||
|
||||
String MARK_STRING = "CellExpandAttrPanelProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* @return 创建单元格属性-扩展设置中的额外面板 |
||||
*/ |
||||
BasicBeanPane<TemplateCellElement> createPanel(); |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/05/14 |
||||
**/ |
||||
public interface ClipboardHandlerProvider<T> extends Mutable { |
||||
|
||||
String XML_TAG = "ClipboardHandlerProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 剪切 |
||||
* |
||||
* @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); |
||||
} |
@ -0,0 +1,57 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icontainer.UIScrollPane; |
||||
import com.fr.design.mainframe.DockingView; |
||||
import com.fr.stable.fun.mark.Immutable; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* 组件库面板处理器 |
||||
* |
||||
* created by Harrison on 2020/03/16 |
||||
**/ |
||||
public interface ComponentLibraryPaneProcessor extends Immutable { |
||||
|
||||
String XML_TAG = "ComponentLibraryPaneProcessor"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 创建展示面板 |
||||
* |
||||
* @param isEdit 是否可以编辑 |
||||
* @return 展示面板 |
||||
*/ |
||||
UIScrollPane createShowPanel(boolean isEdit); |
||||
|
||||
/** |
||||
* 创建菜单的上部面板 |
||||
* |
||||
* @return 面板 |
||||
*/ |
||||
JPanel createMenuNorthPane(); |
||||
|
||||
/** |
||||
* 创建复选框 |
||||
* |
||||
* @return 复选框 |
||||
*/ |
||||
UIComboBox createMenuComBox(); |
||||
|
||||
void parentView(DockingView dockingView); |
||||
|
||||
/** |
||||
* 父面板 |
||||
* |
||||
* @param panel 面板 |
||||
*/ |
||||
void parentPane(JPanel panel); |
||||
|
||||
/** |
||||
* 创建完成 |
||||
*/ |
||||
void complete(); |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.stable.fun.mark.Mutable; |
||||
import com.fr.start.BaseDesigner; |
||||
|
||||
/** |
||||
* 设计器启动类替换接口 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/5/7 |
||||
*/ |
||||
|
||||
public interface DesignerStartClassProcessor extends Mutable { |
||||
|
||||
String MARK_STRING = "DesignerStartClassProcessor"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
|
||||
Class<? extends BaseDesigner> transform(); |
||||
|
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.menu.ShortCut; |
||||
import com.fr.stable.fun.mark.Immutable; |
||||
|
||||
import javax.swing.JComponent; |
||||
import java.awt.Dimension; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
* 临时接口,后续自适应内置后删除 |
||||
*/ |
||||
public interface FormAdaptiveConfigUIProcessor extends Immutable { |
||||
|
||||
String MARK_STRING = "FormAdaptiveConfigUIProcessor"; |
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 获取表单自适应配置菜单 |
||||
* @return 表单自适应配置菜单 |
||||
*/ |
||||
ShortCut getConfigShortCut(JTemplate jTemplate); |
||||
|
||||
/** |
||||
* 绘制自适应下报表块在表单界面中显示图片 |
||||
* @param size 绘制尺寸 |
||||
* @param elementCasePane 报表块内容对象 |
||||
* @return 自适应下报表块在表单界面中显示的图片 |
||||
*/ |
||||
BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane); |
||||
|
||||
|
||||
/** |
||||
* 获取新自适应下字体显示的dpi |
||||
* @return dpi |
||||
*/ |
||||
int fontResolution(); |
||||
|
||||
} |
||||
|
@ -0,0 +1,25 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/31 |
||||
*/ |
||||
public interface MobileTemplateStyleProvider extends Mutable { |
||||
|
||||
String XML_TAG = "MobileTemplateStyleProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
Class<? extends MobileTemplateStyle> classFroMobileTemplateStyle(); |
||||
|
||||
|
||||
Class<? extends BasicBeanPane<MobileTemplateStyle>> classFroMobileTemplateStyleAppearance(); |
||||
|
||||
String displayName(); |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.stable.fun.mark.Mutable; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
public interface ReportLengthUNITProvider extends Mutable { |
||||
String MARK_STRING = "ReportLengthUNITProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 标尺单位显示字符 |
||||
* @return 标尺单位字符 |
||||
*/ |
||||
String unitText(); |
||||
|
||||
/** |
||||
* 标尺单位类型(之前是将int类型的值直接保存在数据库里面的) |
||||
* @return 返回标尺单位类型 |
||||
*/ |
||||
int unitType(); |
||||
|
||||
/** |
||||
* UNIT转标尺单位值 |
||||
* @param value UNIT |
||||
* @return 标尺单位值 |
||||
*/ |
||||
float unit2Value4Scale(UNIT value); |
||||
|
||||
/** |
||||
* 标尺单位值转UNIT |
||||
* @param value 标尺单位值 |
||||
* @return UNIT |
||||
*/ |
||||
UNIT float2UNIT(float value); |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.CellExpandAttrPanelProvider; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author yaohwu |
||||
* created by yaohwu at 2020/4/26 16:08 |
||||
*/ |
||||
@API(level = CellExpandAttrPanelProvider.CURRENT_LEVEL) |
||||
public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelProvider { |
||||
|
||||
/** |
||||
* 当前接口的API等级,用于判断是否需要升级插件 |
||||
* |
||||
* @return API等级 |
||||
*/ |
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CellExpandAttrPanelProvider.CURRENT_LEVEL; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前provider的标记(可以使用类路径保证唯一)以避免provider的重复加载 |
||||
* |
||||
* @return 当前provider的标记 |
||||
*/ |
||||
@Override |
||||
public String mark4Provider() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicBeanPane<TemplateCellElement> createPanel() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.ClipboardHandlerProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* created by Harrison on 2020/05/14 |
||||
**/ |
||||
@API(level = ClipboardHandlerProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractClipboardHandlerProvider<T> extends AbstractProvider implements ClipboardHandlerProvider<T> { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return ClipboardHandlerProvider.CURRENT_LEVEL; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.DesignerStartClassProcessor; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/5/7 |
||||
*/ |
||||
@API(level = DesignerStartClassProcessor.CURRENT_LEVEL) |
||||
public abstract class AbstractDesignerStartClassProcessorProcessor implements DesignerStartClassProcessor { |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
|
||||
import com.fr.design.fun.FormAdaptiveConfigUIProcessor; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
@API(level = FormAdaptiveConfigUIProcessor.CURRENT_LEVEL) |
||||
public abstract class AbstractFormAdaptiveConfigUIProcessor implements FormAdaptiveConfigUIProcessor { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public int layerIndex() { |
||||
return DEFAULT_LAYER_INDEX; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.MobileTemplateStyleProvider; |
||||
import com.fr.design.fun.MobileWidgetStyleProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/3/31 |
||||
*/ |
||||
@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractMobileTemplateStyleProvider extends AbstractProvider implements MobileTemplateStyleProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
|
||||
import com.fr.design.fun.ReportLengthUNITProvider; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-04-09 |
||||
*/ |
||||
@API(level = ReportLengthUNITProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractReportLengthUNITProvider extends AbstractProvider implements ReportLengthUNITProvider { |
||||
|
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String unitText() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public int unitType() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public float unit2Value4Scale(UNIT value) { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public UNIT float2UNIT(float value) { |
||||
return UNIT.ZERO; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,38 @@
|
||||
package com.fr.design.gui.ibutton; |
||||
|
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.style.color.ColorControlWindow; |
||||
import com.fr.design.style.color.ColorControlWindowWithAuto; |
||||
import com.fr.general.ComparatorUtils; |
||||
|
||||
import java.awt.Color; |
||||
|
||||
public class UIColorButtonWithAuto extends UIColorButton { |
||||
|
||||
protected void checkColorChange(Color oldColor, Color newColor) { |
||||
if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { |
||||
setIcon(UIConstants.FONT_ICON); |
||||
} |
||||
|
||||
if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { |
||||
setIcon(UIConstants.AUTO_FONT_ICON); |
||||
} |
||||
|
||||
super.checkColorChange(oldColor, newColor); |
||||
} |
||||
|
||||
protected ColorControlWindow getColorControlWindow() { |
||||
if (getPopupWin() == null) { |
||||
ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) { |
||||
protected void colorChanged() { |
||||
UIColorButtonWithAuto.this.setColor(this.getColor()); |
||||
} |
||||
}; |
||||
|
||||
setPopupWin(colorControlWindowWithAuto); |
||||
} |
||||
|
||||
return getPopupWin(); |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.DefaultComboBoxModel; |
||||
import javax.swing.JLabel; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Font; |
||||
import java.util.Vector; |
||||
|
||||
public class MobileStyleFontConfigPane extends JPanel { |
||||
public static final int FONT_NONE = 0; |
||||
private static final int MAX_FONT_SIZE = 18; |
||||
private static final int MIN_FONT_SIZE = 12; |
||||
private static final Dimension BUTTON_SIZE = new Dimension(20, 18); |
||||
|
||||
public static Vector<Integer> getFontSizes() { |
||||
Vector<Integer> FONT_SIZES = new Vector<Integer>(); |
||||
FONT_SIZES.add(FONT_NONE); |
||||
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { |
||||
FONT_SIZES.add(i); |
||||
} |
||||
return FONT_SIZES; |
||||
} |
||||
|
||||
private UIComboBox fontSizeComboBox; |
||||
private UIToggleButton underline; |
||||
private UIToggleButton italic; |
||||
private UIToggleButton bold; |
||||
|
||||
public MobileStyleFontConfigPane() { |
||||
this.initComponent(); |
||||
} |
||||
|
||||
private void initComponent() { |
||||
|
||||
fontSizeComboBox = new UIComboBox(); |
||||
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes())); |
||||
fontSizeComboBox.setSelectedItem(0); |
||||
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); |
||||
fontSizeComboBox.setRenderer(new LineCellRenderer()); |
||||
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); |
||||
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); |
||||
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); |
||||
|
||||
this.setButtonsTips(); |
||||
this.setButtonsSize(BUTTON_SIZE); |
||||
|
||||
Component[] components_font = new Component[]{ |
||||
fontSizeComboBox, underline, italic, bold |
||||
}; |
||||
|
||||
JPanel buttonPane = new JPanel(new BorderLayout()); |
||||
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE)); |
||||
|
||||
this.setLayout(new BorderLayout(0,0)); |
||||
this.add(buttonPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private void setButtonsTips() { |
||||
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); |
||||
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic")); |
||||
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold")); |
||||
} |
||||
|
||||
private void setButtonsSize(Dimension size) { |
||||
underline.setPreferredSize(size); |
||||
italic.setPreferredSize(size); |
||||
bold.setPreferredSize(size); |
||||
} |
||||
|
||||
|
||||
public void populateBean(FRFont frFont) { |
||||
fontSizeComboBox.setSelectedItem(frFont.getSize()); |
||||
bold.setSelected(frFont.isBold()); |
||||
italic.setSelected(frFont.isItalic()); |
||||
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE); |
||||
} |
||||
|
||||
public FRFont updateBean() { |
||||
int style = Font.PLAIN; |
||||
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; |
||||
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; |
||||
return FRFont.getInstance( |
||||
FRFont.DEFAULT_FONTNAME, |
||||
style, |
||||
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), |
||||
Color.BLACK, |
||||
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE |
||||
); |
||||
} |
||||
|
||||
private class LineCellRenderer extends UIComboBoxRenderer { |
||||
public LineCellRenderer() { |
||||
super(); |
||||
} |
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
int currentValue = ((Integer) value).intValue(); |
||||
if (currentValue == MobileStyleFontConfigPane.FONT_NONE) { |
||||
renderer.setText(StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None")); |
||||
} |
||||
return renderer; |
||||
} |
||||
} |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue