diff --git a/designer/src/com/fr/design/parameter/ParameterDefinitePane.java b/designer/src/com/fr/design/parameter/ParameterDefinitePane.java index 300d42c3fc..394c6facc9 100644 --- a/designer/src/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer/src/com/fr/design/parameter/ParameterDefinitePane.java @@ -355,6 +355,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus reportParameterAttr.setShowWindow(bridge.isDisplay()); reportParameterAttr.setAlign(bridge.getPosition()); reportParameterAttr.setBackground(bridge.getDataBackground()); + reportParameterAttr.setUseParamsTemplate(bridge.isUseParamsTemplate()); } //这里不用 parameterUI 的原因是考虑到没有控件的时候设置宽度有效果但不保存,只有含有控件才保存属性 paraDesignEditor.getParaTarget().setDesignSize(new Dimension(bridge.getDesignWidth(), diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 968e44ba69..6ab2f5cd65 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2092,6 +2092,8 @@ FR-Designer_CellWrite_Show_As_HTML=CellWrite_Show_As_HTML FR-Designer_Datasource_Other_Attributes=Other_Attributes FR-Designer_Not_use_a_cell_attribute_table_editing=Not_use_a_cell_attribute_table_editing FR-Designer_CellElement_Property_Table=CellElement_Property_Table +FR-Designer_Use_Params_Template= +FR-Designer_Label_Name= FR-Designer_T_Insert_Float=Insert_Float FR-Designer_Add_FloatElement=Add_FloatElement FR-Designer_Insert_Image=Insert_Image diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index c72a2b2944..94367ad22c 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2093,6 +2093,8 @@ FR-Designer_CellWrite_Show_As_HTML=CellWrite_Show_As_HTML FR-Designer_Datasource_Other_Attributes=Other_Attributes FR-Designer_Not_use_a_cell_attribute_table_editing=Not_use_a_cell_attribute_table_editing FR-Designer_CellElement_Property_Table=CellElement_Property_Table +FR-Designer_Use_Params_Template=use parameter template +FR-Designer_Label_Name=label name FR-Designer_T_Insert_Float=Insert_Float FR-Designer_Add_FloatElement=Add_FloatElement FR-Designer_Insert_Image=Insert_Image diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 1f09cfa1f1..7d0517cb72 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2092,6 +2092,8 @@ FR-Designer_CellWrite_Show_As_HTML=\u7528HTML\u663E\u793A\u5185\u5BB9 FR-Designer_Datasource_Other_Attributes=\u5176\u4ED6\u5C5E\u6027 FR-Designer_Not_use_a_cell_attribute_table_editing=\u60A8\u4E0D\u53EF\u4EE5\u7528\u5355\u5143\u683C\u5C5E\u6027\u8868\u7F16\u8F91 FR-Designer_CellElement_Property_Table=\u5355\u5143\u683C\u5C5E\u6027\u8868 +FR-Designer_Use_Params_Template=\u4F7F\u7528\u5E38\u7528\u53C2\u6570\u7EC4\u5408 +FR-Designer_Label_Name=\u6807\u7B7E\u540D\u79F0 FR-Designer_T_Insert_Float=\u63D2\u5165\u60AC\u6D6E\u5143\u7D20 FR-Designer_Add_FloatElement=\u6DFB\u52A0\u5143\u7D20 FR-Designer_Insert_Image=\u63D2\u5165\u56FE\u7247 diff --git a/designer_base/src/com/fr/design/parameter/ParameterBridge.java b/designer_base/src/com/fr/design/parameter/ParameterBridge.java index f9250c59e7..dcae82231a 100644 --- a/designer_base/src/com/fr/design/parameter/ParameterBridge.java +++ b/designer_base/src/com/fr/design/parameter/ParameterBridge.java @@ -16,6 +16,12 @@ public interface ParameterBridge { */ public boolean isDelayDisplayContent(); + /** + * 是否启用参数模板 + * @return 显示参数模板界面则返回true,否则返回false + */ + public boolean isUseParamsTemplate(); + /** * 是否显示参数界面 * @return 显示参数界面则返回true,否则返回false @@ -48,4 +54,6 @@ public interface ParameterBridge { public void setDisplay(boolean showWindow); public void setBackground(Background background); + + public void setUseParamsTemplate(boolean isUse); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java b/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java index 3ba3d610da..e0d2ffb55e 100644 --- a/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java +++ b/designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java @@ -68,5 +68,4 @@ public interface ParameterDesignerProvider { void removeSelection(); ParameterBridge getParaComponent(); - } \ No newline at end of file diff --git a/designer_base/src/com/fr/start/StartServer.java b/designer_base/src/com/fr/start/StartServer.java index e21beef7b1..79b3f739dc 100644 --- a/designer_base/src/com/fr/start/StartServer.java +++ b/designer_base/src/com/fr/start/StartServer.java @@ -28,173 +28,173 @@ import java.net.URI; import java.net.URISyntaxException; public class StartServer { - public static boolean NEED_LOAD_ENV = true; - // 原先的jettyHost放在类JettyHost里面,很不方便操作,而且因为存在多个进程的原因, - // 原先的getInstance()方法无多大意义 - private static JettyHost jettyHost = null; - - static { - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - public void envChanged() { - currentEnvChanged(); - } - }); - } + public static boolean NEED_LOAD_ENV = true; + // 原先的jettyHost放在类JettyHost里面,很不方便操作,而且因为存在多个进程的原因, + // 原先的getInstance()方法无多大意义 + private static JettyHost jettyHost = null; + + static { + GeneralContext.addEnvChangedListener(new EnvChangedListener() { + public void envChanged() { + currentEnvChanged(); + } + }); + } /** * 预览Demo * 找默认工作目录,不应该按照名字去找,而应该按照安装路径,因为默认工作目录的名字可能会改变。 */ - public static void browserDemoURL() { - if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 - String web = GeneralContext.getCurrentAppNameOfEnv(); - browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() - + "?op=fs"); - return; - } - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - if (!envManager.isCurrentEnvDefault()) { - InformationPane inf = new InformationPane(envManager.getDefaultEnvName()); - inf.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - try { - SignIn.signIn(DesignerEnvManager.getEnvManager().getDefaultEnv()); - TemplateTreePane.getInstance().refreshDockingView(); - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); - } catch (Exception e) { - FRContext.getLogger().errorWithServerLevel(e.getMessage()); - } - initDemoServerAndBrowser(); - } - - }).setVisible(true); - } else { - initDemoServerAndBrowser(); - } - } - - private static void initDemoServerAndBrowser() { - if (jettyHost != null) { - if (!jettyHost.isDemoAppLoaded()) { - jettyHost.exit(); - jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - jettyHost.addAndStartInstallHomeWebApp(); - } - } else { - jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - jettyHost.addAndStartInstallHomeWebApp(); - } - try { - if (!jettyHost.isStarted()) { - jettyHost.start(); - } - } catch (Exception e) { - FRContext.getLogger().errorWithServerLevel(e.getMessage()); - } finally { - //先访问Demo, 后访问报表, 不需要重置服务器. - NEED_LOAD_ENV = false; - browser("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + ProjectConstants.WEBAPP_NAME + "/" + ConfigManager.getProviderInstance().getServletMapping() - + "?op=fs"); - } - } + public static void browserDemoURL() { + if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 + String web = GeneralContext.getCurrentAppNameOfEnv(); + browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() + + "?op=fs"); + return; + } + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + if (!envManager.isCurrentEnvDefault()) { + InformationPane inf = new InformationPane(envManager.getDefaultEnvName()); + inf.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + try { + SignIn.signIn(DesignerEnvManager.getEnvManager().getDefaultEnv()); + TemplateTreePane.getInstance().refreshDockingView(); + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); + } catch (Exception e) { + FRContext.getLogger().errorWithServerLevel(e.getMessage()); + } + initDemoServerAndBrowser(); + } + + }).setVisible(true); + } else { + initDemoServerAndBrowser(); + } + } + + private static void initDemoServerAndBrowser() { + if (jettyHost != null) { + if (!jettyHost.isDemoAppLoaded()) { + jettyHost.exit(); + jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); + jettyHost.addAndStartInstallHomeWebApp(); + } + } else { + jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); + jettyHost.addAndStartInstallHomeWebApp(); + } + try { + if (!jettyHost.isStarted()) { + jettyHost.start(); + } + } catch (Exception e) { + FRContext.getLogger().errorWithServerLevel(e.getMessage()); + } finally { + //先访问Demo, 后访问报表, 不需要重置服务器. + NEED_LOAD_ENV = false; + browser("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + ProjectConstants.WEBAPP_NAME + "/" + ConfigManager.getProviderInstance().getServletMapping() + + "?op=fs"); + } + } /** * 本地环境浏览url * * @param url 指定路径 */ - public static void browserURLWithLocalEnv(String url) { - try { - if (jettyHost != null) { - if (NEED_LOAD_ENV) { - jettyHost.exit(); - jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - jettyHost.addAndStartLocalEnvHomeWebApp(); - - } - } else { - jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - jettyHost.addAndStartLocalEnvHomeWebApp(); - - } - if (!jettyHost.isStarted()) { - jettyHost.start(); - } - } catch (InterruptedException e) { - FRContext.getLogger().errorWithServerLevel(e.getMessage()); - } catch (Exception e) { - FRContext.getLogger().errorWithServerLevel(e.getMessage()); - } finally { - NEED_LOAD_ENV = false; - browser(url); - } - } - - public static JettyHost getInstance() { - // august: 正确的逻辑能保证jettyHost不为null,不然就有bug,不允许这儿加是否等于null判断 - return jettyHost; - } + public static void browserURLWithLocalEnv(String url) { + try { + if (jettyHost != null) { + if (NEED_LOAD_ENV) { + jettyHost.exit(); + jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); + jettyHost.addAndStartLocalEnvHomeWebApp(); + + } + } else { + jettyHost = new JettyHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); + jettyHost.addAndStartLocalEnvHomeWebApp(); + + } + if (!jettyHost.isStarted()) { + jettyHost.start(); + } + } catch (InterruptedException e) { + FRContext.getLogger().errorWithServerLevel(e.getMessage()); + } catch (Exception e) { + FRContext.getLogger().errorWithServerLevel(e.getMessage()); + } finally { + NEED_LOAD_ENV = false; + browser(url); + } + } + + public static JettyHost getInstance() { + // august: 正确的逻辑能保证jettyHost不为null,不然就有bug,不允许这儿加是否等于null判断 + return jettyHost; + } /** * 运行环境改变事件 */ - public static void currentEnvChanged() { - if (!NEED_LOAD_ENV) { - NEED_LOAD_ENV = true; - } - } - - private static void browser(String uri) { - if (StringUtils.isEmpty(uri)) { - FRContext.getLogger().info("The URL is empty!"); - return; - } - try { - Desktop.getDesktop().browse(new URI(uri)); - - } catch (IOException e) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); - FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); - } catch (URISyntaxException e) { - FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); - } catch (Exception e) { - FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); - FRContext.getLogger().error("Can not open the browser for URL: " + uri); - } - } - - private static class InformationPane extends BasicPane { - private static final long serialVersionUID = 1L; - - public InformationPane(String message) { - this.setLayout(new BorderLayout(10, 10)); - this.setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5)); - String text; - if (!ComparatorUtils.equals(message, Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}))) { - text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) + public static void currentEnvChanged() { + if (!NEED_LOAD_ENV) { + NEED_LOAD_ENV = true; + } + } + + private static void browser(String uri) { + if (StringUtils.isEmpty(uri)) { + FRContext.getLogger().info("The URL is empty!"); + return; + } + try { + Desktop.getDesktop().browse(new URI(uri)); + + } catch (IOException e) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); + FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); + } catch (URISyntaxException e) { + FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); + } catch (Exception e) { + FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); + FRContext.getLogger().error("Can not open the browser for URL: " + uri); + } + } + + private static class InformationPane extends BasicPane { + private static final long serialVersionUID = 1L; + + public InformationPane(String message) { + this.setLayout(new BorderLayout(10, 10)); + this.setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5)); + String text; + if (!ComparatorUtils.equals(message, Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}))) { + text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) .append(ProductConstants.APP_NAME) .append(Inter.getLocText("FR-Designer_Utils-OpenDemoEnv")) .append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); - }else{ - text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) + } else { + text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) .append(ProductConstants.APP_NAME) .append(Inter.getLocText("FR-Designer_Utils-NewDemoEnv")) .append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); - } - UITextArea a = new UITextArea(text); - a.setFont(new Font("Dialog", Font.PLAIN, 12)); - a.setEditable(false); - a.setBackground(this.getBackground()); - a.setLineWrap(true); - this.add(a); - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("FR-Designer_Tooltips"); - } - - } + } + UITextArea a = new UITextArea(text); + a.setFont(new Font("Dialog", Font.PLAIN, 12)); + a.setEditable(false); + a.setBackground(this.getBackground()); + a.setLineWrap(true); + this.add(a); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Tooltips"); + } + + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XLabel.java b/designer_form/src/com/fr/design/designer/creator/XLabel.java index 2a47eb3af8..80dcca3b13 100644 --- a/designer_form/src/com/fr/design/designer/creator/XLabel.java +++ b/designer_form/src/com/fr/design/designer/creator/XLabel.java @@ -3,19 +3,11 @@ */ package com.fr.design.designer.creator; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; -import java.beans.IntrospectionException; - -import javax.swing.JComponent; -import javax.swing.SwingConstants; - import com.fr.base.BaseUtils; import com.fr.base.ScreenResolution; import com.fr.base.Style; import com.fr.design.border.UIRoundedBorder; +import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.widget.editors.FontEditor; import com.fr.design.mainframe.widget.editors.ItemCellEditor; @@ -23,98 +15,114 @@ import com.fr.design.mainframe.widget.editors.WidgetValueEditor; import com.fr.design.mainframe.widget.renderer.FontCellRenderer; import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer; import com.fr.form.ui.Label; -import com.fr.design.form.util.XCreatorConstants; +import com.fr.form.ui.container.WParameterLayout; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; +import com.fr.stable.core.PropertyChangeAdapter; + +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.beans.IntrospectionException; /** * @author richer * @since 6.5.3 */ public class XLabel extends XWidgetCreator { - - private int cornerSize = 15; - public XLabel(Label widget, Dimension initSize) { - super(widget, initSize); - } + private int cornerSize = 15; + + public XLabel(Label widget, Dimension initSize) { + super(widget, initSize); + } + + /** + * 生成creator对应的控件widget + * + * @return 控件widget + */ + public Label toData() { + return (Label) data; + } + + /** + * 返回组件属性值 + * + * @return 返回组件属性值 + * @throws IntrospectionException 异常 + */ + @Override + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), + new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( + Inter.getLocText(new String[]{"FR-Designer_Widget", "Value"})).setEditorClass( + WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") + .setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + XCreator parent = (XCreator) XLabel.this.getParent(); + ((WParameterLayout) parent.toData()).refreshTagList(); + } + }), + new CRPropertyDescriptor("wrap", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_StyleAlignment-Wrap_Text")).putKeyValue( + XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("verticalCenter", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_PageSetup-Vertically")).putKeyValue( + XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("textalign", this.data.getClass()).setI18NName( + Inter.getLocText("FR-Designer_Alignment-Style")).setEditorClass(ItemCellEditor.class) + .setRendererClass(LabelHorizontalAlignmentRenderer.class).putKeyValue( + XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Font")) + .setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue( + XCreatorConstants.PROPERTY_CATEGORY, "Advanced")}); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Label label = (Label) data; + Dimension size = this.getSize(); + //先画背景,再画标题 + if (toData().getBackground() != null) { + toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); + } + if (label.getWidgetValue() != null) { + Graphics2D g2d = (Graphics2D) g.create(); + BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue() + .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign()) + .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) + .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), + ScreenResolution.getScreenResolution()); + } + } + + @Override + protected JComponent initEditor() { + if (editor == null) { + editor = new UILabel(); + } + return editor; + } - /** - * 生成creator对应的控件widget - * @return 控件widget - */ - public Label toData() { - return (Label) data; - } - - /** - * 返回组件属性值 - * @return 返回组件属性值 - * @throws IntrospectionException 异常 - */ - @Override - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), - new CRPropertyDescriptor[] { - new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( - Inter.getLocText(new String[]{"FR-Designer_Widget", "Value"})).setEditorClass( - WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("wrap", this.data.getClass()).setI18NName( - Inter.getLocText("FR-Designer_StyleAlignment-Wrap_Text")).putKeyValue( - XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("verticalCenter", this.data.getClass()).setI18NName( - Inter.getLocText("FR-Designer_PageSetup-Vertically")).putKeyValue( - XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("textalign", this.data.getClass()).setI18NName( - Inter.getLocText("FR-Designer_Alignment-Style")).setEditorClass(ItemCellEditor.class) - .setRendererClass(LabelHorizontalAlignmentRenderer.class).putKeyValue( - XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Font")) - .setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue( - XCreatorConstants.PROPERTY_CATEGORY, "Advanced") }); - } + @Override + protected void initXCreatorProperties() { + super.initXCreatorProperties(); + if (toData().getBorder() != Constants.LINE_NONE) { + this.setBorder(new UIRoundedBorder(toData().getBorder(), toData().getColor(), toData().isCorner() ? cornerSize : 0)); + } else { + this.setBorder(DEFALUTBORDER); + } + } - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Label label = (Label) data; - Dimension size = this.getSize(); - //先画背景,再画标题 - if (toData().getBackground() != null) { - toData().getBackground().paint(g,new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); - } - if (label.getWidgetValue() != null) { - Graphics2D g2d = (Graphics2D) g.create(); - BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue() - .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign()) - .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) - .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), - ScreenResolution.getScreenResolution()); - } - } + @Override + protected String getIconName() { + return "label_16.png"; + } - @Override - protected JComponent initEditor() { - if (editor == null) { - editor = new UILabel(); - } - return editor; - } - - @Override - protected void initXCreatorProperties() { - super.initXCreatorProperties(); - if (toData().getBorder() != Constants.LINE_NONE) { - this.setBorder(new UIRoundedBorder(toData().getBorder(), toData().getColor(), toData().isCorner() ? cornerSize : 0)); - } else { - this.setBorder(DEFALUTBORDER); - } - } - - @Override - protected String getIconName() { - return "label_16.png"; - } - } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java b/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java index edd1c69f0f..27288cb62d 100644 --- a/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java @@ -412,6 +412,15 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme return false; } + /** + * 是否启用参数模板 + * @return 显示参数模板界面则返回true,否则返回false + */ + public boolean isUseParamsTemplate() { + return false; + } + + /** * 是否显示参数界面 * @@ -485,6 +494,10 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme } + public void setUseParamsTemplate(boolean isUse) { + + } + public void setPosition(int align) { } diff --git a/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java b/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java index d85c610ac9..979d9bf082 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java @@ -67,6 +67,9 @@ public class XWParameterLayout extends XWAbsoluteLayout { new CRPropertyDescriptor("position", this.data.getClass()).setEditorClass(WidgetDisplayPosition.class) .setRendererClass(WidgetDisplayPositionRender.class).setI18NName(Inter.getLocText("FR-Designer_WidgetDisplyPosition")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), + new CRPropertyDescriptor("useParamsTemplate", this.data.getClass()).setEditorClass(BooleanEditor.class) + .setI18NName(Inter.getLocText("FR-Designer_Use_Params_Template")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), }; ParameterWindowEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(ParameterWindowEditorProcessor.MARK_STRING); @@ -124,6 +127,14 @@ public class XWParameterLayout extends XWAbsoluteLayout { return toData().isDelayDisplayContent(); } + /** + * 是否启用参数模板 + * @return 显示参数模板界面则返回true,否则返回false + */ + public boolean isUseParamsTemplate() { + return toData().isUseParamsTemplate(); + } + /** * 是否显示参数界面 * @return 显示参数界面则返回true,否则返回false @@ -152,6 +163,10 @@ public class XWParameterLayout extends XWAbsoluteLayout { this.toData().setDelayDisplayContent(delayPlaying); } + public void setUseParamsTemplate(boolean isUse) { + this.toData().setUseParamsTemplate(isUse); + } + public void setPosition(int align){ this.toData().setPosition(align); } diff --git a/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java b/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java index 2c1be0eab4..21ff4ed20c 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java @@ -3,17 +3,17 @@ */ package com.fr.design.designer.creator; -import java.awt.*; -import java.beans.IntrospectionException; - import com.fr.base.BaseUtils; import com.fr.base.FRContext; +import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.FormDesigner; import com.fr.form.ui.Widget; import com.fr.general.Inter; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.*; +import java.awt.*; +import java.beans.IntrospectionException; /** * @author richer @@ -21,8 +21,8 @@ import javax.swing.*; */ public abstract class XWidgetCreator extends XCreator { - protected static final float FULL_OPACITY = 1.0f; - protected static final float HALF_OPACITY = 0.4f; + protected static final float FULL_OPACITY = 1.0f; + protected static final float HALF_OPACITY = 0.4f; public XWidgetCreator(Widget widget, Dimension initSize) { super(widget, initSize); @@ -31,35 +31,41 @@ public abstract class XWidgetCreator extends XCreator { /** * 待说明 - * @return 待说明 + * + * @return 待说明 * @throws IntrospectionException */ - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return new CRPropertyDescriptor[] { - new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter - .getLocText("Form-Widget_Name")), - new CRPropertyDescriptor("enabled", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Enabled")) - .setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - setEnabled(toData().isEnabled()); - } - }), - new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter + .getLocText("Form-Widget_Name")), + new CRPropertyDescriptor("enabled", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Enabled")) + .setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + setEnabled(toData().isEnabled()); + } + }), + new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( Inter.getLocText("FR-Designer_Widget-Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { - @Override - public void propertyChange() { - makeVisible(toData().isVisible()); - } - }) }; + @Override + public void propertyChange() { + makeVisible(toData().isVisible()); + } + }), + new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName") + .setI18NName(Inter.getLocText("FR-Designer_Label_Name")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Advanced") + }; - } + } /** * 待说明 - * @return 待说明 + * + * @return 待说明 */ public Widget toData() { return this.data; @@ -80,94 +86,96 @@ public abstract class XWidgetCreator extends XCreator { } - protected void makeVisible(boolean visible) { - } - - public class LimpidButton extends JButton { - private String name; - private String imagePath; - private float opacity = 0.4f; - public LimpidButton(String name, String imagePath, float opacity) { - this.name = name; - this.imagePath = imagePath; - this.opacity = opacity; - this.draw(); - } - - public void draw() { - try { - ImageIcon imageIcon =(ImageIcon) BaseUtils.readIcon(imagePath); - Image img = imageIcon.getImage(); - MediaTracker mt = new MediaTracker(this); - int w = 21; - int h = 21; - mt.addImage(img, 0); - mt.waitForAll(); - - GraphicsConfiguration gc = new JFrame().getGraphicsConfiguration(); // 本地图形设备 - Image image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);//建立透明画布 - Graphics2D g = (Graphics2D) image.getGraphics(); //在画布上创建画笔 - - Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f); //指定透明度为半透明90% - g.setComposite(alpha); - g.drawImage(img, 0, 0, this); //注意是,将image画到g画笔所在的画布上 - g.setColor(Color.black);//设置颜色为黑色 - g.drawString(name, 25, 20);//写字 - g.dispose(); //释放内存 - - Composite alpha2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity); - Image image1 = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); - g = (Graphics2D) image1.getGraphics(); - g.setComposite(alpha2); - g.drawImage(img, 2, 2, this); //改变图像起始位置,产生动态效果 - g.setColor(Color.black); - g.drawString(name, 25, 20); - g.dispose(); - - this.setIgnoreRepaint(true); - this.setFocusable(false);//设置没有焦点 - this.setBorder(null);//设置不画按钮边框 - this.setContentAreaFilled(false);//设置不画按钮背景 - this.setIcon(new ImageIcon(image1)); //把刚才生成的半透明image变成ImageIcon,贴到按钮上去 - this.setRolloverIcon(new ImageIcon(image1)); - this.setPressedIcon(new ImageIcon(image));//按下去的图标 - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); - } - } + protected void makeVisible(boolean visible) { + } + + public class LimpidButton extends JButton { + private String name; + private String imagePath; + private float opacity = 0.4f; + + public LimpidButton(String name, String imagePath, float opacity) { + this.name = name; + this.imagePath = imagePath; + this.opacity = opacity; + this.draw(); + } + + public void draw() { + try { + ImageIcon imageIcon = (ImageIcon) BaseUtils.readIcon(imagePath); + Image img = imageIcon.getImage(); + MediaTracker mt = new MediaTracker(this); + int w = 21; + int h = 21; + mt.addImage(img, 0); + mt.waitForAll(); + + GraphicsConfiguration gc = new JFrame().getGraphicsConfiguration(); // 本地图形设备 + Image image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);//建立透明画布 + Graphics2D g = (Graphics2D) image.getGraphics(); //在画布上创建画笔 + + Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f); //指定透明度为半透明90% + g.setComposite(alpha); + g.drawImage(img, 0, 0, this); //注意是,将image画到g画笔所在的画布上 + g.setColor(Color.black);//设置颜色为黑色 + g.drawString(name, 25, 20);//写字 + g.dispose(); //释放内存 + + Composite alpha2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity); + Image image1 = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); + g = (Graphics2D) image1.getGraphics(); + g.setComposite(alpha2); + g.drawImage(img, 2, 2, this); //改变图像起始位置,产生动态效果 + g.setColor(Color.black); + g.drawString(name, 25, 20); + g.dispose(); + + this.setIgnoreRepaint(true); + this.setFocusable(false);//设置没有焦点 + this.setBorder(null);//设置不画按钮边框 + this.setContentAreaFilled(false);//设置不画按钮背景 + this.setIcon(new ImageIcon(image1)); //把刚才生成的半透明image变成ImageIcon,贴到按钮上去 + this.setRolloverIcon(new ImageIcon(image1)); + this.setPressedIcon(new ImageIcon(image));//按下去的图标 + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage()); + } + } /** * 待说明 - * @param visible 待说明 + * + * @param visible 待说明 */ - public void makeVisible(boolean visible) { - this.opacity = visible ? FULL_OPACITY : HALF_OPACITY; - this.draw(); - } - } - - /** - * 渲染Painter - */ - public void paint(Graphics g) { - //不可见时,按钮.4f透明 - AlphaComposite composite = this.data.isVisible() ? (AlphaComposite)((Graphics2D)g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER,HALF_OPACITY); - ((Graphics2D)g).setComposite(composite); - super.paint(g); - } - /** - * 重命名 - * - * @param designer 表单设计器 - * @param creator 当前组件 - * - */ - public void ChangeCreatorName(FormDesigner designer,XCreator creator){ + public void makeVisible(boolean visible) { + this.opacity = visible ? FULL_OPACITY : HALF_OPACITY; + this.draw(); + } + } + + /** + * 渲染Painter + */ + public void paint(Graphics g) { + //不可见时,按钮.4f透明 + AlphaComposite composite = this.data.isVisible() ? (AlphaComposite) ((Graphics2D) g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER, HALF_OPACITY); + ((Graphics2D) g).setComposite(composite); + super.paint(g); + } + + /** + * 重命名 + * + * @param designer 表单设计器 + * @param creator 当前组件 + */ + public void ChangeCreatorName(FormDesigner designer, XCreator creator) { String oldName = creator.toData().getWidgetName(); String value = JOptionPane.showInputDialog(designer, Inter.getLocText("Form-Change_Widget_Name_Discription"), oldName); - if(value != null) { - designer.renameCreator(creator, value); + if (value != null) { + designer.renameCreator(creator, value); } - } + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 80fa7f8950..e32ba8cc53 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -1,41 +1,12 @@ package com.fr.design.mainframe; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.geom.RoundRectangle2D; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.BorderFactory; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableColumn; -import javax.swing.table.TableModel; - -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itable.GroupRenderer; -import com.fr.design.gui.itable.HeaderRenderer; -import com.fr.design.gui.itextfield.UITextField; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itable.HeaderRenderer; +import com.fr.design.gui.itextfield.UITextField; import com.fr.form.ui.Label; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WParameterLayout; @@ -43,6 +14,18 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.StringUtils; +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.table.*; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.geom.RoundRectangle2D; +import java.util.EventObject; + /** * MobileParaWidgetTable主要显示参数面板容器的控件列表,与MobileWidgetTable的区别就是该表多了UITextField这一列 * Created with IntelliJ IDEA. @@ -53,9 +36,10 @@ import com.fr.stable.StringUtils; */ class MobileParaWidgetTable extends JTable { + private final int WIDGET_NAME_COLUMN = 1; private FormDesigner designer; - private String[][] cellData ; - private String[] headers = {Inter.getLocText("FR-Utils_Label"), Inter.getLocText("Form-Widget_Name")}; + private String[][] cellData; + private String[] headers = {Inter.getLocText("Form-Widget_Name")}; private static final int WIDGET_TABLE_ROW_HEIGHT = 22; private static final int UITEXTFIELD_WIDTH = 40; private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件 @@ -75,7 +59,7 @@ class MobileParaWidgetTable extends JTable { TableColumn tc = this.getColumn(this.getColumnName(0)); tc.setPreferredWidth(UITEXTFIELD_WIDTH); this.repaint(); - this.setDefaultRenderer(Object.class,new MobileWidgetTableCellRenderer()); + this.setDefaultRenderer(Object.class, new MobileWidgetTableCellRenderer()); refreshData(); this.addMouseListener(mouseAdapter); this.addMouseMotionListener(mouseAdapter); @@ -112,12 +96,12 @@ class MobileParaWidgetTable extends JTable { */ @Override public void mouseReleased(MouseEvent e) { - if(!draging){ + if (!draging) { return; } draging = false; moveComponent.setVisible(false); - int toIndex = e.getY() < GAP ? 0 : (int)Math.rint((e.getY() - GAP)/WIDGET_TABLE_ROW_HEIGHT) + 1; + int toIndex = e.getY() < GAP ? 0 : (int) Math.rint((e.getY() - GAP) / WIDGET_TABLE_ROW_HEIGHT) + 1; //当鼠标放开时,将选中的容器调整至新的顺序 ((WParameterLayout) designer.getParaComponent().toData()).adjustOrder(selectedRow, toIndex); //拿取排序后表格数据,然后重绘表格 @@ -135,13 +119,13 @@ class MobileParaWidgetTable extends JTable { public void mouseMoved(MouseEvent e) { int overColumn = e.getX() < getColumnModel().getColumn(0).getWidth() ? 0 : 1; // 判断当前鼠标在哪一列 int overRow = -1; - for (int i = 0;i < getRowCount();i++) { + for (int i = 0; i < getRowCount(); i++) { if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT) { overRow = i; //判断当前鼠标在哪一行 } } //如果鼠标移动到当前选中的行列上面的时候,并且不能在第一列 - if (overRow == selectedRow && overColumn == selectedColumn && overColumn !=0) { + if (overRow == selectedRow && overColumn == selectedColumn && overColumn != 0) { //把当前选中的那一列行的光标改成(除了第一列)移动样式MOVE_CURSOR setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } else { @@ -156,34 +140,31 @@ class MobileParaWidgetTable extends JTable { */ @Override public void mouseDragged(MouseEvent e) { - int width = getColumnModel().getColumn(1).getWidth(); - //如果点击选中的是第二列,就可以拖动 - if (selectedColumn == 1){ - setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - draging = true; - moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString()); - moveComponent.setLocation(getColumnModel().getColumn(0).getWidth(), e.getY() - GAP); - moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT)); - moveComponent.setVisible(true); - moveComponent.setForeground(Color.lightGray); - moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); - } + int width = getColumnModel().getColumn(0).getWidth(); + setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + draging = true; + moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString()); + moveComponent.setLocation(getColumnModel().getColumn(0).getWidth(), e.getY() - GAP); + moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT)); + moveComponent.setVisible(true); + moveComponent.setForeground(Color.lightGray); + moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); } /** - * 设置鼠标单击时处理的事件(单击第二列的控件列表进入控件属性表) + * 设置鼠标单击时处理的事件 * @param e */ @Override public void mouseClicked(MouseEvent e) { - if(getSelectedRow() != -1 && getSelectedColumn() == 1){ + if (getSelectedRow() != -1 && getSelectedColumn() == 0) { String widgetName = cellData[getSelectedRow()][getSelectedColumn()]; - if (StringUtils.isNotEmpty(widgetName)){ + if (StringUtils.isNotEmpty(widgetName)) { int count = getEditingDesigner().getParaComponent().getComponentCount(); - for (int i = 0; i < count; i++){ - XCreator xCreator = (XCreator)getEditingDesigner().getParaComponent().getComponent(i); + for (int i = 0; i < count; i++) { + XCreator xCreator = (XCreator) getEditingDesigner().getParaComponent().getComponent(i); Widget widget = xCreator.toData(); - if (!widget.acceptType(Label.class) && ComparatorUtils.equals(widgetName,widget.getWidgetName())) { + if (!widget.acceptType(Label.class) && ComparatorUtils.equals(widgetName, widget.getWidgetName())) { //设置选中的component,这句代码控制点击之后跳转到相应component属性表 getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator); } @@ -204,12 +185,12 @@ class MobileParaWidgetTable extends JTable { } }; - public MobileParaWidgetTable getInstance(){ + public MobileParaWidgetTable getInstance() { return this; } - private FormDesigner getEditingDesigner(){ - return designer; + private FormDesigner getEditingDesigner() { + return designer; } /** @@ -229,8 +210,8 @@ class MobileParaWidgetTable extends JTable { /** * 重新get排序后的数据 */ - public void refreshData(){ - cellData = getData(); + public void refreshData() { + cellData = getData(); } /** @@ -238,30 +219,30 @@ class MobileParaWidgetTable extends JTable { * * @return String[][] 二维数组,[0][0]widgetTag, [0][1]widgetName */ - private String[][] getData(){ - XLayoutContainer paraContainer = designer.getParaComponent(); - if(paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)){ - return new String[0][0]; - } - - WParameterLayout para = (WParameterLayout) (paraContainer.toData()); + private String[][] getData() { + XLayoutContainer paraContainer = designer.getParaComponent(); + if (paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)) { + return new String[0][1]; + } + + WParameterLayout para = (WParameterLayout) (paraContainer.toData()); return para.getWidgetNameTag(); } /** * 自定义的tableRender类 */ - private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer{ + private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - if (column == 0){ + if (column == 0) { UITextField uiTableTextField; - if (getSelectedColumn() == column && getSelectedRow() == row){ - uiTableTextField = new UITableTextField(value.toString()); + if (getSelectedColumn() == column && getSelectedRow() == row) { + uiTableTextField = new UITableTextField(value.toString()); } else { - uiTableTextField = new UITextField(value.toString()); + uiTableTextField = new UITextField(value.toString()); } return uiTableTextField; } @@ -275,7 +256,8 @@ class MobileParaWidgetTable extends JTable { */ private class MobileCellEditor extends AbstractCellEditor implements TableCellEditor { UITableTextField uiTableTextField; - MobileCellEditor(){ + + MobileCellEditor() { uiTableTextField = new UITableTextField(); uiTableTextField.addFocusListener(new FocusAdapter() { @Override @@ -306,7 +288,7 @@ class MobileParaWidgetTable extends JTable { * cell改变,相应的nametag改变 */ - private void firePropertyChange(){ + private void firePropertyChange() { ((WParameterLayout) designer.getParaComponent().toData()).add2NameTagMap(uiTableTextField.getText(), cellData[getSelectedRow()][1]); ((WParameterLayout) designer.getParaComponent().toData()).setNameTagModified(cellData[getSelectedRow()][1], @@ -314,21 +296,21 @@ class MobileParaWidgetTable extends JTable { } @Override - public Object getCellEditorValue(){ + public Object getCellEditorValue() { return uiTableTextField.getText(); } /** - * 双击以编辑, 表示只有双击的情况下才可以编辑 - */ + * 双击以编辑, 表示只有双击的情况下才可以编辑 + */ @Override public boolean isCellEditable(EventObject anEvent) { return !(anEvent instanceof MouseEvent) || ((MouseEvent) anEvent).getClickCount() >= 2; } @Override - public Component getTableCellEditorComponent( JTable table,Object value, - boolean isSelected,int row,int column){ + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { uiTableTextField.setText(value.toString()); return uiTableTextField; } @@ -360,7 +342,7 @@ class MobileParaWidgetTable extends JTable { } Object[] rowValue = cellData[row]; if (column > -1 && column < rowValue.length) { - return cellData[row][column]; + return cellData[row][WIDGET_NAME_COLUMN]; } return null; } @@ -381,23 +363,21 @@ class MobileParaWidgetTable extends JTable { return; } if (aValue == null) { - cellData[row][column] = null; + cellData[row][WIDGET_NAME_COLUMN] = null; return; } - cellData[row][column] = aValue.toString(); + cellData[row][WIDGET_NAME_COLUMN] = aValue.toString(); } /** - * 是否可编辑 控件标签列可以编辑,控件名不可编辑 - * @param row 行号 - * @param column 列号 + * 是否可编辑 控件标签列可以编辑,控件名不可编辑 + * + * @param row 行号 + * @param column 列号 * @return 是否可编辑 */ public boolean isCellEditable(int row, int column) { - if(column ==1){ - return false; - } - return true; + return false; } } @@ -406,11 +386,11 @@ class MobileParaWidgetTable extends JTable { * 继承自JTextField类,重写了编辑框的样式 */ private class UITableTextField extends UITextField { - public UITableTextField(){ + public UITableTextField() { super(); } - public UITableTextField(String string){ + public UITableTextField(String string) { super(string); }