* commit '46299876f2cf7ae55176d15f07a2da3d635b3575': (103 commits) 1 REPORT-12584 设计器编码转换 交互修改 REPORT-13254 10.0的设计器mac不能点最大按钮 REPORT-10535 验收bug修复 DEC-5580 【10.0.2迭代验收】【全局水印】设计器字号可选范围与平台不统一 DEC-5580 【10.0.2迭代验收】【全局水印】设计器字号可选范围与平台不统一 DEC-5624 【10.0.2迭代验收】【全局水印】设计器中颜色配置不显示 REPORT-13067 npe 无法拖报表块 REPORT-13067 npe 无法拖报表块 f REPORT-11623 模板加密 设计器拷贝剪切控制 格式化 REPORT-13034 FR模板挂载到BI,自适应异常 REPORT-12578 全局配置保存问题 f remove useless code REPORT-12635 REPORT-12635 REPORT-11623 模板加密 REPORT-12635 REPORT-12635 ...final/10.0
@ -0,0 +1,83 @@
|
||||
package com.fr.base.vcs; |
||||
|
||||
import com.fr.design.base.mode.DesignModeContext; |
||||
|
||||
/** |
||||
* 兼容 |
||||
* |
||||
* @deprecated user {@link com.fr.design.base.mode.DesignerMode} and {@link DesignModeContext} instead |
||||
*/ |
||||
@Deprecated |
||||
public enum DesignerMode { |
||||
|
||||
NORMAL() { |
||||
@Override |
||||
public void doSwitch() { |
||||
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); |
||||
} |
||||
}, |
||||
VCS() { |
||||
@Override |
||||
public void doSwitch() { |
||||
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.VCS); |
||||
} |
||||
}, |
||||
AUTHORITY() { |
||||
@Override |
||||
public void doSwitch() { |
||||
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.AUTHORITY); |
||||
} |
||||
}; |
||||
|
||||
abstract void doSwitch(); |
||||
|
||||
|
||||
/** |
||||
* @return 是否时版本控制模式 |
||||
* @deprecated use {@link DesignModeContext#isVcsMode()} instead |
||||
*/ |
||||
@Deprecated |
||||
public static boolean isVcsMode() { |
||||
return DesignModeContext.isVcsMode(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 切换设计器模式 |
||||
* |
||||
* @param mode mode |
||||
* @deprecated use {@link DesignModeContext#switchTo(com.fr.design.base.mode.DesignerMode)} instead |
||||
*/ |
||||
@Deprecated |
||||
public static void setMode(DesignerMode mode) { |
||||
mode.doSwitch(); |
||||
} |
||||
|
||||
/** |
||||
* @return 获取当前设计器模式 |
||||
* @deprecated use {@link DesignModeContext#getMode()} instead |
||||
*/ |
||||
@Deprecated |
||||
public static DesignerMode getMode() { |
||||
switch (DesignModeContext.getMode()) { |
||||
case VCS: |
||||
return VCS; |
||||
case AUTHORITY: |
||||
return AUTHORITY; |
||||
case NORMAL: |
||||
default: |
||||
return NORMAL; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 是否为权限编辑 |
||||
* |
||||
* @return 是否为权限编辑 |
||||
* @deprecated use {@link DesignModeContext#isAuthorityEditing()} instead |
||||
*/ |
||||
@Deprecated |
||||
public static boolean isAuthorityEditing() { |
||||
return DesignModeContext.isAuthorityEditing(); |
||||
} |
||||
} |
@ -0,0 +1,223 @@
|
||||
package com.fr.design.actions.file.export; |
||||
|
||||
import com.fr.base.vcs.DesignerMode; |
||||
import com.fr.design.actions.JTemplateAction; |
||||
import com.fr.design.gui.iprogressbar.FRProgressBar; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.exception.RemoteDesignPermissionDeniedException; |
||||
import com.fr.file.FILE; |
||||
import com.fr.file.FILEChooserPane; |
||||
import com.fr.io.exporter.ExporterKey; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.io.exporter.DesignExportType; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.ProductConstants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.jodd.io.FileNameUtil; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.exporter.TemplateExportOperator; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingWorker; |
||||
import javax.swing.UIManager; |
||||
import java.awt.event.ActionEvent; |
||||
import java.io.OutputStream; |
||||
import java.util.Map; |
||||
|
||||
public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JTemplateAction<E> { |
||||
|
||||
private FRProgressBar progressbar; |
||||
|
||||
public AbstractExportAction(E t) { |
||||
super(t); |
||||
} |
||||
|
||||
/** |
||||
* 导出接口名 |
||||
* |
||||
* @return String scopeName |
||||
*/ |
||||
public abstract ExporterKey exportKey(); |
||||
|
||||
/** |
||||
* 导出类型 |
||||
* |
||||
* @return DesignExportType tyoe |
||||
*/ |
||||
public abstract DesignExportType exportType(); |
||||
|
||||
/** |
||||
* 目标文件过滤器 |
||||
* |
||||
* @return ChooseFileFilter filter |
||||
*/ |
||||
protected abstract ChooseFileFilter getChooseFileFilter(); |
||||
|
||||
/** |
||||
* 目标文件扩展名 |
||||
* |
||||
* @return String extensionName |
||||
*/ |
||||
protected abstract String getDefaultExtension(); |
||||
|
||||
/** |
||||
* 处理参数 |
||||
* |
||||
* @return Map para |
||||
*/ |
||||
protected abstract Map<String, Object> processParameter(); |
||||
|
||||
|
||||
/** |
||||
* 执行方法 |
||||
*/ |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
|
||||
if (!processNotSaved()) { |
||||
return; |
||||
} |
||||
|
||||
Map<String, Object> para = processParameter(); |
||||
|
||||
// 选择输入的文件
|
||||
FILEChooserPane fileChooserPane = FILEChooserPane.getMultiEnvInstance(true, false); |
||||
fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter()); |
||||
|
||||
|
||||
String fileName = getTargetFileName(); |
||||
fileChooserPane.setFileNameTextField(fileName, "." + this.getDefaultExtension()); |
||||
int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), "." + this.getDefaultExtension()); |
||||
if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) { |
||||
FILE target = fileChooserPane.getSelectedFILE(); |
||||
try { |
||||
target.mkfile(); |
||||
} catch (Exception exp) { |
||||
FineLoggerFactory.getLogger().error("Error In Make New File", exp); |
||||
} |
||||
FineLoggerFactory.getLogger().info("\"" + target.getName() + "\"" + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!"); |
||||
|
||||
progressbar = new FRProgressBar( |
||||
createExportWork(getSource(), target, para), |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Report_Exporting"), |
||||
StringUtils.EMPTY, |
||||
0, |
||||
100); |
||||
|
||||
progressbar.start(); |
||||
} |
||||
} |
||||
|
||||
private FILE getSource() { |
||||
return this.getEditingComponent().getEditingFILE(); |
||||
} |
||||
|
||||
private String getTargetFileName() { |
||||
FILE source = getSource(); |
||||
String fileName = source.getName(); |
||||
return FileNameUtil.removeExtension(fileName); |
||||
} |
||||
|
||||
private boolean processNotSaved() { |
||||
//当前编辑的模板
|
||||
E e = getEditingComponent(); |
||||
if (!e.isALLSaved() && !DesignerMode.isVcsMode()) { |
||||
e.stopEditing(); |
||||
int returnVal = JOptionPane.showConfirmDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + e.getEditingFILE() + "\" ?", |
||||
ProductConstants.PRODUCT_NAME, |
||||
JOptionPane.YES_NO_CANCEL_OPTION, |
||||
JOptionPane.QUESTION_MESSAGE |
||||
); |
||||
if (returnVal == JOptionPane.YES_OPTION) { |
||||
e.saveTemplate(); |
||||
FineLoggerFactory.getLogger().info( |
||||
Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", e.getEditingFILE().getName()) |
||||
); |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
private SwingWorker createExportWork(final FILE source, final FILE target, final Map<String, Object> parameterMap) { |
||||
final String path = source.getPath(); |
||||
final String name = target.getName(); |
||||
|
||||
return new SwingWorker<Void, Void>() { |
||||
|
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
//bug 10516
|
||||
Thread.sleep(100); |
||||
try (OutputStream outputStream = target.asOutputStream()) { |
||||
this.setProgress(10); |
||||
dealExporter(outputStream, path, parameterMap); |
||||
this.setProgress(80); |
||||
outputStream.flush(); |
||||
outputStream.close(); |
||||
this.setProgress(100); |
||||
|
||||
FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!"); |
||||
JOptionPane.showMessageDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + name); |
||||
|
||||
|
||||
} catch (RemoteDesignPermissionDeniedException exp) { |
||||
this.setProgress(100); |
||||
target.closeTemplate(); |
||||
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); |
||||
JOptionPane.showMessageDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"), |
||||
null, |
||||
JOptionPane.ERROR_MESSAGE, |
||||
UIManager.getIcon("OptionPane.errorIcon") |
||||
); |
||||
} catch (Exception exp) { |
||||
this.setProgress(100); |
||||
target.closeTemplate(); |
||||
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); |
||||
JOptionPane.showMessageDialog( |
||||
DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path, |
||||
null, |
||||
JOptionPane.ERROR_MESSAGE, |
||||
UIManager.getIcon("OptionPane.errorIcon") |
||||
); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void done() { |
||||
progressbar.close(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void dealExporter(OutputStream outputStream, String path, final Map<String, Object> para) throws Exception { |
||||
|
||||
// 没有办法处理这个 isLocal 判断,因为一个是修改参数传递结果,一个是返回值做结果
|
||||
// todo 后续想想办法
|
||||
if (WorkContext.getCurrent().isLocal()) { |
||||
WorkContext.getCurrent().get(TemplateExportOperator.class) |
||||
.export(exportKey(), exportType(), outputStream, path, para); |
||||
} else { |
||||
byte[] contents = |
||||
WorkContext.getCurrent().get(TemplateExportOperator.class) |
||||
.export(exportKey(), exportType(), null, path, para); |
||||
|
||||
outputStream.write(contents); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,66 @@
|
||||
package com.fr.design.base.mode; |
||||
|
||||
import com.fr.design.designer.TargetComponent; |
||||
|
||||
import static com.fr.design.base.mode.DesignerMode.AUTHORITY; |
||||
|
||||
public class DesignModeContext { |
||||
|
||||
private static DesignerMode mode = DesignerMode.NORMAL; |
||||
|
||||
public static void switchTo(DesignerMode mode) { |
||||
DesignModeContext.mode = mode; |
||||
} |
||||
|
||||
public static DesignerMode getMode() { |
||||
return mode; |
||||
} |
||||
|
||||
/** |
||||
* 是否是版本控制模式 |
||||
* |
||||
* @return 是否是版本控制模式 |
||||
*/ |
||||
public static boolean isVcsMode() { |
||||
return mode == DesignerMode.VCS; |
||||
} |
||||
|
||||
/** |
||||
* @return 是否是禁止拷贝剪切模式 |
||||
*/ |
||||
public static boolean isBanCopyAndCut() { |
||||
return mode == DesignerMode.BAN_COPY_AND_CUT; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 是否为权限编辑 |
||||
* |
||||
* @return 是否为权限编辑 |
||||
*/ |
||||
public static boolean isAuthorityEditing() { |
||||
return mode == AUTHORITY; |
||||
} |
||||
|
||||
|
||||
public static void doCopy(TargetComponent principal) { |
||||
if (isBanCopyAndCut() || principal == null) { |
||||
return; |
||||
} |
||||
principal.copy(); |
||||
} |
||||
|
||||
public static boolean doPaste(TargetComponent principal) { |
||||
if (principal == null) { |
||||
return false; |
||||
} |
||||
return principal.paste(); |
||||
} |
||||
|
||||
public static boolean doCut(TargetComponent principal) { |
||||
if (isBanCopyAndCut() || principal == null) { |
||||
return false; |
||||
} |
||||
return principal.cut(); |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
package com.fr.design.base.mode; |
||||
|
||||
public enum DesignerMode { |
||||
NORMAL, |
||||
BAN_COPY_AND_CUT, |
||||
VCS, |
||||
AUTHORITY |
||||
} |
@ -0,0 +1,7 @@
|
||||
package com.fr.design.designer; |
||||
|
||||
/** |
||||
* 暂时是空接口,标记一下模板设计时推出的代理其他 {@link TargetComponent} 的类 |
||||
*/ |
||||
public interface DesignerProxy { |
||||
} |
@ -0,0 +1,5 @@
|
||||
package com.fr.design.designer.properties; |
||||
|
||||
public enum PropertyTab { |
||||
ATTR, MOBILE |
||||
} |
@ -0,0 +1,93 @@
|
||||
package com.fr.design.dialog; |
||||
|
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* 封装了"为该模版单独设置、采用服务器设置"选项功能的设置面板 |
||||
* Created by plough on 2018/11/7. |
||||
*/ |
||||
public abstract class AbstractTemplateServerSettingPane extends BasicPane { |
||||
private static final String[] CHOOSEITEM = new String[] { |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings") |
||||
}; |
||||
|
||||
protected static final int SINGLE_SET = 0; |
||||
protected static final int SERVER_SET = 1; |
||||
|
||||
protected UIComboBox chooseComboBox; |
||||
protected JPanel buttonPane; |
||||
private JPanel contentPane; |
||||
|
||||
protected AbstractTemplateServerSettingPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
chooseComboBox = new UIComboBox(CHOOSEITEM); |
||||
chooseComboBox.addItemListener(itemListener); |
||||
UILabel belowSetLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Blow_Set")); |
||||
belowSetLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); |
||||
buttonPane = GUICoreUtils.createFlowPane(new Component[] { |
||||
belowSetLabel, chooseComboBox}, FlowLayout.LEFT, 0, 0); |
||||
buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0)); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(buttonPane, BorderLayout.NORTH); |
||||
this.contentPane = getContentPane(); |
||||
this.add(contentPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/** |
||||
* 包含设置项的主面板 |
||||
*/ |
||||
protected abstract JPanel getContentPane(); |
||||
|
||||
private ItemListener itemListener = new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
if (isUsingServerSettings()) { |
||||
populateServerSettings(); |
||||
setSettingPaneEnabled(false); |
||||
} else { |
||||
setSettingPaneEnabled(true); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
|
||||
private void setSettingPaneEnabled(boolean enabled) { |
||||
// GUICoreUtils.setEnabled 会遍历所有 Component。所以要先设置外层,如果是生效的,再设置内层
|
||||
GUICoreUtils.setEnabled(contentPane, enabled); |
||||
if (enabled) { |
||||
checkContentPaneEnabled(); |
||||
} |
||||
} |
||||
|
||||
protected boolean isUsingServerSettings() { |
||||
return chooseComboBox.getSelectedIndex() == SERVER_SET; |
||||
} |
||||
|
||||
/** |
||||
* 整个配置面板设置为可用后,可能还需要检测面板中部分区域的可用性 |
||||
*/ |
||||
protected void checkContentPaneEnabled() { |
||||
// do nothing
|
||||
} |
||||
|
||||
/** |
||||
* 读取服务器配置并 populate 到主面板中 |
||||
*/ |
||||
protected abstract void populateServerSettings(); |
||||
} |
@ -1,31 +0,0 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.stable.fun.ReportFitAttrProvider; |
||||
import com.fr.stable.fun.mark.Immutable; |
||||
|
||||
import java.beans.PropertyDescriptor; |
||||
|
||||
/** |
||||
* Created by Slpire on 2016/10/28. |
||||
*/ |
||||
public interface FormElementCaseEditorProcessor extends Immutable { |
||||
String MARK_STRING = "PropertyEditor"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
|
||||
/** |
||||
* 生成属性表 |
||||
* @param temp 传入当前操作的class |
||||
* @param reportFitAttr 传入的自适应属性 |
||||
* @return 返回属性表 |
||||
*/ |
||||
PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportFitAttrProvider reportFitAttr); |
||||
|
||||
/** |
||||
* 返回pc自适应属性值 |
||||
* @param fitAttrProvider 传入的自适应属性 |
||||
* @return 返回pc自适应属性值 |
||||
*/ |
||||
int getFitStateInPC(ReportFitAttrProvider fitAttrProvider); |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
import com.fr.design.designer.properties.PropertyTab; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.stable.fun.mark.Mutable; |
||||
|
||||
/** |
||||
* created by hades on 18/10/16 |
||||
* 该接口支持在设计器cpt&frm参数界面的属性和移动端下添加一个UIExpandablePane(可展开面板) |
||||
*/ |
||||
public interface ParameterExpandablePaneUIProvider extends Mutable { |
||||
|
||||
String XML_TAG = "ParameterExpandablePaneUIProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 创建可展开面板并添加子容器 |
||||
* |
||||
* @return UIExpandablePane |
||||
*/ |
||||
UIExpandablePane createUIExpandablePane(); |
||||
|
||||
/** |
||||
* 指定添加UIExpandablePane到哪个PropertyTab下,例如属性,移动端 |
||||
* |
||||
* @return PropertyTab |
||||
*/ |
||||
PropertyTab addToWhichPropertyTab(); |
||||
|
||||
} |
@ -1,44 +0,0 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.FormElementCaseEditorProcessor; |
||||
import com.fr.stable.fun.ReportFitAttrProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
import java.beans.PropertyDescriptor; |
||||
|
||||
/** |
||||
* Created by zhouping on 2015/9/10. |
||||
*/ |
||||
@API(level = FormElementCaseEditorProcessor.CURRENT_LEVEL) |
||||
public abstract class AbstractFormElementCaseEditorProcessor implements FormElementCaseEditorProcessor { |
||||
|
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
public int layerIndex() { |
||||
return DEFAULT_LAYER_INDEX; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 生成属性表 |
||||
* @param temp 传入当前操作的class |
||||
* @param reportFitAttr 传入的自适应属性 |
||||
* @return 返回属性表 |
||||
*/ |
||||
@Override |
||||
public PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportFitAttrProvider reportFitAttr) { |
||||
return new PropertyDescriptor[0]; |
||||
} |
||||
|
||||
/** |
||||
* 返回pc自适应属性值 |
||||
* @param fitAttrProvider 传入的自适应属性 |
||||
* @return 返回pc自适应属性值 |
||||
*/ |
||||
@Override |
||||
public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) { |
||||
return 0; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.ParameterExpandablePaneUIProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
@API(level = ParameterExpandablePaneUIProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractParameterExpandablePaneUIProvider extends AbstractProvider implements ParameterExpandablePaneUIProvider{ |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
} |
@ -1,184 +0,0 @@
|
||||
package com.fr.design.hyperlink; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
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.itextfield.UITextField; |
||||
import com.fr.design.gui.itree.filetree.ReportletPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import com.fr.js.ReportletHyperlink; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* 热点链接部分 上方 定义特征 样式 报表 等属性的界面. |
||||
* |
||||
* @author kunsnat |
||||
*/ |
||||
public class ReporletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyperlink> { |
||||
private UITextField itemNameTextField; |
||||
private boolean needRenamePane = false; |
||||
private UITextField reportPathTextField; |
||||
private UICheckBox showParameterInterface; |
||||
private UIButton browserButton; |
||||
|
||||
// richer:参数传递方式
|
||||
private UIComboBox postComboBox; |
||||
|
||||
public ReporletHyperNorthPane(boolean needRenamePane) { |
||||
this.needRenamePane = needRenamePane; |
||||
this.inits(); |
||||
} |
||||
|
||||
public ReporletHyperNorthPane() { |
||||
this.inits(); |
||||
} |
||||
|
||||
/** |
||||
* 初始化组件 |
||||
*/ |
||||
public void inits() { |
||||
super.initComponents(); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel setHeaderPanel() { |
||||
JPanel headerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p, p}; |
||||
double[] columnSize = {p, TableLayout.FILL}; |
||||
// Reportlet.
|
||||
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
|
||||
reportPathTextField = new UITextField(20); |
||||
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); |
||||
|
||||
browserButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); |
||||
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); |
||||
reportletNamePane.add(browserButton, BorderLayout.EAST); |
||||
browserButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent evt) { |
||||
final ReportletPane reportletPane = new ReportletPane(); |
||||
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
||||
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ReporletHyperNorthPane.this)); |
||||
|
||||
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
public void doOk() { |
||||
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
||||
} |
||||
}); |
||||
reportletDialog.setVisible(true); |
||||
} |
||||
}); |
||||
|
||||
Component[][] components; |
||||
if (!this.needRenamePane) { |
||||
components = new Component[][]{ |
||||
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), reportletNamePane}, |
||||
}; |
||||
} else { |
||||
itemNameTextField = new UITextField(); |
||||
components = new Component[][]{ |
||||
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), itemNameTextField}, |
||||
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), reportletNamePane}, |
||||
}; |
||||
} |
||||
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
headerPane.add(northPane, BorderLayout.NORTH); |
||||
return headerPane; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "reportlet"; |
||||
} |
||||
|
||||
@Override |
||||
protected void populateSubHyperlinkBean(ReportletHyperlink link) { |
||||
if (itemNameTextField != null) { |
||||
this.itemNameTextField.setText(link.getItemName()); |
||||
} |
||||
this.reportPathTextField.setText(link.getReportletPath()); |
||||
this.showParameterInterface.setSelected(link.isShowParameterInterface()); |
||||
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0); |
||||
} |
||||
|
||||
@Override |
||||
protected ReportletHyperlink updateSubHyperlinkBean() { |
||||
ReportletHyperlink reportletHyperlink = new ReportletHyperlink(); |
||||
updateSubHyperlinkBean(reportletHyperlink); |
||||
|
||||
return reportletHyperlink; |
||||
} |
||||
|
||||
@Override |
||||
protected void updateSubHyperlinkBean(ReportletHyperlink reportletHyperlink) { |
||||
if (itemNameTextField != null) { |
||||
reportletHyperlink.setItemName(this.itemNameTextField.getText()); |
||||
} |
||||
reportletHyperlink.setReportletPath(this.reportPathTextField.getText()); |
||||
reportletHyperlink.setShowParameterInterface(this.showParameterInterface.isSelected()); |
||||
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1 ? true : false); |
||||
} |
||||
|
||||
public String getReportletName() { |
||||
return StringUtils.isBlank(this.reportPathTextField.getText()) ? StringUtils.EMPTY : this.reportPathTextField.getText().substring(1); |
||||
} |
||||
|
||||
/** |
||||
* 获取按钮焦点 |
||||
*/ |
||||
public void requestButtonFocus() { |
||||
this.browserButton.requestFocus(); |
||||
JPopupMenu popup = new JPopupMenu(); |
||||
FakeTipAction tip = new FakeTipAction(); |
||||
tip.setEnabled(false); |
||||
popup.add(tip); |
||||
GUICoreUtils.showPopupCloseMenu(popup, this.browserButton); |
||||
} |
||||
|
||||
private class FakeTipAction extends UpdateAction { |
||||
public FakeTipAction() { |
||||
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Select")); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent e) { |
||||
//do nothing
|
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel setFootPanel() { |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p, p}; |
||||
double[] columnSize = {p, TableLayout.FILL}; |
||||
showParameterInterface = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_UI_Display")); |
||||
JPanel showParameterPanel = new JPanel(); |
||||
showParameterPanel.add(new UILabel()); |
||||
showParameterPanel.add(showParameterInterface); |
||||
|
||||
postComboBox = new UIComboBox(new String[]{"GET", "POST"}); |
||||
JPanel postPanel = new JPanel(); |
||||
postPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Reportlet_Parameter_Type"))); |
||||
postPanel.add(postComboBox); |
||||
Component[][] components = {{postPanel}, |
||||
{showParameterPanel}, |
||||
{new UILabel(" ")} |
||||
}; |
||||
|
||||
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,450 @@
|
||||
package com.fr.design.hyperlink; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.formula.TinyFormulaPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
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.itextfield.UINumberField; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.gui.itree.filetree.ReportletPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.js.ReportletHyperlink; |
||||
import com.fr.js.ReportletHyperlinkDialogAttr; |
||||
import com.fr.stable.CommonUtils; |
||||
import com.fr.stable.FormulaProvider; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.ButtonGroup; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JPopupMenu; |
||||
import javax.swing.SwingUtilities; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 热点链接部分 上方 定义特征 样式 报表 等属性的界面. |
||||
* |
||||
* @author kunsnat |
||||
*/ |
||||
public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyperlink> { |
||||
/** |
||||
* item name text filed |
||||
*/ |
||||
private UITextField itemNameTextField; |
||||
/** |
||||
* 是否展示item name |
||||
*/ |
||||
private boolean needRenamePane = false; |
||||
/** |
||||
* 参数路径输入框 |
||||
*/ |
||||
private UITextField reportPathTextField; |
||||
/** |
||||
* 是否展示参数面板勾选框 |
||||
*/ |
||||
private UICheckBox showParameterInterface; |
||||
/** |
||||
* 选择文件按钮 |
||||
*/ |
||||
private UIButton browserButton; |
||||
|
||||
/** |
||||
* 参数传递方式下拉选择框 |
||||
*/ |
||||
private UIComboBox postComboBox; |
||||
/** |
||||
* 对话框标题输入框 |
||||
*/ |
||||
private TinyFormulaPane titleFiled; |
||||
|
||||
|
||||
/** |
||||
* 对话框居中按钮 |
||||
*/ |
||||
private UIRadioButton center; |
||||
/** |
||||
* 对话框位置自定义按钮 |
||||
*/ |
||||
private UIRadioButton custom; |
||||
/** |
||||
* 距左 |
||||
*/ |
||||
private UINumberField leftLocation; |
||||
/** |
||||
* 距上 |
||||
*/ |
||||
private UINumberField topLocation; |
||||
|
||||
|
||||
public ReportletHyperNorthPane(boolean needRenamePane) { |
||||
this.needRenamePane = needRenamePane; |
||||
} |
||||
|
||||
public ReportletHyperNorthPane() { |
||||
} |
||||
|
||||
/** |
||||
* 初始化面板 |
||||
*/ |
||||
@Override |
||||
protected void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
|
||||
final List<Component[]> dialogComponents = new ArrayList<>(); |
||||
final List<Component[]> othersComponents = new ArrayList<>(); |
||||
|
||||
initRenamePanel(dialogComponents, othersComponents); |
||||
initHeaderPanel(dialogComponents, othersComponents); |
||||
initTargetComboBoxPanel(dialogComponents, othersComponents); |
||||
|
||||
initTitlePanel(dialogComponents); |
||||
initDialogSizePanel(dialogComponents); |
||||
initDialogLocationPanel(dialogComponents); |
||||
|
||||
initFooterPanel(dialogComponents, othersComponents); |
||||
|
||||
initPlaceHolder(othersComponents); |
||||
|
||||
bindListener(dialogComponents, othersComponents); |
||||
|
||||
// 创建内容面板
|
||||
JPanel content = TableLayoutHelper.createTableLayoutPane(dialogComponents.toArray(new Component[dialogComponents.size()][]), TableLayoutHelper.FILL_LASTCOL_AND_ROW); |
||||
this.add(content, BorderLayout.CENTER); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 生成最上方的配置面板 |
||||
* |
||||
* @return JPanel |
||||
*/ |
||||
@Override |
||||
protected JPanel setHeaderPanel() { |
||||
|
||||
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
// 路径输入框
|
||||
reportPathTextField = new UITextField(20); |
||||
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); |
||||
|
||||
// 选择路径按钮
|
||||
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select")); |
||||
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); |
||||
reportletNamePane.add(browserButton, BorderLayout.EAST); |
||||
browserButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent evt) { |
||||
final ReportletPane reportletPane = new ReportletPane(); |
||||
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
||||
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ReportletHyperNorthPane.this)); |
||||
|
||||
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
||||
} |
||||
}); |
||||
reportletDialog.setVisible(true); |
||||
} |
||||
}); |
||||
return reportletNamePane; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "reportlet"; |
||||
} |
||||
|
||||
@Override |
||||
protected void populateSubHyperlinkBean(ReportletHyperlink link) { |
||||
if (itemNameTextField != null) { |
||||
this.itemNameTextField.setText(link.getItemName()); |
||||
} |
||||
this.reportPathTextField.setText(link.getReportletPath()); |
||||
this.showParameterInterface.setSelected(link.isShowParameterInterface()); |
||||
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0); |
||||
|
||||
ReportletHyperlinkDialogAttr attr = link.getAttr(); |
||||
titleFiled.populateBean(StringUtils.EMPTY); |
||||
leftLocation.setText(StringUtils.EMPTY); |
||||
topLocation.setText(StringUtils.EMPTY); |
||||
center.setSelected(true); |
||||
if (attr != null) { |
||||
Object title = attr.getTitle(); |
||||
String titleContent; |
||||
if (title instanceof FormulaProvider) { |
||||
titleContent = ((FormulaProvider) title).getContent(); |
||||
} else { |
||||
titleContent = title == null ? StringUtils.EMPTY : title.toString(); |
||||
} |
||||
titleFiled.populateBean(titleContent); |
||||
boolean isCenter = attr.isCenter(); |
||||
if (!isCenter) { |
||||
int left = attr.getLeft(), top = attr.getTop(); |
||||
leftLocation.setText(Integer.toString(left)); |
||||
topLocation.setText(Integer.toString(top)); |
||||
} |
||||
center.setSelected(isCenter); |
||||
custom.setSelected(!isCenter); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected ReportletHyperlink updateSubHyperlinkBean() { |
||||
ReportletHyperlink reportletHyperlink = new ReportletHyperlink(); |
||||
updateSubHyperlinkBean(reportletHyperlink); |
||||
return reportletHyperlink; |
||||
} |
||||
|
||||
@Override |
||||
protected void updateSubHyperlinkBean(ReportletHyperlink reportletHyperlink) { |
||||
if (itemNameTextField != null) { |
||||
reportletHyperlink.setItemName(this.itemNameTextField.getText()); |
||||
} |
||||
reportletHyperlink.setReportletPath(this.reportPathTextField.getText()); |
||||
reportletHyperlink.setShowParameterInterface(this.showParameterInterface.isSelected()); |
||||
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1); |
||||
|
||||
ReportletHyperlinkDialogAttr attr = new ReportletHyperlinkDialogAttr(); |
||||
String title = titleFiled.updateBean(); |
||||
if (CommonUtils.maybeFormula(title)) { |
||||
attr.setTitle(BaseFormula.createFormulaBuilder().build(titleFiled.updateBean())); |
||||
} else { |
||||
attr.setTitle(title); |
||||
} |
||||
attr.setCenter(center.isSelected()); |
||||
if (!attr.isCenter()) { |
||||
attr.setLeft((int) leftLocation.getValue()); |
||||
attr.setTop((int) topLocation.getValue()); |
||||
} |
||||
reportletHyperlink.setAttr(attr); |
||||
|
||||
} |
||||
|
||||
public String getReportletName() { |
||||
String text = this.reportPathTextField.getText(); |
||||
return StringUtils.isBlank(text) ? StringUtils.EMPTY : text.substring(1); |
||||
} |
||||
|
||||
/** |
||||
* 获取按钮焦点 |
||||
*/ |
||||
public void requestButtonFocus() { |
||||
this.browserButton.requestFocus(); |
||||
JPopupMenu popup = new JPopupMenu(); |
||||
FakeTipAction tip = new FakeTipAction(); |
||||
tip.setEnabled(false); |
||||
popup.add(tip); |
||||
GUICoreUtils.showPopupCloseMenu(popup, this.browserButton); |
||||
} |
||||
|
||||
private class FakeTipAction extends UpdateAction { |
||||
public FakeTipAction() { |
||||
this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Select")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
// do nothing
|
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 底部面板,参数传递方式 |
||||
* |
||||
* @return JPanel |
||||
*/ |
||||
@Override |
||||
protected JPanel setFootPanel() { |
||||
JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
|
||||
// 参数传递方式下拉框
|
||||
postComboBox = new UIComboBox(new String[]{"GET", "POST"}); |
||||
postComboBox.setPreferredSize(new Dimension(60, 20)); |
||||
postComboBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
content.add(postComboBox); |
||||
|
||||
|
||||
showParameterInterface = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Parameter_UI_Display")); |
||||
|
||||
showParameterInterface.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
content.add(showParameterInterface); |
||||
return content; |
||||
} |
||||
|
||||
private void bindListener(final List<Component[]> dialogComponents, final List<Component[]> othersComponents) { |
||||
final UIComboBox targetFrameComboBox = this.getTargetFrameComboBox(); |
||||
targetFrameComboBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
boolean show = DIALOG == targetFrameComboBox.getSelectedIndex(); |
||||
JPanel content; |
||||
List<Component[]> cs = show ? dialogComponents : othersComponents; |
||||
ReportletHyperNorthPane.this.removeAll(); |
||||
content = TableLayoutHelper.createTableLayoutPane(cs.toArray(new Component[cs.size()][]), TableLayoutHelper.FILL_LASTCOL_AND_ROW); |
||||
ReportletHyperNorthPane.this.add(content, BorderLayout.CENTER); |
||||
ReportletHyperNorthPane.this.revalidate(); |
||||
ReportletHyperNorthPane.this.repaint(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void initPlaceHolder(List<Component[]> othersComponents) { |
||||
JPanel empty1 = new JPanel(); |
||||
empty1.setPreferredSize(new Dimension(20, 20)); |
||||
JPanel empty2 = new JPanel(); |
||||
empty2.setPreferredSize(new Dimension(20, 20)); |
||||
JPanel empty3 = new JPanel(); |
||||
empty3.setPreferredSize(new Dimension(20, 23)); |
||||
|
||||
othersComponents.add(new Component[]{empty1, new JPanel()}); |
||||
othersComponents.add(new Component[]{empty2, new JPanel()}); |
||||
othersComponents.add(new Component[]{empty3, new JPanel()}); |
||||
} |
||||
|
||||
private void initRenamePanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||
// 是否有重命名属性
|
||||
if (this.needRenamePane) { |
||||
itemNameTextField = new UITextField(); |
||||
Component[] renameComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), itemNameTextField}; |
||||
dialogComponents.add(renameComponents); |
||||
othersComponents.add(renameComponents); |
||||
} |
||||
} |
||||
|
||||
private void initHeaderPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||
//最上方位置的面板
|
||||
JPanel headerPane = this.setHeaderPanel(); |
||||
Component[] headerComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), headerPane}; |
||||
dialogComponents.add(headerComponents); |
||||
othersComponents.add(headerComponents); |
||||
} |
||||
|
||||
private void initTargetComboBoxPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||
// 链接打开于
|
||||
UIComboBox targetFrameComboBox = new UIComboBox(getTargetFrames()); |
||||
this.setTargetFrameComboBox(targetFrameComboBox); |
||||
targetFrameComboBox.setEditable(true); |
||||
targetFrameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||
JPanel targetFramePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
targetFramePanel.add(targetFrameComboBox); |
||||
Component[] targetComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Link_Opened_In") + ":"), targetFramePanel}; |
||||
dialogComponents.add(targetComponents); |
||||
othersComponents.add(targetComponents); |
||||
} |
||||
|
||||
private void initTitlePanel(List<Component[]> dialogComponents) { |
||||
// 对话框标题
|
||||
titleFiled = new TinyFormulaPane(); |
||||
titleFiled.getUITextField().setColumns(15); |
||||
final JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
titlePanel.add(titleFiled); |
||||
Component[] titleComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Title") + ":"), titlePanel}; |
||||
dialogComponents.add(titleComponents); |
||||
} |
||||
|
||||
private void initDialogSizePanel(List<Component[]> dialogComponents) {// 对话框大小
|
||||
final JPanel sizeJPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
UILabel heightLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Height") + ":"); |
||||
heightLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); |
||||
sizeJPanel.add(heightLabel); |
||||
UINumberField heightTextFiled = new UINumberField(); |
||||
heightTextFiled.setMinValue(0); |
||||
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); |
||||
heightTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||
sizeJPanel.add(heightTextFiled); |
||||
this.setHeightTextFiled(heightTextFiled); |
||||
UILabel widthLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Designer_Width") + ":"); |
||||
widthLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); |
||||
sizeJPanel.add(widthLabel); |
||||
UINumberField widthTextFiled = new UINumberField(); |
||||
widthTextFiled.setMinValue(0); |
||||
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); |
||||
widthTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||
sizeJPanel.add(widthTextFiled); |
||||
this.setWidthTextFiled(widthTextFiled); |
||||
sizeJPanel.setVisible(true); |
||||
dialogComponents.add(new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Size") + ":"), sizeJPanel}); |
||||
} |
||||
|
||||
private void initDialogLocationPanel(List<Component[]> dialogComponents) { |
||||
// 显示位置
|
||||
final JPanel locationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
// 居中
|
||||
center = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Center")); |
||||
// 自定义
|
||||
custom = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Custom")); |
||||
|
||||
custom.setBorder(BorderFactory.createEmptyBorder(4, 20, 4, 5)); |
||||
ButtonGroup group = new ButtonGroup(); |
||||
group.setSelected(center.getModel(), true); |
||||
group.add(center); |
||||
group.add(custom); |
||||
locationPanel.add(center); |
||||
locationPanel.add(custom); |
||||
|
||||
// 位置 距左
|
||||
final UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Left")); |
||||
leftLabel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10)); |
||||
leftLocation = new UINumberField(); |
||||
leftLocation.setMinValue(0); |
||||
leftLocation.setPreferredSize(new Dimension(40, 20)); |
||||
// 位置 距上
|
||||
final UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Top")); |
||||
topLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); |
||||
topLocation = new UINumberField(); |
||||
topLocation.setMinValue(0); |
||||
topLocation.setPreferredSize(new Dimension(40, 20)); |
||||
|
||||
locationPanel.add(leftLabel); |
||||
locationPanel.add(leftLocation); |
||||
locationPanel.add(topLabel); |
||||
locationPanel.add(topLocation); |
||||
leftLabel.setVisible(false); |
||||
leftLocation.setVisible(false); |
||||
topLabel.setVisible(false); |
||||
topLocation.setVisible(false); |
||||
ChangeListener actionListener = new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
boolean visible = custom.isSelected(); |
||||
leftLabel.setVisible(visible); |
||||
leftLocation.setVisible(visible); |
||||
topLabel.setVisible(visible); |
||||
topLocation.setVisible(visible); |
||||
} |
||||
}; |
||||
// 默认居中
|
||||
center.setSelected(true); |
||||
center.addChangeListener(actionListener); |
||||
custom.addChangeListener(actionListener); |
||||
|
||||
dialogComponents.add(new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Show_Position") + ":"), locationPanel}); |
||||
} |
||||
|
||||
private void initFooterPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||
// 最下方的配置面板
|
||||
// 参数传递方式
|
||||
Component[] footerComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reportlet_Parameter_Type") + ":"), this.setFootPanel()}; |
||||
dialogComponents.add(footerComponents); |
||||
othersComponents.add(footerComponents); |
||||
} |
||||
} |
@ -0,0 +1,108 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; |
||||
import com.fr.form.ui.CardSwitchButton; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import java.awt.BasicStroke; |
||||
import java.awt.Dimension; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
|
||||
public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane { |
||||
|
||||
public DefaultMobileStyleDefinePane(WCardTagLayout tagLayout) { |
||||
super(tagLayout); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(MobileTemplateStyle ob) { |
||||
updatePreviewPane(); |
||||
} |
||||
|
||||
protected void createConfigPane() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected void initDefaultConfig() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateSubStyle() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateBean() { |
||||
return new DefaultMobileTemplateStyle(); |
||||
} |
||||
|
||||
public MobileTemplateStyle updateConfig(){ |
||||
return new DefaultMobileTemplateStyle(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected MobileTemplateStyle getDefaultTemplateStyle() { |
||||
return new DefaultMobileTemplateStyle(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateSubStyle(MobileTemplateStyle ob) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
protected MobileTemplatePreviewPane createPreviewPane() { |
||||
return new DefaultStylePreviewPane(); |
||||
} |
||||
|
||||
public class DefaultStylePreviewPane extends MobileTemplatePreviewPane { |
||||
|
||||
public DefaultStylePreviewPane() { |
||||
this.setBackground(DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR); |
||||
} |
||||
|
||||
public void repaint() { |
||||
super.repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Dimension dimension = this.getSize(); |
||||
int panelWidth = dimension.width; |
||||
int panelHeight = dimension.height; |
||||
Graphics2D g2d = (Graphics2D) g.create(); |
||||
FRFont frFont = DefaultMobileTemplateStyle.DEFAULT_TAB_FONT.getFont(); |
||||
FontMetrics fm = GraphHelper.getFontMetrics(frFont); |
||||
WCardTagLayout cardTagLayout = DefaultMobileStyleDefinePane.this.getTagLayout(); |
||||
int eachWidth = panelWidth / cardTagLayout.getWidgetCount(); |
||||
g2d.setFont(frFont); |
||||
int fontHeight = fm.getHeight(); |
||||
int ascentHeight = fm.getAscent(); |
||||
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { |
||||
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); |
||||
String widgetName = cardSwitchButton.getText(); |
||||
int width = fm.stringWidth(widgetName); |
||||
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); |
||||
if (i == 0) { |
||||
g2d.setStroke(new BasicStroke(2.0f)); |
||||
g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1); |
||||
} |
||||
g2d.translate(eachWidth, 0); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,193 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.base.Icon; |
||||
import com.fr.base.IconManager; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; |
||||
import com.fr.form.ui.CardSwitchButton; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.cardtag.mobile.DownMenuStyle; |
||||
import com.fr.general.cardtag.mobile.LineDescription; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Stroke; |
||||
import java.util.ArrayList; |
||||
|
||||
public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { |
||||
private LinePane splitLinePane; |
||||
private TabIconConfigPane initIconConfigPane; |
||||
private TabIconConfigPane selectIconConfigPane; |
||||
|
||||
public DownMenuStyleDefinePane(WCardTagLayout tagLayout) { |
||||
super(tagLayout); |
||||
} |
||||
|
||||
protected void createExtraConfPane(JPanel centerPane) { |
||||
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); |
||||
UITitleSplitLine iconSplitLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon"), 520); |
||||
iconSplitLine.setPreferredSize(new Dimension(520, 20)); |
||||
centerPane.add(iconSplitLine); |
||||
|
||||
initIconConfigPane = new TabIconConfigPane(getTagLayout().getWidgetCount()); |
||||
selectIconConfigPane = new TabIconConfigPane(getTagLayout().getWidgetCount()); |
||||
|
||||
UILabel initIconLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Initial_Icon")); |
||||
UILabel selectIconLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Icon")); |
||||
initIconLabel.setPreferredSize(new Dimension(55, 20)); |
||||
selectIconLabel.setPreferredSize(new Dimension(55, 20)); |
||||
JPanel initIconContainPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initIconLabel, initIconConfigPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
JPanel selectIconContainePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectIconLabel, selectIconConfigPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
initIconContainPane.setPreferredSize(new Dimension(240, 50)); |
||||
selectIconContainePane.setPreferredSize(new Dimension(240, 50)); |
||||
panel.add(initIconContainPane); |
||||
panel.add(selectIconContainePane); |
||||
UITitleSplitLine splitLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Spit_Line"), 520); |
||||
splitLine.setPreferredSize(new Dimension(520, 20)); |
||||
splitLinePane = new LinePane(); |
||||
splitLinePane.addLineChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
centerPane.add(panel); |
||||
centerPane.add(splitLine); |
||||
centerPane.add(splitLinePane); |
||||
} |
||||
|
||||
@Override |
||||
protected void initDefaultConfig() { |
||||
this.initialColorBox.setSelectObject(DownMenuStyle.DEFAULT_INITIAL_COLOR); |
||||
this.fontConfPane.populate(DownMenuStyle.DEFAULT_TAB_FONT.getFont()); |
||||
this.selectColorBox.setSelectObject(DownMenuStyle.DEFAULT_SELECT_COLOR); |
||||
this.selectFontColor.setColor(DownMenuStyle.DEFAULT_SELECT_FONT_COLOR); |
||||
this.splitLinePane.populate(DownMenuStyle.DEFAULT_SPLIT_LINE); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplatePreviewPane createPreviewPane() { |
||||
return new DownMenuStylePreviewPane(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void populateSubStyle(MobileTemplateStyle ob) { |
||||
super.populateSubStyle(ob); |
||||
DownMenuStyle downMenuStyle = (DownMenuStyle) ob; |
||||
splitLinePane.populate(downMenuStyle.getSplitLine()); |
||||
ArrayList<String> initialIconNames = new ArrayList<String>(); |
||||
ArrayList<String> selectIconNames = new ArrayList<String>(); |
||||
for (int i = 0; i < getTagLayout().getWidgetCount(); i++) { |
||||
CardSwitchButton cardSwitchButton = (CardSwitchButton) getTagLayout().getWidget(i); |
||||
initialIconNames.add(cardSwitchButton.getInitIconName()); |
||||
selectIconNames.add(cardSwitchButton.getSelectIconName()); |
||||
} |
||||
initIconConfigPane.populate(initialIconNames); |
||||
selectIconConfigPane.populate(selectIconNames); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplateStyle getDefaultTemplateStyle() { |
||||
return new DownMenuStyle(); |
||||
} |
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateStyleWithSelectConf() { |
||||
DownMenuStyle downMenuStyle = new DownMenuStyle(); |
||||
downMenuStyle.setSplitLine(splitLinePane.update()); |
||||
ArrayList<String> initialIconNames = initIconConfigPane.update(); |
||||
ArrayList<String> selectIconNames = selectIconConfigPane.update(); |
||||
for (int i = 0; i < getTagLayout().getWidgetCount(); i++) { |
||||
CardSwitchButton cardSwitchButton = (CardSwitchButton) getTagLayout().getWidget(i); |
||||
cardSwitchButton.setInitIconName(initialIconNames.get(i)); |
||||
cardSwitchButton.setSelectIconName(selectIconNames.get(i)); |
||||
} |
||||
return downMenuStyle; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
public class DownMenuStylePreviewPane extends MobileTemplatePreviewPane { |
||||
private static final int ICON_OFFSET = 16; |
||||
private static final int GAP = 6; |
||||
private static final String PAINT_ICON = "fund_white"; |
||||
private static final String ICON_PATH = "/com/fr/web/images/fund_white.png"; |
||||
private LineDescription splitLine; |
||||
|
||||
public DownMenuStylePreviewPane() { |
||||
this.setBackground(Color.decode("#3888EE")); |
||||
} |
||||
|
||||
public void repaint() { |
||||
super.repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Color selectFontColor = this.getTabFontConfig().getSelectColor(); |
||||
Dimension dimension = this.getSize(); |
||||
int panelWidth = dimension.width; |
||||
int panelHeight = dimension.height; |
||||
Graphics2D g2d = (Graphics2D) g.create(); |
||||
FRFont frFont = this.getTabFontConfig().getFont(); |
||||
FontMetrics fm = GraphHelper.getFontMetrics(frFont); |
||||
WCardTagLayout cardTagLayout = DownMenuStyleDefinePane.this.getTagLayout(); |
||||
int eachWidth = panelWidth / cardTagLayout.getWidgetCount(); |
||||
g2d.setFont(frFont); |
||||
int fontHeight = fm.getHeight(); |
||||
int ascent = fm.getAscent(); |
||||
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { |
||||
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); |
||||
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); |
||||
String widgetName = cardSwitchButton.getText(); |
||||
int width = fm.stringWidth(widgetName); |
||||
if(i == 0){ |
||||
Color oldColor = g2d.getColor(); |
||||
g2d.setColor(this.getSelectColor()); |
||||
g2d.fillRect(0, 0 ,eachWidth, panelHeight); |
||||
g2d.setColor(oldColor); |
||||
} |
||||
Icon icon = new Icon(PAINT_ICON, ICON_PATH); |
||||
g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null); |
||||
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent); |
||||
Stroke oldStroke = g2d.getStroke(); |
||||
if (splitLine.getLineStyle() != 0) { |
||||
g2d.setColor(splitLine.getColor()); |
||||
g2d.setStroke(GraphHelper.getStroke(splitLine.getLineStyle())); |
||||
g2d.drawLine(eachWidth, 0, eachWidth, panelHeight); |
||||
} |
||||
g2d.setStroke(oldStroke); |
||||
g2d.translate(eachWidth, 0); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
public void populateConfig(MobileTemplateStyle templateStyle) { |
||||
super.populateConfig(templateStyle); |
||||
this.splitLine = ((DownMenuStyle) templateStyle).getSplitLine(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.icombobox.LineComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.layout.VerticalFlowLayout; |
||||
import com.fr.design.style.color.NewColorSelectBox; |
||||
import com.fr.general.cardtag.mobile.LineDescription; |
||||
import com.fr.stable.CoreConstants; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import javax.swing.event.EventListenerList; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
public class LinePane extends JPanel { |
||||
private LineComboBox lineStyle; |
||||
private NewColorSelectBox lineColor; |
||||
private EventListenerList lineChangeListener = new EventListenerList(); |
||||
|
||||
public LinePane() { |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
this.setLayout(new VerticalFlowLayout(FlowLayout.CENTER, 0, 10)); |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); |
||||
UILabel lineLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style")); |
||||
UILabel colorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Colors")); |
||||
lineLabel.setPreferredSize(new Dimension(55, 20)); |
||||
colorLabel.setPreferredSize(new Dimension(55, 20)); |
||||
|
||||
lineStyle = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); |
||||
lineStyle.setPreferredSize(new Dimension(152, 20)); |
||||
lineColor = new NewColorSelectBox(137); |
||||
lineStyle.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
fireLineStateChanged(); |
||||
} |
||||
}); |
||||
lineColor.addSelectChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
fireLineStateChanged(); |
||||
} |
||||
}); |
||||
this.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{lineLabel, lineStyle}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM)); |
||||
this.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{colorLabel, lineColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM)); |
||||
} |
||||
|
||||
public LineDescription update() { |
||||
LineDescription lineDescription = new LineDescription(); |
||||
lineDescription.setColor(lineColor.getSelectObject()); |
||||
lineDescription.setLineStyle(lineStyle.getSelectedLineStyle()); |
||||
return lineDescription; |
||||
} |
||||
|
||||
public void populate(LineDescription lineDescription) { |
||||
lineStyle.setSelectedLineStyle(lineDescription.getLineStyle()); |
||||
lineColor.setSelectObject(lineDescription.getColor()); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 添加监听 |
||||
* |
||||
* @param changeListener 监听列表 |
||||
*/ |
||||
public void addLineChangeListener(ChangeListener changeListener) { |
||||
lineChangeListener.add(ChangeListener.class, changeListener); |
||||
} |
||||
|
||||
/** |
||||
* 移除监听 |
||||
* Removes an old ColorChangeListener. |
||||
* |
||||
* @param changeListener 监听列表 |
||||
*/ |
||||
public void removeLineChangeListener(ChangeListener changeListener) { |
||||
lineChangeListener.remove(ChangeListener.class, changeListener); |
||||
} |
||||
|
||||
/** |
||||
* 颜色状态改变 |
||||
*/ |
||||
public void fireLineStateChanged() { |
||||
Object[] listeners = lineChangeListener.getListenerList(); |
||||
ChangeEvent e = null; |
||||
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
||||
if (listeners[i] == ChangeListener.class) { |
||||
if (e == null) { |
||||
e = new ChangeEvent(this); |
||||
} |
||||
((ChangeListener) listeners[i + 1]).stateChanged(e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,233 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.dialog.AttrScrollPane; |
||||
import com.fr.design.dialog.BasicScrollPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.MobileTabFontConfPane; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; |
||||
import com.fr.design.style.color.NewColorSelectBox; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.form.ui.CardSwitchButton; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.TabFontConfig; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.border.TitledBorder; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
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.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<MobileTemplateStyle> { |
||||
private static final String[] TAB_STYLES = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom")}; |
||||
private UIComboBox custom; |
||||
protected NewColorSelectBox initialColorBox; |
||||
protected MobileTabFontConfPane fontConfPane; |
||||
private JPanel centerPane; |
||||
protected MobileTemplatePreviewPane previewPane; |
||||
private WCardTagLayout tagLayout; |
||||
|
||||
|
||||
public MobileTemplatePreviewPane getPreviewPane() { |
||||
return previewPane; |
||||
} |
||||
|
||||
public MobileTemplateStyleDefinePane(WCardTagLayout tagLayout) { |
||||
this.tagLayout = tagLayout; |
||||
init(); |
||||
} |
||||
|
||||
|
||||
public WCardTagLayout getTagLayout() { |
||||
return tagLayout; |
||||
} |
||||
|
||||
protected void init() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
previewPane = createPreviewPane(); |
||||
previewPane.setPreferredSize(new Dimension(500, 60)); |
||||
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null); |
||||
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 9, Color.BLUE)); |
||||
northPane.setBorder(titledBorder); |
||||
northPane.setPreferredSize(new Dimension(500, 83)); |
||||
northPane.add(previewPane, BorderLayout.CENTER); |
||||
this.add(northPane, BorderLayout.NORTH); |
||||
createConfigPane(); |
||||
|
||||
} |
||||
|
||||
protected void createConfigPane() { |
||||
JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); |
||||
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 9, Color.BLUE)); |
||||
configPane.setBorder(titledBorder); |
||||
centerPane = createCenterPane(); |
||||
custom = new UIComboBox(TAB_STYLES); |
||||
custom.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
boolean isCustom = custom.getSelectedIndex() == 1; |
||||
centerPane.setVisible(isCustom); |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
centerPane.setVisible(false); |
||||
custom.setPreferredSize(new Dimension(157, 20)); |
||||
final JPanel scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
BasicScrollPane basicScrollPane = new AttrScrollPane() { |
||||
@Override |
||||
protected JPanel createContentPane() { |
||||
return scrollPanel; |
||||
} |
||||
}; |
||||
configPane.add(basicScrollPane, BorderLayout.CENTER); |
||||
this.add(configPane, BorderLayout.CENTER); |
||||
|
||||
JPanel outPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); |
||||
outPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20)); |
||||
UILabel tabStyleLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Style")); |
||||
tabStyleLabel.setPreferredSize(new Dimension(55, 20)); |
||||
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tabStyleLabel, custom}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
jPanel.setPreferredSize(new Dimension(200, 20)); |
||||
outPanel.add(jPanel); |
||||
scrollPanel.add(outPanel, BorderLayout.NORTH); |
||||
|
||||
UITitleSplitLine backgroundSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 520); |
||||
backgroundSplit.setPreferredSize(new Dimension(520, 20)); |
||||
centerPane.add(backgroundSplit); |
||||
|
||||
centerPane.add(createBackgroundConfPane()); |
||||
|
||||
UITitleSplitLine fontSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Char"), 520); |
||||
fontSplit.setPreferredSize(new Dimension(520, 20)); |
||||
centerPane.add(fontSplit); |
||||
|
||||
centerPane.add(createFontConfPane()); |
||||
|
||||
createExtraConfPane(centerPane); |
||||
|
||||
scrollPanel.add(centerPane, BorderLayout.CENTER); |
||||
initDefaultConfig(); |
||||
} |
||||
|
||||
protected JPanel createCenterPane() { |
||||
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
||||
return panel; |
||||
} |
||||
|
||||
protected JPanel createBackgroundConfPane() { |
||||
initialColorBox = new NewColorSelectBox(137); |
||||
initialColorBox.addSelectChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
UILabel fillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill")); |
||||
fillLabel.setPreferredSize(new Dimension(55, 20)); |
||||
|
||||
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{fillLabel, initialColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
jPanel.setPreferredSize(new Dimension(240, 20)); |
||||
initialColorBox.setPreferredSize(new Dimension(157, 20)); |
||||
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); |
||||
return jPanel; |
||||
} |
||||
|
||||
protected JPanel createFontConfPane() { |
||||
fontConfPane = new MobileTabFontConfPane(); |
||||
fontConfPane.addFontChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
UILabel initCharLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Init_Char")); |
||||
initCharLabel.setPreferredSize(new Dimension(55, 20)); |
||||
JPanel jPanel3 = GUICoreUtils.createBoxFlowInnerContainerPane(5, 0); |
||||
jPanel3.add(initCharLabel); |
||||
jPanel3.add(fontConfPane); |
||||
jPanel3.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); |
||||
return jPanel3; |
||||
} |
||||
|
||||
|
||||
protected void createExtraConfPane(JPanel centerPane) { |
||||
|
||||
} |
||||
|
||||
protected abstract void initDefaultConfig(); |
||||
|
||||
protected abstract MobileTemplatePreviewPane createPreviewPane(); |
||||
|
||||
@Override |
||||
public void populateBean(MobileTemplateStyle ob) { |
||||
centerPane.setVisible(ob.isCustom()); |
||||
populateSubStyle(ob); |
||||
custom.setSelectedItem(!ob.isCustom() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default") : |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom")); |
||||
initialColorBox.setSelectObject(ob.getInitialColor()); |
||||
fontConfPane.populate(ob.getTabFontConfig().getFont()); |
||||
updatePreviewPane(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateBean() { |
||||
//保存之前需要先将cardSwitchBtn的icon设置清空
|
||||
for (int i = 0; i < getTagLayout().getWidgetCount(); i++) { |
||||
CardSwitchButton cardSwitchButton = (CardSwitchButton) getTagLayout().getWidget(i); |
||||
cardSwitchButton.setInitIconName(StringUtils.EMPTY); |
||||
cardSwitchButton.setSelectIconName(StringUtils.EMPTY); |
||||
} |
||||
return updateConfig(); |
||||
} |
||||
|
||||
public MobileTemplateStyle updateConfig(){ |
||||
if (custom.getSelectedIndex() == 0) { |
||||
return getDefaultTemplateStyle(); |
||||
} |
||||
MobileTemplateStyle ob = updateSubStyle(); |
||||
ob.setCustom(custom.getSelectedIndex() == 1); |
||||
ob.setInitialColor(initialColorBox.getSelectObject()); |
||||
TabFontConfig config = ob.getTabFontConfig(); |
||||
config.setFont(fontConfPane.update()); |
||||
return ob; |
||||
} |
||||
|
||||
protected abstract MobileTemplateStyle getDefaultTemplateStyle(); |
||||
|
||||
public void updatePreviewPane() { |
||||
previewPane.populateConfig(updateConfig()); |
||||
previewPane.setBackground(previewPane.getInitialColor()); |
||||
previewPane.repaint(); |
||||
} |
||||
|
||||
public abstract void populateSubStyle(MobileTemplateStyle ob); |
||||
|
||||
public abstract MobileTemplateStyle updateSubStyle(); |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,164 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; |
||||
import com.fr.design.style.color.NewColorSelectBox; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.SliderStyle; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
|
||||
public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane { |
||||
private NewColorSelectBox initDotColor; |
||||
private NewColorSelectBox selectDotColor; |
||||
|
||||
|
||||
public SliderStyleDefinePane(WCardTagLayout tagLayout) { |
||||
super(tagLayout); |
||||
} |
||||
|
||||
@Override |
||||
public void populateSubStyle(MobileTemplateStyle ob) { |
||||
SliderStyle sliderStyle = (SliderStyle) ob; |
||||
initDotColor.setSelectObject(sliderStyle.getInitDotColor()); |
||||
selectDotColor.setSelectObject(sliderStyle.getSelectDotColor()); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplateStyle getDefaultTemplateStyle() { |
||||
return new SliderStyle(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateSubStyle() { |
||||
SliderStyle sliderStyle = new SliderStyle(); |
||||
sliderStyle.setInitDotColor(initDotColor.getSelectObject()); |
||||
sliderStyle.setSelectDotColor(selectDotColor.getSelectObject()); |
||||
return sliderStyle; |
||||
} |
||||
|
||||
|
||||
protected void createExtraConfPane(JPanel centerPane) { |
||||
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); |
||||
UITitleSplitLine dotIndicator = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Slider_Dot_Indicator"), 520); |
||||
dotIndicator.setPreferredSize(new Dimension(520, 20)); |
||||
centerPane.add(dotIndicator); |
||||
initDotColor = new NewColorSelectBox(137); |
||||
initDotColor.addSelectChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
selectDotColor = new NewColorSelectBox(137); |
||||
selectDotColor.addSelectChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
UILabel initColor = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Init_Fill")); |
||||
|
||||
UILabel selectColor = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Fill")); |
||||
initColor.setPreferredSize(new Dimension(55, 20)); |
||||
selectColor.setPreferredSize(new Dimension(55, 20)); |
||||
JPanel initDotColorPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initColor, initDotColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
JPanel selectDotColorPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectColor, selectDotColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
initDotColorPane.setPreferredSize(new Dimension(240, 20)); |
||||
selectDotColorPane.setPreferredSize(new Dimension(240, 20)); |
||||
panel.add(initDotColorPane); |
||||
panel.add(selectDotColorPane); |
||||
centerPane.add(panel); |
||||
} |
||||
|
||||
@Override |
||||
protected void initDefaultConfig() { |
||||
this.initialColorBox.setSelectObject(SliderStyle.DEFAULT_INITIAL_COLOR); |
||||
this.fontConfPane.populate(SliderStyle.DEFAULT_TAB_FONT.getFont()); |
||||
initDotColor.setSelectObject(SliderStyle.DEFAULT_INITIAL_DOT_COLOR); |
||||
selectDotColor.setSelectObject(SliderStyle.DEFAULT_SELECT_DOT_COLOR); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplatePreviewPane createPreviewPane() { |
||||
return new SliderStylePreviewPane(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
|
||||
public class SliderStylePreviewPane extends MobileTemplatePreviewPane { |
||||
private static final int CIRCLE_SIZE = 6; |
||||
private static final int GAP = 4; |
||||
private static final int OFFSET_X = 10; |
||||
private Color initDotColor; |
||||
private Color selectDotColor; |
||||
|
||||
public SliderStylePreviewPane() { |
||||
|
||||
} |
||||
|
||||
public void repaint() { |
||||
super.repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Dimension dimension = this.getSize(); |
||||
int panelHeight = dimension.height; |
||||
Graphics2D g2d = (Graphics2D) g.create(); |
||||
FRFont frFont = this.getTabFontConfig().getFont(); |
||||
g2d.setFont(frFont); |
||||
g2d.setColor(frFont.getForeground()); |
||||
FontMetrics fm = GraphHelper.getFontMetrics(frFont); |
||||
int fontHeight = fm.getHeight(); |
||||
int ascent = fm.getAscent(); |
||||
g2d.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Slider_Title"), OFFSET_X, (panelHeight - fontHeight - GAP - CIRCLE_SIZE) / 2 + ascent); |
||||
WCardTagLayout cardTagLayout = SliderStyleDefinePane.this.getTagLayout(); |
||||
g2d.translate(OFFSET_X, (panelHeight + fontHeight + GAP - CIRCLE_SIZE) / 2); |
||||
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { |
||||
if (i == 0) { |
||||
g2d.setColor(selectDotColor); |
||||
g2d.fillOval(0, 0, CIRCLE_SIZE, CIRCLE_SIZE); |
||||
g2d.translate(CIRCLE_SIZE + GAP, 0); |
||||
continue; |
||||
} |
||||
g2d.setColor(initDotColor); |
||||
g2d.fillOval(0, 0, CIRCLE_SIZE, CIRCLE_SIZE); |
||||
g2d.translate(CIRCLE_SIZE + GAP, 0); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void populateConfig(MobileTemplateStyle templateStyle) { |
||||
super.populateConfig(templateStyle); |
||||
this.initDotColor = ((SliderStyle) templateStyle).getInitDotColor(); |
||||
this.selectDotColor = ((SliderStyle) templateStyle).getSelectDotColor(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,110 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.MobileTabFontConfPane; |
||||
import com.fr.design.style.color.NewColorSelectBox; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
|
||||
public abstract class StyleDefinePaneWithSelectConf extends MobileTemplateStyleDefinePane { |
||||
|
||||
protected NewColorSelectBox selectColorBox; |
||||
protected UIColorButton selectFontColor; |
||||
|
||||
public StyleDefinePaneWithSelectConf(WCardTagLayout tagLayout) { |
||||
super(tagLayout); |
||||
} |
||||
|
||||
protected JPanel createBackgroundConfPane() { |
||||
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); |
||||
initialColorBox = new NewColorSelectBox(137); |
||||
initialColorBox.addSelectChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
|
||||
selectColorBox = new NewColorSelectBox(137); |
||||
selectColorBox.addSelectChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
UILabel initFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Init_Fill")); |
||||
UILabel selectFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Fill")); |
||||
initFillLabel.setPreferredSize(new Dimension(55, 20)); |
||||
selectFillLabel.setPreferredSize(new Dimension(55, 20)); |
||||
JPanel jPanel2 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initFillLabel, initialColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
JPanel jPanel3 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectFillLabel, selectColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
jPanel2.setPreferredSize(new Dimension(240, 20)); |
||||
jPanel3.setPreferredSize(new Dimension(240, 20)); |
||||
panel.add(jPanel2); |
||||
panel.add(jPanel3); |
||||
return panel; |
||||
} |
||||
|
||||
protected JPanel createFontConfPane() { |
||||
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); |
||||
fontConfPane = new MobileTabFontConfPane(); |
||||
fontConfPane.addFontChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
selectFontColor = new UIColorButton(); |
||||
selectFontColor.addColorChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
|
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
UILabel initCharLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Init_Char")); |
||||
initCharLabel.setPreferredSize(new Dimension(55, 20)); |
||||
JPanel jPanel3 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initCharLabel, fontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
jPanel3.setPreferredSize(new Dimension(500, 20)); |
||||
|
||||
UILabel selectCharLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Select_Char")); |
||||
selectCharLabel.setPreferredSize(new Dimension(55, 20)); |
||||
selectFontColor.setPreferredSize(new Dimension(20, 20)); |
||||
JPanel jPanel4 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectCharLabel, selectFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
JPanel jPanel5 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
||||
jPanel5.setPreferredSize(new Dimension(500, 20)); |
||||
jPanel5.add(jPanel4); |
||||
panel.add(jPanel3); |
||||
panel.add(jPanel5); |
||||
return panel; |
||||
} |
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateSubStyle() { |
||||
MobileTemplateStyle mobileTemplateStyle = updateStyleWithSelectConf(); |
||||
mobileTemplateStyle.setSelectColor(selectColorBox.getSelectObject()); |
||||
mobileTemplateStyle.getTabFontConfig().setSelectColor(selectFontColor.getColor()); |
||||
return mobileTemplateStyle; |
||||
} |
||||
|
||||
protected abstract MobileTemplateStyle updateStyleWithSelectConf(); |
||||
|
||||
public void populateSubStyle(MobileTemplateStyle ob) { |
||||
selectColorBox.setSelectObject(ob.getSelectColor()); |
||||
selectFontColor.setColor(ob.getTabFontConfig().getSelectColor()); |
||||
} |
||||
} |
@ -0,0 +1,182 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.base.IconManager; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.utils.DrawRoutines; |
||||
import com.fr.design.web.CustomIconPane; |
||||
import com.fr.form.ui.WidgetInfoConfig; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.FRFont; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JToggleButton; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import javax.swing.plaf.basic.BasicButtonUI; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Cursor; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Font; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Image; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
|
||||
public class TabIconConfigPane extends JPanel { |
||||
private UIButton editIconButton; |
||||
private String curIconName; |
||||
private IconButton selectIconButton; |
||||
private ArrayList<IconButton> iconButtons = new ArrayList<IconButton>(); |
||||
|
||||
public TabIconConfigPane(int count) { |
||||
initComp(count); |
||||
} |
||||
|
||||
public void initComp(int count) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); |
||||
editIconButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); |
||||
editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); |
||||
editIconButton.setPreferredSize(new Dimension(62, 20)); |
||||
panel.add(editIconButton); |
||||
editIconButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
final CustomIconPane cip = new CustomIconPane(){ |
||||
protected String createDescriptionText(){ |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Custom_Icon_Message"); |
||||
} |
||||
}; |
||||
BasicDialog editDialog = cip.showWindow(DesignerContext.getDesignerFrame()); |
||||
editDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
curIconName = cip.update(); |
||||
setShowIconImage(); |
||||
TabIconConfigPane.this.repaint(); |
||||
} |
||||
}); |
||||
editDialog.setVisible(true); |
||||
} |
||||
}); |
||||
editIconButton.setEnabled(false); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
|
||||
JPanel northPane = new JPanel(); |
||||
northPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
||||
for (int i = 0; i < count; i++) { |
||||
IconButton iconButton = new IconButton(""); |
||||
northPane.add(iconButton); |
||||
iconButtons.add(iconButton); |
||||
} |
||||
this.add(northPane, BorderLayout.NORTH); |
||||
} |
||||
|
||||
public void setShowIconImage() { |
||||
selectIconButton.setIconName(curIconName); |
||||
} |
||||
|
||||
public void populate(ArrayList<String> iconArr) { |
||||
for (int i = 0; i < iconButtons.size(); i++) { |
||||
iconButtons.get(i).setIconName(iconArr.get(i)); |
||||
} |
||||
} |
||||
|
||||
public ArrayList<String> update() { |
||||
ArrayList<String> iconNames = new ArrayList<String>(); |
||||
for (int i = 0; i < iconButtons.size(); i++) { |
||||
iconNames.add(iconButtons.get(i).getIconName()); |
||||
} |
||||
return iconNames; |
||||
} |
||||
|
||||
|
||||
private class IconButton extends JToggleButton implements ActionListener { |
||||
private String iconName; |
||||
private Image iconImage = null; |
||||
private static final int ICON_BUTTON_SIZE = 20; |
||||
private static final int ICON_X = 2; |
||||
private static final int ICON_Y = 2; |
||||
|
||||
public IconButton(String name) { |
||||
this.iconName = name; |
||||
this.addActionListener(this); |
||||
this.setBackground(Color.WHITE); |
||||
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name); |
||||
} |
||||
|
||||
@Override |
||||
public void updateUI() { |
||||
setUI(new BasicButtonUI() { |
||||
public void paint(Graphics g, JComponent c) { |
||||
super.paint(g, c); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
protected void paintBorder(Graphics g) { |
||||
super.paintBorder(g); |
||||
if (ComparatorUtils.equals(this, selectIconButton)) { |
||||
DrawRoutines.drawRoundedBorder( |
||||
g, Color.decode("#419BF9"), 0, 0, 20, 20); |
||||
} else { |
||||
DrawRoutines.drawRoundedBorder( |
||||
g, Color.decode("#D9DADD"), 0, 0, 20, 20); |
||||
} |
||||
|
||||
} |
||||
|
||||
public String getIconName() { |
||||
return iconName; |
||||
} |
||||
|
||||
public void setIconName(String iconName) { |
||||
this.iconName = iconName; |
||||
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName); |
||||
} |
||||
|
||||
@Override |
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
// carl:这里缩放显示 16 × 16
|
||||
if (iconImage != null) { |
||||
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent evt) { |
||||
selectIconButton = this; |
||||
editIconButton.setEnabled(true); |
||||
TabIconConfigPane.this.repaint();// repaint
|
||||
} |
||||
|
||||
@Override |
||||
public void addChangeListener(ChangeListener changeListener) { |
||||
this.changeListener = changeListener; |
||||
} |
||||
|
||||
private void fireChagneListener() { |
||||
if (this.changeListener != null) { |
||||
ChangeEvent evt = new ChangeEvent(this); |
||||
this.changeListener.stateChanged(evt); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.DownMenuStyle; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.SliderStyle; |
||||
import com.fr.general.cardtag.mobile.UpMenuStyle; |
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class TemplateStyleDefinePaneFactory { |
||||
private static Map<String, StyleDefinePaneUI> defineMap = new HashMap<String, StyleDefinePaneUI>(); |
||||
|
||||
static { |
||||
defineMap.put(DefaultMobileTemplateStyle.STYLE_NAME, new StyleDefinePaneUI(DefaultMobileStyleDefinePane.class)); |
||||
defineMap.put(UpMenuStyle.STYLE_NAME, new StyleDefinePaneUI(UpMenuStyleDefinePane.class)); |
||||
defineMap.put(DownMenuStyle.STYLE_NAME, new StyleDefinePaneUI(DownMenuStyleDefinePane.class)); |
||||
defineMap.put(SliderStyle.STYLE_NAME, new StyleDefinePaneUI(SliderStyleDefinePane.class)); |
||||
} |
||||
|
||||
public static BasicBeanPane<MobileTemplateStyle> createDefinePane(String style, WCardTagLayout tagLayout) { |
||||
StyleDefinePaneUI styleDefinePaneUI = defineMap.get(style); |
||||
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = styleDefinePaneUI.getaClass(); |
||||
if (clazz == null) { |
||||
} |
||||
BasicBeanPane<MobileTemplateStyle> quickPane = null; |
||||
try { |
||||
quickPane = Reflect.on(clazz).create(tagLayout).get(); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return quickPane; |
||||
} |
||||
|
||||
private static class StyleDefinePaneUI { |
||||
private Class<? extends BasicBeanPane<MobileTemplateStyle>> aClass; |
||||
|
||||
public StyleDefinePaneUI(Class<? extends BasicBeanPane<MobileTemplateStyle>> aClass) { |
||||
this.aClass = aClass; |
||||
} |
||||
|
||||
public Class<? extends BasicBeanPane<MobileTemplateStyle>> getaClass() { |
||||
return aClass; |
||||
} |
||||
|
||||
public void setaClass(Class<? extends BasicBeanPane<MobileTemplateStyle>> aClass) { |
||||
this.aClass = aClass; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,219 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.UITitleSplitLine; |
||||
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; |
||||
import com.fr.form.ui.CardSwitchButton; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.FRFont; |
||||
import com.fr.general.cardtag.mobile.LineDescription; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.UpMenuStyle; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.ButtonGroup; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Stroke; |
||||
|
||||
public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { |
||||
private UIRadioButton gapFix; |
||||
private UIRadioButton titleWidthFix; |
||||
private LinePane bottomBorderPane; |
||||
private LinePane underLinePane; |
||||
|
||||
public UpMenuStyleDefinePane(WCardTagLayout tagLayout) { |
||||
super(tagLayout); |
||||
} |
||||
|
||||
protected JPanel createCenterPane() { |
||||
JPanel panel = super.createCenterPane(); |
||||
UILabel displayGap = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Display_Gap")); |
||||
displayGap.setPreferredSize(new Dimension(55, 20)); |
||||
gapFix = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Gap_Fix")); |
||||
titleWidthFix = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Title_Width_Fix")); |
||||
ButtonGroup buttonGroup = new ButtonGroup(); |
||||
titleWidthFix.setSelected(true); |
||||
buttonGroup.add(gapFix); |
||||
gapFix.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
titleWidthFix.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
buttonGroup.add(titleWidthFix); |
||||
gapFix.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
titleWidthFix.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
|
||||
|
||||
JPanel flowLeft = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); |
||||
flowLeft.add(gapFix); |
||||
flowLeft.add(titleWidthFix); |
||||
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{displayGap, flowLeft}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); |
||||
centerPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 15, 20)); |
||||
centerPane.setPreferredSize(new Dimension(500, 20)); |
||||
JPanel outerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
outerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 15, 0)); |
||||
outerPane.add(centerPane, BorderLayout.CENTER); |
||||
panel.add(outerPane); |
||||
return panel; |
||||
} |
||||
|
||||
protected void createExtraConfPane(JPanel centerPane) { |
||||
bottomBorderPane = new LinePane(); |
||||
underLinePane = new LinePane(); |
||||
bottomBorderPane.addLineChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
underLinePane.addLineChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
updatePreviewPane(); |
||||
} |
||||
}); |
||||
UITitleSplitLine titleSplitLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Bottom_Border"), 520); |
||||
titleSplitLine.setPreferredSize(new Dimension(520, 20)); |
||||
centerPane.add(titleSplitLine); |
||||
centerPane.add(bottomBorderPane); |
||||
UITitleSplitLine titleUnderLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Under_Line"), 520); |
||||
titleUnderLine.setPreferredSize(new Dimension(520, 20)); |
||||
centerPane.add(titleUnderLine); |
||||
centerPane.add(underLinePane); |
||||
} |
||||
|
||||
@Override |
||||
protected void initDefaultConfig() { |
||||
this.initialColorBox.setSelectObject(UpMenuStyle.DEFAULT_INITIAL_COLOR); |
||||
this.fontConfPane.populate(UpMenuStyle.DEFAULT_TAB_FONT.getFont()); |
||||
this.selectColorBox.setSelectObject(UpMenuStyle.DEFAULT_SELECT_COLOR); |
||||
this.selectFontColor.setColor(UpMenuStyle.DEFAULT_SELECT_FONT_COLOR); |
||||
this.bottomBorderPane.populate(UpMenuStyle.DEFAULT_BOTTOM_BORDER); |
||||
this.underLinePane.populate(UpMenuStyle.DEFAULT_UNDER_LINE); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplatePreviewPane createPreviewPane() { |
||||
return new UpMenuStylePreviewPane(); |
||||
} |
||||
|
||||
@Override |
||||
public void populateSubStyle(MobileTemplateStyle ob) { |
||||
super.populateSubStyle(ob); |
||||
UpMenuStyle style = (UpMenuStyle) ob; |
||||
gapFix.setSelected(style.isGapFix()); |
||||
titleWidthFix.setSelected(style.isTitleWidthFix()); |
||||
bottomBorderPane.populate(style.getBottomBorder()); |
||||
underLinePane.populate(style.getUnderline()); |
||||
} |
||||
|
||||
@Override |
||||
protected MobileTemplateStyle getDefaultTemplateStyle() { |
||||
return new UpMenuStyle(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public MobileTemplateStyle updateStyleWithSelectConf() { |
||||
UpMenuStyle style = new UpMenuStyle(); |
||||
style.setGapFix(gapFix.isSelected()); |
||||
style.setTitleWidthFix(titleWidthFix.isSelected()); |
||||
style.setBottomBorder(bottomBorderPane.update()); |
||||
style.setUnderline(underLinePane.update()); |
||||
return style; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
|
||||
public class UpMenuStylePreviewPane extends MobileTemplatePreviewPane { |
||||
private LineDescription bottomBorder; |
||||
private LineDescription underLine; |
||||
private boolean isGapFix; |
||||
|
||||
public UpMenuStylePreviewPane() { |
||||
this.setBackground(Color.WHITE); |
||||
} |
||||
|
||||
public void repaint() { |
||||
super.repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Color selectFontColor = this.getTabFontConfig().getSelectColor(); |
||||
Dimension dimension = this.getSize(); |
||||
int panelWidth = dimension.width; |
||||
int panelHeight = dimension.height; |
||||
Graphics2D g2d = (Graphics2D) g.create(); |
||||
FRFont frFont = UpMenuStyleDefinePane.this.fontConfPane.update(); |
||||
FontMetrics fm = GraphHelper.getFontMetrics(frFont); |
||||
WCardTagLayout cardTagLayout = UpMenuStyleDefinePane.this.getTagLayout(); |
||||
int eachWidth = panelWidth / cardTagLayout.getWidgetCount(); |
||||
g2d.setFont(frFont); |
||||
int fontHeight = fm.getHeight(); |
||||
int ascentHeight = fm.getAscent(); |
||||
if (bottomBorder.getLineStyle() != 0) { |
||||
g2d.setColor(bottomBorder.getColor()); |
||||
g2d.setStroke(GraphHelper.getStroke(bottomBorder.getLineStyle())); |
||||
g2d.drawLine(0, panelHeight - 1, panelWidth, panelHeight - 1); |
||||
} |
||||
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) { |
||||
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground()); |
||||
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i); |
||||
String widgetName = cardSwitchButton.getText(); |
||||
int width = fm.stringWidth(widgetName); |
||||
if(i == 0){ |
||||
Color oldColor = g2d.getColor(); |
||||
g2d.setColor(this.getSelectColor()); |
||||
g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2); |
||||
g2d.setColor(oldColor); |
||||
} |
||||
g2d.drawString(widgetName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight); |
||||
Stroke oldStroke = g2d.getStroke(); |
||||
if (i == 0) { |
||||
g2d.setColor(this.underLine.getColor()); |
||||
g2d.setStroke(GraphHelper.getStroke(underLine.getLineStyle())); |
||||
int underLineX = this.isGapFix ? (eachWidth - width) / 2 : 0; |
||||
int underLineWidth = this.isGapFix ? width : eachWidth; |
||||
g2d.drawLine(underLineX, panelHeight - 2, underLineX + underLineWidth, panelHeight - 2); |
||||
} |
||||
g2d.setStroke(oldStroke); |
||||
g2d.translate(eachWidth, 0); |
||||
} |
||||
} |
||||
|
||||
public void populateConfig(MobileTemplateStyle templateStyle) { |
||||
super.populateConfig(templateStyle); |
||||
this.bottomBorder = ((UpMenuStyle) templateStyle).getBottomBorder(); |
||||
this.underLine = ((UpMenuStyle) templateStyle).getUnderline(); |
||||
this.isGapFix = ((UpMenuStyle) templateStyle).isGapFix(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,144 @@
|
||||
package com.fr.design.mainframe.widget; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Utils; |
||||
import com.fr.design.gui.ibutton.UIColorButton; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.general.FRFont; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import javax.swing.event.EventListenerList; |
||||
import java.awt.Dimension; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.Font; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.Vector; |
||||
|
||||
public class MobileTabFontConfPane extends JPanel { |
||||
private static final Icon[] ITALIC_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")}; |
||||
private static final Icon[] BOLD_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")}; |
||||
|
||||
private EventListenerList fontChangeListener = new EventListenerList(); |
||||
private UIComboBox fontFamily; |
||||
private UIComboBox fontSize; |
||||
private UIToggleButton bold; |
||||
private UIColorButton color; |
||||
private UIToggleButton italic; |
||||
|
||||
|
||||
public MobileTabFontConfPane() { |
||||
super(); |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
||||
fontFamily = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); |
||||
Vector<Integer> integerList = new Vector<Integer>(); |
||||
for (int i = 1; i < 100; i++) { |
||||
integerList.add(i); |
||||
} |
||||
fontFamily.setPreferredSize(new Dimension(152, 20)); |
||||
fontSize = new UIComboBox(integerList); |
||||
color = new UIColorButton(); |
||||
bold = new UIToggleButton(BOLD_ICONS, true); |
||||
italic = new UIToggleButton(ITALIC_ICONS, true); |
||||
fontFamily.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
fireFontStateChanged(); |
||||
} |
||||
}); |
||||
fontSize.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
fireFontStateChanged(); |
||||
} |
||||
}); |
||||
bold.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
fireFontStateChanged(); |
||||
} |
||||
}); |
||||
italic.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
fireFontStateChanged(); |
||||
} |
||||
}); |
||||
color.addColorChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
fireFontStateChanged(); |
||||
} |
||||
}); |
||||
this.add(fontFamily); |
||||
this.add(fontSize); |
||||
this.add(color); |
||||
this.add(bold); |
||||
this.add(italic); |
||||
|
||||
} |
||||
|
||||
public FRFont update() { |
||||
String family = (String) fontFamily.getSelectedItem(); |
||||
int size = (int) fontSize.getSelectedItem(); |
||||
int style = Font.PLAIN; |
||||
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; |
||||
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; |
||||
FRFont frFont = FRFont.getInstance(family, style, size, color.getColor()); |
||||
return frFont; |
||||
} |
||||
|
||||
public void populate(FRFont frFont) { |
||||
fontFamily.setSelectedItem(frFont.getFamily()); |
||||
fontSize.setSelectedItem(frFont.getSize()); |
||||
color.setColor(frFont.getForeground()); |
||||
bold.setSelected(frFont.isBold()); |
||||
italic.setSelected(frFont.isItalic()); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 添加监听 |
||||
* |
||||
* @param changeListener 监听列表 |
||||
*/ |
||||
public void addFontChangeListener(ChangeListener changeListener) { |
||||
fontChangeListener.add(ChangeListener.class, changeListener); |
||||
} |
||||
|
||||
/** |
||||
* 移除监听 |
||||
* Removes an old ColorChangeListener. |
||||
* |
||||
* @param changeListener 监听列表 |
||||
*/ |
||||
public void removeFontChangeListener(ChangeListener changeListener) { |
||||
fontChangeListener.remove(ChangeListener.class, changeListener); |
||||
} |
||||
|
||||
/** |
||||
* 颜色状态改变 |
||||
*/ |
||||
public void fireFontStateChanged() { |
||||
Object[] listeners = fontChangeListener.getListenerList(); |
||||
ChangeEvent e = null; |
||||
|
||||
for (int i = listeners.length - 2; i >= 0; i -= 2) { |
||||
if (listeners[i] == ChangeListener.class) { |
||||
if (e == null) { |
||||
e = new ChangeEvent(this); |
||||
} |
||||
((ChangeListener) listeners[i + 1]).stateChanged(e); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.mainframe.widget; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.general.FRFont; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
|
||||
public class UITitleSplitLine extends JPanel { |
||||
private static final Color LINE_COLOR = Color.decode("#E0E0E1"); |
||||
private static final Color TITLE_COLOR = Color.decode("#333334"); |
||||
private static final FRFont TITLE_FONT = FRFont.getInstance("PingFangSC-Regular", 0, 12.0F); |
||||
private static final int OFFSETX = 10; |
||||
private static final int OFFSET = 3; |
||||
private Color color; |
||||
private UILabel label; |
||||
private int width; |
||||
|
||||
|
||||
|
||||
public UITitleSplitLine(String title, int width) { |
||||
this(title, LINE_COLOR, width); |
||||
} |
||||
|
||||
public UITitleSplitLine(String title, Color color, int width) { |
||||
super(); |
||||
this.color = color; |
||||
this.width = width; |
||||
this.label = new UILabel(title); |
||||
} |
||||
|
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Dimension size = label.getPreferredSize(); |
||||
int labelH = size.height; |
||||
g.setColor(color); |
||||
g.drawLine(0, labelH / 2, OFFSETX, labelH / 2); |
||||
g.drawLine(OFFSETX + size.width + OFFSET * 2, labelH / 2, width, labelH / 2); |
||||
g.translate(OFFSETX + OFFSET, 0); |
||||
label.setFont(TITLE_FONT); |
||||
label.setForeground(TITLE_COLOR); |
||||
label.setSize(size.width, size.height); |
||||
label.paint(g); |
||||
g.translate(-OFFSETX - OFFSET, 0); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.design.mainframe.widget.accessibles; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
|
||||
public abstract class AbstractTemplateStylePane<T> extends BasicPane { |
||||
|
||||
public abstract void populate(T ob); |
||||
|
||||
public abstract T update(); |
||||
} |
@ -0,0 +1,112 @@
|
||||
package com.fr.design.mainframe.widget.accessibles; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyleType; |
||||
import javax.swing.DefaultListCellRenderer; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.ListCellRenderer; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTemplateStyle> { |
||||
private static final List<MobileTemplateStyleType> STYLE_LIST = new ArrayList<MobileTemplateStyleType>(); |
||||
static { |
||||
STYLE_LIST.add(MobileTemplateStyleType.DEFAULT_STYLE); |
||||
STYLE_LIST.add(MobileTemplateStyleType.UP_MENU_STYLE); |
||||
STYLE_LIST.add(MobileTemplateStyleType.DOWN_MENU_STYLE); |
||||
STYLE_LIST.add(MobileTemplateStyleType.SLIDER_STYLE); |
||||
} |
||||
|
||||
private DefaultListModel listModel; |
||||
private JList styleList; |
||||
private Map<String, BasicBeanPane<MobileTemplateStyle>> map = new HashMap<>(); |
||||
private JPanel right; |
||||
private CardLayout card; |
||||
public MobileTemplateStylePane(WCardTagLayout tagLayout){ |
||||
init(tagLayout); |
||||
} |
||||
|
||||
public void init(WCardTagLayout tagLayout){ |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
listModel = new DefaultListModel(); |
||||
card = new CardLayout(); |
||||
right = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
right.setLayout(card); |
||||
for(MobileTemplateStyleType style : STYLE_LIST){ |
||||
listModel.addElement(style.getDisplayName()); |
||||
BasicBeanPane<MobileTemplateStyle> styleBasicBeanPane = TemplateStyleDefinePaneFactory.createDefinePane(style.getStyle(), tagLayout); |
||||
map.put(style.getDisplayName(), styleBasicBeanPane); |
||||
right.add(style.getDisplayName(), styleBasicBeanPane); |
||||
} |
||||
styleList = new JList(listModel); |
||||
styleList.setCellRenderer(render); |
||||
|
||||
JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
westPane.add(styleList, BorderLayout.CENTER); |
||||
westPane.setPreferredSize(new Dimension(100, 500)); |
||||
|
||||
|
||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
JPanel attrConfPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
centerPane.setPreferredSize(new Dimension(500, 500)); |
||||
attrConfPane.add(right, BorderLayout.CENTER); |
||||
centerPane.add(attrConfPane, BorderLayout.CENTER); |
||||
styleList.addMouseListener(new MouseAdapter() { |
||||
public void mouseClicked(MouseEvent e) { |
||||
String selectedValue = (String)styleList.getSelectedValue(); |
||||
card.show(right, selectedValue); |
||||
} |
||||
}); |
||||
this.add(westPane, BorderLayout.WEST); |
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
} |
||||
public static ListCellRenderer render = new DefaultListCellRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
|
||||
if (value instanceof MobileTemplateStyle) { |
||||
MobileTemplateStyle l = (MobileTemplateStyle) value; |
||||
this.setText(l.toString()); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template"); |
||||
} |
||||
|
||||
public void populate(MobileTemplateStyle templateStyle) { |
||||
for(int i = 0; i< listModel.getSize(); i++){ |
||||
String style = templateStyle.getStyle(); |
||||
MobileTemplateStyleType templateStyleType = MobileTemplateStyleType.parse(style); |
||||
if((listModel.getElementAt(i)).equals(templateStyleType.getDisplayName())){ |
||||
styleList.setSelectedIndex(i); |
||||
map.get(templateStyle.toString()).populateBean(templateStyle); |
||||
card.show(right, templateStyle.toString()); |
||||
return; |
||||
} |
||||
} |
||||
styleList.setSelectedIndex(0); |
||||
} |
||||
|
||||
public MobileTemplateStyle update() { |
||||
return map.get(styleList.getSelectedValue()).updateBean(); |
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
package com.fr.design.mainframe.widget.preview; |
||||
|
||||
import com.fr.general.cardtag.mobile.MobileTemplateStyle; |
||||
import com.fr.general.cardtag.mobile.TabFontConfig; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Color; |
||||
|
||||
public abstract class MobileTemplatePreviewPane extends JPanel { |
||||
private Color initialColor; |
||||
private Color selectColor; |
||||
private TabFontConfig tabFontConfig = new TabFontConfig(); |
||||
|
||||
public Color getInitialColor() { |
||||
return initialColor; |
||||
} |
||||
|
||||
public void setInitialColor(Color initialColor) { |
||||
this.initialColor = initialColor; |
||||
} |
||||
|
||||
public Color getSelectColor() { |
||||
return selectColor; |
||||
} |
||||
|
||||
public void setSelectColor(Color selectColor) { |
||||
this.selectColor = selectColor; |
||||
} |
||||
|
||||
public TabFontConfig getTabFontConfig() { |
||||
return tabFontConfig; |
||||
} |
||||
|
||||
public void setTabFontConfig(TabFontConfig tabFontConfig) { |
||||
this.tabFontConfig = tabFontConfig; |
||||
} |
||||
|
||||
public MobileTemplatePreviewPane(){ |
||||
|
||||
} |
||||
|
||||
public void populateConfig(MobileTemplateStyle templateStyle){ |
||||
this.setInitialColor(templateStyle.getInitialColor()); |
||||
this.setBackground(templateStyle.getInitialColor()); |
||||
this.setSelectColor(templateStyle.getSelectColor()); |
||||
this.setTabFontConfig(templateStyle.getTabFontConfig()); |
||||
} |
||||
|
||||
public void repaint (){ |
||||
super.repaint(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.fr.design.report; |
||||
|
||||
import com.fr.base.iofile.attr.WatermarkAttr; |
||||
import com.fr.design.dialog.AbstractTemplateServerSettingPane; |
||||
import com.fr.report.core.ReportUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* Created by plough on 2018/11/7. |
||||
*/ |
||||
public class WatermarkSettingPane extends AbstractTemplateServerSettingPane { |
||||
private WatermarkPane watermarkPane; |
||||
|
||||
public WatermarkSettingPane() { |
||||
super(); |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 8, 0, 0)); |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel getContentPane() { |
||||
if (watermarkPane == null) { |
||||
watermarkPane = new WatermarkPane(); |
||||
} |
||||
return watermarkPane; |
||||
} |
||||
|
||||
@Override |
||||
protected void populateServerSettings() { |
||||
WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromServerConfig(); |
||||
watermarkPane.populate(watermarkAttr); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark"); |
||||
} |
||||
|
||||
public void populate(WatermarkAttr watermark) { |
||||
if (!watermark.isValid()) { |
||||
chooseComboBox.setSelectedIndex(SERVER_SET); |
||||
populateServerSettings(); |
||||
return; |
||||
} |
||||
chooseComboBox.setSelectedIndex(SINGLE_SET); |
||||
watermarkPane.populate(watermark); |
||||
} |
||||
|
||||
|
||||
public WatermarkAttr update() { |
||||
WatermarkAttr watermark = watermarkPane.update(); |
||||
if (isUsingServerSettings()) { |
||||
watermark.setValid(false); |
||||
} |
||||
return watermark; |
||||
} |
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.fr.design.report.fit; |
||||
|
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/4/13/0013. |
||||
*/ |
||||
public enum FitType { |
||||
DEFAULT(0) { |
||||
@Override |
||||
public String description() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Default"); |
||||
} |
||||
|
||||
}, |
||||
// 横向自适应, 纵向根据横向的比例来适配
|
||||
HORIZONTAL_FIT(1) { |
||||
@Override |
||||
public String description() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Horizontal"); |
||||
} |
||||
}, |
||||
// 双向自适应, 横纵向都是根据页面宽高来计算
|
||||
DOUBLE_FIT(2) { |
||||
@Override |
||||
public String description() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Horizontal_Vertical"); |
||||
} |
||||
}, |
||||
|
||||
NOT_FIT(3) { |
||||
@Override |
||||
public String description() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No"); |
||||
} |
||||
}; |
||||
|
||||
|
||||
private int state; |
||||
|
||||
|
||||
FitType(int state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public static FitType parse(ReportFitAttr attr) { |
||||
|
||||
if (attr == null) { |
||||
return DEFAULT; |
||||
} |
||||
|
||||
for (FitType attrState : values()) { |
||||
if (attrState.state == attr.fitStateInPC()) { |
||||
return attrState; |
||||
} |
||||
} |
||||
|
||||
return DEFAULT; |
||||
} |
||||
|
||||
public int getState() { |
||||
return this.state; |
||||
} |
||||
|
||||
|
||||
public String description() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
public Item propertyItem() { |
||||
return new Item(this.description(), this.getState()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,240 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.config.Configuration; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.report.fit.FitType; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
import com.fr.report.fit.ReportFitConfig; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.Worker; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.ButtonGroup; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Cursor; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/5/0005. |
||||
*/ |
||||
public class BrowserFitAttrPane extends BasicBeanPane<ReportFitAttr> { |
||||
|
||||
protected FontRadioGroup fontRadioGroup; |
||||
protected FitRadioGroup fitRadionGroup; |
||||
protected UICheckBox globalCheck; |
||||
protected FitPreviewPane fitPreviewPane; |
||||
protected ReportFitAttr localFitAttr; |
||||
protected UIRadioButton defaultRadio; |
||||
protected UIRadioButton horizonRadio; |
||||
protected UIRadioButton doubleRadio; |
||||
protected UIRadioButton notFitRadio; |
||||
protected UIRadioButton fontFitRadio; |
||||
protected UIRadioButton fontNotFitRadio; |
||||
private UIButton editGlobalOps; |
||||
private JPanel borderPane; |
||||
private JPanel globalOpsPane; |
||||
private JPanel fitOpsPane; |
||||
|
||||
public BrowserFitAttrPane() { |
||||
initComponents(ReportFitConfig.getInstance().getFrmFitAttr()); |
||||
} |
||||
|
||||
protected void initComponents(ReportFitAttr globalFitAttr) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
globalOpsPane = initGlobalOpsPane(globalFitAttr); |
||||
this.add(globalOpsPane, BorderLayout.NORTH); |
||||
fitOpsPane = initFitOpsPane(); |
||||
|
||||
} |
||||
|
||||
protected void initBorderPane(String title) { |
||||
borderPane = FRGUIPaneFactory.createTitledBorderPaneCenter(title); |
||||
borderPane.add(fitOpsPane, BorderLayout.CENTER); |
||||
fitPreviewPane = new FitPreviewPane(); |
||||
borderPane.add(fitPreviewPane, BorderLayout.SOUTH); |
||||
this.add(borderPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private JPanel initFitOpsPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p}; |
||||
double[] columnSize = {p, p, p, p, p}; |
||||
|
||||
ActionListener actionListener = getPreviewActionListener(); |
||||
|
||||
fontRadioGroup = new FontRadioGroup(); |
||||
fontFitRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit")); |
||||
fontFitRadio.setSelected(true); |
||||
fontNotFitRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No")); |
||||
addRadioToGroup(fontRadioGroup, fontFitRadio, fontNotFitRadio); |
||||
fontRadioGroup.addActionListener(actionListener); |
||||
|
||||
fitRadionGroup = new FitRadioGroup(); |
||||
defaultRadio = new UIRadioButton(FitType.DEFAULT.description()); |
||||
horizonRadio = new UIRadioButton(FitType.HORIZONTAL_FIT.description()); |
||||
doubleRadio = new UIRadioButton(FitType.DOUBLE_FIT.description()); |
||||
notFitRadio = new UIRadioButton(FitType.NOT_FIT.description()); |
||||
addRadioToGroup(fitRadionGroup, defaultRadio, horizonRadio, doubleRadio, notFitRadio); |
||||
fitRadionGroup.addActionListener(actionListener); |
||||
|
||||
|
||||
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(initFitComponents(), rowSize, columnSize); |
||||
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); |
||||
return fitOpsPane; |
||||
} |
||||
|
||||
protected Component[][] initFitComponents() { |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Font")), fontFitRadio, null, fontNotFitRadio}, |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Element")), defaultRadio, horizonRadio, doubleRadio, notFitRadio} |
||||
}; |
||||
return components; |
||||
} |
||||
|
||||
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) { |
||||
for (UIRadioButton radio : radios) { |
||||
buttonGroup.add(radio); |
||||
} |
||||
} |
||||
|
||||
private JPanel initGlobalOpsPane(final ReportFitAttr globalFitAttr) { |
||||
final JPanel globalOpsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); |
||||
globalCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-UseGlobal")); |
||||
globalOpsPane.add(globalCheck); |
||||
globalCheck.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
boolean isLocalConfig = !globalCheck.isSelected(); |
||||
//勾选全局时,采用全局保存的自适应属性更新界面
|
||||
if (!isLocalConfig) { |
||||
ReportFitAttr attr = globalFitAttr; |
||||
fontRadioGroup.selectFontFit(((ReportFitAttr) attr).isFitFont()); |
||||
fitRadionGroup.selectIndexButton(attr.fitStateInPC()); |
||||
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); |
||||
remove(BrowserFitAttrPane.this.borderPane); |
||||
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Global")); |
||||
} else { |
||||
ReportFitAttr attr = localFitAttr; |
||||
fontRadioGroup.selectFontFit(((ReportFitAttr) attr).isFitFont()); |
||||
fitRadionGroup.selectIndexButton(attr.fitStateInPC()); |
||||
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); |
||||
remove(BrowserFitAttrPane.this.borderPane); |
||||
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); |
||||
} |
||||
fontRadioGroup.setEnabled(isLocalConfig); |
||||
fitRadionGroup.setEnabled(isLocalConfig); |
||||
editGlobalOps.setVisible(!isLocalConfig); |
||||
String fitOptions = getCurrentFitOptions(); |
||||
fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled()); |
||||
} |
||||
}); |
||||
|
||||
editGlobalOps = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-EditGlobal")); |
||||
editGlobalOps.setVisible(false); |
||||
editGlobalOps.addMouseListener(new MouseAdapter() { |
||||
public void mouseClicked(MouseEvent evt) { |
||||
fontRadioGroup.setEnabled(true); |
||||
fitRadionGroup.setEnabled(true); |
||||
String fitOptions = getCurrentFitOptions(); |
||||
|
||||
fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled()); |
||||
} |
||||
|
||||
public void mouseEntered(MouseEvent e) { |
||||
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
||||
} |
||||
|
||||
public void mouseExited(MouseEvent e) { |
||||
setCursor(Cursor.getDefaultCursor()); |
||||
} |
||||
}); |
||||
globalOpsPane.add(editGlobalOps); |
||||
return globalOpsPane; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-AttrSet"); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ReportFitAttr attr) { |
||||
if (attr == null) { |
||||
//如果为空, 就用全局的
|
||||
attr = ReportFitConfig.getInstance().getFrmFitAttr(); |
||||
populateGlobalComponents(); |
||||
} else { |
||||
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); |
||||
} |
||||
this.localFitAttr = attr; |
||||
fontRadioGroup.selectFontFit((attr).isFitFont()); |
||||
fitRadionGroup.selectIndexButton(attr.fitStateInPC()); |
||||
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); |
||||
} |
||||
|
||||
protected void populateGlobalComponents() { |
||||
globalCheck.setSelected(true); |
||||
fontRadioGroup.setEnabled(false); |
||||
fitRadionGroup.setEnabled(false); |
||||
editGlobalOps.setVisible(true); |
||||
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Global")); |
||||
} |
||||
|
||||
//有八种组合, 不过有意义的就是6种, 以此为key去缓存里找对应的预览图片
|
||||
public String getCurrentFitOptions() { |
||||
return fitRadionGroup.getSelectRadioIndex() + "" + fontRadioGroup.getSelectRadioIndex(); |
||||
} |
||||
|
||||
private ActionListener getPreviewActionListener() { |
||||
return new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
String fitOptions = getCurrentFitOptions(); |
||||
fitPreviewPane.refreshPreview(fitOptions, fontRadioGroup.isEnabled()); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public ReportFitAttr updateBean() { |
||||
ReportFitAttr attr = new ReportFitAttr(); |
||||
attr.setFitFont(fontRadioGroup.isFontFit()); |
||||
attr.setFitStateInPC(fitRadionGroup.getSelectRadioIndex()); |
||||
|
||||
// 直接用全局的
|
||||
if (globalCheck.isSelected()) { |
||||
updateGlobalConfig(attr); |
||||
return null; |
||||
} |
||||
this.localFitAttr = attr; |
||||
return attr; |
||||
} |
||||
|
||||
private void updateGlobalConfig(final ReportFitAttr attr) { |
||||
|
||||
Configurations.update(new Worker() { |
||||
@Override |
||||
public void run() { |
||||
ReportFitConfig manager = ReportFitConfig.getInstance(); |
||||
manager.setFrmFitAttr(attr); |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Configuration>[] targets() { |
||||
return new Class[]{ReportFitConfig.class}; |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/5/0005. |
||||
*/ |
||||
public class FitPreviewPane extends BasicPane { |
||||
private static final String DEFAULT_FONT_TAG = "00"; |
||||
private static final String DEFAULT_TAG = "01"; |
||||
private static final String HORIZON_FONT_TAG = "10"; |
||||
private static final String HORIZON_TAG = "11"; |
||||
private static final String DOUBLE_FONT_TAG = "20"; |
||||
private static final String DOUBLE_TAG = "21"; |
||||
private static final String NOT_FONT_TAG = "30"; |
||||
private static final String NOT_TAG = "31"; |
||||
|
||||
private UILabel imageLabel; |
||||
private Map<String, ImageIcon> cachedPreviewImage = new HashMap<String, ImageIcon>(); |
||||
private Map<String, ImageIcon> globalCachedPreviewImage = new HashMap<String, ImageIcon>(); |
||||
|
||||
public FitPreviewPane() { |
||||
//初始化缓存图片, 有些无意义的组合.
|
||||
initCacheImage(); |
||||
//初始化组件
|
||||
initComponents(); |
||||
} |
||||
|
||||
//默认和不自适应时,字体自适应不起效,只有6张图
|
||||
private void initCacheImage() { |
||||
globalCachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DEFAULT_FONT_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DEFAULT_FONT_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_FONT_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_FONT_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(NOT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png"))); |
||||
globalCachedPreviewImage.put(NOT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png"))); |
||||
cachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DEFAULT_FONT_TAG + ".png"))); |
||||
cachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DEFAULT_FONT_TAG + ".png"))); |
||||
cachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_FONT_TAG + ".png"))); |
||||
cachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_TAG + ".png"))); |
||||
cachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_FONT_TAG + ".png"))); |
||||
cachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_TAG + ".png"))); |
||||
cachedPreviewImage.put(NOT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png"))); |
||||
cachedPreviewImage.put(NOT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png"))); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
imageLabel = new UILabel(); |
||||
imageLabel.setIcon(cachedPreviewImage.get(DEFAULT_TAG)); |
||||
this.add(imageLabel); |
||||
} |
||||
|
||||
public void refreshPreview(String index, boolean isEditedable) { |
||||
ImageIcon newImageIcon = isEditedable ? cachedPreviewImage.get(index) : globalCachedPreviewImage.get(index); |
||||
imageLabel.setIcon(newImageIcon); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Preview"); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,80 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
|
||||
import javax.swing.AbstractButton; |
||||
import javax.swing.ButtonGroup; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 自适应四个按钮选项的group |
||||
* <p> |
||||
* Created by Administrator on 2016/5/5/0005. |
||||
*/ |
||||
public class FitRadioGroup extends ButtonGroup { |
||||
|
||||
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>(); |
||||
|
||||
@Override |
||||
public void add(AbstractButton button) { |
||||
super.add(button); |
||||
|
||||
UIRadioButton radioButton = (UIRadioButton) button; |
||||
radioButtons.add(radioButton); |
||||
} |
||||
|
||||
/** |
||||
* 设置按钮状态 |
||||
*/ |
||||
public boolean isEnabled() { |
||||
return radioButtons.get(0).isEnabled(); |
||||
} |
||||
|
||||
/** |
||||
* 设置按钮状态 |
||||
*/ |
||||
public void setEnabled(boolean enabled) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.setEnabled(enabled); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取当前选中的按钮index |
||||
* |
||||
* @return 按钮index |
||||
*/ |
||||
public int getSelectRadioIndex() { |
||||
for (int i = 0, len = radioButtons.size(); i < len; i++) { |
||||
if (radioButtons.get(i).isSelected()) { |
||||
return i; |
||||
} |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/** |
||||
* 选中指定index的按钮 |
||||
*/ |
||||
public void selectIndexButton(int index) { |
||||
if (index < 0 || index > radioButtons.size() - 1) { |
||||
return; |
||||
} |
||||
|
||||
UIRadioButton button = radioButtons.get(index); |
||||
button.setSelected(true); |
||||
} |
||||
|
||||
/** |
||||
* 给所有的按钮加上监听 |
||||
*/ |
||||
public void addActionListener(ActionListener actionListener) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.addActionListener(actionListener); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
/** |
||||
* 字体的两个选项组成的group |
||||
* <p> |
||||
* Created by Administrator on 2016/5/5/0005. |
||||
*/ |
||||
public class FontRadioGroup extends FitRadioGroup { |
||||
|
||||
public void selectFontFit(boolean isFontFit) { |
||||
selectIndexButton(isFontFit ? 0 : 1); |
||||
} |
||||
|
||||
public boolean isFontFit() { |
||||
return getSelectRadioIndex() == 0; |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.JTemplateAction; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.menu.MenuKeySet; |
||||
import com.fr.report.fit.FitProvider; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
|
||||
import javax.swing.KeyStroke; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* Created by Administrator on 2015/7/6 0006. |
||||
*/ |
||||
public class ReportFitAttrAction extends JTemplateAction { |
||||
private static final Dimension MEDIUM = new Dimension(430, 400); |
||||
private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 'T'; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Template"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
private static final MenuKeySet REPORT_FIT_ATTR_ELEMENTCASE = new MenuKeySet() { |
||||
@Override |
||||
public char getMnemonic() { |
||||
return 'T'; |
||||
} |
||||
|
||||
@Override |
||||
public String getMenuName() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Elementcase"); |
||||
} |
||||
|
||||
@Override |
||||
public KeyStroke getKeyStroke() { |
||||
return null; |
||||
} |
||||
}; |
||||
|
||||
public ReportFitAttrAction(JTemplate jTemplate) { |
||||
super(jTemplate); |
||||
initMenuStyle(); |
||||
} |
||||
|
||||
private void initMenuStyle() { |
||||
JTemplate jTemplate = getEditingComponent(); |
||||
if (jTemplate.isJWorkBook()) { |
||||
this.setMenuKeySet(REPORT_FIT_ATTR); |
||||
} else { |
||||
this.setMenuKeySet(REPORT_FIT_ATTR_ELEMENTCASE); |
||||
} |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/reportfit/fit.png")); |
||||
} |
||||
|
||||
/** |
||||
* Action触发事件 |
||||
* |
||||
* @param e 事件 |
||||
*/ |
||||
public void actionPerformed(ActionEvent e) { |
||||
final JTemplate jwb = getEditingComponent(); |
||||
if (jwb == null) { |
||||
return; |
||||
} |
||||
final FitProvider wbTpl = (FitProvider) jwb.getTarget(); |
||||
ReportFitAttr fitAttr = wbTpl.getReportFitAttr(); |
||||
if (jwb.isJWorkBook()) { |
||||
final TemplateFitAttrPane attrPane = new TemplateFitAttrPane(); |
||||
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane); |
||||
} else { |
||||
final ReportFitAttrPane attrPane = new ReportFitAttrPane(); |
||||
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane); |
||||
} |
||||
} |
||||
|
||||
private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) { |
||||
attrPane.populateBean(fitAttr); |
||||
UIDialog dialog = attrPane.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
wbTpl.setReportFitAttr(attrPane.updateBean()); |
||||
jwb.fireTargetModified(); |
||||
} |
||||
}); |
||||
dialog.setSize(MEDIUM); |
||||
dialog.setVisible(true); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.BoxLayout; |
||||
|
||||
/** |
||||
* Created by Administrator on 2015/7/6 0006. |
||||
*/ |
||||
public class ReportFitAttrPane extends BasicBeanPane<ReportFitAttr> { |
||||
|
||||
private BrowserFitAttrPane attrPane; |
||||
|
||||
|
||||
public ReportFitAttrPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
attrPane = new BrowserFitAttrPane(); |
||||
this.add(attrPane); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 展示界面 |
||||
* |
||||
* @param fitAttr 自适应属性 |
||||
*/ |
||||
public void populateBean(ReportFitAttr fitAttr) { |
||||
attrPane.populateBean(fitAttr); |
||||
} |
||||
|
||||
/** |
||||
* 提交数据 |
||||
* |
||||
* @return 界面上的更新数据 |
||||
*/ |
||||
public ReportFitAttr updateBean() { |
||||
return attrPane.updateBean(); |
||||
} |
||||
|
||||
/** |
||||
* 标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr"); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,85 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.config.Configuration; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
import com.fr.report.fit.ReportFitConfig; |
||||
import com.fr.transaction.Configurations; |
||||
import com.fr.transaction.Worker; |
||||
|
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by 夏翔 on 2016/6/24. |
||||
*/ |
||||
public class TemplateBrowserFitAttrPane extends BrowserFitAttrPane { |
||||
|
||||
public TemplateBrowserFitAttrPane() { |
||||
initComponents(ReportFitConfig.getInstance().getCptFitAttr()); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected Component[][] initFitComponents() { |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Font")), fontFitRadio, null, fontNotFitRadio}, |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Element")), horizonRadio, doubleRadio, notFitRadio} |
||||
}; |
||||
return components; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ReportFitAttr attr) { |
||||
//模板界面,自适应选项去掉了默认,这边的判断为了兼容之前的设置
|
||||
if (attr != null && attr.fitStateInPC() == 0) { |
||||
attr.setFitStateInPC(3); |
||||
} |
||||
ReportFitAttr fitAttr = ReportFitConfig.getInstance().getCptFitAttr(); |
||||
if (attr == null) { |
||||
//如果为空, 就用全局的
|
||||
attr = fitAttr; |
||||
populateGlobalComponents(); |
||||
} else if (fitAttr.fitStateInPC() == 0) { |
||||
attr = new ReportFitAttr(); |
||||
attr.setFitStateInPC(3); |
||||
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); |
||||
} else { |
||||
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local")); |
||||
} |
||||
this.localFitAttr = attr; |
||||
fontRadioGroup.selectFontFit((attr).isFitFont()); |
||||
fitRadionGroup.selectIndexButton(attr.fitStateInPC()); |
||||
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled()); |
||||
} |
||||
|
||||
@Override |
||||
public ReportFitAttr updateBean() { |
||||
ReportFitAttr attr = new ReportFitAttr(); |
||||
attr.setFitFont(fontRadioGroup.isFontFit()); |
||||
attr.setFitStateInPC(fitRadionGroup.getSelectRadioIndex()); |
||||
|
||||
// 直接用全局的
|
||||
if (globalCheck.isSelected()) { |
||||
updateGlobalConfig(attr); |
||||
return null; |
||||
} |
||||
this.localFitAttr = attr; |
||||
return attr; |
||||
} |
||||
|
||||
private void updateGlobalConfig(final ReportFitAttr attr) { |
||||
|
||||
Configurations.update(new Worker() { |
||||
@Override |
||||
public void run() { |
||||
ReportFitConfig manager = ReportFitConfig.getInstance(); |
||||
manager.setCptFitAttr(attr); |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Configuration>[] targets() { |
||||
return new Class[]{ReportFitConfig.class}; |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.report.fit.menupane; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.report.fit.ReportFitAttr; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.BoxLayout; |
||||
|
||||
/** |
||||
* Created by 夏翔 on 2016/6/24. |
||||
*/ |
||||
public class TemplateFitAttrPane extends BasicBeanPane<ReportFitAttr> { |
||||
private TemplateBrowserFitAttrPane attrPane; |
||||
|
||||
|
||||
public TemplateFitAttrPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
attrPane = new TemplateBrowserFitAttrPane(); |
||||
this.add(attrPane); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 展示界面 |
||||
* |
||||
* @param fitAttr 自适应属性 |
||||
*/ |
||||
public void populateBean(ReportFitAttr fitAttr) { |
||||
attrPane.populateBean(fitAttr); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 提交数据 |
||||
* |
||||
* @return 界面上的更新数据 |
||||
*/ |
||||
public ReportFitAttr updateBean() { |
||||
return attrPane.updateBean(); |
||||
} |
||||
|
||||
/** |
||||
* 标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr"); |
||||
} |
||||
} |
After Width: | Height: | Size: 976 B |
After Width: | Height: | Size: 745 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 788 B |
After Width: | Height: | Size: 788 B |
After Width: | Height: | Size: 745 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 740 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 782 B |
After Width: | Height: | Size: 783 B |
@ -1,4 +1,4 @@
|
||||
package com.fr.design.mainframe.actions; |
||||
package com.fr.design.actions; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark; |
@ -1,4 +1,4 @@
|
||||
package com.fr.design.mainframe.actions; |
||||
package com.fr.design.actions; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
@ -1,4 +1,4 @@
|
||||
package com.fr.design.mainframe.actions; |
||||
package com.fr.design.actions; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Parameter; |
@ -0,0 +1,77 @@
|
||||
package com.fr.design.actions.file.export; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Parameter; |
||||
import com.fr.base.extension.FileExtension; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.JForm; |
||||
import com.fr.design.menu.KeySetUtils; |
||||
import com.fr.design.parameter.ParameterInputPane; |
||||
import com.fr.file.filter.ChooseFileFilter; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.io.exporter.DesignExportScope; |
||||
import com.fr.io.exporter.DesignExportType; |
||||
import com.fr.io.exporter.ExporterKey; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Export Embedded. |
||||
*/ |
||||
public class EmbeddedFormExportExportAction extends AbstractExportAction<JForm> { |
||||
|
||||
|
||||
public EmbeddedFormExportExportAction(JForm jwb) { |
||||
super(jwb); |
||||
this.setMenuKeySet(KeySetUtils.EMBEDDED_EXPORT); |
||||
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); |
||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/oem/logo.png")); |
||||
} |
||||
|
||||
@Override |
||||
public ExporterKey exportKey() { |
||||
return DesignExportScope.FINE_FORM; |
||||
} |
||||
|
||||
@Override |
||||
protected String getDefaultExtension() { |
||||
return getEditingComponent().suffix().substring(1); |
||||
} |
||||
|
||||
@Override |
||||
public DesignExportType exportType() { |
||||
return DesignExportType.EMBEDDED_FORM; |
||||
} |
||||
|
||||
@Override |
||||
protected Map<String, Object> processParameter() { |
||||
// 输入参数
|
||||
final Map<String, Object> parameterMap = new HashMap<String, Object>(); |
||||
Form tpl = this.getEditingComponent().getTarget(); |
||||
|
||||
Parameter[] parameters = tpl.getParameters(); |
||||
// 检查Parameter.
|
||||
if (ArrayUtils.isNotEmpty(parameters)) { |
||||
final ParameterInputPane pPane = new ParameterInputPane(parameters); |
||||
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
parameterMap.putAll(pPane.update()); |
||||
} |
||||
}).setVisible(true); |
||||
} |
||||
return parameterMap; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected ChooseFileFilter getChooseFileFilter() { |
||||
return new ChooseFileFilter(FileExtension.FRM.getExtensions(), Toolkit.i18nText("Fine-Design_Form_EmbeddedTD")); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XTextEditor; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.widget.ui.designer.mobile.ScanCodeMobileDefinePane; |
||||
|
||||
public class ScanCodeMobilePropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public ScanCodeMobilePropertyUI(XTextEditor xTextEditor) { |
||||
this.xCreator = xTextEditor; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicPane createWidgetAttrPane() { |
||||
return new ScanCodeMobileDefinePane(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.widget.ui.designer.mobile.TabMobileWidgetDefinePane; |
||||
|
||||
public class TabMobilePropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
private XCreator xCreator; |
||||
|
||||
public TabMobilePropertyUI(XCreator xCreator){ |
||||
this.xCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicPane createWidgetAttrPane() { |
||||
return new TabMobileWidgetDefinePane(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); |
||||
} |
||||
} |