diff --git a/build.9.0.gradle b/build.9.0.gradle index 8268c0f6b..f2fe42850 100644 --- a/build.9.0.gradle +++ b/build.9.0.gradle @@ -11,12 +11,12 @@ task appletJar<<{ mkdir(dir:"./tmp") mkdir(dir:"build/classes/main") copy(todir:"build/classes/"){ - fileset(dir:"${basicDir}/core/build/classes/main") fileset(dir:"${basicDir}/chart/build/classes/main") fileset(dir:"${basicDir}/report/build/classes/main") fileset(dir:"${basicDir}/platform/build/classes/main") } - unjar(src:"${libDir}/3rd.jar",dest:"./tmp") + unjar(src:"${libDir}/fr-core-9.0.jar",dest:"./tmp") + unjar(src:"${libDir}/fr-third-9.0.jar",dest:"./tmp") unjar(src:"${libDir}/servlet-api.jar",dest:"./tmp") jar(jarfile:"build/libs/fr-applet-9.0.jar"){ fileset(dir:"build/classes"){ diff --git a/designer/designer.iml b/designer/designer.iml deleted file mode 100644 index 9ff693f28..000000000 --- a/designer/designer.iml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/ButtonGroupAction.java b/designer/src/com/fr/design/actions/ButtonGroupAction.java index ad461c1f0..b45a5d34a 100644 --- a/designer/src/com/fr/design/actions/ButtonGroupAction.java +++ b/designer/src/com/fr/design/actions/ButtonGroupAction.java @@ -6,12 +6,12 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.mainframe.ElementCasePane; public abstract class ButtonGroupAction extends ElementCaseAction{ - protected Icon[] iconArray; + protected Icon[][] iconArray; protected Integer[] valueArray; private UIButtonGroup group; - protected ButtonGroupAction(ElementCasePane t, Icon[] iconArray, Integer[] valueArray) { + protected ButtonGroupAction(ElementCasePane t, Icon[][] iconArray, Integer[] valueArray) { super(t); this.iconArray = iconArray; this.valueArray = valueArray; @@ -36,7 +36,7 @@ public abstract class ButtonGroupAction extends ElementCaseAction{ break; } } - if(value == -1 && createToolBarComponent().hasClick()) { + if(createToolBarComponent().hasClick()) { index = getSelectedIndex(); createToolBarComponent().setClickState(false); } diff --git a/designer/src/com/fr/design/actions/cell/AbstractCellElementAction.java b/designer/src/com/fr/design/actions/cell/AbstractCellElementAction.java index 49eab9911..457c5bf72 100644 --- a/designer/src/com/fr/design/actions/cell/AbstractCellElementAction.java +++ b/designer/src/com/fr/design/actions/cell/AbstractCellElementAction.java @@ -1,10 +1,10 @@ package com.fr.design.actions.cell; import com.fr.design.actions.CellSelectionAction; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.GridUtils; import com.fr.grid.selection.CellSelection; @@ -14,87 +14,93 @@ import com.fr.report.core.SheetUtils; import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.stable.ReportConstants; -// TODO ALEX_SEP 这个类与AbstractCellAction有什么关系? +/** + * TODO ALEX_SEP 这个类与AbstractCellAction有什么关系? + * + * @author null + */ public abstract class AbstractCellElementAction extends CellSelectionAction { - protected AbstractCellElementAction(ElementCasePane t) { - super(t); - } - - @Override - protected boolean executeActionReturnUndoRecordNeededWithCellSelection(CellSelection cs) { - final ElementCasePane ePane = this.getEditingComponent(); - final TemplateElementCase tplEC = ePane.getEditingElementCase(); - TemplateCellElement editCellElement = tplEC.getTemplateCellElement(cs.getColumn(), cs.getRow()); - if (editCellElement == null) { - editCellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); - tplEC.addCellElement(editCellElement); - } - if (tplEC != null) { - SheetUtils.calculateDefaultParent(tplEC); - } - final CellSelection finalCS = cs; - final BasicPane bp = populateBasicPane(editCellElement); - BasicDialog dialog = bp.showWindow(DesignerContext.getDesignerFrame()); - dialog.addDialogActionListener(new DialogActionAdapter() { - @Override - public void doOk() { - // 需要先行后列地增加新元素。 - for (int j = 0; j < finalCS.getRowSpan(); j++) { - for (int i = 0; i < finalCS.getColumnSpan(); i++) { - int column = i + finalCS.getColumn(); - int row = j + finalCS.getRow(); - TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); - if (editCellElement == null) { - editCellElement = new DefaultTemplateCellElement(column, row); - tplEC.addCellElement(editCellElement); - } - // alex:不加这一句话会导致跨行跨列的格子被多次update - if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { - continue; - } - updateBasicPane(bp, editCellElement); - // update cell attributes - if (isNeedShinkToFit()) { - // shink to fit.(如果value是String) - Object editElementValue = editCellElement.getValue(); - if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { - // TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 - GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); - } - } - } - } - ePane.fireTargetModified(); - } - }); + + protected AbstractCellElementAction() { + super(); + } + + protected AbstractCellElementAction(ElementCasePane t) { + super(t); + } + + @Override + protected boolean executeActionReturnUndoRecordNeededWithCellSelection(CellSelection cs) { + final ElementCasePane ePane = this.getEditingComponent(); + final TemplateElementCase tplEC = ePane.getEditingElementCase(); + TemplateCellElement editCellElement = tplEC.getTemplateCellElement(cs.getColumn(), cs.getRow()); + if (editCellElement == null) { + editCellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); + tplEC.addCellElement(editCellElement); + } + SheetUtils.calculateDefaultParent(tplEC); + final CellSelection finalCS = cs; + final BasicPane bp = populateBasicPane(editCellElement); + BasicDialog dialog = bp.showWindow(DesignerContext.getDesignerFrame()); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + // 需要先行后列地增加新元素。 + for (int j = 0; j < finalCS.getRowSpan(); j++) { + for (int i = 0; i < finalCS.getColumnSpan(); i++) { + int column = i + finalCS.getColumn(); + int row = j + finalCS.getRow(); + TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); + if (editCellElement == null) { + editCellElement = new DefaultTemplateCellElement(column, row); + tplEC.addCellElement(editCellElement); + } + // alex:不加这一句话会导致跨行跨列的格子被多次update + if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { + continue; + } + updateBasicPane(bp, editCellElement); + // update cell attributes + if (isNeedShinkToFit()) { + // shink to fit.(如果value是String) + Object editElementValue = editCellElement.getValue(); + if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { + // TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 + GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); + } + } + } + } + ePane.fireTargetModified(); + } + }); //控件设置记住dlg,提交入库智能添加单元格后可以show出来 DesignerContext.setReportWritePane(dialog); - dialog.setVisible(true); - return false; - } + dialog.setVisible(true); + return false; + } - /** - * 初始化对话框 - * - * @param cellElement - * @return - */ - protected abstract BasicPane populateBasicPane(TemplateCellElement cellElement); + /** + * 初始化对话框 + * + * @param cellElement 单元格 + * @return 对话框 + */ + protected abstract BasicPane populateBasicPane(TemplateCellElement cellElement); - /** - * 更新对话框之后,改变值 - * - * @param cellElement - * @return - */ - protected abstract void updateBasicPane(BasicPane basicPane, TemplateCellElement cellElement); + /** + * 更新对话框之后,改变值 + * + * @param cellElement 单元格 + */ + protected abstract void updateBasicPane(BasicPane basicPane, TemplateCellElement cellElement); - /** - * if isNeedShinkToFit,please override this method - * - * @return isNeedShinkToFit - */ - protected boolean isNeedShinkToFit() { - return false; - } + /** + * if isNeedShinkToFit,please override this method + * + * @return isNeedShinkToFit + */ + protected boolean isNeedShinkToFit() { + return false; + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/CellAttributeAction.java b/designer/src/com/fr/design/actions/cell/CellAttributeAction.java index 949d72de0..e2455a159 100644 --- a/designer/src/com/fr/design/actions/cell/CellAttributeAction.java +++ b/designer/src/com/fr/design/actions/cell/CellAttributeAction.java @@ -1,5 +1,6 @@ package com.fr.design.actions.cell; +import com.fr.base.BaseUtils; import com.fr.design.menu.KeySetUtils; import com.fr.general.Inter; @@ -9,9 +10,9 @@ import com.fr.general.Inter; public class CellAttributeAction extends CellAttributeTableAction { public CellAttributeAction() { this.setMenuKeySet(KeySetUtils.CELL_OTHER_ATTR); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - // this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cellAttr.png")); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cellAttr.png")); } @Override diff --git a/designer/src/com/fr/design/actions/cell/CellAttributeTableAction.java b/designer/src/com/fr/design/actions/cell/CellAttributeTableAction.java index 2906306d0..70812af32 100644 --- a/designer/src/com/fr/design/actions/cell/CellAttributeTableAction.java +++ b/designer/src/com/fr/design/actions/cell/CellAttributeTableAction.java @@ -1,9 +1,10 @@ package com.fr.design.actions.cell; -import java.awt.event.ActionEvent; - import com.fr.design.actions.UpdateAction; import com.fr.design.mainframe.CellElementPropertyPane; +import com.fr.design.mainframe.EastRegionContainerPane; + +import java.awt.event.ActionEvent; /** * 所有的CellAttributeTableAction都是指向单元格属性表的,点了就自动跳转到单元格属性表 @@ -20,4 +21,9 @@ public abstract class CellAttributeTableAction extends UpdateAction { CellElementPropertyPane.getInstance().GoToPane(getID()); } + @Override + public void update() { + super.update(); + this.setEnabled(EastRegionContainerPane.getInstance().isCellAttrPaneEnabled()); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/CellWidgetAttrAction.java b/designer/src/com/fr/design/actions/cell/CellWidgetAttrAction.java index f5307b2ac..e6f0fec24 100644 --- a/designer/src/com/fr/design/actions/cell/CellWidgetAttrAction.java +++ b/designer/src/com/fr/design/actions/cell/CellWidgetAttrAction.java @@ -1,24 +1,18 @@ package com.fr.design.actions.cell; import com.fr.base.BaseUtils; -import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.actions.UpdateAction; +import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.menu.KeySetUtils; -import com.fr.design.present.CellWriteAttrPane; -import com.fr.design.dialog.BasicPane; -import com.fr.form.ui.Widget; -import com.fr.general.FRLogger; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.privilege.finegrain.WidgetPrivilegeControl; -import com.fr.report.cell.TemplateCellElement; + +import java.awt.event.ActionEvent; /** * Cell Widget Attribute. */ -public class CellWidgetAttrAction extends AbstractCellElementAction { +public class CellWidgetAttrAction extends UpdateAction { - public CellWidgetAttrAction(ElementCasePane t) { - super(t); + public CellWidgetAttrAction() { this.setMenuKeySet(KeySetUtils.CELL_WIDGET_ATTR); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); @@ -26,47 +20,14 @@ public class CellWidgetAttrAction extends AbstractCellElementAction { } @Override - protected BasicPane populateBasicPane(TemplateCellElement cellElement) { - CellWriteAttrPane pane = new CellWriteAttrPane(this.getEditingComponent()); - //got simple cell element from column and row. - pane.populate(cellElement); - - return pane; - } - - @Override - protected void updateBasicPane(BasicPane bp, TemplateCellElement cellElement) { - CellWriteAttrPane pane = (CellWriteAttrPane) bp; - if (cellElement.getWidget() == null) { - pane.update(cellElement); - return; - } - try { - Widget oldWidget = (Widget) cellElement.getWidget().clone(); - pane.update(cellElement); - //这边需要重新设置权限细粒度的hashset是因为Update是直接生成一个新的来update的,所以以前里面的hashset都没有了 - Widget newWidget = cellElement.getWidget(); - if (newWidget.getClass() == oldWidget.getClass()) { - newWidget.setWidgetPrivilegeControl((WidgetPrivilegeControl) oldWidget.getWidgetPrivilegeControl().clone()); - } - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - - @Override - protected boolean isNeedShinkToFit() { - return true; + public void actionPerformed(ActionEvent e) { + EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS); + EastRegionContainerPane.getInstance().setWindow2PreferWidth(); } @Override public void update() { - ElementCasePane ePane = this.getEditingComponent(); - Selection sel = ePane.getSelection(); - if (sel instanceof CellSelection) { - this.setEnabled(true); - } else { - this.setEnabled(false); - } + super.update(); + this.setEnabled(EastRegionContainerPane.getInstance().isWidgetSettingsPaneEnabled()); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/ConditionAttributesAction.java b/designer/src/com/fr/design/actions/cell/ConditionAttributesAction.java new file mode 100644 index 000000000..1aecf94d5 --- /dev/null +++ b/designer/src/com/fr/design/actions/cell/ConditionAttributesAction.java @@ -0,0 +1,35 @@ +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.actions.cell; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.menu.KeySetUtils; + +import java.awt.event.ActionEvent; + +/** + * Condition Attributes. + */ +public class ConditionAttributesAction extends UpdateAction { + public ConditionAttributesAction() { + this.setMenuKeySet(KeySetUtils.CONDITION_ATTR); + this.setName(getMenuKeySet().getMenuKeySetName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/highlight.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_CONDITION_ATTR); + EastRegionContainerPane.getInstance().setWindow2PreferWidth(); + } + + @Override + public void update() { + super.update(); + this.setEnabled(EastRegionContainerPane.getInstance().isConditionAttrPaneEnabled()); + } +} \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java b/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java index 27adef643..63c38a042 100644 --- a/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java +++ b/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java @@ -186,6 +186,7 @@ public class GlobalStyleMenuDef extends MenuDef { } stylePane.updateGlobalStyle(getEditingComponent()); + CellElementPropertyPane.getInstance().GoToPane(Inter.getLocText("FR-Designer-Widget_Style")); return true; } diff --git a/designer/src/com/fr/design/actions/cell/style/AlignmentAction.java b/designer/src/com/fr/design/actions/cell/style/AlignmentAction.java index 326b47f65..acc9b6302 100644 --- a/designer/src/com/fr/design/actions/cell/style/AlignmentAction.java +++ b/designer/src/com/fr/design/actions/cell/style/AlignmentAction.java @@ -1,40 +1,49 @@ package com.fr.design.actions.cell.style; -import javax.swing.Icon; - import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.base.chart.BaseChartCollection; -import com.fr.design.constants.UIConstants; import com.fr.design.actions.ButtonGroupAction; import com.fr.design.actions.utils.ReportActionUtils; +import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.general.Inter; +import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.mainframe.ElementCasePane; +import com.fr.general.Inter; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.report.cell.FloatElement; import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.Constants; + +import javax.swing.*; public class AlignmentAction extends ButtonGroupAction implements StyleActionInterface { - public AlignmentAction(ElementCasePane t, Icon[] iconArray, - Integer[] valueArray) { - super(t, iconArray, valueArray); - } + private static final Icon[][] ICONS = new Icon[][]{ + {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")}, + {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")}, + {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")}}; - /** - * executeStyle - * - * @param style - * @param selectedStyle - * @return style - */ - public Style executeStyle(Style style, Style selectedStyle) { - return style.deriveHorizontalAlignment(getSelectedValue()); - } + private static final Integer[] valueArray = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}; + + public AlignmentAction(ElementCasePane t) { + super(t, ICONS, valueArray); + } + + + /** + * executeStyle + * + * @param style + * @param selectedStyle + * @return style + */ + public Style executeStyle(Style style, Style selectedStyle) { + return style.deriveHorizontalAlignment(getSelectedValue()); + } /** * 更新Style @@ -45,67 +54,67 @@ public class AlignmentAction extends ButtonGroupAction implements StyleActionInt setSelectedIndex(BaseUtils.getAlignment4Horizontal(style)); } - /** - * executeActionReturnUndoRecordNeeded - * - * @return - */ - public boolean executeActionReturnUndoRecordNeeded() { - ElementCasePane reportPane = this.getEditingComponent(); - if (reportPane == null) { - return false; - } - - return ReportActionUtils.executeAction(this, reportPane); - } - - /** - * update - */ - public void update() { - super.update(); - - //peter:如果当前没有ReportFrame,不需要继续. - if (!this.isEnabled()) { - return; - } - - //got simple cell element from row and column - ElementCasePane reportPane = this.getEditingComponent(); - if (reportPane == null) { - this.setEnabled(false); - return; - } - Selection cs = reportPane.getSelection(); - TemplateElementCase tplEC = reportPane.getEditingElementCase(); - - if (tplEC != null && cs instanceof FloatSelection) { - FloatElement selectedFloat = tplEC.getFloatElement(((FloatSelection) cs).getSelectedFloatName()); - Object value = selectedFloat.getValue(); - if (value instanceof BaseChartCollection) { - this.setEnabled(false); - return; - } - } - this.updateStyle(ReportActionUtils.getCurrentStyle(reportPane)); - } - - /** - * 创建工具条,且有提示 - * - * @return - */ - public UIButtonGroup createToolBarComponent() { - UIButtonGroup group = super.createToolBarComponent(); - if (group != null) { - group.setForToolBarButtonGroup(true); - group.setAllToolTips(new String[]{Inter.getLocText("StyleAlignment-Left"), Inter.getLocText("Center"), Inter.getLocText("StyleAlignment-Right")}); - } - for (int i = 0; i < 3; i++) { - group.getButton(i).setRoundBorder(true, UIConstants.ARC); - group.getButton(i).setBorderPainted(true); - } - return group; - } + /** + * executeActionReturnUndoRecordNeeded + * + * @return + */ + public boolean executeActionReturnUndoRecordNeeded() { + ElementCasePane reportPane = this.getEditingComponent(); + if (reportPane == null) { + return false; + } + + return ReportActionUtils.executeAction(this, reportPane); + } + + /** + * update + */ + public void update() { + super.update(); + + //peter:如果当前没有ReportFrame,不需要继续. + if (!this.isEnabled()) { + return; + } + + //got simple cell element from row and column + ElementCasePane reportPane = this.getEditingComponent(); + if (reportPane == null) { + this.setEnabled(false); + return; + } + Selection cs = reportPane.getSelection(); + TemplateElementCase tplEC = reportPane.getEditingElementCase(); + + if (tplEC != null && cs instanceof FloatSelection) { + FloatElement selectedFloat = tplEC.getFloatElement(((FloatSelection) cs).getSelectedFloatName()); + Object value = selectedFloat.getValue(); + if (value instanceof BaseChartCollection) { + this.setEnabled(false); + return; + } + } + this.updateStyle(ReportActionUtils.getCurrentStyle(reportPane)); + } + + /** + * 创建工具条,且有提示 + * + * @return + */ + public UIButtonGroup createToolBarComponent() { + UIButtonGroup group = super.createToolBarComponent(); + if (group != null) { + group.setForToolBarButtonGroup(true); + group.setAllToolTips(new String[]{Inter.getLocText("StyleAlignment-Left"), Inter.getLocText("Center"), Inter.getLocText("StyleAlignment-Right")}); + } + for (int i = 0; i < 3; i++) { + group.getButton(i).setRoundBorder(true, UIConstants.ARC); + group.getButton(i).setBorderPainted(true); + } + return group; + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/style/ReportFontBoldAction.java b/designer/src/com/fr/design/actions/cell/style/ReportFontBoldAction.java index 101d1f1f0..7b62ffb51 100644 --- a/designer/src/com/fr/design/actions/cell/style/ReportFontBoldAction.java +++ b/designer/src/com/fr/design/actions/cell/style/ReportFontBoldAction.java @@ -8,24 +8,27 @@ import com.fr.base.Style; import com.fr.base.core.StyleUtils; import com.fr.design.actions.ToggleButtonUpdateAction; import com.fr.design.gui.ibutton.UIToggleButton; -import com.fr.general.FRFont; -import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.Inter; + +import javax.swing.*; /** * Bold. */ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleButtonUpdateAction { - private UIToggleButton button; - protected Style style; + private UIToggleButton button; + protected Style style; + private final static Icon[] ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")}; - public ReportFontBoldAction(ElementCasePane t) { - super(t); + public ReportFontBoldAction(ElementCasePane t) { + super(t); - this.setName(Inter.getLocText("FRFont-bold")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); - } + this.setName(Inter.getLocText("FRFont-bold")); + this.setSmallIcon(ICONS, true); + } /** * 根据按钮状态获取格式 @@ -45,16 +48,17 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB createToolBarComponent().setSelected(true); } - return this.style; - } + return this.style; + } - protected void setSelectedFont(Style style) { - this.style = StyleUtils.boldReportFont(style); - } - protected void setUnselectedFont(Style style) { - this.style = StyleUtils.unBoldReportFont(style); - } + protected void setSelectedFont(Style style) { + this.style = StyleUtils.boldReportFont(style); + } + + protected void setUnselectedFont(Style style) { + this.style = StyleUtils.unBoldReportFont(style); + } /** * Update Style. @@ -71,21 +75,21 @@ public class ReportFontBoldAction extends AbstractStyleAction implements ToggleB createToolBarComponent().setSelected(isStyle(frFont)); } - protected boolean isStyle(FRFont frFont) { - return frFont.isBold(); - } + protected boolean isStyle(FRFont frFont) { + return frFont.isBold(); + } - /** - * Gets component on toolbar. - * - * @return the created components on toolbar. - */ - @Override - public UIToggleButton createToolBarComponent() { - if (button == null) { - button = GUICoreUtils.createToolBarComponent(this); - button.setEventBannded(true); - } - return button; - } + /** + * Gets component on toolbar. + * + * @return the created components on toolbar. + */ + @Override + public UIToggleButton createToolBarComponent() { + if (button == null) { + button = GUICoreUtils.createToolBarComponentWhiteIcon(this); + button.setEventBannded(true); + } + return button; + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/cell/style/ReportFontItalicAction.java b/designer/src/com/fr/design/actions/cell/style/ReportFontItalicAction.java index 1e6c87a1a..9fdf217da 100644 --- a/designer/src/com/fr/design/actions/cell/style/ReportFontItalicAction.java +++ b/designer/src/com/fr/design/actions/cell/style/ReportFontItalicAction.java @@ -10,16 +10,20 @@ import com.fr.general.FRFont; import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; +import javax.swing.*; + /** * Bold. */ public class ReportFontItalicAction extends ReportFontBoldAction { - - public ReportFontItalicAction(ElementCasePane t) { + + private final static Icon[] ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")}; + + public ReportFontItalicAction(ElementCasePane t) { super(t); - this.setName(Inter.getLocText("FRFont-italic")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + this.setName(Inter.getLocText("FR-Designer-FRFont_Italic")); + this.setSmallIcon(ICONS, true); } @@ -31,7 +35,6 @@ public class ReportFontItalicAction extends ReportFontBoldAction { this.style = StyleUtils.unItalicReportFont(style); } - protected boolean isStyle(FRFont frFont) { return frFont.isItalic(); } diff --git a/designer/src/com/fr/design/actions/cell/style/ReportFontUnderlineAction.java b/designer/src/com/fr/design/actions/cell/style/ReportFontUnderlineAction.java index e79782abf..b44d696ce 100644 --- a/designer/src/com/fr/design/actions/cell/style/ReportFontUnderlineAction.java +++ b/designer/src/com/fr/design/actions/cell/style/ReportFontUnderlineAction.java @@ -11,15 +11,20 @@ import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; import com.fr.stable.Constants; +import javax.swing.*; + /** * Bold. */ public class ReportFontUnderlineAction extends ReportFontBoldAction { - public ReportFontUnderlineAction(ElementCasePane t) { + + private final static Icon[] ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline_white.png")}; + + public ReportFontUnderlineAction(ElementCasePane t) { super(t); this.setName(Inter.getLocText("FRFont-Underline")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); + this.setSmallIcon(ICONS, true); } protected void setSelectedFont (Style style) { diff --git a/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java b/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java index 8143409cf..55c5f95ab 100644 --- a/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java +++ b/designer/src/com/fr/design/actions/columnrow/DSColumnConditionAction.java @@ -9,16 +9,34 @@ import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.report.cell.TemplateCellElement; +/** + * 数据列过滤条件Action + * + * @author null + * @version 2017年11月17日15点11分 + * @since 8.0 + */ public class DSColumnConditionAction extends AbstractCellElementAction { + public DSColumnConditionAction() { + super(); + this.setName(Inter.getLocText("Filter")); + this.setMnemonic('E'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/expand/cellAttr.gif")); + } + public DSColumnConditionAction(ElementCasePane t) { super(t); - this.setName(Inter.getLocText("Filter")); this.setMnemonic('E'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/expand/cellAttr.gif")); } + @Override + public void setEditingComponent(ElementCasePane casePane) { + super.setEditingComponent(casePane); + } + @Override protected BasicPane populateBasicPane(TemplateCellElement cellElement) { DSColumnConditionsPane dSColumnConditionsPane = new DSColumnConditionsPane(); diff --git a/designer/src/com/fr/design/actions/edit/HyperlinkAction.java b/designer/src/com/fr/design/actions/edit/HyperlinkAction.java new file mode 100644 index 000000000..269d50917 --- /dev/null +++ b/designer/src/com/fr/design/actions/edit/HyperlinkAction.java @@ -0,0 +1,30 @@ +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.actions.edit; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.menu.KeySetUtils; + +import java.awt.event.ActionEvent; + +/** + * HyperlinkAction. + */ +public class HyperlinkAction extends UpdateAction { + + public HyperlinkAction() { + this.setMenuKeySet(KeySetUtils.HYPER_LINK); + this.setName(getMenuKeySet().getMenuKeySetName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/hyperLink.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_HYPERLINK); + EastRegionContainerPane.getInstance().setWindow2PreferWidth(); + } +} \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java b/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java index e80e75fb9..13a836c92 100644 --- a/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java +++ b/designer/src/com/fr/design/actions/file/export/AbstractExportAction.java @@ -139,7 +139,7 @@ public abstract class AbstractExportAction extends JWorkBookAction { if (exporter instanceof AppExporter) { AppExporter appExporter = (AppExporter) exporter; if (exporter instanceof ExcelExporter || exporter instanceof CSVExporter - || exporter instanceof PDFExporterProcessor || exporter instanceof WordExporter) { + || exporter instanceof PDFExporterProcessor || exporter instanceof WordExporter) { ReportHelper.clearFormulaResult(tpl);// 清空rpt中的公式计算结果 appExporter.export(fileOutputStream, tpl.execute(parameterMap, ActorFactory.getActor(ActorConstants.TYPE_PAGE) diff --git a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java index 499b9119d..56abd1e35 100644 --- a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java @@ -3,8 +3,8 @@ */ package com.fr.design.actions.insert.cell; +import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; -import com.fr.base.Formula; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; @@ -48,6 +48,6 @@ public class FormulaCellAction extends AbstractCellAction implements WorkBookSup @Override public Class getCellValueClass() { - return Formula.class; + return BaseFormula.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java index 8f20a1577..292d4f287 100644 --- a/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -4,6 +4,7 @@ package com.fr.design.actions.insert.flot; import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; import com.fr.base.Style; import com.fr.base.chart.BaseChartCollection; import com.fr.design.actions.ElementCaseAction; @@ -16,10 +17,14 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.Constants; import com.fr.stable.bridge.StableFactory; +import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; import javax.swing.*; @@ -30,13 +35,15 @@ import java.awt.*; */ public class ChartFloatAction extends ElementCaseAction { + private boolean isRecordNeeded; + /** * 构造函数 图表插入悬浮元素 */ public ChartFloatAction(ElementCasePane t) { super(t); this.setMenuKeySet(FLOAT_INSERT_CHART); - this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/chart.png")); } @@ -64,9 +71,10 @@ public class ChartFloatAction extends ElementCaseAction { * @return 是则返回true */ public boolean executeActionReturnUndoRecordNeeded() { + isRecordNeeded = false; final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); if (reportPane == null) { - return false; + return isRecordNeeded; } reportPane.stopEditing(); @@ -78,25 +86,41 @@ public class ChartFloatAction extends ElementCaseAction { chartDialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { - + isRecordNeeded = true; FloatElement newFloatElement; try { newFloatElement = new FloatElement(chartDialog.getChartCollection().clone()); - newFloatElement.setLeftDistance(new OLDPIX(20)); - newFloatElement.setTopDistance(new OLDPIX(20)); newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); + Grid grid = reportPane.getGrid(); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int resolution = grid.getResolution(); + int floatWdith = newFloatElement.getWidth().toPixI(resolution); + int floatHeight = newFloatElement.getWidth().toPixI(resolution); + + int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; + int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; + FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); + FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); + + FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); + FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); + + newFloatElement.setLeftDistance(leftDistance); + newFloatElement.setTopDistance(topDistance); + Style style = newFloatElement.getStyle(); if (style != null) { - newFloatElement.setStyle(style.deriveBorder(Constants.LINE_NONE, Color.black, - Constants.LINE_NONE, Color.black, - Constants.LINE_NONE, Color.black, - Constants.LINE_NONE, Color.black)); + newFloatElement.setStyle(style.deriveBorder(Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black)); } reportPane.getEditingElementCase().addFloatElement(newFloatElement); reportPane.setSelection(new FloatSelection(newFloatElement.getName())); - reportPane.fireTargetModified(); reportPane.fireSelectionChangeListener(); } catch (CloneNotSupportedException e) { FRLogger.getLogger().error("Error in Float"); @@ -105,6 +129,6 @@ public class ChartFloatAction extends ElementCaseAction { }); chartDialog.setVisible(true); - return true; + return isRecordNeeded; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java index de7cbe582..99f0b3157 100644 --- a/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/FormulaFloatAction.java @@ -1,98 +1,128 @@ -/* - * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. - */ -package com.fr.design.actions.insert.flot; - -import com.fr.base.BaseUtils; -import com.fr.base.DynamicUnitList; -import com.fr.base.Formula; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.menu.MenuKeySet; -import com.fr.general.Inter; -import com.fr.grid.Grid; -import com.fr.grid.selection.FloatSelection; -import com.fr.report.ReportHelper; -import com.fr.report.cell.FloatElement; -import com.fr.report.elementcase.TemplateElementCase; -import com.fr.stable.unit.FU; - -import javax.swing.*; -import java.awt.event.ActionEvent; - -/** - * Insert formula. - */ -public class FormulaFloatAction extends AbstractShapeAction { - public FormulaFloatAction(ElementCasePane t) { - super(t); - this.setMenuKeySet(FLOAT_INSERT_FORMULA); - this.setName(getMenuKeySet().getMenuKeySetName() + "..."); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); - } - - public static final MenuKeySet FLOAT_INSERT_FORMULA = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'F'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Designer_Insert_Formula"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; - - /** - * 动作 - * - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - ElementCasePane jws = getEditingComponent(); - if (jws == null) { - return; - } - // - FloatElement floatElement = new FloatElement(new Formula("")); - this.startDraw(floatElement); - doWithDrawingFloatElement(); - jws.getGrid().startEditing(); - } - - private void doWithDrawingFloatElement() { - ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - Grid grid = jws.getGrid(); - - ElementCasePane reportPane = grid.getElementCasePane(); - TemplateElementCase report = reportPane.getEditingElementCase(); - DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); - DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); - - int horizentalScrollValue = grid.getHorizontalValue(); - int verticalScrollValue = grid.getVerticalValue(); - - int resolution = grid.getResolution(); - int floatWdith = grid.getDrawingFloatElement().getWidth().toPixI(resolution); - int floatHeight = grid.getDrawingFloatElement().getWidth().toPixI(resolution); - - FU evtX_fu = FU.valueOfPix((grid.getWidth() - floatWdith) / 2, resolution); - FU evtY_fu = FU.valueOfPix((grid.getHeight() - floatHeight) / 2, resolution); - - FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); - FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); - - grid.getDrawingFloatElement().setLeftDistance(leftDistance); - grid.getDrawingFloatElement().setTopDistance(topDistance); - - report.addFloatElement(grid.getDrawingFloatElement()); - reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); - } - +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.design.actions.insert.flot; + +import com.fr.base.BaseFormula; +import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; +import com.fr.design.actions.ElementCaseAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.UIFormula; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.menu.MenuKeySet; +import com.fr.general.Inter; +import com.fr.grid.Grid; +import com.fr.grid.selection.FloatSelection; +import com.fr.report.ReportHelper; +import com.fr.report.cell.FloatElement; +import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.unit.FU; + +import javax.swing.*; + +/** + * Insert formula. + */ +public class FormulaFloatAction extends ElementCaseAction { + + private boolean returnValue = false; + + public FormulaFloatAction(ElementCasePane t) { + super(t); + this.setMenuKeySet(FLOAT_INSERT_FORMULA); + this.setName(getMenuKeySet().getMenuKeySetName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); + } + + public static final MenuKeySet FLOAT_INSERT_FORMULA = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'F'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_Insert_Formula"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + private void doWithDrawingFloatElement() { + ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + Grid grid = jws.getGrid(); + + ElementCasePane reportPane = grid.getElementCasePane(); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int resolution = grid.getResolution(); + int floatWdith = grid.getDrawingFloatElement().getWidth().toPixI(resolution); + int floatHeight = grid.getDrawingFloatElement().getWidth().toPixI(resolution); + + FU evtX_fu = FU.valueOfPix((grid.getWidth() - floatWdith) / 2, resolution); + FU evtY_fu = FU.valueOfPix((grid.getHeight() - floatHeight) / 2, resolution); + + FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); + FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); + + grid.getDrawingFloatElement().setLeftDistance(leftDistance); + grid.getDrawingFloatElement().setTopDistance(topDistance); + + report.addFloatElement(grid.getDrawingFloatElement()); + reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); + } + + /** + * 执行动作 + * + * @return 成功返回true + */ + @Override + public boolean executeActionReturnUndoRecordNeeded() { + final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (reportPane == null) { + return false; + } + + reportPane.stopEditing(); + final FloatElement floatElement = new FloatElement(); + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build()); + + BasicDialog dialog = formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + + @Override + public void doOk() { + floatElement.setValue(formulaPane.update()); + if (reportPane == null) { + return; + } + reportPane.getGrid().setDrawingFloatElement(floatElement); + doWithDrawingFloatElement(); + returnValue = true; + } + + @Override + public void doCancel() { + returnValue = false; + } + }); + dialog.setVisible(true); + return returnValue; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java index 8814936cd..9861499bf 100644 --- a/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/ImageFloatAction.java @@ -4,6 +4,7 @@ package com.fr.design.actions.insert.flot; import com.fr.base.BaseUtils; +import com.fr.base.DynamicUnitList; import com.fr.base.ScreenResolution; import com.fr.design.actions.ElementCaseAction; import com.fr.design.dialog.BasicDialog; @@ -14,9 +15,12 @@ import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; import com.fr.design.report.SelectImagePane; import com.fr.general.Inter; +import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; import com.fr.report.cell.cellattr.CellImage; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.CoreGraphHelper; import com.fr.stable.unit.FU; @@ -34,7 +38,7 @@ public class ImageFloatAction extends ElementCaseAction { public ImageFloatAction(ElementCasePane t) { super(t); this.setMenuKeySet(FLOAT_INSERT_IMAGE); - this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); } @@ -87,12 +91,33 @@ public class ImageFloatAction extends ElementCaseAction { CoreGraphHelper.waitForImage(image); floatElement.setValue(image); - - int resolution = ScreenResolution.getScreenResolution(); + Grid grid = reportPane.getGrid(); + int resolution = grid.getResolution(); floatElement.setWidth(FU.valueOfPix(image.getWidth(null), resolution)); floatElement.setHeight(FU.valueOfPix(image.getHeight(null), resolution)); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int floatWdith = floatElement.getWidth().toPixI(resolution); + int floatHeight = floatElement.getHeight().toPixI(resolution); + + int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; + int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; + FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); + FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); + + FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); + FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); + + floatElement.setLeftDistance(leftDistance); + floatElement.setTopDistance(topDistance); + floatElement.setStyle(cellImage.getStyle()); - reportPane.addFloatElementToCenterOfElementPane(floatElement); +// reportPane.addFloatElementToCenterOfElementPane(floatElement); + reportPane.getEditingElementCase().addFloatElement(floatElement); reportPane.setSelection(new FloatSelection(floatElement.getName())); returnValue = true; diff --git a/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java b/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java index 3f0be1c56..6001e2e72 100644 --- a/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java +++ b/designer/src/com/fr/design/actions/insert/flot/TextBoxFloatAction.java @@ -26,7 +26,7 @@ public class TextBoxFloatAction extends AbstractShapeAction { public TextBoxFloatAction(ElementCasePane t) { super(t); this.setMenuKeySet(FLOAT_INSERT_TEXT); - this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png")); } @@ -54,6 +54,7 @@ public class TextBoxFloatAction extends AbstractShapeAction { * * @param e 动作 */ + @Override public void actionPerformed(ActionEvent e) { ElementCasePane jws = getEditingComponent(); if (jws == null) { @@ -67,7 +68,7 @@ public class TextBoxFloatAction extends AbstractShapeAction { private void doWithDrawingFloatElement() { ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); - ; + Grid grid = jws.getGrid(); ElementCasePane reportPane = grid.getElementCasePane(); @@ -93,5 +94,6 @@ public class TextBoxFloatAction extends AbstractShapeAction { report.addFloatElement(grid.getDrawingFloatElement()); reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); + reportPane.fireTargetModified(); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/cell/bar/DynamicScrollButton.java b/designer/src/com/fr/design/cell/bar/DynamicScrollButton.java index d4a3db8a7..680244f89 100644 --- a/designer/src/com/fr/design/cell/bar/DynamicScrollButton.java +++ b/designer/src/com/fr/design/cell/bar/DynamicScrollButton.java @@ -1,5 +1,6 @@ package com.fr.design.cell.bar; +import com.fr.design.constants.UIConstants; import com.fr.general.ComparatorUtils; import javax.swing.*; @@ -63,48 +64,16 @@ public class DynamicScrollButton extends BasicArrowButton { private void paintArrow(Graphics g, Dimension size) { switch (direction) { case SwingConstants.NORTH: - g.drawLine(8, 5, 8, 5); - g.drawLine(7, 6, 9, 6); - g.drawLine(6, 7, 10, 7); - g.drawLine(5, 8, 7, 8); - g.drawLine(9, 8, 11, 8); - g.drawLine(4, 9, 6, 9); - g.drawLine(10, 9, 12, 9); - g.drawLine(5, 10, 5, 10); - g.drawLine(11, 10, 11, 10); + g.drawImage(UIConstants.ARROW_NORTH, 0, 0, this); break; case SwingConstants.SOUTH: - g.drawLine(5, 6, 5, 6); - g.drawLine(11, 6, 11, 6); - g.drawLine(4, 7, 6, 7); - g.drawLine(10, 7, 12, 7); - g.drawLine(5, 8, 7, 8); - g.drawLine(9, 8, 11, 8); - g.drawLine(6, 9, 10, 9); - g.drawLine(7, 10, 9, 10); - g.drawLine(8, 11, 8, 11); + g.drawImage(UIConstants.ARROW_SOUTH, 0, 0, this); break; case SwingConstants.EAST: - g.drawLine(6, 5, 6, 5); - g.drawLine(6, 11, 6, 11); - g.drawLine(7, 4, 7, 6); - g.drawLine(7, 10, 7, 12); - g.drawLine(8, 5, 8, 7); - g.drawLine(8, 9, 8, 11); - g.drawLine(9, 6, 9, 10); - g.drawLine(10, 7, 10, 9); - g.drawLine(11, 8, 11, 8); + g.drawImage(UIConstants.ARROW_EAST, 0, 0, this); break; case SwingConstants.WEST: - g.drawLine(4, 8, 4, 8); - g.drawLine(5, 7, 5, 9); - g.drawLine(6, 6, 6, 10); - g.drawLine(7, 5, 7, 7); - g.drawLine(7, 9, 7, 11); - g.drawLine(8, 4, 8, 6); - g.drawLine(8, 10, 8, 12); - g.drawLine(9, 5, 9, 5); - g.drawLine(9, 11, 9, 11); + g.drawImage(UIConstants.ARROW_WEST, 0, 0, this); break; } } diff --git a/designer/src/com/fr/design/cell/clipboard/CellElementsClip.java b/designer/src/com/fr/design/cell/clipboard/CellElementsClip.java index 64d649d3d..191f14959 100644 --- a/designer/src/com/fr/design/cell/clipboard/CellElementsClip.java +++ b/designer/src/com/fr/design/cell/clipboard/CellElementsClip.java @@ -12,6 +12,7 @@ import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElementComparator; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; /** @@ -62,8 +63,12 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { if (sbuf.length() > 0 && sbuf.charAt(sbuf.length() - 1) != '\n') { sbuf.append('\t'); } - - sbuf.append(cellElement.getValue()); + //REPORT-5134:会复制出null + if (cellElement.getValue() == null) { + sbuf.append(StringUtils.EMPTY); + } else { + sbuf.append(cellElement.getValue()); + } } return sbuf.toString(); diff --git a/designer/src/com/fr/design/cell/editor/AbstractCellEditor.java b/designer/src/com/fr/design/cell/editor/AbstractCellEditor.java index cc9c43564..33e29c1f6 100644 --- a/designer/src/com/fr/design/cell/editor/AbstractCellEditor.java +++ b/designer/src/com/fr/design/cell/editor/AbstractCellEditor.java @@ -7,6 +7,7 @@ import java.awt.Point; import javax.swing.event.EventListenerList; +import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.event.CellEditorEvent; import com.fr.grid.event.CellEditorListener; @@ -114,6 +115,7 @@ public abstract class AbstractCellEditor implements CellEditor { } if(ePane != null) { ePane.fireSelectionChangeListener(); + EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_CELL_ELEMENT); } } diff --git a/designer/src/com/fr/design/cell/editor/FormulaCellEditor.java b/designer/src/com/fr/design/cell/editor/FormulaCellEditor.java index e69742ea9..38b8b7551 100644 --- a/designer/src/com/fr/design/cell/editor/FormulaCellEditor.java +++ b/designer/src/com/fr/design/cell/editor/FormulaCellEditor.java @@ -3,7 +3,7 @@ */ package com.fr.design.cell.editor; -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; @@ -34,7 +34,7 @@ public class FormulaCellEditor extends com.fr.design.cell.editor.AbstractCellEdi */ @Override public Object getCellEditorValue() throws Exception { - Formula newFormula = this.formulaEditorPane.update(); + BaseFormula newFormula = this.formulaEditorPane.update(); if (newFormula.getContent() != null && newFormula.getContent().trim().length() > 1) { return newFormula; } else { @@ -64,13 +64,13 @@ public class FormulaCellEditor extends com.fr.design.cell.editor.AbstractCellEdi if (cellElement != null) { value = cellElement.getValue(); } - if (value == null || !(value instanceof Formula)) { - value = new Formula(""); + if (value == null || !(value instanceof BaseFormula)) { + value = BaseFormula.createFormulaBuilder().build(); } this.formulaEditorPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); - this.formulaEditorPane.populate((Formula) value); + this.formulaEditorPane.populate((BaseFormula) value); return this.formulaEditorPane.showLargeWindow(SwingUtilities.getWindowAncestor(grid), new DialogActionAdapter() { @Override diff --git a/designer/src/com/fr/design/cell/editor/FormulaFloatEditor.java b/designer/src/com/fr/design/cell/editor/FormulaFloatEditor.java index 046b3ebe3..23a41bbdd 100644 --- a/designer/src/com/fr/design/cell/editor/FormulaFloatEditor.java +++ b/designer/src/com/fr/design/cell/editor/FormulaFloatEditor.java @@ -3,7 +3,7 @@ */ package com.fr.design.cell.editor; -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; @@ -31,7 +31,7 @@ public class FormulaFloatEditor extends AbstractFloatEditor { */ @Override public Object getFloatEditorValue() throws Exception { - Formula newFormula = this.formulaEditorPane.update(); + BaseFormula newFormula = this.formulaEditorPane.update(); if (newFormula.getContent() != null && newFormula.getContent().trim().length() > 1) { return newFormula; } else { @@ -59,12 +59,12 @@ public class FormulaFloatEditor extends AbstractFloatEditor { public Component getFloatEditorComponent(Grid grid, FloatElement floatElement, int resolution) { //populate data to UI Object value = floatElement.getValue(); - if (value == null || !(value instanceof com.fr.base.Formula)) { - value = new Formula(""); + if (value == null || !(value instanceof BaseFormula)) { + value = BaseFormula.createFormulaBuilder().build(); } this.formulaEditorPane = FormulaFactory.createFormulaPane(); - this.formulaEditorPane.populate((Formula) value); + this.formulaEditorPane.populate((BaseFormula) value); return this.formulaEditorPane.showLargeWindow(SwingUtilities.getWindowAncestor(grid), new DialogActionAdapter() { diff --git a/designer/src/com/fr/design/cell/editor/RichTextToolBar.java b/designer/src/com/fr/design/cell/editor/RichTextToolBar.java index 0b5721975..d48070371 100644 --- a/designer/src/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer/src/com/fr/design/cell/editor/RichTextToolBar.java @@ -3,9 +3,9 @@ */ package com.fr.design.cell.editor; +import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; import com.fr.base.FRContext; -import com.fr.base.Formula; import com.fr.base.Utils; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; @@ -27,10 +27,27 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import javax.swing.*; -import javax.swing.event.*; -import javax.swing.text.*; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.Element; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; /** @@ -311,12 +328,12 @@ public class RichTextToolBar extends BasicPane{ private ActionListener formulaActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { final UIFormula formulaPane = FormulaFactory.createFormulaPane(); - formulaPane.populate(new Formula()); + formulaPane.populate(BaseFormula.createFormulaBuilder().build()); formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { StyledDocument doc = (StyledDocument) textPane.getDocument(); - Formula fm = formulaPane.update(); + BaseFormula fm = formulaPane.update(); String content = RichTextConverter.asFormula(fm.getContent()); int start = textPane.getSelectionStart(); AttributeSet attrs = start > 0 ? doc.getCharacterElement(start - 1).getAttributes() : new SimpleAttributeSet(); diff --git a/designer/src/com/fr/design/condition/HyperlinkPane.java b/designer/src/com/fr/design/condition/HyperlinkPane.java index bbdecf661..7ff03a7c8 100644 --- a/designer/src/com/fr/design/condition/HyperlinkPane.java +++ b/designer/src/com/fr/design/condition/HyperlinkPane.java @@ -37,7 +37,7 @@ public class HyperlinkPane extends ConditionAttrSingleConditionPane DSColumnPane.SETTING_DSRELATED) { - selectCountPane = new SelectCountPane(); - selectCountPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Results_Filter"),null)); - } - - valuePane = new ValuePane(); - valuePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Custom_Data_Appearance"),null)); - - - JPanel extendablePane = null; - if (setting > DSColumnPane.SETTING_DSRELATED) { - // extendableDirectionPane - JPanel extendableDirectionPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - - extendableDirectionPane.add(horizontalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); - extendableDirectionPane.add(verticalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); - - extendablePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("ExpandD-Expandable")); - extendablePane.setLayout(new BorderLayout()); - extendablePane.add(extendableDirectionPane, BorderLayout.CENTER); - } - - JPanel multiNumPane = null; - if (setting > DSColumnPane.SETTING_DSRELATED) { - multiNumPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Fill_blank_Data")); - useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); - multiNumPane.add(useMultiplyNumCheckBox); - multiNumPane.add(new UILabel(InsetText)); - - multiNumSpinner = new UISpinner(1, 10000, 1, 1); - multiNumPane.add(multiNumSpinner); - - useMultiplyNumCheckBox.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) { - checkButtonEnabled(); - } - }); - } - - double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, - TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; - double[] columnSize = {TableLayout.FILL}; - - Component[][] components = null; - if (setting > DSColumnPane.SETTING_DSRELATED) { - components = new Component[][]{ - {sortPane}, - {selectCountPane}, - {valuePane}, - {extendablePane}, - {multiNumPane} - }; - } else { - components = new Component[][]{ - {sortPane}, - {valuePane} - }; - } - this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("Advanced"); - } - - public void populate(TemplateCellElement cellElement) { - if (cellElement == null) { - return; - } - - sortPane.populate(cellElement); - valuePane.populate(cellElement); - - if (selectCountPane != null) { - selectCountPane.populate(cellElement); - - CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (cellExpandAttr == null) { - cellExpandAttr = new CellExpandAttr(); - cellElement.setCellExpandAttr(cellExpandAttr); - } - - // extendable - switch (cellExpandAttr.getExtendable()) { - case CellExpandAttr.Both_EXTENDABLE: - horizontalExtendableCheckBox.setSelected(true); - verticalExtendableCheckBox.setSelected(true); - break; - case CellExpandAttr.Vertical_EXTENDABLE: - horizontalExtendableCheckBox.setSelected(false); - verticalExtendableCheckBox.setSelected(true); - break; - case CellExpandAttr.Horizontal_EXTENDABLE: - horizontalExtendableCheckBox.setSelected(true); - verticalExtendableCheckBox.setSelected(false); - break; - default: { - horizontalExtendableCheckBox.setSelected(false); - verticalExtendableCheckBox.setSelected(false); - } - - } - - if (cellExpandAttr.getMultipleNumber() == -1) { - this.useMultiplyNumCheckBox.setSelected(false); - } else { - this.useMultiplyNumCheckBox.setSelected(true); - this.multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); - } - - this.checkButtonEnabled(); - } - } - - public void update(TemplateCellElement cellElement) { - if (cellElement == null) { - return; - } - - sortPane.update(cellElement); - valuePane.update(cellElement); - - if (selectCountPane != null) { - selectCountPane.update(cellElement); - - CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (cellExpandAttr == null) { - cellExpandAttr = new CellExpandAttr(); - cellElement.setCellExpandAttr(cellExpandAttr); - } - - // extendable - if (horizontalExtendableCheckBox.isSelected()) { - if (verticalExtendableCheckBox.isSelected()) { - cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); - } else { - cellExpandAttr.setExtendable(CellExpandAttr.Horizontal_EXTENDABLE); - } - } else { - if (verticalExtendableCheckBox.isSelected()) { - cellExpandAttr.setExtendable(CellExpandAttr.Vertical_EXTENDABLE); - } else { - cellExpandAttr.setExtendable(CellExpandAttr.None_EXTENDABLE); - } - } - - if (this.useMultiplyNumCheckBox.isSelected()) { - cellExpandAttr.setMultipleNumber((int) this.multiNumSpinner.getValue()); - } else { - cellExpandAttr.setMultipleNumber(-1); - } - } - } - - private static class SortPane extends SortFormulaPane { - private CellElement cellElement; - - @Override - public void formulaAction() { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - - String[] displayNames = DesignTableDataManager.getSelectedColumnNames( - DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName()); - - showFormulaDialog(displayNames); - } - - void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - this.cellElement = cellElement; - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) value; - - int sort = dSColumn.getOrder(); - this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); - - String sortFormula = dSColumn.getSortFormula(); - if (sortFormula != null && sortFormula.length() >= 1) { - sortFormulaTextField.setText(sortFormula); - } else { - sortFormulaTextField.setText(sortFormula); - } - } - - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - - dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); - //lance:sort formula - - String sText = null; - if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { - sText = new String(sortFormulaTextField.getText()); - } - if (!(sText == null || sText.length() < 1)) { - dSColumn.setSortFormula(sText); - } else { - dSColumn.setSortFormula(null); - } - } - } - - private static class SelectCountPane extends JPanel { - - CellElement cellElement; - // private Comparator sortComparator; - private UIComboBox selectCountComboBox; - private JPanel selectCountCardPane; - private UITextField serialTextField; - - JFormulaField topFormulaPane; - JFormulaField bottomFormulaPane; - - public SelectCountPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - selectCountComboBox = new UIComboBox(new String[]{ - Inter.getLocText("Undefined"), - Inter.getLocText("BindColumn-Top_N"), - Inter.getLocText("BindColumn-Bottom_N"), - Inter.getLocText("Odd"), - Inter.getLocText("Even"), - Inter.getLocText("Specify"),}); - selectCountComboBox.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - int selectIndex = selectCountComboBox.getSelectedIndex(); - CardLayout c1 = (CardLayout) selectCountCardPane.getLayout(); - if (selectIndex == 1) { - c1.show(selectCountCardPane, "TOP"); - } else if (selectIndex == 2) { - c1.show(selectCountCardPane, "BOTTOM"); - } else if (selectIndex == 3) { - c1.show(selectCountCardPane, "ODD"); - } else if (selectIndex == 4) { - c1.show(selectCountCardPane, "EVEN"); - } else if (selectIndex == 5) { - c1.show(selectCountCardPane, "SPECIFY"); - } else { - c1.show(selectCountCardPane, "UNDEFINE"); - } - } - }); - - selectCountCardPane =FRGUIPaneFactory.createCardLayout_S_Pane(); - this.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(InsetText), selectCountComboBox, - new UILabel(InsetText), selectCountCardPane}, FlowLayout.LEFT), BorderLayout.WEST); -// selectCountCardPane.setLayout(new CardLayout()); - - //not define pane - - JPanel undefinedPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("Undefined")), FlowLayout.LEFT); - topFormulaPane = new JFormulaField("-1"); - bottomFormulaPane = new JFormulaField("-1"); - serialTextField = new UITextField(18); - JPanel oddPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") - + " " + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), FlowLayout.LEFT); - JPanel evenPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") - + " " + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), FlowLayout.LEFT); - JPanel specifyPane = GUICoreUtils.createFlowPane(new JComponent[]{ - serialTextField, new UILabel( - Inter.getLocText(new String[]{ - "Format", "BindColumn-Result_Serial_Number_Start_From_1", "Inner_Parameter", "Group_Count"}, - new String[]{": 1,2-3,5,8 ", ",", "$__count__"}) - ) - }, FlowLayout.LEFT); - serialTextField.setToolTipText(Inter.getLocText("StyleFormat-Sample") + ":=JOINARRAY(GREPARRAY(RANGE($__count__), item!=4), \",\")"); - selectCountCardPane.add(undefinedPane, "UNDEFINE"); - selectCountCardPane.add(topFormulaPane, "TOP"); - selectCountCardPane.add(bottomFormulaPane, "BOTTOM"); - //odd - selectCountCardPane.add(oddPane, "ODD"); - //even - selectCountCardPane.add(evenPane, "EVEN"); - //specify - selectCountCardPane.add(specifyPane, "SPECIFY"); - } - - public void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - this.cellElement = cellElement; - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - SelectCount selectCount = dSColumn.getSelectCount(); - this.topFormulaPane.populateElement(cellElement); - this.bottomFormulaPane.populateElement(cellElement); - if (selectCount != null) { - int selectCountType = selectCount.getType(); - this.selectCountComboBox.setSelectedIndex(selectCountType); - if (selectCountType == SelectCount.TOP) { - this.topFormulaPane.populate(selectCount.getFormulaCount()); - } else if (selectCountType == SelectCount.BOTTOM) { - this.bottomFormulaPane.populate(selectCount.getFormulaCount()); - } else if (selectCountType == SelectCount.SPECIFY) { - this.serialTextField.setText(selectCount.getSerial()); - } - } - } - - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - - //alex:SelectCount - int selectCountSelectIndex = this.selectCountComboBox.getSelectedIndex(); - if (selectCountSelectIndex == 0) { - dSColumn.setSelectCount(null); - } else { - SelectCount selectCount = new SelectCount(); - dSColumn.setSelectCount(selectCount); - selectCount.setType(selectCountSelectIndex); - if (selectCountSelectIndex == SelectCount.TOP) { - selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); - } else if (selectCountSelectIndex == SelectCount.BOTTOM) { - selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); - } else if (selectCountSelectIndex == SelectCount.SPECIFY) { - selectCount.setSerial(this.serialTextField.getText()); - } - } - } - - private JFormattedTextField getTextField(JSpinner spinner) { - JComponent editor = spinner.getEditor(); - if (editor instanceof JSpinner.DefaultEditor) { - return ((JSpinner.DefaultEditor) editor).getTextField(); - } else { - System.err.println("Unexpected editor type: " - + spinner.getEditor().getClass() - + " isn't a descendant of DefaultEditor"); - return null; - } - } - } - - private static class JFormulaField extends JPanel { - private CellElement cellElement; - private UITextField formulaTextField; - private String defaultValue; - - public JFormulaField(String defaultValue) { - this.defaultValue = defaultValue; - - this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - UILabel bottomLabel = new UILabel("="); - bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); - this.add(bottomLabel); - formulaTextField = new UITextField(24); - this.add(formulaTextField); - formulaTextField.setText(defaultValue); - - UIButton bottomFrmulaButton = new UIButton("..."); - this.add(bottomFrmulaButton); - bottomFrmulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); - bottomFrmulaButton.setPreferredSize(new Dimension(25, formulaTextField.getPreferredSize().height)); - bottomFrmulaButton.addActionListener(formulaButtonActionListener); - } - - public void populate(String formulaContent) { - this.formulaTextField.setText(formulaContent); - } - public void populateElement(CellElement cellElement) { - this.cellElement = cellElement; - } - - public String getFormulaText() { - return this.formulaTextField.getText(); - } - - private ActionListener formulaButtonActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - Formula valueFormula = new Formula(); - String text = formulaTextField.getText(); - if (text == null || text.length() <= 0) { - valueFormula.setContent(defaultValue); - } else { - valueFormula.setContent(text); - } - - final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); - - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dsColumn = (DSColumn) value; - - String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); - - formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); - formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(JFormulaField.this), new DialogActionAdapter() { - @Override - public void doOk() { - Formula valueFormula = formulaPane.update(); - if (valueFormula.getContent().length() <= 1) { - formulaTextField.setText(defaultValue); - } else { - formulaTextField.setText(valueFormula.getContent().substring(1)); - } - } - }).setVisible(true); - } - }; - } - - private static class ValuePane extends JPanel { - private JFormulaField formulaField; - - public ValuePane() { - this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - - this.add(new UILabel(InsetText + Inter.getLocText("Value") + ":")); - this.add(Box.createHorizontalStrut(2)); - this.add((formulaField = new JFormulaField("$$$"))); - } - - public void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) value; - - //formula - String valueFormula = dSColumn.getResult(); - if (valueFormula == null) { - valueFormula = "$$$"; - } - formulaField.populateElement(cellElement); - formulaField.populate(valueFormula); - } - - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - - //formula - dSColumn.setResult(this.formulaField.getFormulaText()); - } - } - - private void checkButtonEnabled() { - if (useMultiplyNumCheckBox.isSelected()) { - multiNumSpinner.setEnabled(true); - } else { - multiNumSpinner.setEnabled(false); - } - } +package com.fr.design.dscolumn; + +import com.fr.base.BaseFormula; +import com.fr.data.util.SortOrder; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.formula.CustomVariableResolver; +import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.SortFormulaPane; +import com.fr.design.formula.UIFormula; +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.ispinner.UISpinner; +import com.fr.design.gui.itextfield.UITextField; +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.general.Inter; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellExpandAttr; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.group.SelectCount; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; +import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.SPECIFY; +import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.TOP; + +public class DSColumnAdvancedPane extends BasicPane { + + private static final String InsetText = " "; + private SortPane sortPane; + private SelectCountPane selectCountPane; + private ValuePane valuePane; + private UICheckBox horizontalExtendableCheckBox; + private UICheckBox verticalExtendableCheckBox; + private UICheckBox useMultiplyNumCheckBox; + private UISpinner multiNumSpinner; + + public DSColumnAdvancedPane() { + this(DSColumnPane.SETTING_ALL); + } + + public DSColumnAdvancedPane(int setting) { + this.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + sortPane = new SortPane(); + sortPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Sort-Sort_Order"), null)); + + if (setting > DSColumnPane.SETTING_DSRELATED) { + selectCountPane = new SelectCountPane(); + selectCountPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Results_Filter"), null)); + } + + valuePane = new ValuePane(); + valuePane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("BindColumn-Custom_Data_Appearance"), null)); + + + JPanel extendablePane = null; + if (setting > DSColumnPane.SETTING_DSRELATED) { + // extendableDirectionPane + JPanel extendableDirectionPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + + extendableDirectionPane.add(horizontalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); + extendableDirectionPane.add(verticalExtendableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); + + extendablePane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("ExpandD-Expandable")); + extendablePane.setLayout(new BorderLayout()); + extendablePane.add(extendableDirectionPane, BorderLayout.CENTER); + } + + JPanel multiNumPane = null; + if (setting > DSColumnPane.SETTING_DSRELATED) { + multiNumPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("Fill_blank_Data")); + useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); + multiNumPane.add(useMultiplyNumCheckBox); + multiNumPane.add(new UILabel(InsetText)); + + multiNumSpinner = new UISpinner(1, 10000, 1, 1); + multiNumPane.add(multiNumSpinner); + + useMultiplyNumCheckBox.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + checkButtonEnabled(); + } + }); + } + + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, + TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] columnSize = {TableLayout.FILL}; + + Component[][] components = null; + if (setting > DSColumnPane.SETTING_DSRELATED) { + components = new Component[][]{ + {sortPane}, + {selectCountPane}, + {valuePane}, + {extendablePane}, + {multiNumPane} + }; + } else { + components = new Component[][]{ + {sortPane}, + {valuePane} + }; + } + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Advanced"); + } + + public void populate(TemplateCellElement cellElement) { + if (cellElement == null) { + return; + } + + sortPane.populate(cellElement); + valuePane.populate(cellElement); + + if (selectCountPane != null) { + selectCountPane.populate(cellElement); + + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + + // extendable + switch (cellExpandAttr.getExtendable()) { + case CellExpandAttr.Both_EXTENDABLE: + horizontalExtendableCheckBox.setSelected(true); + verticalExtendableCheckBox.setSelected(true); + break; + case CellExpandAttr.Vertical_EXTENDABLE: + horizontalExtendableCheckBox.setSelected(false); + verticalExtendableCheckBox.setSelected(true); + break; + case CellExpandAttr.Horizontal_EXTENDABLE: + horizontalExtendableCheckBox.setSelected(true); + verticalExtendableCheckBox.setSelected(false); + break; + default: { + horizontalExtendableCheckBox.setSelected(false); + verticalExtendableCheckBox.setSelected(false); + } + + } + + if (cellExpandAttr.getMultipleNumber() == -1) { + this.useMultiplyNumCheckBox.setSelected(false); + } else { + this.useMultiplyNumCheckBox.setSelected(true); + this.multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); + } + + this.checkButtonEnabled(); + } + } + + public void update(TemplateCellElement cellElement) { + if (cellElement == null) { + return; + } + + sortPane.update(cellElement); + valuePane.update(cellElement); + + if (selectCountPane != null) { + selectCountPane.update(cellElement); + + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + + // extendable + if (horizontalExtendableCheckBox.isSelected()) { + if (verticalExtendableCheckBox.isSelected()) { + cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); + } else { + cellExpandAttr.setExtendable(CellExpandAttr.Horizontal_EXTENDABLE); + } + } else { + if (verticalExtendableCheckBox.isSelected()) { + cellExpandAttr.setExtendable(CellExpandAttr.Vertical_EXTENDABLE); + } else { + cellExpandAttr.setExtendable(CellExpandAttr.None_EXTENDABLE); + } + } + + if (this.useMultiplyNumCheckBox.isSelected()) { + cellExpandAttr.setMultipleNumber((int) this.multiNumSpinner.getValue()); + } else { + cellExpandAttr.setMultipleNumber(-1); + } + } + } + + private static class SortPane extends SortFormulaPane { + private CellElement cellElement; + + @Override + public void formulaAction() { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + + String[] displayNames = DesignTableDataManager.getSelectedColumnNames( + DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName()); + + showFormulaDialog(displayNames); + } + + void populate(CellElement cellElement) { + if (cellElement == null) { + return; + } + this.cellElement = cellElement; + + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) value; + + int sort = dSColumn.getOrder(); + this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); + + String sortFormula = dSColumn.getSortFormula(); + if (sortFormula != null && sortFormula.length() >= 1) { + sortFormulaTextField.setText(sortFormula); + } else { + sortFormulaTextField.setText(sortFormula); + } + } + + public void update(CellElement cellElement) { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + + dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); + //lance:sort formula + + String sText = null; + if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { + sText = new String(sortFormulaTextField.getText()); + } + if (!(sText == null || sText.length() < 1)) { + dSColumn.setSortFormula(sText); + } else { + dSColumn.setSortFormula(null); + } + } + } + + private static class SelectCountPane extends JPanel { + + CellElement cellElement; + // private Comparator sortComparator; + private UIComboBox selectCountComboBox; + private JPanel selectCountCardPane; + private UITextField serialTextField; + + JFormulaField topFormulaPane; + JFormulaField bottomFormulaPane; + + public SelectCountPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + selectCountComboBox = new UIComboBox(new String[]{ + Inter.getLocText("Undefined"), + Inter.getLocText("BindColumn-Top_N"), + Inter.getLocText("BindColumn-Bottom_N"), + Inter.getLocText("Odd"), + Inter.getLocText("Even"), + Inter.getLocText("Specify"),}); + selectCountComboBox.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int selectIndex = selectCountComboBox.getSelectedIndex(); + CardLayout c1 = (CardLayout) selectCountCardPane.getLayout(); + if (selectIndex == 1) { + c1.show(selectCountCardPane, "TOP"); + } else if (selectIndex == 2) { + c1.show(selectCountCardPane, "BOTTOM"); + } else if (selectIndex == 3) { + c1.show(selectCountCardPane, "ODD"); + } else if (selectIndex == 4) { + c1.show(selectCountCardPane, "EVEN"); + } else if (selectIndex == 5) { + c1.show(selectCountCardPane, "SPECIFY"); + } else { + c1.show(selectCountCardPane, "UNDEFINE"); + } + } + }); + + selectCountCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + this.add(GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(InsetText), selectCountComboBox, + new UILabel(InsetText), selectCountCardPane}, FlowLayout.LEFT), BorderLayout.WEST); +// selectCountCardPane.setLayout(new CardLayout()); + + //not define pane + + JPanel undefinedPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("Undefined")), FlowLayout.LEFT); + topFormulaPane = new JFormulaField("-1"); + bottomFormulaPane = new JFormulaField("-1"); + serialTextField = new UITextField(18); + JPanel oddPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + " " + Inter.getLocText("BindColumn-Odd_Selected_(1,3,5...)")), FlowLayout.LEFT); + JPanel evenPane = GUICoreUtils.createFlowPane(new UILabel(Inter.getLocText("BindColumn-Result_Serial_Number_Start_From_1") + + " " + Inter.getLocText("BindColumn-Even_Selected_(2,4,6...)")), FlowLayout.LEFT); + JPanel specifyPane = GUICoreUtils.createFlowPane(new JComponent[]{ + serialTextField, new UILabel( + Inter.getLocText(new String[]{ + "Format", "BindColumn-Result_Serial_Number_Start_From_1", "Inner_Parameter", "Group_Count"}, + new String[]{": 1,2-3,5,8 ", ",", "$__count__"}) + ) + }, FlowLayout.LEFT); + serialTextField.setToolTipText(Inter.getLocText("StyleFormat-Sample") + ":=JOINARRAY(GREPARRAY(RANGE($__count__), item!=4), \",\")"); + selectCountCardPane.add(undefinedPane, "UNDEFINE"); + selectCountCardPane.add(topFormulaPane, "TOP"); + selectCountCardPane.add(bottomFormulaPane, "BOTTOM"); + //odd + selectCountCardPane.add(oddPane, "ODD"); + //even + selectCountCardPane.add(evenPane, "EVEN"); + //specify + selectCountCardPane.add(specifyPane, "SPECIFY"); + } + + public void populate(CellElement cellElement) { + if (cellElement == null) { + return; + } + this.cellElement = cellElement; + + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + SelectCount selectCount = dSColumn.getSelectCount(); + this.topFormulaPane.populateElement(cellElement); + this.bottomFormulaPane.populateElement(cellElement); + if (selectCount != null) { + int selectCountType = selectCount.getType(); + this.selectCountComboBox.setSelectedIndex(selectCountType); + if (selectCountType == TOP.getValue()) { + this.topFormulaPane.populate(selectCount.getFormulaCount()); + } else if (selectCountType == BOTTOM.getValue()) { + this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + } else if (selectCountType == SPECIFY.getValue()) { + this.serialTextField.setText(selectCount.getSerial()); + } + } + } + + public void update(CellElement cellElement) { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + + //alex:SelectCount + int selectCountSelectIndex = this.selectCountComboBox.getSelectedIndex(); + if (selectCountSelectIndex == 0) { + dSColumn.setSelectCount(null); + } else { + SelectCount selectCount = new SelectCount(); + dSColumn.setSelectCount(selectCount); + selectCount.setType(selectCountSelectIndex); + if (selectCountSelectIndex == TOP.getValue()) { + selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); + } else if (selectCountSelectIndex == BOTTOM.getValue()) { + selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); + } else if (selectCountSelectIndex == SPECIFY.getValue()) { + selectCount.setSerial(this.serialTextField.getText()); + } + } + } + + private JFormattedTextField getTextField(JSpinner spinner) { + JComponent editor = spinner.getEditor(); + if (editor instanceof JSpinner.DefaultEditor) { + return ((JSpinner.DefaultEditor) editor).getTextField(); + } else { + System.err.println("Unexpected editor type: " + + spinner.getEditor().getClass() + + " isn't a descendant of DefaultEditor"); + return null; + } + } + } + + private static class JFormulaField extends JPanel { + private CellElement cellElement; + private UITextField formulaTextField; + private String defaultValue; + + public JFormulaField(String defaultValue) { + this.defaultValue = defaultValue; + + this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + UILabel bottomLabel = new UILabel("="); + bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); + this.add(bottomLabel); + formulaTextField = new UITextField(24); + this.add(formulaTextField); + formulaTextField.setText(defaultValue); + + UIButton bottomFrmulaButton = new UIButton("..."); + this.add(bottomFrmulaButton); + bottomFrmulaButton.setToolTipText(Inter.getLocText("Formula") + "..."); + bottomFrmulaButton.setPreferredSize(new Dimension(25, formulaTextField.getPreferredSize().height)); + bottomFrmulaButton.addActionListener(formulaButtonActionListener); + } + + public void populate(String formulaContent) { + this.formulaTextField.setText(formulaContent); + } + + public void populateElement(CellElement cellElement) { + this.cellElement = cellElement; + } + + public String getFormulaText() { + return this.formulaTextField.getText(); + } + + private ActionListener formulaButtonActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); + String text = formulaTextField.getText(); + if (text == null || text.length() <= 0) { + valueFormula.setContent(defaultValue); + } else { + valueFormula.setContent(text); + } + + final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); + + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dsColumn = (DSColumn) value; + + String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); + + formulaPane.populate(valueFormula, new CustomVariableResolver(displayNames, true)); + formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(JFormulaField.this), new DialogActionAdapter() { + @Override + public void doOk() { + BaseFormula valueFormula = formulaPane.update(); + if (valueFormula.getContent().length() <= 1) { + formulaTextField.setText(defaultValue); + } else { + formulaTextField.setText(valueFormula.getContent().substring(1)); + } + } + }).setVisible(true); + } + }; + } + + private static class ValuePane extends JPanel { + private JFormulaField formulaField; + + public ValuePane() { + this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + + this.add(new UILabel(InsetText + Inter.getLocText("Value") + ":")); + this.add(Box.createHorizontalStrut(2)); + this.add((formulaField = new JFormulaField("$$$"))); + } + + public void populate(CellElement cellElement) { + if (cellElement == null) { + return; + } + + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) value; + + //formula + String valueFormula = dSColumn.getResult(); + if (valueFormula == null) { + valueFormula = "$$$"; + } + formulaField.populateElement(cellElement); + formulaField.populate(valueFormula); + } + + public void update(CellElement cellElement) { + if (cellElement == null) { + return; + } + Object value = cellElement.getValue(); + if (value == null || !(value instanceof DSColumn)) { + return; + } + DSColumn dSColumn = (DSColumn) (cellElement.getValue()); + + //formula + dSColumn.setResult(this.formulaField.getFormulaText()); + } + } + + private void checkButtonEnabled() { + if (useMultiplyNumCheckBox.isSelected()) { + multiNumSpinner.setEnabled(true); + } else { + multiNumSpinner.setEnabled(false); + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/DSColumnConditionsPane.java b/designer/src/com/fr/design/dscolumn/DSColumnConditionsPane.java index 228e88ae4..88e807e92 100644 --- a/designer/src/com/fr/design/dscolumn/DSColumnConditionsPane.java +++ b/designer/src/com/fr/design/dscolumn/DSColumnConditionsPane.java @@ -38,7 +38,7 @@ public class DSColumnConditionsPane extends BasicPane { if (setting > DSColumnPane.SETTING_DSRELATED) { liteConditionPane = new DSColumnLiteConditionPane() { - protected boolean needDoWithCondition(Condition liteCondition) { + protected boolean isNeedDoWithCondition(Condition liteCondition) { return liteCondition != null; } }; diff --git a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java index 530c92f84..61ac3bd36 100644 --- a/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java +++ b/designer/src/com/fr/design/dscolumn/ResultSetGroupDockingPane.java @@ -7,7 +7,6 @@ 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.mainframe.ElementCasePane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import com.fr.report.cell.TemplateCellElement; @@ -24,7 +23,7 @@ import java.awt.event.ItemListener; * 这个pane是选中数据列后,在上方QuickRegion处显示的pane * * @author zhou, yaoh.wu - * @version 2017年8月2日14点55分 + * @version 2017年9月26日17点22分 * @since 8.0 */ public class ResultSetGroupDockingPane extends ResultSetGroupPane { @@ -41,12 +40,12 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { private ItemListener listener; - public ResultSetGroupDockingPane(ElementCasePane ePane) { + public ResultSetGroupDockingPane() { super(); - this.initComponents(ePane); + this.initComponents(); } - public void initComponents(ElementCasePane ePane) { + public void initComponents() { goBox = new UIComboBox(new String[]{Inter.getLocText("BindColumn-Group"), Inter.getLocText("BindColumn-Select"), Inter.getLocText("BindColumn-Summary")}); initCardPane(); contentPane = layoutPane(); @@ -66,23 +65,23 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { }; goBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ee) { - checkButtonEnabled(); int i = goBox.getSelectedIndex(); if (i == BIND_GROUP) { cardLayout.show(cardPane, "groupPane"); - cardPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane,2,10); + cardPane.setPreferredSize(new Dimension(158, 20)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 10); } else if (i == BIND_SELECTED) { cardLayout.show(cardPane, "listPane"); cardPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane,2,0); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); } else if (i == BIND_SUMMARY) { cardLayout.show(cardPane, "summaryPane"); - cardPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane,2,10); + cardPane.setPreferredSize(new Dimension(158, 20)); + TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 10); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); cellExpandAttr.setDirection(Constants.NONE); } + checkButtonEnabled(); } }); @@ -96,7 +95,6 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { cardLayout = new CardLayout(); cardPane.setLayout(cardLayout); - JPanel pane = new JPanel(new BorderLayout(3, 0)); groupComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { checkButtonEnabled(); @@ -104,7 +102,9 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { }); advancedButton = new UIButton(Inter.getLocText("Custom")); advancedButton.addActionListener(groupAdvancedListener); - pane.add(groupComboBox, BorderLayout.WEST); + + JPanel pane = new JPanel(new BorderLayout(0, 10)); + pane.add(groupComboBox, BorderLayout.NORTH); pane.add(advancedButton, BorderLayout.CENTER); cardPane.add(pane, "groupPane"); @@ -115,16 +115,16 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { @Override public void populate(TemplateCellElement cellElement) { + //更新面板信息时可能会触发绑定在组件上的事件,先移除这些事件 + this.removeListener(); this.cellElement = cellElement; - - if (isNPE(cellElement)) return; + if (isNPE(cellElement)) { + return; + } DSColumn dSColumn = (DSColumn) cellElement.getValue(); - - // populate groupPane - // RecordGrouper recordGrouper = dSColumn.getGrouper(); if (recordGrouper instanceof FunctionGrouper && !((FunctionGrouper) recordGrouper).isCustom()) { - int mode = ((FunctionGrouper) recordGrouper).getDivideMode(); + int mode = recordGrouper.getDivideMode(); if (mode == FunctionGrouper.GROUPING_MODE) { cardLayout.show(cardPane, "groupPane"); this.goBox.setSelectedIndex(BIND_GROUP); @@ -152,15 +152,17 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { this.goBox.setSelectedIndex(BIND_GROUP); this.groupComboBox.setSelectedIndex(ADVANCED); } - checkButtonEnabled(); + //加上面板组件的交互事件监听 + this.addListener(); } @Override public void update() { - if (isNPE(cellElement)) return; + if (isNPE(cellElement)) { + return; + } DSColumn dSColumn = (DSColumn) cellElement.getValue(); - if (this.goBox.getSelectedIndex() == BIND_GROUP) { recordGrouper = updateGroupCombox(); } else if (this.goBox.getSelectedIndex() == BIND_SELECTED) { @@ -190,12 +192,25 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { advancedButton.setEnabled(true); } } + if (advancedButton.isEnabled()) { + cardPane.setPreferredSize(new Dimension(158, 50)); + cardPane.revalidate(); + cardPane.repaint(); + return; + } + if (groupComboBox.isEnabled() || functionComboBox.isEnabled()) { + cardPane.setPreferredSize(new Dimension(158, 20)); + cardPane.revalidate(); + cardPane.repaint(); + return; + } + cardPane.setPreferredSize(new Dimension(158, 0)); + cardPane.revalidate(); + cardPane.repaint(); } - public void addListener(ItemListener listener) { - goBox.addItemListener(listener); - groupComboBox.addItemListener(listener); - functionComboBox.addItemListener(listener); + + public void setListener(ItemListener listener) { this.listener = listener; } @@ -207,4 +222,16 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane { public void setRecordGrouper(RecordGrouper recordGrouper) { this.recordGrouper = recordGrouper; } + + private void addListener() { + goBox.addItemListener(this.listener); + groupComboBox.addItemListener(this.listener); + functionComboBox.addItemListener(this.listener); + } + + private void removeListener() { + goBox.removeItemListener(this.listener); + groupComboBox.removeItemListener(this.listener); + functionComboBox.removeItemListener(this.listener); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java index d67281028..362c28166 100644 --- a/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java +++ b/designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java @@ -41,7 +41,7 @@ import java.util.regex.Pattern; * * @author yaoh.wu * @version 2017年8月3日 - * 复用对话框代码,保留对话框原始布局 + * 复用对话框代码,保留对话框原始布局 * @since 8.0 */ public class SelectedDataColumnPane extends BasicPane { @@ -282,7 +282,7 @@ public class SelectedDataColumnPane extends BasicPane { private void initWithParameterButton(final ElementCasePane casePane, final TemplateCellElement cellElement) { final SelectedDataColumnPane that = this; editorPane = new UITableEditorPane(new ParameterTableModel()); - paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); + paramButton = new UIButton(Inter.getLocText("FR-Designer-Basic_Dynamic_Parameter_Injection")); paramButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { diff --git a/designer/src/com/fr/design/dscolumn/SpecifiedGroupAttrPane.java b/designer/src/com/fr/design/dscolumn/SpecifiedGroupAttrPane.java index 7321f2ca6..d03a6e47b 100644 --- a/designer/src/com/fr/design/dscolumn/SpecifiedGroupAttrPane.java +++ b/designer/src/com/fr/design/dscolumn/SpecifiedGroupAttrPane.java @@ -1,6 +1,6 @@ package com.fr.design.dscolumn; -import com.fr.base.Formula; +import com.fr.base.BaseFormula; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.DSColumnLiteConditionPane; import com.fr.design.dialog.BasicPane; @@ -333,7 +333,7 @@ public class SpecifiedGroupAttrPane extends BasicPane { formulaButton.setPreferredSize(new Dimension(25, valueField.getPreferredSize().height)); formulaButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { - Formula valueFormula = new Formula(); + BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); String text = valueField.getText(); if (text == null || text.length() <= 0) { valueFormula.setContent("$$$"); @@ -347,7 +347,7 @@ public class SpecifiedGroupAttrPane extends BasicPane { formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(FormulaGroupPane.this), new DialogActionAdapter(){ @Override public void doOk() { - Formula valueFormula = formulaPane.update(); + BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { valueField.setText("$$$"); } else { diff --git a/designer/src/com/fr/design/expand/SortExpandAttrPane.java b/designer/src/com/fr/design/expand/SortExpandAttrPane.java index d346dd890..11260c74b 100644 --- a/designer/src/com/fr/design/expand/SortExpandAttrPane.java +++ b/designer/src/com/fr/design/expand/SortExpandAttrPane.java @@ -24,11 +24,11 @@ public class SortExpandAttrPane extends JPanel { public SortExpandAttrPane() { this.setLayout(new BorderLayout(0, 4)); - Icon[] iconArray = { - BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), - BaseUtils.readIcon("/com/fr/design/images/expand/asc.png"), - BaseUtils.readIcon("/com/fr/design/images/expand/des.png") - }; + Icon[][] iconArray = { + {BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), BaseUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")}, + {BaseUtils.readIcon("/com/fr/design/images/expand/asc.png"), BaseUtils.readIcon("/com/fr/design/images/expand/asc_selected.png")}, + {BaseUtils.readIcon("/com/fr/design/images/expand/des.png"), BaseUtils.readIcon("/com/fr/design/images/expand/des_selected.png")} + }; String[] nameArray = { Inter.getLocText("Sort-Original"), Inter.getLocText("Sort-Ascending"), Inter.getLocText("Sort-Descending") }; sort_type_pane = new UIButtonGroup(iconArray); sort_type_pane.setAllToolTips(nameArray); diff --git a/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java b/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java index f30a6e212..f432c39f7 100644 --- a/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java +++ b/designer/src/com/fr/design/headerfooter/HFAttributesEditDialog.java @@ -3,8 +3,16 @@ */ package com.fr.design.headerfooter; -import com.fr.base.Formula; -import com.fr.base.headerfooter.*; +import com.fr.base.BaseFormula; +import com.fr.base.headerfooter.DateHFElement; +import com.fr.base.headerfooter.FormulaHFElement; +import com.fr.base.headerfooter.HFElement; +import com.fr.base.headerfooter.ImageHFElement; +import com.fr.base.headerfooter.NewLineHFElement; +import com.fr.base.headerfooter.NumberOfPageHFElement; +import com.fr.base.headerfooter.PageNumberHFElement; +import com.fr.base.headerfooter.TextHFElement; +import com.fr.base.headerfooter.TimeHFElement; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.FormulaFactory; @@ -121,7 +129,7 @@ public class HFAttributesEditDialog extends BasicPane { formulaButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { - Formula valueFormula = new Formula(); + BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); String text = formulaContentField.getText(); if (text == null || text.length() <= 0) { valueFormula.setContent(""); @@ -135,7 +143,7 @@ public class HFAttributesEditDialog extends BasicPane { @Override public void doOk() { - Formula valueFormula = formulaPane.update(); + BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { formulaContentField.setText(""); } else { diff --git a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java index 3a57b11ec..a941660aa 100644 --- a/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java +++ b/designer/src/com/fr/design/mainframe/ActiveKeyGenerator.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe; -import com.fr.base.BaseUtils; +import com.fr.base.ConfigManager; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.stable.StableUtils; @@ -102,7 +101,7 @@ public class ActiveKeyGenerator { HashMap para = new HashMap(); para.put("uuid", envManager.getUUID()); para.put("key", key); - para.put("username", envManager.getBBSName()); + para.put("username", ConfigManager.getProviderInstance().getBbsUsername()); HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("verify.code"), para); if (timeout != -1) { hc.setTimeout(timeout); diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 79e52bfe1..23e4622e1 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -238,7 +238,6 @@ public class AuthorityToolBarPane extends BasicBeanPane extends Tar /** * Constructor. */ - public ElementCasePane(T t) { + public ElementCasePane(T t) { super(t); // marks:能触发processEvent,不管是否给component增加listener。这里是使在reportPane中的任意位置滑动鼠标轮都能 // 下拉grid。 @@ -209,7 +161,7 @@ public abstract class ElementCasePane extends Tar this.setLayout(new RGridLayout()); //todo 直接修改分辨率 - if (this.resolution == 0){ + if (this.resolution == 0) { this.resolution = ScreenResolution.getScreenResolution(); } @@ -243,7 +195,6 @@ public abstract class ElementCasePane extends Tar } - public int getMenuState() { return DesignState.WORK_SHEET; } @@ -294,8 +245,8 @@ public abstract class ElementCasePane extends Tar setFormatState(DesignerContext.FORMAT_STATE_NULL); formatBrush.setSelected(false); grid.setCursor(UIConstants.CELL_DEFAULT_CURSOR); - if(DesignerContext.getReferencedElementCasePane() == null){ - return; + if (DesignerContext.getReferencedElementCasePane() == null) { + return; } ((ElementCasePane) DesignerContext.getReferencedElementCasePane()).getGrid().setNotShowingTableSelectPane(true); @@ -348,11 +299,11 @@ public abstract class ElementCasePane extends Tar } - public void setResolution(int resolution){ + public void setResolution(int resolution) { this.resolution = resolution; } - public int getResolution(){ + public int getResolution() { return this.resolution; } @@ -371,7 +322,7 @@ public abstract class ElementCasePane extends Tar private void initDefaultEditors() { Grid grid = this.getGrid(); grid.setDefaultCellEditor(DSColumn.class, new DSColumnCellEditor(this)); - grid.setDefaultCellEditor(Formula.class, new FormulaCellEditor(this)); + grid.setDefaultCellEditor(BaseFormula.class, new FormulaCellEditor(this)); grid.setDefaultCellEditor(RichText.class, new RichTextCellEditor(this)); grid.setDefaultCellEditor(BiasTextPainter.class, new BiasTextPainterCellEditor(this)); @@ -1150,7 +1101,7 @@ public abstract class ElementCasePane extends Tar HeadColumnAction headcolumnAction = new HeadColumnAction(this); FootColumnAction footcolumnAction = new FootColumnAction(this); - ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(this, evt.getX(), evt.getY(),this.resolution); + ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(this, evt.getX(), evt.getY(), this.resolution); ElementCase elementCase = this.getEditingElementCase(); boolean cancel = false; ReportPageAttrProvider reportPageAttr = elementCase.getReportPageAttr(); @@ -1268,11 +1219,7 @@ public abstract class ElementCasePane extends Tar protected ToolBarDef createAlignmentToolBar() { return ShortCut.asToolBarDef(new ShortCut[]{ - new AlignmentAction(this, new Icon[]{ - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")}, - new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT})} + new AlignmentAction(this)} ); } @@ -1325,7 +1272,7 @@ public abstract class ElementCasePane extends Tar * @return 返回正在编辑的状态. */ public EditingState createEditingState() { - return new ElementCaseEditingState(this.selection, this.verScrollBar.getValue(), this.horScrollBar.getValue()); + return new ElementCaseEditingState(this.selection, this.verScrollBar.getValue(), this.horScrollBar.getValue(), this.resolution); } public void setCellNeedTOFormat(CellSelection selection) { @@ -1341,15 +1288,18 @@ public abstract class ElementCasePane extends Tar protected Selection selection; protected int verticalValue = 0; protected int horizontalValue = 0; + protected int resolution = ScreenResolution.getScreenResolution(); - protected ElementCaseEditingState(Selection selection, int verticalValue, int horizontalValue) { + protected ElementCaseEditingState(Selection selection, int verticalValue, int horizontalValue, int resolution) { try { this.selection = selection.clone(); + this.resolution = resolution; } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } this.verticalValue = verticalValue; this.horizontalValue = horizontalValue; + this.resolution = resolution; } @Override @@ -1363,7 +1313,8 @@ public abstract class ElementCasePane extends Tar ElementCasePane.this.getVerticalScrollBar().setValue(this.verticalValue); ElementCasePane.this.getHorizontalScrollBar().setValue(this.horizontalValue); - +// ElementCasePane.this.setResolution(this.resolution); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(this.resolution); // 重绘. ElementCasePane.this.repaint(); } diff --git a/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java index cf63c4448..8d25463ab 100644 --- a/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.design.actions.edit.HyperlinkAction; import com.fr.design.fun.MenuHandler; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.menu.KeySetUtils; @@ -44,58 +45,72 @@ public class ElementCasePaneDelegate extends ElementCasePane { public ElementCasePaneDelegate(WorkSheet sheet) { super(sheet); this.addSelectionChangeListener(new SelectionListener() { - @Override public void selectionChanged(SelectionEvent e) { - //在编辑权限,所以要更新权限编辑面板 - if (BaseUtils.isAuthorityEditing()) { - AuthorityPropertyPane authorityPropertyPane = new AuthorityPropertyPane(ElementCasePaneDelegate.this); - authorityPropertyPane.populate(); - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION); - EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(authorityPropertyPane); - EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance()); + if (!isEditable() && !BaseUtils.isAuthorityEditing()) { return; } - CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); - CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); - QuickEditorRegion.getInstance().populate(getCurrentEditor()); - JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (editingTemplate != null && !editingTemplate.isUpMode()) { - Selection editingSelection = ((ElementCasePaneDelegate)e.getSource()).getSelection(); - // 模板初始化完成后,才能初始化超级链接面板 - HyperlinkGroupPane hyperlinkGroupPane = editingTemplate.getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance()); - hyperlinkGroupPane.populate(ElementCasePaneDelegate.this); - if (editingSelection instanceof FloatSelection) { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_FLOAT); - JPanel floatPane = new JPanel(new BorderLayout()); - floatPane.add(ReportFloatPane.getInstance(), BorderLayout.NORTH); - floatPane.add(QuickEditorRegion.getInstance(), BorderLayout.CENTER); - EastRegionContainerPane.getInstance().replaceFloatElementPane(floatPane); - } else { - // 条件属性 - ConditionAttributesGroupPane conditionAttributesGroupPane = ConditionAttributesGroupPane.getInstance(); - conditionAttributesGroupPane.populate(ElementCasePaneDelegate.this); - - EastRegionContainerPane.getInstance().replaceFloatElementPane(ReportFloatPane.getInstance()); - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); - EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); - EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); - EastRegionContainerPane.getInstance().replaceConditionAttrPane(conditionAttributesGroupPane); - EastRegionContainerPane.getInstance().replaceWidgetSettingsPane(CellWidgetPropertyPane.getInstance()); - } - EastRegionContainerPane.getInstance().replaceHyperlinkPane(hyperlinkGroupPane); - EastRegionContainerPane.getInstance().removeParameterPane(); - } + refreshPropertyPanes(); } }); this.addTargetModifiedListener(new TargetModifiedListener() { @Override public void targetModified(TargetModifiedEvent e) { - CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); + if (DesignerContext.isRefreshOnTargetModifiedEnabled()) { + refreshPropertyPanes(); + } else { + CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); + } } }); } + private void refreshPropertyPanes() { + //在编辑权限,所以要更新权限编辑面板 + if (BaseUtils.isAuthorityEditing()) { + AuthorityPropertyPane authorityPropertyPane = new AuthorityPropertyPane(ElementCasePaneDelegate.this); + authorityPropertyPane.populate(); + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.AUTHORITY_EDITION); + EastRegionContainerPane.getInstance().replaceAuthorityEditionPane(authorityPropertyPane); + EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance()); + return; + } + if (DesignerContext.getDesignerFrame().getSelectedJTemplate() != null) { + CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); + } + CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); + QuickEditorRegion.getInstance().populate(getCurrentEditor()); + JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (editingTemplate != null && !editingTemplate.isUpMode()) { + Selection editingSelection = getSelection(); + // 模板初始化完成后,才能初始化超级链接面板 + HyperlinkGroupPane hyperlinkGroupPane = editingTemplate.getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance()); + hyperlinkGroupPane.populate(ElementCasePaneDelegate.this); + if (editingSelection instanceof FloatSelection) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_FLOAT); + JPanel floatPane = new JPanel(new BorderLayout()); + floatPane.add(ReportFloatPane.getInstance(), BorderLayout.NORTH); + floatPane.add(QuickEditorRegion.getInstance(), BorderLayout.CENTER); + EastRegionContainerPane.getInstance().replaceFloatElementPane(floatPane); + } else { + // 条件属性 + ConditionAttributesGroupPane conditionAttributesGroupPane = ConditionAttributesGroupPane.getInstance(); + conditionAttributesGroupPane.populate(ElementCasePaneDelegate.this); + + EastRegionContainerPane.getInstance().replaceFloatElementPane(ReportFloatPane.getInstance()); + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); + EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); + EastRegionContainerPane.getInstance().replaceConditionAttrPane(conditionAttributesGroupPane); + EastRegionContainerPane.getInstance().replaceWidgetSettingsPane(CellWidgetPropertyPane.getInstance()); + + EastRegionContainerPane.getInstance().updateCellElementState(isSelectedOneCell()); + } + EastRegionContainerPane.getInstance().replaceHyperlinkPane(hyperlinkGroupPane); + EastRegionContainerPane.getInstance().removeParameterPane(); + } + } + @Override protected boolean supportRepeatedHeaderFooter() { return true; @@ -122,6 +137,7 @@ public class ElementCasePaneDelegate extends ElementCasePane { * * @return 不是必须在可见范围. */ + @Override public boolean mustInVisibleRange() { return false; } @@ -162,6 +178,9 @@ public class ElementCasePaneDelegate extends ElementCasePane { for (int i = 0; i < actions.length; i++) { subMenuDef.addShortCut(actions[i]); } + + // 顺便更新右侧属性面板悬浮元素tab中的菜单项 + ReportFloatPane.getInstance().refreshInsertFloatMenu(this); } // 格式菜单 @@ -169,12 +188,13 @@ public class ElementCasePaneDelegate extends ElementCasePane { MenuDef menuDef = new MenuDef(KeySetUtils.CELL.getMenuKeySetName(), KeySetUtils.CELL.getMnemonic()); menuDef.addShortCut(new CellExpandAttrAction()); - menuDef.addShortCut(new CellWidgetAttrAction(this)); menuDef.addShortCut(new GlobalStyleMenuDef(this)); - // 单元格形态 menuDef.addShortCut(DeprecatedActionManager.getPresentMenu(this)); + menuDef.addShortCut(new CellWidgetAttrAction()); + menuDef.addShortCut(new ConditionAttributesAction()); + menuDef.addShortCut(new HyperlinkAction()); menuDef.addShortCut(SeparatorDef.DEFAULT); menuDef.addShortCut(new MergeCellAction(this)); menuDef.addShortCut(new UnmergeCellAction(this)); diff --git a/designer/src/com/fr/design/mainframe/InformationCollector.java b/designer/src/com/fr/design/mainframe/InformationCollector.java index 4bac9a15b..7cc6eb6c4 100644 --- a/designer/src/com/fr/design/mainframe/InformationCollector.java +++ b/designer/src/com/fr/design/mainframe/InformationCollector.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe; +import com.fr.base.ConfigManagerFactory; import com.fr.base.FRContext; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.dialect.DialectFactory; @@ -12,23 +13,51 @@ import com.fr.data.core.db.dml.Table; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; -import com.fr.general.*; +import com.fr.general.ComparatorUtils; +import com.fr.general.DateUtils; +import com.fr.general.DesUtils; +import com.fr.general.GeneralUtils; +import com.fr.general.IOUtils; +import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; import com.fr.json.JSONException; -import com.fr.record.DBRecordManager; -import com.fr.stable.*; -import com.fr.stable.xml.*; +import com.fr.json.JSONObject; +import com.fr.record.DBRecordXManager; +import com.fr.stable.ArrayUtils; +import com.fr.stable.EncodeConstants; +import com.fr.stable.ProductConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLTools; +import com.fr.stable.xml.XMLWriter; +import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; -import org.json.JSONObject; -import java.io.*; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.DateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author neil @@ -125,19 +154,23 @@ public class InformationCollector implements XMLReadable, XMLWriter { JSONArray startStopArray = new JSONArray(); for (int i = 0; i < startStop.size(); i++) { JSONObject jo = new JSONObject(); - jo.put(ATTR_START, startStop.get(i).getStartDate()); - jo.put(ATTR_STOP, startStop.get(i).getStopDate()); - startStopArray.put(jo); + try { + jo.put(ATTR_START, startStop.get(i).getStartDate()); + jo.put(ATTR_STOP, startStop.get(i).getStopDate()); + startStopArray.put(jo); + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + content.put(XML_START_STOP, startStopArray); + content.put(XML_UUID, envManager.getUUID()); + content.put(XML_JAR, GeneralUtils.readBuildNO()); + content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); + content.put(XML_USERNAME, ConfigManagerFactory.getProviderInstance().getBbsUsername()); + content.put(XML_KEY, envManager.getActivationKey()); + content.put(XML_OS, System.getProperty("os.name")); + } catch (JSONException e) { + FRContext.getLogger().error(e.getMessage(), e); + } } - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - content.put(XML_START_STOP, startStopArray); - content.put(XML_UUID, envManager.getUUID()); - content.put(XML_JAR, GeneralUtils.readBuildNO()); - content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); - content.put(XML_USERNAME, envManager.getBBSName()); - content.put(XML_KEY, envManager.getActivationKey()); - content.put(XML_OS, System.getProperty("os.name")); - + try { return content.toString().getBytes(EncodeConstants.ENCODING_UTF_8); } catch (UnsupportedEncodingException e) { @@ -161,7 +194,12 @@ public class InformationCollector implements XMLReadable, XMLWriter { } String res = hc.getResponseText(); //服务器返回true,说明已经取得成功,清空当前记录的信息 - boolean success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); + boolean success = false; + try { + success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); + } catch (JSONException e) { + FRContext.getLogger().error(e.getMessage(), e); + } if (success){ this.reset(); } @@ -179,7 +217,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { Table table = new Table(TABLE_NAME); try { - conn = DBRecordManager.getDB().createConnection(); + conn = DBRecordXManager.getDB().createConnection(); ResultSet rs = selectAllFromLogDB(conn, table); if(rs == null){ @@ -201,8 +239,13 @@ public class InformationCollector implements XMLReadable, XMLWriter { } String res = httpClient.getResponseText(); - boolean success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); - //服务器返回true, 说明已经获取成功, 清空当前记录的信息 + boolean success = false; + try { + success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); + } catch (JSONException e) { + FRContext.getLogger().error(e.getMessage(), e); + } + //服务器返回true, 说明已经获取成功, 清空当前记录的信息 if (success) { deleteLogDB(conn, table); } @@ -211,7 +254,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { private void deleteLogDB(Connection conn, Table table) { try { - conn = DBRecordManager.getDB().createConnection(); + conn = DBRecordXManager.getDB().createConnection(); Delete delete = new Delete(table); delete.execute(conn); } catch (Exception e) { @@ -254,7 +297,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { } DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - content.put("username", envManager.getBBSName()); + content.put("username", ConfigManagerFactory.getProviderInstance().getBbsUsername()); content.put("uuid", envManager.getUUID()); content.put("functions", functionArray); diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 2b23dabb7..82d796a30 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -92,7 +92,7 @@ public class JWorkBook extends JTemplate { private UIModeControlContainer centerPane; public ReportComponentComposite reportComposite; private ParameterDefinitePane parameterPane; - private int resolution; + private int resolution = ScreenResolution.getScreenResolution(); public JWorkBook() { super(new WorkBook(new WorkSheet()), "WorkBook"); @@ -114,10 +114,13 @@ public class JWorkBook extends JTemplate { if (isEditingPolySheet()) { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.POLY); } else { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); - EastRegionContainerPane.getInstance().replaceCellElementPane(getEastUpPane()); - EastRegionContainerPane.getInstance().replaceCellAttrPane(getEastDownPane()); + if (isUpMode()) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); + } else { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + } } + refreshToolArea(); } private boolean isEditingPolySheet() { @@ -129,6 +132,11 @@ public class JWorkBook extends JTemplate { return getEditingElementCasePane(); } + @Override + public JComponent getCurrentReportComponentPane() { + return reportComposite; + } + @Override protected UIModeControlContainer createCenterPane() { parameterPane = ModuleContext.isModuleStarted(Module.FORM_MODULE) ? new ParameterDefinitePane() : null; @@ -394,7 +402,6 @@ public class JWorkBook extends JTemplate { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setJTemplateResolution(resolution); polyDezi.updateUI(); } - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); } @Override @@ -854,6 +861,11 @@ public class JWorkBook extends JTemplate { return ReportHyperlinkGroupPane.getInstance(hyperlinkGroupPaneActionProvider); } + @Override + public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return ReportHyperlinkGroupPaneNoPop.getInstance(hyperlinkGroupPaneActionProvider); + } + public void setAuthorityMode(boolean isUpMode) { centerPane.setAuthorityMode(isUpMode); } diff --git a/designer/src/com/fr/design/mainframe/ReportComponent.java b/designer/src/com/fr/design/mainframe/ReportComponent.java index 6ca268545..699f6c1c5 100644 --- a/designer/src/com/fr/design/mainframe/ReportComponent.java +++ b/designer/src/com/fr/design/mainframe/ReportComponent.java @@ -44,6 +44,11 @@ public abstract class ReportComponent= textX && evtX < textX + textWidth) { - if (getSelectedIndex() != i) { + boolean needRefreshPropertiesPane = getSelectedIndex() != i; + setSelectedIndex(i); + if (needRefreshPropertiesPane) { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); } - setSelectedIndex(i); + isBlank = false; reportComposite.setComposite(); if (isAuthorityEditing) { diff --git a/designer/src/com/fr/design/mainframe/WorkSheetDesigner.java b/designer/src/com/fr/design/mainframe/WorkSheetDesigner.java index d25812095..454315f95 100644 --- a/designer/src/com/fr/design/mainframe/WorkSheetDesigner.java +++ b/designer/src/com/fr/design/mainframe/WorkSheetDesigner.java @@ -4,11 +4,13 @@ import java.awt.BorderLayout; import javax.swing.*; +import com.fr.base.ScreenResolution; import com.fr.design.DesignState; import com.fr.design.actions.report.*; import com.fr.design.designer.EditingState; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.*; import com.fr.grid.selection.CellSelection; @@ -21,6 +23,8 @@ import com.fr.stable.ArrayUtils; public class WorkSheetDesigner extends ReportComponent { + private static final int HUND = 100; + public WorkSheetDesigner(WorkSheet sheet) { super(sheet); @@ -166,6 +170,13 @@ public class WorkSheetDesigner extends ReportComponent { private static final int OFFSET = 45; + private static final String SELECTED_PATH = AlphaFineConstants.IMAGE_URL + "selected"; + private static final String CELL_PATH = AlphaFineConstants.IMAGE_URL + "alphafine"; + private static final String SUFFIX = ".png"; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -30,13 +33,13 @@ public class ContentCellRender implements ListCellRenderer { titleLabel.setText(" " + model.getName()); if (model.hasAction()) { if (isSelected) { - String iconUrl = "/com/fr/design/mainframe/alphafine/images/selected" + model.getType().getTypeValue() + ".png"; + String iconUrl = SELECTED_PATH + model.getType().getTypeValue() + SUFFIX; panel.setBackground(AlphaFineConstants.BLUE); titleLabel.setForeground(Color.WHITE); - titleLabel.setIcon(new ImageIcon(IOUtils.readImage(iconUrl))); + titleLabel.setIcon(IconLoader.getIcon(iconUrl)); } else { - String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png"; - titleLabel.setIcon(new ImageIcon(IOUtils.readImage(iconUrl))); + String iconUrl = CELL_PATH + model.getType().getTypeValue() + SUFFIX; + titleLabel.setIcon(IconLoader.getIcon(iconUrl)); titleLabel.setForeground(AlphaFineConstants.BLACK); } @@ -51,7 +54,7 @@ public class ContentCellRender implements ListCellRenderer { detailLabel.setForeground(AlphaFineConstants.LIGHT_GRAY); panel.add(detailLabel, BorderLayout.CENTER); int width = (int) (titleLabel.getPreferredSize().getWidth() + detailLabel.getPreferredSize().getWidth()); - if ( width > AlphaFineConstants.LEFT_WIDTH - OFFSET) { + if (width > AlphaFineConstants.LEFT_WIDTH - OFFSET) { int nameWidth = (int) (AlphaFineConstants.LEFT_WIDTH - detailLabel.getPreferredSize().getWidth() - OFFSET); titleLabel.setPreferredSize(new Dimension(nameWidth, AlphaFineConstants.CELL_HEIGHT)); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java index c5329da68..8d1d5a5f9 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/render/TitleCellRender.java @@ -3,7 +3,6 @@ package com.fr.design.mainframe.alphafine.cell.render; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; -import com.fr.general.IOUtils; import javax.swing.*; import java.awt.*; @@ -33,14 +32,6 @@ public class TitleCellRender implements ListCellRenderer { showMoreLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); panel.add(showMoreLabel, BorderLayout.EAST); } - if (moreModel.isLoading()) { - ImageIcon imageIcon = new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/loading.gif")); - //设置cell的加载动画 - imageIcon.setImageObserver(list); - UILabel loadingLabel = new UILabel(imageIcon); - loadingLabel.setBorder(BorderFactory.createEmptyBorder(LOAD_OFFSET,0,0,0)); - panel.add(loadingLabel, 0); - } panel.setPreferredSize(new Dimension(list.getFixedCellWidth(), AlphaFineConstants.CELL_TITLE_HEIGHT)); return panel; } diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 6b1113f35..995d2d336 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -1,7 +1,10 @@ package com.fr.design.mainframe.alphafine.component; +import com.bulenkov.iconloader.IconLoader; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; @@ -16,11 +19,16 @@ import com.fr.design.mainframe.alphafine.cell.model.PluginModel; import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; import com.fr.design.mainframe.alphafine.model.SearchResult; -import com.fr.design.mainframe.alphafine.preview.ActionPreviewPane; import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane; import com.fr.design.mainframe.alphafine.preview.FilePreviewPane; +import com.fr.design.mainframe.alphafine.preview.NoResultPane; import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane; -import com.fr.design.mainframe.alphafine.search.manager.*; +import com.fr.design.mainframe.alphafine.search.manager.ActionSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.DocumentSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.FileSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.PluginSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.RecentSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.RecommendSearchManager; import com.fr.form.main.Form; import com.fr.form.main.FormIO; import com.fr.general.ComparatorUtils; @@ -42,7 +50,13 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.awt.event.*; +import java.awt.event.AWTEventListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; @@ -69,12 +83,16 @@ public class AlphaFineDialog extends UIDialog { private static final String PLUGIN_MARK_SHORT = "k:4 "; private static final String PLUGIN_MARK = "k:shop "; private static final String PLACE_HOLDER = Inter.getLocText("FR-Designer_AlphaFine"); + private static final int MAX_SHOW_SIZE = 12; private AlphaFineTextField searchTextField; private UIButton closeButton; private JPanel searchResultPane; - private Point pressedPoint; private UIScrollPane leftSearchResultPane; + + private JPanel defaultPane; + //分割线 + private UILabel splitLabel; private JPanel rightSearchResultPane; private AlphaFineList searchResultList; private SearchListModel searchListModel; @@ -84,7 +102,6 @@ public class AlphaFineDialog extends UIDialog { //是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下 private boolean forceOpen; - public AlphaFineDialog(Frame parent, boolean forceOpen) { super(parent); this.forceOpen = forceOpen; @@ -107,7 +124,7 @@ public class AlphaFineDialog extends UIDialog { KeyEvent e = (KeyEvent) event; KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); KeyStroke storeKeyStroke = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortCutKeyStore(); - if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) { + if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFineConfigManager.isALPHALicAvailable() && AlphaFinePane.getAlphaFinePane().isVisible()) { doClickAction(); } @@ -129,7 +146,7 @@ public class AlphaFineDialog extends UIDialog { private void initComponents() { initSearchTextField(); JPanel topPane = new JPanel(new BorderLayout()); - UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png"))); + UILabel iconLabel = new UILabel(IconLoader.getIcon(AlphaFineConstants.IMAGE_URL + "bigsearch.png")); iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE); iconLabel.setOpaque(true); iconLabel.setBackground(Color.WHITE); @@ -144,7 +161,7 @@ public class AlphaFineDialog extends UIDialog { } }; closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE); - closeButton.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png"))); + closeButton.setIcon(IconLoader.getIcon(AlphaFineConstants.IMAGE_URL + "alphafine_close.png")); closeButton.set4ToolbarButton(); closeButton.setBorderPainted(false); closeButton.setRolloverEnabled(false); @@ -156,12 +173,6 @@ public class AlphaFineDialog extends UIDialog { }); topPane.add(closeButton, BorderLayout.EAST); add(topPane, BorderLayout.CENTER); - searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { - @Override - protected void textChanged(DocumentEvent e) { - doSearch(searchTextField.getText()); - } - }); } /** @@ -169,7 +180,7 @@ public class AlphaFineDialog extends UIDialog { */ private void initSearchTextField() { searchTextField = new AlphaFineTextField(PLACE_HOLDER); - initTextFieldKeyListener(); + initTextFieldListener(); searchTextField.setFont(AlphaFineConstants.GREATER_FONT); searchTextField.setBackground(Color.WHITE); searchTextField.setBorderPainted(false); @@ -223,16 +234,11 @@ public class AlphaFineDialog extends UIDialog { * @param text */ private void doSearch(String text) { - - if (StringUtils.isBlank(text) || isNeedSearch(text)) { - removeSearchResult(); - } else { - showSearchResult(); - } + showSearchResult(text); } - boolean isNeedSearch(String text) { - return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'"); + boolean isNoNeedSearch(String text) { + return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'") || StringUtils.isBlank(text); } @Override @@ -267,17 +273,17 @@ public class AlphaFineDialog extends UIDialog { searchResultPane = null; } setSize(AlphaFineConstants.FIELD_SIZE); - repaint(); + refreshContainer(); } /** * 展示搜索结果 */ - private void showSearchResult() { + private void showSearchResult(String text) { if (searchResultPane == null) { initSearchResultComponents(); } - initSearchWorker(); + initSearchWorker(text); } /** @@ -294,20 +300,15 @@ public class AlphaFineDialog extends UIDialog { searchResultList.setCellRenderer(new ContentCellRender()); leftSearchResultPane = new UIScrollPane(searchResultList); + leftSearchResultPane.setBorder(null); leftSearchResultPane.setBackground(Color.WHITE); - leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); rightSearchResultPane = new JPanel(); rightSearchResultPane.setBackground(Color.WHITE); - UILabel splitLine = new UILabel(); - splitLine.setBackground(AlphaFineConstants.GRAY); - splitLine.setPreferredSize(new Dimension(1, AlphaFineConstants.CONTENT_HEIGHT)); rightSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH - 1, AlphaFineConstants.CONTENT_HEIGHT)); searchResultPane.add(leftSearchResultPane, BorderLayout.WEST); - searchResultPane.add(splitLine, BorderLayout.CENTER); searchResultPane.add(rightSearchResultPane, BorderLayout.EAST); - UILabel splitLabel = new UILabel(); - splitLabel.setBackground(AlphaFineConstants.GRAY); + splitLabel = new UILabel(); splitLabel.setPreferredSize(new Dimension(AlphaFineConstants.HEIGHT, 1)); searchResultPane.add(splitLabel, BorderLayout.NORTH); add(searchResultPane, BorderLayout.SOUTH); @@ -317,7 +318,7 @@ public class AlphaFineDialog extends UIDialog { /** * 异步加载搜索结果 */ - private void initSearchWorker() { + private void initSearchWorker(final String text) { if (this.searchWorker != null && !this.searchWorker.isDone()) { this.searchWorker.cancel(true); this.searchWorker = null; @@ -325,13 +326,14 @@ public class AlphaFineDialog extends UIDialog { this.searchWorker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { - rebuildList(searchTextField.getText().toLowerCase()); + rebuildList(text); return null; } @Override protected void done() { if (!isCancelled()) { + splitLabel.setIcon(null); fireStopLoading(); } } @@ -339,11 +341,45 @@ public class AlphaFineDialog extends UIDialog { this.searchWorker.execute(); } + /** + * 恢复左侧列表面板 + */ + private void resumeLeftPane() { + if (searchResultPane != null && defaultPane != null) { + searchResultPane.remove(defaultPane); + defaultPane = null; + searchResultPane.add(leftSearchResultPane, BorderLayout.WEST); + } + } + + /** + * 移除左侧列表面板 + */ + private void removeLeftPane() { + if (searchListModel.isEmpty() && defaultPane == null) { + defaultPane = new NoResultPane(Inter.getLocText("FR-Designer-AlphaFine_NO_Result"), AlphaFineConstants.IMAGE_URL + "no_result.png"); + searchResultPane.remove(leftSearchResultPane); + searchResultPane.add(defaultPane, BorderLayout.WEST); + refreshContainer(); + } + } + /** * 停止加载状态 */ private void fireStopLoading() { - searchListModel.resetState(); + if (searchResultPane != null) { + removeLeftPane(); + } + } + + /** + * 刷新容器 + */ + private void refreshContainer() { + validate(); + repaint(); + revalidate(); } /** @@ -354,25 +390,26 @@ public class AlphaFineDialog extends UIDialog { */ private void rebuildList(String searchText) { resetContainer(); + if (searchText.startsWith(ADVANCED_SEARCH_MARK)) { if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); - getActionList(storeText); + buildActionList(storeText); } else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); - getDocumentList(storeText); + buildDocumentList(storeText); } else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); - getFileList(storeText); + buildFileList(storeText); } else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); - getFileList(searchText); + buildFileList(searchText); } else if (searchText.startsWith(DS_MARK)) { storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); - getFileList(DS_NAME + storeText); + buildFileList(DS_NAME + storeText); } else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); - getPluginList(storeText); + buildPluginList(storeText); } } else { storeText = searchText.trim(); @@ -385,11 +422,12 @@ public class AlphaFineDialog extends UIDialog { * 重置面板 */ private void resetContainer() { + rightSearchResultPane.removeAll(); + splitLabel.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigloading.gif"))); + resumeLeftPane(); searchListModel.removeAllElements(); searchListModel.resetSelectedState(); - rightSearchResultPane.removeAll(); - validate(); - repaint(); + refreshContainer(); } /** @@ -398,23 +436,22 @@ public class AlphaFineDialog extends UIDialog { * @param searchText */ private void doNormalSearch(String searchText) { - getRecentList(searchText); - getRecommendList(searchText); - getActionList(searchText); - getFileList(searchText); - getDocumentList(searchText); - getPluginList(searchText); + buildRecentList(searchText); + buildRecommendList(searchText); + buildActionList(searchText); + buildFileList(searchText); + buildDocumentList(searchText); + buildPluginList(searchText); } - private void getDocumentList(final String searchText) { + private void buildDocumentList(final String searchText) { SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); for (AlphaCellModel object : documentModelList) { - AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - private void getFileList(final String searchText) { + private void buildFileList(final String searchText) { SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); for (AlphaCellModel object : fileModelList) { AlphaFineHelper.checkCancel(); @@ -422,34 +459,30 @@ public class AlphaFineDialog extends UIDialog { } } - private void getActionList(final String searchText) { + private void buildActionList(final String searchText) { SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); for (AlphaCellModel object : actionModelList) { - AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - private void getPluginList(final String searchText) { + private void buildPluginList(final String searchText) { SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); for (AlphaCellModel object : pluginModelList) { - AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - private void getRecommendList(final String searchText) { + private void buildRecommendList(final String searchText) { SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); for (AlphaCellModel object : recommendModelList) { - AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } } - private void getRecentList(final String searchText) { + private void buildRecentList(final String searchText) { SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); for (AlphaCellModel object : recentModelList) { - AlphaFineHelper.checkCancel(); searchListModel.addElement(object); } @@ -534,7 +567,7 @@ public class AlphaFineDialog extends UIDialog { break; case ACTION: rightSearchResultPane.removeAll(); - rightSearchResultPane.add(new ActionPreviewPane()); + rightSearchResultPane.add(new NoResultPane(Inter.getLocText("FR-Designer_NoResult"), AlphaFineConstants.IMAGE_URL + "noresult.png")); validate(); repaint(); break; @@ -584,7 +617,7 @@ public class AlphaFineDialog extends UIDialog { this.showWorker.execute(); break; default: - return; + rightSearchResultPane.removeAll(); } @@ -600,11 +633,10 @@ public class AlphaFineDialog extends UIDialog { } } - private void HandleMoreOrLessResult(int index, MoreModel selectedValue) { - if (selectedValue.getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"))) { + private void dealWithMoreOrLessResult(int index, MoreModel selectedValue) { + if (ComparatorUtils.equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), selectedValue.getContent())) { selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowLess")); rebuildShowMoreList(index, selectedValue); - } else { selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowAll")); rebuildShowMoreList(index, selectedValue); @@ -616,8 +648,7 @@ public class AlphaFineDialog extends UIDialog { UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"))); label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0)); rightSearchResultPane.add(label, BorderLayout.CENTER); - validate(); - repaint(); + refreshContainer(); } /** @@ -625,34 +656,43 @@ public class AlphaFineDialog extends UIDialog { */ private void initGlobalListener() { initAWTEventListener(); - initMouseListener(); } /** - * 为textfield添加键盘监听器 + * 为textfield添加监听器 */ - private void initTextFieldKeyListener() { + private void initTextFieldListener() { searchTextField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_DOWN) { - searchResultList.requestFocus(); + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + if (searchResultList.getModel().getSize() > 1) { + dealWithSearchResult(searchResultList.getSelectedValue()); + } + } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { + if (searchResultList.getSelectedIndex() == searchResultList.getModel().getSize() - 1) { + searchResultList.setSelectedIndex(0); + } searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1); - } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { - doNavigate(); - saveHistory(searchResultList.getSelectedValue()); - } + } else if (e.getKeyCode() == KeyEvent.VK_UP) { + searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() - 1); + } else escAlphaFineDialog(e); } + }); + searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { @Override - public void keyReleased(KeyEvent e) { - int keyCode = e.getKeyCode(); - if (keyCode == KeyEvent.VK_ESCAPE) { - if (StringUtils.isBlank(searchTextField.getText()) || ComparatorUtils.equals(searchTextField.getText(), searchTextField.getPlaceHolder())) { - AlphaFineDialog.this.setVisible(false); - } else { - searchTextField.setText(null); + protected void textChanged(DocumentEvent e) { + if (isNoNeedSearch(searchTextField.getText())) { + removeSearchResult(); + } else { + try { + Thread.sleep(10); + doSearch(searchTextField.getText().toLowerCase()); + } catch (InterruptedException e1) { + FRLogger.getLogger().error(e1.getMessage()); } + } } }); @@ -661,42 +701,13 @@ public class AlphaFineDialog extends UIDialog { } /** - * 窗口拖拽 + * 处理搜索结果 + * + * @param selectedValue */ - private void initMouseListener() { - addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseDragged(MouseEvent e) { - doMouseDragged(e); - } - }); - - addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - doMousePressed(e); - } - - }); - } - - private void doMousePressed(MouseEvent e) { - - pressedPoint = e.getPoint(); - - } - - private void doMouseDragged(MouseEvent e) { - - Point point = e.getPoint();// 获取当前坐标 - - Point locationPoint = getLocation();// 获取窗体坐标 - - int x = locationPoint.x + point.x - pressedPoint.x;// 计算移动后的新坐标 - - int y = locationPoint.y + point.y - pressedPoint.y; - - setLocation(x, y);// 改变窗体位置 - + private void dealWithSearchResult(AlphaCellModel selectedValue) { + doNavigate(); + saveLocalHistory(selectedValue); } /** @@ -727,25 +738,30 @@ public class AlphaFineDialog extends UIDialog { @Override public void checkValid() throws Exception { - + //不处理 } + /** + * 导航到结果页面 + */ private void doNavigate() { AlphaFineDialog.this.dispose(); final AlphaCellModel model = searchResultList.getSelectedValue(); - model.doAction(); + if (model != null) { + model.doAction(); + } } /** - * 保存本地(本地常用) + * 保存结果到本地(本地常用) * * @param cellModel */ - private void saveHistory(AlphaCellModel cellModel) { + private void saveLocalHistory(AlphaCellModel cellModel) { RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger(); recentSearchManager.addRecentModel(storeText, cellModel); recentSearchManager.saveXMLFile(); - sendToServer(storeText, cellModel); + sendDataToServer(storeText, cellModel); } @@ -755,9 +771,9 @@ public class AlphaFineDialog extends UIDialog { * @param searchKey * @param cellModel */ - private void sendToServer(String searchKey, AlphaCellModel cellModel) { + private void sendDataToServer(String searchKey, AlphaCellModel cellModel) { if (cellModel.isNeedToSendToServer()) { - String username = DesignerEnvManager.getEnvManager().getBBSName(); + String username = ConfigManager.getProviderInstance().getBbsUsername(); String uuid = DesignerEnvManager.getEnvManager().getUUID(); String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); @@ -772,14 +788,13 @@ public class AlphaFineDialog extends UIDialog { } final HashMap para = new HashMap<>(); String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); - para.put("token", CodeUtils.md5Encode(date, "", "MD5")); + para.put("token", CodeUtils.md5Encode(date, StringUtils.EMPTY, "MD5")); para.put("content", object.toString()); HttpClient httpClient = new HttpClient(AlphaFineConstants.CLOUD_SERVER_URL, para, true); httpClient.asGet(); if (!httpClient.isServerAlive()) { FRLogger.getLogger().error("Failed to sent data to server!"); } - httpClient.setTimeout(5000); } @@ -860,6 +875,33 @@ public class AlphaFineDialog extends UIDialog { this.storeText = storeText; } + public UILabel getSplitLabel() { + return splitLabel; + } + + public void setSplitLabel(UILabel splitLabel) { + this.splitLabel = splitLabel; + } + + /** + * 键盘退出AlphaFine + * + * @param e + */ + private void escAlphaFineDialog(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (StringUtils.isBlank(searchTextField.getText()) || ComparatorUtils.equals(searchTextField.getText(), searchTextField.getPlaceHolder())) { + AlphaFineDialog.this.setVisible(false); + } else { + searchTextField.setText(null); + removeSearchResult(); + } + } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { + if (searchResultList.getModel().getSize() > 1) { + dealWithSearchResult(searchResultList.getSelectedValue()); + } + } + } /** * +-------------------------------------+ @@ -879,7 +921,9 @@ public class AlphaFineDialog extends UIDialog { */ @Override public void setSelectedIndex(int index) { - if (index > 0 && checkSelectedIndex(index)) { + if (index == 0 && getModel().getSize() > 1) { + super.setSelectedIndex(1); + } else if (index > 0 && checkSelectedIndex(index)) { int previousIndex = getSelectedIndex(); super.setSelectedIndex(index); AlphaCellModel cellModel = getSelectedValue(); @@ -902,31 +946,16 @@ public class AlphaFineDialog extends UIDialog { } private void initListListener() { - addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - doNavigate(); - saveHistory(getSelectedValue()); - } else if (e.getKeyCode() == KeyEvent.VK_UP) { - if (getSelectedIndex() == 1) { - searchTextField.requestFocus(); - } - } - } - }); - addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int selectedIndex = getSelectedIndex(); AlphaCellModel selectedValue = getSelectedValue(); if (e.getClickCount() == 2 && selectedValue.hasAction()) { - doNavigate(); - saveHistory(selectedValue); + dealWithSearchResult(selectedValue); } else if (e.getClickCount() == 1) { if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) { - HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); + dealWithMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); } } } @@ -940,6 +969,14 @@ public class AlphaFineDialog extends UIDialog { } } }); + + addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + escAlphaFineDialog(e); + + } + }); } } @@ -962,10 +999,23 @@ public class AlphaFineDialog extends UIDialog { @Override public void addElement(AlphaCellModel element) { + AlphaFineHelper.checkCancel(); int index = myDelegate.size(); myDelegate.add(element); fireContentsChanged(this, index, index); fireSelectedStateChanged(element, index); + + } + + @Override + protected void fireContentsChanged(Object source, int index0, int index1) { + if (myDelegate.size() > MAX_SHOW_SIZE) { + leftSearchResultPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); + leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 2)); + } else { + leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + } + super.fireContentsChanged(source, index0, index1); } /** @@ -1025,8 +1075,13 @@ public class AlphaFineDialog extends UIDialog { isValidSelected = selected; } + @Override + public boolean isEmpty() { + return myDelegate.isEmpty(); + } + public void resetState() { - for (int i = 0; i< getSize(); i++) { + for (int i = 0; i < getSize(); i++) { getElementAt(i).resetState(); } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java index cfd37479e..86ddc8b40 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/component/AlphaFinePane.java @@ -1,16 +1,15 @@ package com.fr.design.mainframe.alphafine.component; -import com.fr.design.DesignerEnvManager; +import com.bulenkov.iconloader.IconLoader; import com.fr.design.actions.help.alphafine.AlphaFineContext; import com.fr.design.actions.help.alphafine.AlphaFineListener; +import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.utils.ThemeUtils; -import com.fr.general.IOUtils; import com.fr.general.Inter; -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -21,17 +20,20 @@ import java.awt.event.ActionListener; public class AlphaFinePane extends BasicPane { private static AlphaFinePane alphaFinePane; + static { + Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK); + } + public AlphaFinePane() { - setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 14)); - if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - Toolkit.getDefaultToolkit().addAWTEventListener(AlphaFineDialog.listener(), AWTEvent.KEY_EVENT_MASK); - } + setPreferredSize(new Dimension(24, 24)); + setLayout(new BorderLayout()); UIButton refreshButton = new UIButton(); - refreshButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); + refreshButton.setIcon(IconLoader.getIcon("/com/fr/design/mainframe/alphafine/images/smallsearch.png")); refreshButton.setToolTipText(Inter.getLocText("FR-Designer_AlphaFine")); refreshButton.set4ToolbarButton(); + refreshButton.setRolloverEnabled(false); this.add(refreshButton); - this.setBackground(ThemeUtils.WHITE_BORDER_COLOR); + this.setBackground(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/alphafine1@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine1@2x.png new file mode 100644 index 000000000..97ee11685 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine1@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/alphafine2@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine2@2x.png new file mode 100644 index 000000000..667a7c0cd Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine2@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/alphafine3@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine3@2x.png new file mode 100644 index 000000000..a3d5423f9 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine3@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/alphafine4@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine4@2x.png new file mode 100644 index 000000000..7eed33901 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine4@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/alphafine5@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine5@2x.png new file mode 100644 index 000000000..b1c3675a0 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine5@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/alphafine_close@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine_close@2x.png new file mode 100644 index 000000000..ce2ed4a89 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/alphafine_close@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/bigloading.gif b/designer/src/com/fr/design/mainframe/alphafine/images/bigloading.gif new file mode 100644 index 000000000..ab4d295f0 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/bigloading.gif differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch.png b/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch.png index 192a8131d..83576a216 100644 Binary files a/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch.png and b/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch@2x.png new file mode 100644 index 000000000..58d1c92c8 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/bigsearch@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/no_result.png b/designer/src/com/fr/design/mainframe/alphafine/images/no_result.png new file mode 100644 index 000000000..cd3d803af Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/no_result.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/no_result@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/no_result@2x.png new file mode 100644 index 000000000..53c12eb30 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/no_result@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/noresult@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/noresult@2x.png new file mode 100644 index 000000000..c5fb22863 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/noresult@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/opening@2x.gif b/designer/src/com/fr/design/mainframe/alphafine/images/opening@2x.gif new file mode 100644 index 000000000..d6c165e57 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/opening@2x.gif differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/selected1@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/selected1@2x.png new file mode 100644 index 000000000..dfc820247 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/selected1@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/selected2@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/selected2@2x.png new file mode 100644 index 000000000..d02b7971d Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/selected2@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/selected3@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/selected3@2x.png new file mode 100644 index 000000000..568b5428e Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/selected3@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/selected4@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/selected4@2x.png new file mode 100644 index 000000000..56396c803 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/selected4@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/selected5@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/selected5@2x.png new file mode 100644 index 000000000..1d571ada5 Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/selected5@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch.png b/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch.png index f23024ad1..63012b282 100644 Binary files a/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch.png and b/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch@2x.png b/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch@2x.png new file mode 100644 index 000000000..10d2fe15b Binary files /dev/null and b/designer/src/com/fr/design/mainframe/alphafine/images/smallsearch@2x.png differ diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java deleted file mode 100644 index c7286850f..000000000 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/ActionPreviewPane.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.fr.design.mainframe.alphafine.preview; - - -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; -import com.fr.general.IOUtils; -import com.fr.general.Inter; - -import javax.swing.*; -import java.awt.*; - - -/** - * Created by XiaXiang on 2017/5/5. - */ -public class ActionPreviewPane extends JPanel { - private static final Font NAME = new Font("Song_TypeFace", 0, 14); - - public ActionPreviewPane() { - setLayout(new BorderLayout()); - setBackground(null); - setBorder(BorderFactory.createEmptyBorder(135, 0, 0, 0)); - UILabel image = new UILabel(); - image.setPreferredSize(new Dimension(150, 111)); - image.setHorizontalAlignment(SwingConstants.CENTER); - image.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); - image.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/noresult.png")); - UILabel description = new UILabel(Inter.getLocText("FR-Designer_NoResult")); - description.setForeground(AlphaFineConstants.MEDIUM_GRAY); - description.setFont(NAME); - description.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - description.setHorizontalAlignment(SwingConstants.CENTER); - this.add(image, BorderLayout.CENTER); - this.add(description, BorderLayout.SOUTH); - } - -} diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java index ed96fbed9..6aa46f1a6 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java @@ -3,7 +3,6 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.mainframe.alphafine.AlphaFineConstants; -import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.*; import java.awt.*; @@ -16,30 +15,18 @@ public class DocumentPreviewPane extends JPanel { public DocumentPreviewPane(String title, String summary) { this.setLayout(new BorderLayout()); this.setBackground(Color.WHITE); + this.setPreferredSize(new Dimension(AlphaFineConstants.RIGHT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); UITextArea titleArea = new UITextArea(title); - UITextArea contentArea = new UITextArea(summary); - titleArea.setOpaque(false); - contentArea.setOpaque(false); - titleArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + titleArea.setBorder(null); + titleArea.setEditable(false); titleArea.setForeground(AlphaFineConstants.BLUE); - contentArea.setForeground(AlphaFineConstants.BLACK); - titleArea.setPreferredSize(new Dimension(360, 30)); titleArea.setFont(AlphaFineConstants.LARGE_FONT); - contentArea.setFont(AlphaFineConstants.MEDIUM_FONT); add(titleArea, BorderLayout.NORTH); + UITextArea contentArea = new UITextArea(summary); + contentArea.setEditable(false); + contentArea.setBorder(null); + contentArea.setForeground(AlphaFineConstants.BLACK); + contentArea.setFont(AlphaFineConstants.MEDIUM_FONT); add(contentArea, BorderLayout.CENTER); } - - - public static void main(String[] args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(null); - - content.add(new DocumentPreviewPane("test", "ababababaabbababab")); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 400); - jf.setVisible(true); - } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java index 15b69aab2..1ba7a5b91 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java @@ -18,7 +18,7 @@ public class FilePreviewPane extends JPanel { float widthScale = (AlphaFineConstants.RIGHT_WIDTH) / (float) image.getWidth(); float heightScale = (AlphaFineConstants.CONTENT_HEIGHT) / (float) image.getHeight(); Image showImage; - showImage = widthScale > heightScale? image.getScaledInstance((int) (image.getWidth() * heightScale), AlphaFineConstants.CONTENT_HEIGHT, Image.SCALE_SMOOTH) : image.getScaledInstance(AlphaFineConstants.RIGHT_WIDTH, (int) (image.getWidth() * widthScale), Image.SCALE_SMOOTH); + showImage = widthScale > heightScale ? image.getScaledInstance((int) (image.getWidth() * heightScale), AlphaFineConstants.CONTENT_HEIGHT, Image.SCALE_SMOOTH) : image.getScaledInstance(AlphaFineConstants.RIGHT_WIDTH, (int) (image.getWidth() * widthScale), Image.SCALE_SMOOTH); label.setIcon(new ImageIcon(showImage)); add(label); } diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/NoResultPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/NoResultPane.java new file mode 100644 index 000000000..738ecf4ef --- /dev/null +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/NoResultPane.java @@ -0,0 +1,32 @@ +package com.fr.design.mainframe.alphafine.preview; + +import com.bulenkov.iconloader.IconLoader; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.general.FRFont; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by XiaXiang on 2017/8/14. + */ +public class NoResultPane extends JPanel { + public NoResultPane(String title, String iconUrl) { + setLayout(new BorderLayout()); + setBackground(Color.white); + setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); + UILabel image = new UILabel(); + image.setPreferredSize(new Dimension(150, 111)); + image.setHorizontalAlignment(SwingConstants.CENTER); + image.setIcon(IconLoader.getIcon(iconUrl)); + image.setBorder(BorderFactory.createEmptyBorder(100, 0, 0, 0)); + UILabel description = new UILabel(title); + description.setForeground(AlphaFineConstants.MEDIUM_GRAY); + description.setFont(FRFont.getInstance("SimSun", Font.PLAIN, 14)); + description.setBorder(BorderFactory.createEmptyBorder(0, 0, 135, 0)); + description.setHorizontalAlignment(SwingConstants.CENTER); + add(image, BorderLayout.CENTER); + add(description, BorderLayout.SOUTH); + } +} diff --git a/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java b/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java index fed36e99f..d6cffc885 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java +++ b/designer/src/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java @@ -49,10 +49,10 @@ public class PluginPreviewPane extends JPanel { nameLabel.setBackground(AlphaFineConstants.BLUE); nameLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); line.setBorder(BorderFactory.createEmptyBorder(20, 0, 10, 0)); - String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : String.valueOf(price); + String price0 = price == 0 ? Inter.getLocText("FR-Designer-Collect_Information_free") : "¥" + String.valueOf(price); UILabel priceLabel = new UILabel(price0); priceLabel.setForeground(AlphaFineConstants.RED); - priceLabel.setFont(AlphaFineConstants.SMALL_FONT); + priceLabel.setFont(AlphaFineConstants.MEDIUM_FONT); bottomPane.add(priceLabel, BorderLayout.WEST); panel.add(nameLabel, BorderLayout.NORTH); panel.add(line, BorderLayout.SOUTH); diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java index 3756b03ae..185938ab8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java @@ -74,15 +74,12 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { if (!AlphaFineHelper.getFilterResult().contains(object)) { result.add(object); } - } - if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { + if (result.isEmpty()) { + return lessModelList; + } else if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"))); - if (result.size() == 0) { - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); - } else { - lessModelList.addAll(result); - } + lessModelList.addAll(result); } else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Set"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.ACTION)); lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); @@ -97,4 +94,4 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { public SearchResult getMoreSearchResult() { return moreModelList; } -} +} \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java index ebabc9aa2..11df76276 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java @@ -61,7 +61,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { if (!httpClient.isServerAlive()) { return getNoConnectList(); } - httpClient.setTimeout(5000); result = httpClient.getResponseText(); AlphaFineHelper.checkCancel(); try { @@ -76,13 +75,11 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { searchResult.add(cellModel); } } - if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { + if (searchResult.isEmpty()) { + return lessModelList; + } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"))); - if (searchResult.size() == 0) { - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); - } else { - lessModelList.addAll(searchResult); - } + lessModelList.addAll(searchResult); } else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.DOCUMENT)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); @@ -91,7 +88,6 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { } } catch (JSONException e) { FRLogger.getLogger().error("document search error: " + e.getMessage()); - return lessModelList; } } return lessModelList; @@ -114,4 +110,4 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor { return moreModelList; } -} +} \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java index 21f2b5fc4..8704e1776 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java @@ -19,7 +19,12 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; @@ -83,6 +88,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor { Env env = FRContext.getCurrentEnv(); fileNodes = new ArrayList<>(); fileNodes = listTpl(env, ProjectConstants.REPORTLETS_NAME, true); + AlphaFineHelper.checkCancel(); isContainCpt = true; isContainFrm = true; for (FileNode node : fileNodes) { @@ -100,13 +106,11 @@ public class FileSearchManager implements AlphaFineSearchProcessor { } } - if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { + if (result.isEmpty()) { + return lessModelList; + } else if (result.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"))); - if (result.size() == 0) { - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); - } else { - lessModelList.addAll(result); - } + lessModelList.addAll(result); } else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_Templates"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.FILE)); lessModelList.addAll(result.subList(0, AlphaFineConstants.SHOW_SIZE)); @@ -248,4 +252,4 @@ public class FileSearchManager implements AlphaFineSearchProcessor { public void setContainFrm(boolean containFrm) { isContainFrm = containFrm; } -} +} \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java index 5855168d7..2ea8ba0e8 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java @@ -96,7 +96,6 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { if (!httpClient.isServerAlive()) { return getNoConnectList(); } - httpClient.setTimeout(5000); result = httpClient.getResponseText(); AlphaFineHelper.checkCancel(); JSONObject jsonObject = new JSONObject(result); @@ -104,18 +103,17 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { if (jsonArray != null) { SearchResult searchResult = new SearchResult(); for (int i = 0; i < jsonArray.length(); i++) { + AlphaFineHelper.checkCancel(); PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false); if (!AlphaFineHelper.getFilterResult().contains(cellModel)) { searchResult.add(cellModel); } } - if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { + if (searchResult.isEmpty()) { + return this.lessModelList; + } else if (searchResult.size() < AlphaFineConstants.SHOW_SIZE + 1) { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"))); - if (searchResult.size() == 0) { - lessModelList.add(AlphaFineHelper.NO_RESULT_MODEL); - } else { - lessModelList.addAll(searchResult); - } + lessModelList.addAll(searchResult); } else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), true, CellType.PLUGIN)); lessModelList.addAll(searchResult.subList(0, AlphaFineConstants.SHOW_SIZE)); @@ -142,4 +140,4 @@ public class PluginSearchManager implements AlphaFineSearchProcessor { public SearchResult getMoreSearchResult() { return this.moreModelList; } -} +} \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java index 69959830c..c191c0c11 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java @@ -10,6 +10,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.file.XMLFileManager; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; @@ -26,8 +27,17 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLableReader; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStream; +import java.io.StringReader; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; /** * Created by XiaXiang on 2017/5/15. @@ -220,21 +230,24 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear recentModelList = recentKVModelMap.get(searchText); SearchResult resultModelList = recentModelList; Iterator modelIterator = resultModelList.iterator(); + SearchResult searchResult = new SearchResult(); while (modelIterator.hasNext()) { AlphaCellModel model = modelIterator.next(); - if (model.getType() == CellType.ACTION && !((ActionModel) model).getAction().isEnabled()) { - modelIterator.remove(); + if (model.getType() == CellType.ACTION && !UpdateActionManager.getUpdateActionManager().isEnable(((ActionModel) model).getAction())) { + continue; + } else { + searchResult.add(model); } } - Collections.sort(resultModelList); - int size = resultModelList.size(); + Collections.sort(searchResult); + int size = searchResult.size(); if (size > MAX_SIZE) { SearchResult result = new SearchResult(); - result.addAll(resultModelList.subList(0, MAX_SIZE)); + result.addAll(searchResult.subList(0, MAX_SIZE)); return result; } - return resultModelList; + return searchResult; } } return recentModelList; diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java index 176a24b24..6c741bd3d 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java @@ -16,6 +16,7 @@ import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.CodeUtils; +import com.fr.stable.StringUtils; import java.util.Iterator; import java.util.List; @@ -37,6 +38,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor { @Override public synchronized SearchResult getLessSearchResult(String searchText) { + searchText = searchText.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); this.modelList = new SearchResult(); this.recommendModelList = new SearchResult(); if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java index 21d815727..d48ce0832 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSConstants.java @@ -1,59 +1,69 @@ /** - * + * */ package com.fr.design.mainframe.bbs; import com.fr.general.IOUtils; +import com.fr.general.SiteCenter; import com.fr.stable.StringUtils; import java.util.Properties; /** * @author neil - * * @date: 2015-3-10-上午9:50:13 */ public class BBSConstants { //判断是否更新的关键字 public static final String UPDATE_KEY = loadAttribute("UPDATE_KEY", "newIsPopup"); - - - private static final String GUEST_KEY = "USER"; - private static final String LINK_KEY = "LINK"; - private static final int GUEST_NUM = 5; - - //用户名信息数组 - public static final String[] ALL_GUEST = loadAllGuestsInfo(GUEST_KEY); - //用户论坛链接信息 - public static final String[] ALL_LINK = loadAllGuestsInfo(LINK_KEY); - - private static Properties PROP = null; - - //加载所有用户的信息, 用户名, 论坛连接 - private static String[] loadAllGuestsInfo(String key){ - String[] allGuests = new String[GUEST_NUM]; - for (int i = 0; i < GUEST_NUM; i++) { - allGuests[i] = loadAttribute(key + i, StringUtils.EMPTY); - } - - return allGuests; - } - //如果要定制, 直接改bbs.properties就行了 - private static String loadAttribute(String key, String defaultValue) { - if (PROP == null) { - PROP = new Properties(); - try { - PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); - } catch (Exception e) { - } - } - - String p = PROP.getProperty(key); - if (StringUtils.isEmpty(p)) { - p = defaultValue; - } - return p; - } - + + + private static final String GUEST_KEY = "USER"; + private static final String GUEST_KEY_ONLINE = "guest.user"; + private static final String LINK_KEY = "LINK"; + private static final String LINK_KEY_ONLINE = "guest.link"; + + private static Properties PROP = null; + + public static String[] getAllGuest() { + return loadAllGuestsInfoOnline(GUEST_KEY_ONLINE, loadAllGuestsInfo(GUEST_KEY)); + } + + public static String[] getAllLink() { + return loadAllGuestsInfoOnline(LINK_KEY_ONLINE, loadAllGuestsInfo(LINK_KEY)); + } + + //加载所有用户的信息, 用户名, 论坛连接 + private static String loadAllGuestsInfo(String key) { + return loadAttribute(key, StringUtils.EMPTY); + } + + //加载所有用户的信息, 用户名, 论坛连接 + private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) { + String[] allGuests = new String[0]; + String guest = SiteCenter.getInstance().acquireUrlByKind(key, defaultValue); + if (StringUtils.isNotEmpty(guest)) { + allGuests = guest.split("\\|"); + } + return allGuests; + } + + //如果要定制, 直接改bbs.properties就行了 + private static String loadAttribute(String key, String defaultValue) { + if (PROP == null) { + PROP = new Properties(); + try { + PROP.load(IOUtils.getResourceAsStream("/com/fr/design/mainframe/bbs/bbs.properties", BBSConstants.class)); + } catch (Exception e) { + } + } + + String p = PROP.getProperty(key); + if (StringUtils.isEmpty(p)) { + p = defaultValue; + } + return p; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSGuestPane.java b/designer/src/com/fr/design/mainframe/bbs/BBSGuestPane.java index b86a0cc5c..2fe20b901 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSGuestPane.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSGuestPane.java @@ -3,15 +3,6 @@ */ package com.fr.design.mainframe.bbs; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Desktop; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URI; - -import javax.swing.JPanel; - import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; @@ -21,6 +12,12 @@ import com.fr.general.Inter; import com.fr.stable.StringUtils; import com.fr.start.BBSGuestPaneProvider; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URI; + /** * @author neil * @@ -54,9 +51,12 @@ public class BBSGuestPane extends JPanel implements BBSGuestPaneProvider{ double[] colSize = {p}; Component[][] components = new Component[rowSize.length][colSize.length]; - for (int i = 0; i < components.length; i++) { - String userName = BBSConstants.ALL_GUEST[i]; - String url = BBSConstants.ALL_LINK[i]; + String[] allGuest = BBSConstants.getAllGuest(); + String[] allLink = BBSConstants.getAllLink(); + int min = Math.min(allGuest.length, components.length); + for (int i = 0; i < min; i++) { + String userName = allGuest[i]; + String url = allLink[i]; components[i][0] = getURLActionLabel(userName, url); } diff --git a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java index 3946b73e5..f5401c028 100644 --- a/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java +++ b/designer/src/com/fr/design/mainframe/bbs/BBSLoginDialog.java @@ -1,6 +1,8 @@ package com.fr.design.mainframe.bbs; -import com.fr.design.DesignerEnvManager; +import com.fr.base.ConfigManager; +import com.fr.base.FRContext; +import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.ActionLabel; @@ -207,8 +209,8 @@ public class BBSLoginDialog extends UIDialog { // 登录成功 private void loginSuccess() { - DesignerEnvManager.getEnvManager().setBBSPassword(String.valueOf(passField.getPassword())); - userInfoLabel.setUserName(nameField.getText()); + String password = String.valueOf(passField.getPassword()); + BBSLoginUtils.bbsLogin(nameField.getText(), password); userInfoLabel.getUserInfoPane().markSignIn(nameField.getText()); BBSLoginDialog.this.setVisible(false); } diff --git a/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java b/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java index c3436755a..a830d3332 100644 --- a/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/ExitLabel.java @@ -9,14 +9,13 @@ import java.awt.event.MouseEvent; import com.fr.base.BaseUtils; -import com.fr.design.DesignerEnvManager; +import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; -import com.fr.stable.StringUtils; /** * @author neil @@ -61,8 +60,7 @@ public class ExitLabel extends UILabel{ } private void clearLoingInformation(){ - DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY); + BBSLoginUtils.bbsLogout(); } private void updateInfoPane(){ diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 4d58b3db6..b313ac1ba 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -3,35 +3,48 @@ */ package com.fr.design.mainframe.bbs; +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; -import com.fr.design.extra.*; +import com.fr.design.bbs.BBSLoginUtils; +import com.fr.design.extra.LoginContextListener; +import com.fr.design.extra.LoginWebBridge; +import com.fr.design.extra.PluginWebBridge; +import com.fr.design.extra.UserLoginContext; +import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.DateUtils; import com.fr.general.Inter; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; -import com.fr.plugin.manage.bbs.BBSPluginLogin; -import com.fr.plugin.manage.bbs.BBSUserInfo; import com.fr.stable.EncodeConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.SwingConstants; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Frame; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.net.URI; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; /** * @author neil @@ -39,6 +52,7 @@ import java.util.Date; */ public class UserInfoLabel extends UILabel { + private static final int VERSION_8 = 8; //默认查询消息时间, 30s private static final long CHECK_MESSAGE_TIME = 30 * 1000L; //默认论坛检测到更新后的弹出延迟时间 @@ -75,41 +89,26 @@ public class UserInfoLabel extends UILabel { } public UserInfoLabel(UserInfoPane userInfoPane) { + init(userInfoPane); + } + + private void init(UserInfoPane userInfoPane) { this.userInfoPane = userInfoPane; - String userName = DesignerEnvManager.getEnvManager().getBBSName(); + String userName = ConfigManager.getProviderInstance().getBbsUsername(); this.addMouseListener(userInfoAdapter); this.setHorizontalAlignment(SwingConstants.CENTER); this.setText(userName); - LoginWebBridge loginWebBridge = new LoginWebBridge(); - loginWebBridge.setUserName(userName, UserInfoLabel.this); - - LoginCheckContext.addLoginCheckListener(new LoginCheckListener() { - @Override - public void loginChecked() { - /* - if (bbsLoginDialog == null) { - bbsLoginDialog = new BBSLoginDialog(DesignerContext.getDesignerFrame(), UserInfoLabel.this); - } - bbsLoginDialog.clearLoginInformation(); - bbsLoginDialog.showTipForDownloadPluginWithoutLogin(); - bbsLoginDialog.setModal(true); - bbsLoginDialog.showWindow(); - */ - } - }); - - if (StableUtils.getMajorJavaVersion() == 8) { + if (StableUtils.getMajorJavaVersion() == VERSION_8) { + LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this); PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this); } - LoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this); UserLoginContext.addLoginContextListener(new LoginContextListener() { @Override public void showLoginContext() { WebViewDlgHelper.createLoginDialog(); - LoginWebBridge.getHelper().setUILabel(UserInfoLabel.this); clearLoginInformation(); updateInfoPane(); } @@ -117,10 +116,7 @@ public class UserInfoLabel extends UILabel { } private void clearLoginInformation() { - DesignerEnvManager.getEnvManager().setBBSName(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setBBSPassword(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); - DesignerEnvManager.getEnvManager().setBbsUid(DEFAULT_BBS_UID); + BBSLoginUtils.bbsLogout(); } private void updateInfoPane() { @@ -131,8 +127,13 @@ public class UserInfoLabel extends UILabel { * showBBSDialog 弹出BBS资讯框 */ public static void showBBSDialog() { - Thread showBBSThread = new Thread(new Runnable() { - + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() + .setNameFormat("bbs-dlg-thread-%s").build(); + ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( + 1, 1, + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue(1), namedThreadFactory); + threadPoolExecutor.execute(new Runnable() { @Override public void run() { // vito:最新mac10.12和javafx弹出框初始化时会有大几率卡死在native方法,这里先屏蔽一下。 @@ -154,18 +155,21 @@ public class UserInfoLabel extends UILabel { return; } String res = hc.getResponseText(); - if (res.indexOf(BBSConstants.UPDATE_KEY) == -1) { + if (!res.contains(BBSConstants.UPDATE_KEY)) { return; } try { - BBSDialog bbsLabel = new BBSDialog(DesignerContext.getDesignerFrame()); - bbsLabel.showWindow(SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); + Class clazz = Class.forName("com.fr.design.mainframe.bbs.BBSDialog"); + Constructor constructor = clazz.getConstructor(Frame.class); + Object instance = constructor.newInstance(DesignerContext.getDesignerFrame()); + Method showWindow = clazz.getMethod("showWindow", String.class); + showWindow.invoke(instance, SiteCenter.getInstance().acquireUrlByKind("bbs.popup")); DesignerEnvManager.getEnvManager().setLastShowBBSNewsTime(DateUtils.DATEFORMAT2.format(new Date())); - } catch (Throwable e) { + } catch (Throwable ignored) { + // ignored } } }); - showBBSThread.start(); } private void sleep(long millis) { @@ -192,8 +196,6 @@ public class UserInfoLabel extends UILabel { return; } - //往designerenvmanger里写一下 - DesignerEnvManager.getEnvManager().setBBSName(userName); this.userName = userName; } @@ -220,26 +222,25 @@ public class UserInfoLabel extends UILabel { } this.messageCount = messageCount; - StringBuilder sb = new StringBuilder(); + String sb = StringUtils.BLANK + this.userName + + "(" + this.messageCount + + ")" + StringUtils.BLANK; //内容eg: aaa(11) - sb.append(StringUtils.BLANK).append(this.userName) - .append("(").append(this.messageCount) - .append(")").append(StringUtils.BLANK); //更新面板Text - this.setText(sb.toString()); + this.setText(sb); } private MouseAdapter userInfoAdapter = new MouseAdapter() { + @Override public void mouseEntered(MouseEvent e) { UserInfoLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR)); } @Override public void mouseClicked(MouseEvent e) { - BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo(); - userName = bbsUserInfo == null ? "" : bbsUserInfo.getUserName(); + userName = ConfigManager.getProviderInstance().getBbsUsername(); if (StringUtils.isNotEmpty(userName)) { UIPopupMenu menu = new UIPopupMenu(); menu.setOnlyText(true); @@ -248,6 +249,7 @@ public class UserInfoLabel extends UILabel { //私人消息 UIMenuItem priviteMessage = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Privite-Message")); priviteMessage.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(MouseEvent e) { if (StringUtils.isNotEmpty(userName)) { try { @@ -256,7 +258,6 @@ public class UserInfoLabel extends UILabel { } catch (Exception exp) { FRContext.getLogger().info(exp.getMessage()); } - return; } } @@ -264,11 +265,11 @@ public class UserInfoLabel extends UILabel { //切换账号 UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer-BBSLogin_Switch-Account")); closeOther.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(MouseEvent e) { - BBSPluginLogin.getInstance().logOut(); + BBSLoginUtils.bbsLogout(); UserLoginContext.fireLoginContextListener(); } - }); menu.add(priviteMessage); menu.add(closeOther); diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java index a638ac3e4..4491fef8e 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -3,25 +3,27 @@ */ package com.fr.design.mainframe.bbs; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - +import com.fr.base.ConfigManager; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; +import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.mainframe.DesignerContext; import com.fr.general.DateUtils; import com.fr.general.FRLogger; +import com.fr.general.GeneralContext; import com.fr.general.Inter; -import com.fr.plugin.manage.bbs.BBSPluginLogin; -import com.fr.plugin.manage.bbs.BBSUserInfo; +import com.fr.stable.EnvChangedListener; import com.fr.stable.StringUtils; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + /** * @author neil @@ -31,7 +33,7 @@ import com.fr.stable.StringUtils; public class UserInfoPane extends BasicPane{ //默认未登录颜色 - private static final Color UN_LOGIN_BACKGROUND = new Color(210, 210, 210); + private static final Color UN_LOGIN_BACKGROUND = UIConstants.TEMPLATE_TAB_PANE_BACKGROUND; private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); private static final int WIDTH = 104; private static final int HEIGHT = 24; @@ -46,6 +48,7 @@ public class UserInfoPane extends BasicPane{ private UserInfoLabel userInfoLabel; + public UserInfoLabel getUserInfoLabel() { return userInfoLabel; } @@ -65,29 +68,26 @@ public class UserInfoPane extends BasicPane{ this.userInfoLabel = new UserInfoLabel(this); this.markUnSignIn(); - autoLogin(); + addEnvChangedListener(); autoPushLoginDialog(); this.add(userInfoLabel, BorderLayout.CENTER); } - - // 后台自动登录 - private void autoLogin(){ - Thread bbsAutoLoginThread = new Thread(new Runnable() { + private void addEnvChangedListener(){ + GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override - public void run() { - String username = DesignerEnvManager.getEnvManager().getBBSName(); - String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); - if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)){ + public void envChanged() { + String username = ConfigManager.getProviderInstance().getBbsUsername(); + if (StringUtils.isEmpty(username)){ markUnSignIn(); } else { markSignIn(username); } } }); - bbsAutoLoginThread.start(); } + // 计算xml保存的上次弹框时间和当前时间的时间差 private int getDiffFromLastLogin(){ @@ -133,7 +133,7 @@ public class UserInfoPane extends BasicPane{ FRContext.getLogger().error(e.getMessage()); } - String userName = DesignerEnvManager.getEnvManager().getBBSName(); + String userName = ConfigManager.getProviderInstance().getBbsUsername(); if(StringUtils.isNotEmpty(userName)){ return; } @@ -169,8 +169,6 @@ public class UserInfoPane extends BasicPane{ * */ public void markSignIn(String userName){ - String password = DesignerEnvManager.getEnvManager().getBBSPassword(); - BBSPluginLogin.getInstance().login(new BBSUserInfo(userName, password)); this.userInfoLabel.setText(userName); this.userInfoLabel.setUserName(userName); this.userInfoLabel.setOpaque(true); diff --git a/designer/src/com/fr/design/mainframe/bbs/bbs.properties b/designer/src/com/fr/design/mainframe/bbs/bbs.properties index 44db03d46..ae39a3ee3 100644 --- a/designer/src/com/fr/design/mainframe/bbs/bbs.properties +++ b/designer/src/com/fr/design/mainframe/bbs/bbs.properties @@ -4,16 +4,8 @@ COLLECT_URL=http://www.finereporthelp.com:8081/bbs/ReportServer?op=bbs&cmd=colle DEFAULT_URL=http\://bbs.finereport.com/home.php?mod=space&do=notice GET_MESSAGE_URL=http://feedback.finedevelop.com:3000/bbs/message/count GET_SIGN_INFO_URL=http\://bbs.finereport.com -LINK0=http\://bbs.finereport.com/space-uid-55823.html -LINK1=http\://bbs.finereport.com/space-uid-56940.html -LINK2=http\://bbs.finereport.com/space-uid-51621.html -LINK3=http\://bbs.finereport.com/space-uid-52618.html -LINK4=http\://bbs.finereport.com/space-uid-48993.html +LINK=http\://bbs.fanruan.com/home.php?mod=space&uid=66470&do=profile|http\://bbs.fanruan.com/home.php?mod=space&uid=67190&do=profile|http\://bbs.fanruan.com/home.php?mod=space&uid=65659&do=profile|http\://bbs.fanruan.com/home.php?mod=space&uid=60352&do=profile|http\://bbs.fanruan.com/home.php?mod=space&uid=78157&do=profile SHARE_URL=http\://bbs.finereport.com -USER0=\u6590\u6CE2\u90A3\u5951(\u5B59\u70B3\u6DA6) -USER1=deafire(\u674E\u5FD7\u4F1F) -USER2=\u963F\u8FEA(\u8C22\u8FEA) -USER3=bingjie(\u5F20\u8BB0\u82B1) -USER4=\u6D77\u7EF5\u5B9D\u5B9D(\u90DD\u6B63) +USER=cherishdqy\uFF08\u9093\u79CB\u4E91\uFF09|yets11\uFF08\u9676\u5B5D\u6587\uFF09|\u661F\u75D5\uFF08\u71D5\u5B8F\u4F1F\uFF09|\u9759\u542C\u7985\u9E23\uFF08\u674E\u51A0\u519B\uFF09|yiyemeiying\uFF08\u5218\u4F73\uFF09 VERIFY_URL=http://www.finereporthelp.com:8081/bbs/ReportServer?op=bbs&cmd=verify UPDATE_INFO_URL=http://bbs.finereport.com/source/plugin/infor/infor.html diff --git a/designer/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java b/designer/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java new file mode 100644 index 000000000..a56d251a7 --- /dev/null +++ b/designer/src/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java @@ -0,0 +1,123 @@ +package com.fr.design.mainframe.cell; + +import com.fr.design.gui.iscrollbar.UIScrollBar; +import com.fr.design.mainframe.CellElementPropertyPane; +import com.fr.quickeditor.cellquick.layout.CellElementBarLayout; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; + +/** + * 右侧单元格元素面板抽象类 + * + * @author yaoh.wu + * @version 2017年7月25日 + * @since 9.0 + */ +public abstract class AbstractDSCellEditorPane extends JPanel { + + /** + * 滚动条相关配置 + */ + private static final int MAXVALUE = 100; + private static final int TITLE_HEIGHT = 95; + private static final int CONTENT_PANE_WIDTH_GAP = 3; + private static final int SCROLLBAR_WIDTH = 7; + private static final int MOUSE_WHEEL_SPEED = 5; + private int maxHeight = 280; + + private JPanel leftContentPane; + private UIScrollBar scrollBar; + + protected abstract JPanel createContentPane(); + + public abstract String getIconPath(); + + public abstract String title4PopupWindow(); + + /** + * 从面板拿数据保存 + */ + public abstract void update(); + + /** + * 更新面板数据 + */ + public abstract void populate(); + + protected void createScrollPane() { + leftContentPane = this.createContentPane(); + this.prepareScrollBar(); + leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); + + this.setLayout(new CellElementBarLayout(leftContentPane) { + @Override + public void layoutContainer(Container parent) { + maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT; + int beginY; + if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) { + beginY = 0; + } else { + int preferredHeight = leftContentPane.getPreferredSize().height; + int value = scrollBar.getValue(); + beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount()); + } + int width = parent.getWidth(); + int height = parent.getHeight(); + if (leftContentPane.getPreferredSize().height > maxHeight) { + leftContentPane.setBounds(0, -beginY, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height + beginY); + scrollBar.setBounds(width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, 0, SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, height); + } else { + leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height); + } + } + }); + this.add(scrollBar); + this.add(leftContentPane); + } + + + private void prepareScrollBar() { + scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) { + @Override + public int getVisibleAmount() { + int preferredHeight = leftContentPane.getPreferredSize().height; + int e = MAXVALUE * (maxHeight) / preferredHeight; + setVisibleAmount(e); + return e; + } + + @Override + public int getMaximum() { + return MAXVALUE; + } + }; + + scrollBar.addAdjustmentListener(new AdjustmentListener() { + + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + doLayout(); + } + }); + this.addMouseWheelListener(new MouseWheelListener() { + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + int value = scrollBar.getValue(); + value += MOUSE_WHEEL_SPEED * e.getWheelRotation(); + scrollBar.setValue(value); + doLayout(); + } + }); + scrollBar.setPreferredSize(new Dimension(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, this.getHeight())); + scrollBar.setBlockIncrement(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP); + scrollBar.setBorder(BorderFactory.createMatteBorder(0, CONTENT_PANE_WIDTH_GAP, 0, 0, this.getBackground())); + } +} diff --git a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java b/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java deleted file mode 100644 index 48b6d8a17..000000000 --- a/designer/src/com/fr/design/mainframe/cell/CellEditorPane.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fr.design.mainframe.cell; - -import com.fr.design.dialog.BasicPane; - -/** - * 右侧单元格元素面板抽象类 - * - * @author yaoh.wu - * @version 2017年7月25日 - * @since 9.0 - */ -public abstract class CellEditorPane extends BasicPane { - - public abstract String getIconPath(); - - public abstract String title4PopupWindow(); - - /** - * 从面板拿数据保存 - */ - public abstract void update(); - - /** - * 更新面板数据 - * - */ - public abstract void populate(); -} diff --git a/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java b/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java index f0ee3937c..e492253bd 100644 --- a/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java +++ b/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java @@ -32,35 +32,22 @@ import java.util.List; * @since 2012-5-8下午12:18:53 */ public class CellElementEditPane extends BasicPane { - private static int TIME_GAP = 80; + private static final int LEFT_BORDER = -5; + private static final int RIGHT_BORDER = 5; private List paneList; private TemplateCellElement cellelement; private ElementCasePane ePane; private UIHeadGroup tabsHeaderIconPane; private boolean isEditing; - private int PaneListIndex; private CardLayout card; private JPanel center; private JPanel downTitle; - private JPanel title; - private UILabel titlename; private TitleChangeListener titleChangeListener = null; private CellAttributeProvider cellAttributeProvider = null; - public static void main(String[] args){ - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(new CellElementEditPane(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(290, 400); - jf.setVisible(true); - } - public CellElementEditPane() { setLayout(new BorderLayout()); initPaneList(); @@ -89,7 +76,7 @@ public class CellElementEditPane extends BasicPane { downTitle = new JPanel(); downTitle.setLayout(new BorderLayout()); downTitle.add(tabsHeaderIconPane, BorderLayout.NORTH); - center.setBorder(BorderFactory.createEmptyBorder(0, -10, 0, -10)); + center.setBorder(BorderFactory.createEmptyBorder(0, LEFT_BORDER, 0, 0)); downTitle.add(center, BorderLayout.CENTER); this.add(downTitle, BorderLayout.CENTER); diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 2f0398701..b903e6804 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.BaseUtils; import com.fr.design.constants.LayoutConstants; +import com.fr.design.constants.UIConstants; import com.fr.design.expand.ExpandLeftFatherPane; import com.fr.design.expand.ExpandUpFatherPane; import com.fr.design.expand.SortExpandAttrPane; @@ -44,10 +45,10 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { */ public JPanel createContentPane() { String[] nameArray = {Inter.getLocText("ExpandD-Not_Expand"), Inter.getLocText("Utils-Top_to_Bottom"), Inter.getLocText("Utils-Left_to_Right")}; - Icon[] iconArray = { - BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), - BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png"), - BaseUtils.readIcon("/com/fr/design/images/expand/landspace.png") + Icon[][] iconArray = { + {BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), BaseUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")}, + {BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png"), BaseUtils.readIcon("/com/fr/design/images/expand/vertical_selected@1x.png")}, + {BaseUtils.readIcon("/com/fr/design/images/expand/landspace.png"), BaseUtils.readIcon("/com/fr/design/images/expand/landspace_selected@1x.png")} }; Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT}; expandDirectionButton = new UIButtonGroup(iconArray, valueArray); @@ -61,18 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { return layoutPane(); } - - public static void main(String[] args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(new CellExpandAttrPane().layoutPane(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(290, 400); - jf.setVisible(true); - } - private void initAllNames() { expandDirectionButton.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")); leftFatherPane.setGlobalName(Inter.getLocText("FR-Designer_LeftParent")); @@ -85,8 +74,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { layoutPane = new JPanel(new BorderLayout()); basicPane = new JPanel(); seniorPane = new JPanel(); - basicPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), 290, 24, basicPane()); - seniorPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 290, 24, seniorPane()); + basicPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), 223, 24, basicPane()); + seniorPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 223, 24, seniorPane()); layoutPane.add(basicPane, BorderLayout.NORTH); layoutPane.add(seniorPane, BorderLayout.CENTER); return layoutPane; @@ -96,8 +85,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; UILabel direction = new UILabel(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction"), SwingConstants.LEFT); -// JPanel directionPane = new JPanel(new BorderLayout()); -// directionPane.add(direction, BorderLayout.NORTH); + JPanel directionPane = new JPanel(new BorderLayout()); + directionPane.add(direction, BorderLayout.NORTH); UILabel left = new UILabel(Inter.getLocText("FR-Designer_LeftParent"), SwingConstants.LEFT); JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(left, BorderLayout.NORTH); @@ -106,7 +95,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { upPane.add(up, BorderLayout.NORTH); Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{direction, expandDirectionButton}, + new Component[]{directionPane, expandDirectionButton}, new Component[]{leftPane, leftFatherPane}, new Component[]{upPane, rightFatherPane}, }; @@ -122,6 +111,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { UILabel expendSort = new UILabel(Inter.getLocText("FR-Designer_ExpendSort"), SwingConstants.LEFT); JPanel expendSortPane = new JPanel(new BorderLayout()); expendSortPane.add(expendSort, BorderLayout.NORTH); + horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{horizontalExpandableCheckBox, null}, @@ -163,6 +154,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { default: { horizontalExpandableCheckBox.setSelected(false); verticalExpandableCheckBox.setSelected(false); + break; } } @@ -196,7 +188,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { // extendable - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD-Expandable"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Expandable"))) { if (horizontalExpandableCheckBox.isSelected()) { if (verticalExpandableCheckBox.isSelected()) { cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 4ace2d620..951333895 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.design.constants.LayoutConstants; +import com.fr.design.constants.UIConstants; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.file.HistoryTemplateListPane; @@ -10,6 +11,7 @@ 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.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.JTemplate; @@ -21,6 +23,7 @@ import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.report.cell.cellattr.CellInsertPolicyAttr; import com.fr.report.cell.cellattr.CellPageAttr; import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -37,6 +40,8 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private static final int HEAD_WDITH = 290; private static final int HEAD_HEIGTH = 24; + private static final Dimension NORMAL_DIMENSION = new Dimension(155, 20); + private static final Dimension SMALL_DIMENSION = new Dimension(150, 20); // normal private UIButtonGroup autoshrik; @@ -77,7 +82,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { JPanel downPane = new JPanel(new BorderLayout()); downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), HEAD_WDITH, HEAD_HEIGTH, seniorPane()), BorderLayout.NORTH); downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Pagination"), HEAD_WDITH, HEAD_HEIGTH, pagePane()), BorderLayout.CENTER); - JPanel contentPane = new JPanel(new BorderLayout(0, 10)); + JPanel contentPane = new JPanel(new BorderLayout(0, 0)); contentPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), HEAD_WDITH, HEAD_HEIGTH, basicPane()), BorderLayout.NORTH); contentPane.add(downPane, BorderLayout.CENTER); initAllNames(); @@ -88,18 +93,19 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private JPanel basicPane() { autoHeightCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); autoWidthCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Auto_Adjust_Wdith")); + autoHeightCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + autoWidthCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p}; + double[] rowSize = {p, p, p, p}; double[] columnSize = {p}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ new Component[]{null}, new Component[]{autoHeightCheckBox}, - new Component[]{null}, new Component[]{autoWidthCheckBox}, new Component[]{null}, }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_LARGE); } @@ -136,7 +142,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { new Component[]{new UILabel(Inter.getLocText("FR-Designer_CellWrite_InsertRow_Policy"), SwingConstants.LEFT), insertRowPolicy}, new Component[]{null, insertRowPane}, }; - southContentPane = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize1, columnSize1, rowCount1, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + southContentPane = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize1, columnSize1, rowCount1, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); JPanel seniorPane = new JPanel(new BorderLayout()); seniorPane.add(seniorUpPane(), BorderLayout.NORTH); seniorPane.add(southContentPane, BorderLayout.CENTER); @@ -146,22 +152,48 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private JPanel seniorUpPane() { JPanel fileNamePane = createNormal(); + previewCellContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + printAndExportContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + printAndExportBackground.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p, p, p, p, p}; + double[] rowSize = {p, p, p, p}; double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{previewCellContent, null}, new Component[]{printAndExportContent, null}, new Component[]{printAndExportBackground, null}, - new Component[]{new UILabel(Inter.getLocText("FR-Designer_Show_Content"), SwingConstants.LEFT), showContent}, - new Component[]{null, fileNamePane}, - new Component[]{new UILabel(Inter.getLocText("FR-Designer_CellWrite_ToolTip"), SwingConstants.RIGHT), tooltipTextField}, + }; + JPanel upPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_LARGE); + + double[] downRowSize = {p, p, p, p, p, p}; + double[] downColumnSize = {p, f}; + int[][] downRowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + + JPanel showContentPane = new JPanel(FRGUIPaneFactory.createRightZeroLayout()); + showContent.setPreferredSize(SMALL_DIMENSION); + showContentPane.add(showContent); + fileNamePane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); + + JPanel tooltipTextFieldPane = new JPanel(FRGUIPaneFactory.createRightZeroLayout()); + tooltipTextField.setPreferredSize(NORMAL_DIMENSION); + tooltipTextFieldPane.add(tooltipTextField); + + Component[][] downComponent = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Show_Content"), SwingConstants.LEFT), showContentPane}, + new Component[]{fileNamePane, null}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_CellWrite_ToolTip"), SwingConstants.LEFT), tooltipTextFieldPane}, + new Component[]{null, null}, new Component[]{null, null}, }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + JPanel downPane = TableLayoutHelper.createGapTableLayoutPane(downComponent, downRowSize, downColumnSize, downRowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); + JPanel pane = new JPanel(new BorderLayout()); + pane.add(upPane, BorderLayout.NORTH); + pane.add(downPane, BorderLayout.CENTER); + return pane; } private JPanel pagePane() { @@ -175,6 +207,13 @@ public class CellOtherSetPane extends AbstractCellAttrPane { canBreakOnPaginateCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_CellPage_Can_Break_On_Paginate")); repeatCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_CellPage_Repeat_Content_When_Paging")); + pageBeforeRowCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + pageAfterRowCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + pageBeforeColumnCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + pageAfterColumnCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + canBreakOnPaginateCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + repeatCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); + double p = TableLayout.PREFERRED; double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p}; double[] columnSize = {p}; @@ -190,7 +229,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { new Component[]{canBreakOnPaginateCheckBox}, new Component[]{repeatCheckBox}, }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_LARGE); } @@ -224,8 +263,6 @@ public class CellOtherSetPane extends AbstractCellAttrPane { } } }); - tooltipTextField = new UITextField(); - tooltipTextField.getUI(); return fileNamePane; } @@ -320,6 +357,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { this.valueEditor.populate(defaultValue); } else { insertRowPolicy.setSelectedIndex(0); + this.valueEditor.populate(StringUtils.EMPTY); } if (insertRowPolicy.getSelectedIndex() == 1) { insertRowPane.setPreferredSize(new Dimension(100, 20)); @@ -428,10 +466,10 @@ public class CellOtherSetPane extends AbstractCellAttrPane { if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Page_After_Column"))) { cellPageAttr.setPageAfterColumn(this.pageAfterColumnCheckBox.isSelected()); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Can_Break_On_Paginate"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellPage_Can_Break_On_Paginate"))) { cellPageAttr.setCanBreakOnPaginate(canBreakOnPaginateCheckBox.isSelected()); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Repeat_Content_When_Paging"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellPage_Repeat_Content_When_Paging"))) { cellPageAttr.setRepeat(this.repeatCheckBox.isSelected()); } diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java index 8d29ff133..07688134f 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.present.Present; +import com.fr.design.constants.UIConstants; import com.fr.design.present.PresentPane; import com.fr.general.Inter; import com.fr.report.cell.DefaultTemplateCellElement; @@ -17,16 +18,18 @@ import java.awt.event.ItemListener; * @since 2012-5-11下午5:24:35 */ public class CellPresentPane extends AbstractCellAttrPane { - private PresentPane presentPane; + private PresentPane presentPane; /** * 初始化面板 - * @return 面板 + * + * @return 面板 */ - public JPanel createContentPane() { - presentPane = new PresentPane(); + public JPanel createContentPane() { + presentPane = new PresentPane(); JPanel content = new JPanel(new BorderLayout()); content.add(presentPane, BorderLayout.CENTER); + presentPane.setBorder(UIConstants.CELL_ATTR_PRESENTBORDER); presentPane.addTabChangeListener(new ItemListener() { @Override @@ -35,23 +38,23 @@ public class CellPresentPane extends AbstractCellAttrPane { } }); return content; - } + } - @Override - public String getIconPath() { + @Override + public String getIconPath() { // return "com/fr/design/images/data/source/dataDictionary.png"; return Inter.getLocText("FR-Designer_Present"); - } + } - @Override - public void updateBean(TemplateCellElement cellElement) { - cellElement.setPresent(presentPane.updateBean()); - } + @Override + public void updateBean(TemplateCellElement cellElement) { + cellElement.setPresent(presentPane.updateBean()); + } /** * 保存 */ - public void updateBeans() { + public void updateBeans() { Present present = presentPane.updateBean(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); int cellRectangleCount = cs.getCellRectangleCount(); @@ -71,21 +74,21 @@ public class CellPresentPane extends AbstractCellAttrPane { } } } - } + } - @Override - protected void populateBean() { + @Override + protected void populateBean() { //选中的所有单元格都有形态,属性表才会有内容,否则是初始值 //主要是解决37664 - Present present = getSelectCellPresent(); + Present present = getSelectCellPresent(); presentPane.populateBean(present); - } + } - private Present getSelectCellPresent(){ + private Present getSelectCellPresent() { TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); //按住ctrl选中多个cell块 int cellRectangleCount = cs.getCellRectangleCount(); - + for (int rect = 0; rect < cellRectangleCount; rect++) { Rectangle cellRectangle = cs.getCellRectangle(rect); for (int j = 0; j < cellRectangle.height; j++) { @@ -93,8 +96,8 @@ public class CellPresentPane extends AbstractCellAttrPane { int column = i + cellRectangle.x; int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if(cellElement == null || cellElement.getPresent() == null){ - return null; + if (cellElement == null || cellElement.getPresent() == null) { + return null; } } } @@ -104,15 +107,16 @@ public class CellPresentPane extends AbstractCellAttrPane { /** * 对话框标题 - * @return 标题 + * + * @return 标题 */ - public String title4PopupWindow() { - return Inter.getLocText("FR-Chart-Style_Present"); - } + public String title4PopupWindow() { + return Inter.getLocText("FR-Chart-Style_Present"); + } - public void setSelectedByIds(int level, String... id) { - presentPane.setSelectedByName(id[level]); - } + public void setSelectedByIds(int level, String... id) { + presentPane.setSelectedByName(id[level]); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index be997ae0b..dc42b82d2 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.Style; +import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.cell.settingpane.style.StylePane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; @@ -25,6 +26,7 @@ public class CellStylePane extends AbstractCellAttrPane { JPanel content = new JPanel(new BorderLayout()); stylePane = new StylePane(); content.add(stylePane, BorderLayout.CENTER); + stylePane.setBorder(UIConstants.CELL_ATTR_PRESENTBORDER); stylePane.addPredefinedChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { attributeChanged(); @@ -37,7 +39,6 @@ public class CellStylePane extends AbstractCellAttrPane { adjustValues();// 里面的Tab切换后要及时调整滚动条,因为一些界面可能不需要滚动条 } }); -// content.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); return content; } diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index ecc22aae7..06b8cb937 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -6,15 +6,12 @@ import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.MultiTabPane; -import com.fr.design.gui.ibutton.FiveButtonLayout; import com.fr.design.gui.style.*; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.style.BorderUtils; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; @@ -40,18 +37,19 @@ public class CustomStylePane extends MultiTabPane