diff --git a/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java b/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java index beb62c06e..874a8f8b1 100644 --- a/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java +++ b/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java @@ -6,18 +6,14 @@ package com.fr.design; import com.fr.base.BaseUtils; import com.fr.design.data.datapane.TableDataNameObjectCreator; -import com.fr.design.fun.CellWidgetOptionProvider; -import com.fr.design.fun.FormWidgetOptionProvider; -import com.fr.design.fun.ParameterWidgetOptionProvider; -import com.fr.design.fun.ServerTableDataDefineProvider; -import com.fr.design.fun.TableDataDefineProvider; -import com.fr.design.fun.ToolbarItemProvider; +import com.fr.design.fun.*; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOptionFactory; import com.fr.design.menu.ShortCut; import com.fr.design.widget.Appearance; import com.fr.design.widget.mobile.WidgetMobilePane; import com.fr.form.ui.Widget; +import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.plugin.AbstractExtraClassManager; import com.fr.plugin.injectable.PluginModule; @@ -207,6 +203,20 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement return map; } + public MobileWidgetStyleProvider[] getMobileStyleOfWidget(String xType) { + Set set = getArray(MobileWidgetStyleProvider.XML_TAG); + if (set.isEmpty()) { + return new MobileWidgetStyleProvider[0]; + } + List providers = new ArrayList<>(); + for (MobileWidgetStyleProvider provider: set) { + if(ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) { + providers.add(provider); + } + } + return providers.toArray(new MobileWidgetStyleProvider[providers.size()]); + } + @Override protected boolean demountSpecific(PluginSingleInjection injection) { diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java index 9d8453f1e..c03d5d3de 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java @@ -7,6 +7,7 @@ import com.fr.base.BaseUtils; import com.fr.design.actions.TemplateComponentAction; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.TargetComponent; +import com.fr.general.IOUtils; import javax.swing.KeyStroke; import java.awt.event.KeyEvent; @@ -25,13 +26,13 @@ public class CutAction extends TemplateComponentAction { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut")); this.setMnemonic('T'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); this.setEnabled(!DesignModeContext.isBanCopyAndCut()); } @Override public boolean executeActionReturnUndoRecordNeeded() { - return DesignModeContext.doPaste(getEditingComponent()); + return DesignModeContext.doCut(getEditingComponent()); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java index dda1fb68b..f78d341a5 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java @@ -1,6 +1,5 @@ package com.fr.design.actions.help.alphafine; -import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; @@ -11,7 +10,7 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; import com.fr.general.IOUtils; -import javax.swing.*; +import javax.swing.KeyStroke; import java.awt.event.ActionEvent; /** @@ -51,9 +50,6 @@ public class AlphaFineAction extends UpdateAction { final AlphaFineConfigPane alphaFineConfigPane = new AlphaFineConfigPane(); final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); - if (!FRContext.isChineseEnv()) { - manager.setSearchOnLine(false); - } alphaFineConfigPane.populate(manager); DialogActionListener dialogActionListener = new DialogActionAdapter() { public void doOk() { diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index c886e3c93..d261de57c 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -189,23 +189,34 @@ public class AlphaFineConfigPane extends BasicPane { } public void populate(AlphaFineConfigManager alphaFineConfigManager) { + this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); - this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv()); + + boolean enabled4Locale = FRContext.isChineseEnv(); + + this.searchOnlineCheckbox.setEnabled(enabled4Locale); this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); + this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); + this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); - this.containDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containDocumentCheckbox.setEnabled(enabled4Locale); + this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); - this.containPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containPluginCheckbox.setEnabled(enabled4Locale); + this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); - this.containRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containRecommendCheckbox.setEnabled(enabled4Locale); + this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); + this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine()); - this.needIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.needIntelligentCustomerService.setEnabled(enabled4Locale); + shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); } diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index 22bdc0a73..1e119d27e 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -3,13 +3,19 @@ */ package com.fr.design.constants; -import com.fr.base.BaseUtils; - +import com.fr.general.IOUtils; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; import javax.swing.border.Border; -import java.awt.*; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Image; +import java.awt.Point; +import java.awt.Stroke; +import java.awt.Toolkit; import java.awt.image.BufferedImage; /** @@ -17,19 +23,19 @@ import java.awt.image.BufferedImage; */ public interface UIConstants { - public static final Icon CPT_ICON = BaseUtils.readIcon("/com/fr/base/images/oem/cpt.png"); - public static final Icon BLACK_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/blank.gif"); + public static final Icon CPT_ICON = IOUtils.readIcon("/com/fr/base/images/oem/cpt.png"); + public static final Icon BLACK_ICON = IOUtils.readIcon("/com/fr/base/images/cell/blank.gif"); - public static final Image APPFIT_V0 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V0.png"); - public static final Image APPFIT_V1 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V1.png"); - public static final Image APPFIT_V2 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V2.png"); - public static final Image APPFIT_V3 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V3.png"); - public static final Image APPFIT_V4 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V4.png"); - public static final Image APPFIT_H0 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H0.png"); - public static final Image APPFIT_H1 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H1.png"); - public static final Image APPFIT_H2 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H2.png"); - public static final Image APPFIT_H3 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png"); - public static final Image APPFIT_H4 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png"); + public static final Image APPFIT_V0 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V0.png"); + public static final Image APPFIT_V1 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V1.png"); + public static final Image APPFIT_V2 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V2.png"); + public static final Image APPFIT_V3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V3.png"); + public static final Image APPFIT_V4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V4.png"); + public static final Image APPFIT_H0 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H0.png"); + public static final Image APPFIT_H1 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H1.png"); + public static final Image APPFIT_H2 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H2.png"); + public static final Image APPFIT_H3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png"); + public static final Image APPFIT_H4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png"); public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 0); @@ -45,15 +51,15 @@ public interface UIConstants { * Cell default cursor. */ public static final Cursor CELL_DEFAULT_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( - BaseUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"), + IOUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"), new Point(16, 16), "CellDefaultCursor"); public static final Cursor DRAW_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( - BaseUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"), + IOUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"), new Point(16, 16), "DrawCursor"); public static final Cursor FORMAT_BRUSH_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( - BaseUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"), + IOUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"), new Point(16, 16), "formatBrushCursor"); /** @@ -140,63 +146,64 @@ public interface UIConstants { - public static final BufferedImage DRAG_BAR = BaseUtils.readImage("com/fr/design/images/control/bar.png"); - public static final BufferedImage DRAG_BAR_LIGHT = BaseUtils.readImage("com/fr/design/images/control/bar-light.png"); - public static final BufferedImage ARROW_NORTH = BaseUtils.readImage("com/fr/design/images/control/up_arrow.png"); - public static final BufferedImage ARROW_SOUTH = BaseUtils.readImage("com/fr/design/images/control/down_arrow.png"); - public static final BufferedImage ARROW_EAST = BaseUtils.readImage("com/fr/design/images/control/east_arrow.png"); - public static final BufferedImage ARROW_WEST = BaseUtils.readImage("com/fr/design/images/control/west_arrow.png"); - - public static final BufferedImage DRAG_BAR_RIGHT = BaseUtils.readImage("com/fr/design/images/control/barm.png"); - public static final BufferedImage DRAG_BAR_LEFT = BaseUtils.readImage("com/fr/design/images/control/barl.png"); - public static final BufferedImage DRAG_UP_NORMAL = BaseUtils.readImage("com/fr/design/images/control/upnor.png"); - public static final BufferedImage DRAG_UP_PRESS = BaseUtils.readImage("com/fr/design/images/control/uppre.png"); - public static final BufferedImage DRAG_DOWN_NORMAL = BaseUtils.readImage("com/fr/design/images/control/downnor.png"); - public static final BufferedImage DRAG_DOWN_PRESS = BaseUtils.readImage("com/fr/design/images/control/downpre.png"); - public static final BufferedImage DRAG_RIGHT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/rightnor.png"); - public static final BufferedImage DRAG_RIGHT_PRESS = BaseUtils.readImage("com/fr/design/images/control/rightpre.png"); - public static final BufferedImage DRAG_LEFT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/leftnor.png"); - public static final BufferedImage DRAG_LEFT_PRESS = BaseUtils.readImage("com/fr/design/images/control/leftpre.png"); - public static final BufferedImage DRAG_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png"); - public static final BufferedImage DRAG_LINE = BaseUtils.readImage("com/fr/design/images/control/dot-line.png"); - public static final BufferedImage ACCESSIBLE_EDITOR_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png"); - public static final BufferedImage DRAG_DOT_VERTICAL = BaseUtils.readImage("com/fr/design/images/control/dotv.png"); - public static final BufferedImage POP_BUTTON_DOWN = BaseUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png"); - public static final BufferedImage POP_BUTTON_UP = BaseUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png"); - public static final BufferedImage DRAG_DOWN_SELECTED_SMALL = BaseUtils.readImage("com/fr/design/images/buttonicon/downSelected.png"); - public static final BufferedImage DRAG_LEFT_NORMAL_SMALL = BaseUtils.readImage("com/fr/design/images/buttonicon/leftNormal.png"); - public static final BufferedImage WATERMARK_BACKGROUND = BaseUtils.readImage("/com/fr/design/images/dialog/watermark/watermark_background.png"); + public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); + public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); + public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png"); + public static final BufferedImage ARROW_SOUTH = IOUtils.readImage("com/fr/design/images/control/down_arrow.png"); + public static final BufferedImage ARROW_EAST = IOUtils.readImage("com/fr/design/images/control/east_arrow.png"); + public static final BufferedImage ARROW_WEST = IOUtils.readImage("com/fr/design/images/control/west_arrow.png"); + + public static final BufferedImage DRAG_BAR_RIGHT = IOUtils.readImage("com/fr/design/images/control/barm.png"); + public static final BufferedImage DRAG_BAR_LEFT = IOUtils.readImage("com/fr/design/images/control/barl.png"); + public static final BufferedImage DRAG_UP_NORMAL = IOUtils.readImage("com/fr/design/images/control/upnor.png"); + public static final BufferedImage DRAG_UP_PRESS = IOUtils.readImage("com/fr/design/images/control/uppre.png"); + public static final BufferedImage DRAG_DOWN_NORMAL = IOUtils.readImage("com/fr/design/images/control/downnor.png"); + public static final BufferedImage DRAG_DOWN_PRESS = IOUtils.readImage("com/fr/design/images/control/downpre.png"); + public static final BufferedImage DRAG_RIGHT_NORMAL = IOUtils.readImage("com/fr/design/images/control/rightnor.png"); + public static final BufferedImage DRAG_RIGHT_PRESS = IOUtils.readImage("com/fr/design/images/control/rightpre.png"); + public static final BufferedImage DRAG_LEFT_NORMAL = IOUtils.readImage("com/fr/design/images/control/leftnor.png"); + public static final BufferedImage DRAG_LEFT_PRESS = IOUtils.readImage("com/fr/design/images/control/leftpre.png"); + public static final BufferedImage DRAG_DOT = IOUtils.readImage("com/fr/design/images/control/dot.png"); + public static final BufferedImage DRAG_LINE = IOUtils.readImage("com/fr/design/images/control/dot-line.png"); + public static final BufferedImage ACCESSIBLE_EDITOR_DOT = IOUtils.readImage("com/fr/design/images/control/dot.png"); + public static final BufferedImage DRAG_DOT_VERTICAL = IOUtils.readImage("com/fr/design/images/control/dotv.png"); + public static final BufferedImage POP_BUTTON_DOWN = IOUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png"); + public static final BufferedImage POP_BUTTON_UP = IOUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png"); + public static final BufferedImage DRAG_DOWN_SELECTED_SMALL = IOUtils.readImage("com/fr/design/images/buttonicon/downSelected.png"); + public static final BufferedImage DRAG_LEFT_NORMAL_SMALL = IOUtils.readImage("com/fr/design/images/buttonicon/leftNormal.png"); + public static final BufferedImage WATERMARK_BACKGROUND = IOUtils.readImage("/com/fr/design/images/dialog/watermark/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_WaterMark_Background_Icon_File_Name")); + public static final int MODEL_NORMAL = 0; public static final int MODEL_PRESS = 1; - public static final Icon ARROW_DOWN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"); - public static final Icon ARROW_UP_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"); - public static final Icon YES_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/yes.png"); - public static final Icon CHOOSEN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/select_item.png"); - public static final Icon PRE_WIDGET_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png"); - public static final Icon EDIT_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editn.png"); - public static final Icon EDIT_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editp.png"); - public static final Icon HIDE_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hiden.png"); - public static final Icon HIDE_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hidep.png"); - public static final Icon VIEW_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewn.png"); - public static final Icon VIEW_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewp.png"); - public static final Icon RUN_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/run24.png"); - public static final Icon RUN_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/runs.png"); - public static final Icon PAGE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png"); - public static final Icon WRITE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png"); - public static final Icon ANA_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anab24.png"); - public static final Icon PAGE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pages.png"); - public static final Icon WRITE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writes.png"); - public static final Icon ANA_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); - public static final Icon REFRESH_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); - public static final Icon FONT_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); - public static final Icon HISTORY_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/history.png"); - public static final Icon DELETE_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/close.png"); - public static final Icon EDIT_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/edit.png"); - public static final Icon SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/search.png"); - public static final Icon BLACK_SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/black_search.png"); - public static final Icon CLEAR_ICON = BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"); - public static final Icon LIST_EDIT_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit.png"); - public static final Icon LIST_EDIT_WHITE_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit_white.png"); + public static final Icon ARROW_DOWN_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"); + public static final Icon ARROW_UP_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"); + public static final Icon YES_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/yes.png"); + public static final Icon CHOOSEN_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/select_item.png"); + public static final Icon PRE_WIDGET_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png"); + public static final Icon EDIT_NORMAL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/editn.png"); + public static final Icon EDIT_PRESSED_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/editp.png"); + public static final Icon HIDE_NORMAL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/hiden.png"); + public static final Icon HIDE_PRESSED_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/hidep.png"); + public static final Icon VIEW_NORMAL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/viewn.png"); + public static final Icon VIEW_PRESSED_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/viewp.png"); + public static final Icon RUN_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/run24.png"); + public static final Icon RUN_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/runs.png"); + public static final Icon PAGE_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png"); + public static final Icon WRITE_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png"); + public static final Icon ANA_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anab24.png"); + public static final Icon PAGE_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/pages.png"); + public static final Icon WRITE_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/writes.png"); + public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); + public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); + public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); + public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png"); + public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png"); + public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png"); + public static final Icon SEARCH_ICON = IOUtils.readIcon("/com/fr/design/images/data/search.png"); + public static final Icon BLACK_SEARCH_ICON = IOUtils.readIcon("/com/fr/design/images/data/black_search.png"); + public static final Icon CLEAR_ICON = IOUtils.readIcon("/com/fr/design/images/data/source/delete.png"); + public static final Icon LIST_EDIT_ICON = IOUtils.readIcon("/com/fr/design/images/control/edit.png"); + public static final Icon LIST_EDIT_WHITE_ICON = IOUtils.readIcon("/com/fr/design/images/control/edit_white.png"); public static final Color PRESSED_DARK_GRAY = new Color(127, 127, 127); public static final Color GRDIENT_DARK_GRAY = new Color(45, 45, 45); public static final Color BARNOMAL = new Color(232, 232, 233); @@ -205,10 +212,10 @@ public interface UIConstants { public static final int BUTTON_GROUP_ARC = 0; public static final int LARGEARC = 6; public static final Stroke BS = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[]{3, 1}, 0); - public static final Icon PREVIEW_DOWN = BaseUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png"); - public static final Icon CLOSE_OF_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close.png"); - public static final Icon CLOSE_OVER_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_over.png"); - public static final Icon CLOSE_PRESS_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_press.png"); + public static final Icon PREVIEW_DOWN = IOUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png"); + public static final Icon CLOSE_OF_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close.png"); + public static final Icon CLOSE_OVER_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close_over.png"); + public static final Icon CLOSE_PRESS_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close_press.png"); public static final int CLOSE_AUTHORITY_HEIGHT_AND_WIDTH = 24; diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java index 4809e536c..d752f58f0 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java @@ -129,7 +129,7 @@ public abstract class BasicPane extends JPanel { * @param dimension 自定义尺寸 * @return 对话框 */ - protected BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) { + public BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) { BasicDialog dg; if (window instanceof Frame) { dg = new DIALOG((Frame) window); diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 774578630..c7c503ff3 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -206,5 +206,21 @@ public class PluginOperateUtils { return pluginInfo.toString(); } + public static String getSwitchedInfo(PluginTaskResult result) { + StringBuilder pluginInfo = new StringBuilder(); + List pluginTaskResults = result.asList(); + for (PluginTaskResult pluginTaskResult : pluginTaskResults) { + PluginTask pluginTask = pluginTaskResult.getCurrentTask(); + if (pluginTask == null) { + continue; + } + PluginMarker pluginMarker = pluginTask.getToMarker(); + PluginContext pluginContext = PluginManager.getContext(pluginMarker); + if (pluginContext != null && pluginContext.getSelfState() == 1) { + pluginInfo.append("\n").append(pluginContext.getSwitchedReason()); + } + } + return pluginInfo.toString(); + } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index e8096efbf..59d5d6a08 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -36,10 +36,12 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { @Override public void done(PluginTaskResult result) { + String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { + String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success")); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success")); + FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 23b6679b6..6e72c0478 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -35,9 +35,10 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { protected void allDone(PluginTaskResult result) { String pluginInfo = PluginOperateUtils.getSuccessInfo(result); if (result.isSuccess()) { + String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success")); - JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success")); + FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index fc46ff59b..cb839c6d7 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -41,17 +41,12 @@ public class HistoryTemplateListCache implements CallbackEvent { private List> historyList; private JTemplate editingTemplate; - private static volatile HistoryTemplateListCache instacne; - public static HistoryTemplateListCache getInstance() { - if (instacne == null) { - synchronized (HistoryTemplateListCache.class) { - if (instacne == null) { - instacne = new HistoryTemplateListCache(); - } - } - } - return instacne; + return Holder.INSTANCE; + } + + private static class Holder { + private static final HistoryTemplateListCache INSTANCE = new HistoryTemplateListCache(); } private HistoryTemplateListCache() { diff --git a/designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java new file mode 100644 index 000000000..bc01837ee --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java @@ -0,0 +1,24 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.stable.fun.mark.Mutable; + +/** + * 移动端组件样式扩展接口 + */ +public interface MobileWidgetStyleProvider extends Mutable { + + String XML_TAG = "MobileWidgetStyleProvider"; + + int CURRENT_LEVEL = 1; + + Class classForMobileStyle(); + + Class classForWidgetAppearance(); + + String xTypeForWidget(); + + String displayName(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java new file mode 100644 index 000000000..407aa058c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java @@ -0,0 +1,20 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.MobileWidgetStyleProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL) +public abstract class AbstractMobileWidgetStyleProvider extends AbstractProvider implements MobileWidgetStyleProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java b/designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java index 26030c47c..78750e389 100644 --- a/designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java +++ b/designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java @@ -76,7 +76,6 @@ public class UIDefaultTheme extends DefaultMetalTheme { table.put("Table.background", ThemeUtils.TEXT_BG_COLOR); table.put("Table.selectionForeground", ThemeUtils.NORMAL_FOREGROUND); table.put("Table.selectionBackground", new ColorUIResource(200, 221, 233)); - table.put("Table.gridColor", new ColorUIResource(200, 221, 233)); table.put("TableHeader.background", new ColorUIResource(229, 229, 229)); table.put("ProgressBar.foreground", ThemeUtils.PROCESS_COLOR); table.put("ProgressBar.background", ThemeUtils.TEXT_BG_COLOR); @@ -85,7 +84,6 @@ public class UIDefaultTheme extends DefaultMetalTheme { table.put("ProgressBar.selectionForeground", ThemeUtils.NORMAL_FOREGROUND); table.put("ProgressBar.selectionBackground", ThemeUtils.NORMAL_FOREGROUND); table.put("PopupMenu.background", ThemeUtils.NORMAL_BG); - table.put("TabbedPane.background", ThemeUtils.TEXT_BG_COLOR); table.put("TabbedPane.background", ThemeUtils.NORMAL_BG); table.put("TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 0)); table.put("TabbedPane.tabInsets", new InsetsUIResource(1, 6, 4, 6)); @@ -108,7 +106,6 @@ public class UIDefaultTheme extends DefaultMetalTheme { table.put("ComboBox.foreground", ThemeUtils.NORMAL_FOREGROUND); table.put("ComboBox.background", ThemeUtils.TEXT_BG_COLOR); table.put("ComboBox.disabledBackground", ThemeUtils.TEXT_DISABLED_BG_COLOR); - table.put("EditorPane.background", ThemeUtils.TEXT_BG_COLOR); table.put("EditorPane.foreground", ThemeUtils.NORMAL_FOREGROUND); table.put("PasswordField.background", ThemeUtils.TEXT_BG_COLOR); table.put("PasswordField.foreground", ThemeUtils.NORMAL_FOREGROUND); diff --git a/designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java b/designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java index b9d9afcc0..8bc805f46 100644 --- a/designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java @@ -195,6 +195,9 @@ public class LanguageAwareCompletionProvider extends CompletionProviderBase // provider. We do not do function/method completions while editing // strings or comments. CompletionProvider provider = getProviderFor(tc); + if (provider == null) { + return null; + } return provider==defaultProvider ? provider.getParameterizedCompletions(tc) : null; } diff --git a/designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java b/designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java index a9dd305b0..78d5e74a4 100644 --- a/designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java +++ b/designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java @@ -517,6 +517,10 @@ class ParameterizedCompletionContext { } } + if (currentNext == null) { + return; + } + // No params after caret - go to first one if (currentNext.getStartOffset() + 1 <= dot) { int nextIndex = getFirstHighlight(highlights); diff --git a/designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java b/designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java index 615a17bce..e94b18269 100644 --- a/designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java @@ -146,6 +146,8 @@ public class ColumnRowPane extends JPanel implements UIObserver { if (cftf != null) { cftf.setColumns(3); // specify more width than we need cftf.setHorizontalAlignment(UITextField.LEFT); + }else { + throw new IllegalArgumentException("Spinner'Editor can not be null!"); } ((AbstractDocument) cftf.getDocument()).setDocumentFilter(new DocumentFilter() { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java index c5786b4c6..be169a744 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java @@ -1,8 +1,8 @@ package com.fr.design.gui.controlpane; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import com.fr.design.beans.BasicBeanPane; +import com.fr.stable.AssistUtils; /** * Created by plough on 2017/8/1. @@ -48,7 +48,7 @@ public abstract class ObjectUIControlPane extends UIListControlPane { if (constructor != null) { return constructor; } else { - if (cls.getName() == Object.class.getName()) { + if (AssistUtils.equals(cls.getName(),Object.class.getName())) { return null; } return getConstructor(clazz, cls.getSuperclass()); diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java index fb44f618f..be3ef20a3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java @@ -157,7 +157,7 @@ public class UIDatePicker extends UIComboBox implements Serializable { /** * 设置当前选择的日期 */ - public void setSelectedDate(Date date) throws ParseException { + public synchronized void setSelectedDate(Date date) throws ParseException { if (date == null) { this.setSelectedItem(null); } else { @@ -165,6 +165,7 @@ public class UIDatePicker extends UIComboBox implements Serializable { } } + @Override public void setSelectedItem(Object anObject) { model.setSelectedItem(anObject); super.setSelectedItem(anObject); @@ -192,12 +193,14 @@ public class UIDatePicker extends UIComboBox implements Serializable { setBorder(BorderFactory.createEmptyBorder()); } + @Override public void hide() { if (isWillHide) { super.hide(); } } + @Override public void show() { if (isWillHide || UIDatePicker.this.isEnabled() == false) { return; @@ -211,6 +214,7 @@ public class UIDatePicker extends UIComboBox implements Serializable { /** * 显示弹出面板 */ + @Override protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { @@ -250,12 +254,14 @@ public class UIDatePicker extends UIComboBox implements Serializable { } } + @Override protected ComboBoxUI getUIComboBoxUI() { return new UIComboBoxUI() { + @Override protected ComboPopup createPopup() { return new DatePopup(comboBox); } - + @Override public void mousePressed(MouseEvent e) { if (UIDatePicker.this.isPopupVisible()) { isWillHide = true; diff --git a/designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java b/designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java index 2eb93ad3e..b17323774 100644 --- a/designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java +++ b/designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java @@ -35,6 +35,7 @@ public class LoadingPaneDemo extends JPanel { Thread.sleep(500); } catch (InterruptedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + Thread.currentThread().interrupt(); } container.add(new UIButton(i + "adfadwdadawdwad")); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java b/designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java index 7c454ad71..e3a1ae7d7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java @@ -24,6 +24,7 @@ public class LoadingBasicPaneTest { Thread.sleep(500); } catch (InterruptedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + Thread.currentThread().interrupt(); } container.add(new UIButton(i + "adfadwdadawdwad")); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java index 7585c0949..5faa21b3c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java @@ -14,6 +14,7 @@ import javax.swing.event.ChangeListener; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.style.NumberDragBar; +import com.fr.stable.AssistUtils; /** * 拖拽的滑条和对应滑条值的数字 @@ -65,7 +66,7 @@ public class UINumberSlidePane extends BasicBeanPane { public void checkValue(double value) { value = Math.max(value, minValue); value = Math.min(value, maxValue); - if (this.value == value) { + if (AssistUtils.equals(this.value, value)) { return; } double diff = Math.abs(value - this.value); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java index ca44c8a22..798b79af0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.*; @@ -81,7 +82,7 @@ public abstract class UnitInputPane extends BasicPane { floatValue = de.floatValue(); } //选中多列, 并且列宽不完全一致的话, 就不显示值了. - temp.setText(floatValue == 0 ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); + temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); // denny:默认应该为选中,方便用户修改 temp.selectAll(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index 7489b4f59..10ea06a8c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -125,60 +125,58 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser private class UICheckBoxUI extends MetalCheckBoxUI { @Override - public void paint(Graphics g, JComponent c) { - synchronized (this) { - AbstractButton b = (AbstractButton) c; - ButtonModel model = b.getModel(); - Dimension size = c.getSize(); - Font f = c.getFont(); - g.setFont(f); - FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); - - Rectangle viewRect = new Rectangle(size); - Rectangle iconRect = new Rectangle(); - Rectangle textRect = new Rectangle(); - - Insets i = c.getInsets(); - viewRect.x += i.left; - viewRect.y += i.top; - viewRect.width -= (i.right + viewRect.x); - viewRect.height -= (i.bottom + viewRect.y); - - Icon altIcon = b.getIcon(); - - String text = SwingUtilities.layoutCompoundLabel( - c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), - b.getVerticalAlignment(), b.getHorizontalAlignment(), - b.getVerticalTextPosition(), b.getHorizontalTextPosition(), - viewRect, iconRect, textRect, b.getIconTextGap()); - - // fill background - if (c.isOpaque()) { - g.setColor(b.getBackground()); - g.fillRect(0, 0, size.width, size.height); - } - - Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - if (model.isSelected()) { - GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height, false, Constants.NULL, - model.isEnabled() ? UIConstants.CHECKBOX_HOVER_SELECTED : UIConstants.DISABLED_ICON_COLOR, 0); - } else if (model.isRollover() && !model.isSelected()) { - g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED); - g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); - } else { - g.setColor(UIConstants.LINE_COLOR); - g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); - } + public synchronized void paint(Graphics g, JComponent c) { + AbstractButton b = (AbstractButton) c; + ButtonModel model = b.getModel(); + Dimension size = c.getSize(); + Font f = c.getFont(); + g.setFont(f); + FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); + + Rectangle viewRect = new Rectangle(size); + Rectangle iconRect = new Rectangle(); + Rectangle textRect = new Rectangle(); + + Insets i = c.getInsets(); + viewRect.x += i.left; + viewRect.y += i.top; + viewRect.width -= (i.right + viewRect.x); + viewRect.height -= (i.bottom + viewRect.y); + + Icon altIcon = b.getIcon(); + + String text = SwingUtilities.layoutCompoundLabel( + c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), + b.getVerticalAlignment(), b.getHorizontalAlignment(), + b.getVerticalTextPosition(), b.getHorizontalTextPosition(), + viewRect, iconRect, textRect, b.getIconTextGap()); + + // fill background + if (c.isOpaque()) { + g.setColor(b.getBackground()); + g.fillRect(0, 0, size.width, size.height); + } - if (model.isSelected()) { - UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); - } - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + if (model.isSelected()) { + GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height, false, Constants.NULL, + model.isEnabled() ? UIConstants.CHECKBOX_HOVER_SELECTED : UIConstants.DISABLED_ICON_COLOR, 0); + } else if (model.isRollover() && !model.isSelected()) { + g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED); + g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); + } else { + g.setColor(UIConstants.LINE_COLOR); + g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); + } - // Draw the Text - drawLine(text, g, b, c, textRect, fm); + if (model.isSelected()) { + UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); } + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + + // Draw the Text + drawLine(text, g, b, c, textRect, fm); } private void drawLine(String text, Graphics g, AbstractButton b, JComponent c, Rectangle textRect, FontMetrics fm) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java index 1a7bbb661..9076d355d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java @@ -64,7 +64,7 @@ public class UICheckBoxUI extends MetalCheckBoxUI { } } - static BasicStroke focusStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[]{1.0f / 1.0f}, 1.0f); + static BasicStroke focusStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[]{1.0f}, 1.0f); protected void paintFocus(Graphics g, Rectangle t, Dimension arg2) { if (!ThemeUtils.BUTTON_FOCUS) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java index be83cf5b1..300790457 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java @@ -84,6 +84,7 @@ public abstract class LazyComboBox extends UIComboBox implements PopupMenuListen LazyComboBox.this.loadList(get()); } catch (InterruptedException | ExecutionException exception) { FineLoggerFactory.getLogger().debug(exception.getMessage()); + Thread.currentThread().interrupt(); } LazyComboBox.this.showPopup(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java index 4016a263c..37e9db154 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java @@ -40,6 +40,7 @@ public class LazyComboBoxTest { Thread.sleep(3000); } catch (InterruptedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + Thread.currentThread().interrupt(); } return m; } diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java index a0f442074..b0b57f29c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java @@ -7,12 +7,25 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; +import com.fr.general.IOUtils; + +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Insets; +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.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; public class UICheckListPopup extends UIPopupMenu { private List listeners = new ArrayList(); @@ -66,10 +79,10 @@ public class UICheckListPopup extends UIPopupMenu { } addSelectListener(); - jScrollPane.setPreferredSize(new Dimension(200, checkBoxList.size() * CHECKBOX_HEIGHT + 10)); + jScrollPane.setPreferredSize(new Dimension(130, checkBoxList.size() * CHECKBOX_HEIGHT + 10)); //超过1页的数量时显示滚动条 if (checkBoxList.size() > maxDisplayNumber) { - jScrollPane.setPreferredSize(new Dimension(200, maxDisplayNumber * CHECKBOX_HEIGHT)); + jScrollPane.setPreferredSize(new Dimension(130, maxDisplayNumber * CHECKBOX_HEIGHT)); } checkboxPane.repaint(); jScrollPane.repaint(); @@ -77,11 +90,11 @@ public class UICheckListPopup extends UIPopupMenu { private void addOneCheckValue(Object checkValue) { JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - checkPane.setPreferredSize(new Dimension(185, CHECKBOX_HEIGHT)); + checkPane.setPreferredSize(new Dimension(120, CHECKBOX_HEIGHT)); final JCheckBox temp = createCheckbox(); final UILabel label = new UILabel(checkValue.toString()); label.setBackground(Color.WHITE); - label.setPreferredSize(new Dimension(156, 20)); + label.setPreferredSize(new Dimension(80, 20)); checkPane.setBackground(Color.WHITE); checkPane.add(temp); checkPane.add(label); @@ -95,8 +108,8 @@ public class UICheckListPopup extends UIPopupMenu { JCheckBox checkBox = new JCheckBox(); checkBox.setPreferredSize(new Dimension(20, 20)); checkBox.setBackground(Color.WHITE); - checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); - checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); + checkBox.setIcon(IOUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); + checkBox.setSelectedIcon(IOUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); return checkBox; } @@ -109,10 +122,12 @@ public class UICheckListPopup extends UIPopupMenu { */ private void addMouseListener(final JCheckBox checkBox, final UILabel label) { label.addMouseListener(new MouseAdapter() { + @Override public void mouseExited(MouseEvent e) { label.setBackground(Color.WHITE); } + @Override public void mouseEntered(MouseEvent e) { label.setOpaque(true); label.setBackground(mouseEnteredColor); @@ -133,6 +148,7 @@ public class UICheckListPopup extends UIPopupMenu { JCheckBox checkBox = checkBoxList.get(i); if (i == 0) { checkBox.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { //全选checkbox事件 doSelectAll(checkBoxList.get(0).isSelected()); @@ -140,6 +156,7 @@ public class UICheckListPopup extends UIPopupMenu { }); } else { checkBox.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { //do半选判断放在commit事件里 commit(); @@ -157,8 +174,17 @@ public class UICheckListPopup extends UIPopupMenu { private void doSelectAll(boolean isSelected) { for (int i = 1; i < checkBoxList.size(); i++) { //全选和反全选都不考虑全选按钮本身 - if (!SELECT_ALL.equals(checkBoxList.get(i).getText())) + if (!SELECT_ALL.equals(checkBoxList.get(i).getText())) { checkBoxList.get(i).setSelected(isSelected); + } + } + } + + public void setSelectedValue(Map selectedValues) { + List allValue = Arrays.asList(values); + for (Object value : selectedValues.keySet()) { + int index = allValue.indexOf(value); + checkBoxList.get(index + 1).setSelected(selectedValues.get(value)); } } @@ -214,8 +240,9 @@ public class UICheckListPopup extends UIPopupMenu { } public void addActionListener(ActionListener listener) { - if (!listeners.contains(listener)) + if (!listeners.contains(listener)) { listeners.add(listener); + } } public void removeActionListener(ActionListener listener) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java index 11cfeb6fe..e570ee515 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java @@ -11,14 +11,23 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.FontMetrics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * 设计器下拉复选框组件 @@ -125,7 +134,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam private UITextField createEditor() { UITextField editor = new UITextField(); editor.setEditable(false); - editor.setPreferredSize(new Dimension(180, 20)); + editor.setPreferredSize(new Dimension(110, 20)); addPopupListener(editor); return editor; @@ -138,6 +147,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam */ private void addPopupListener(Component component) { component.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { togglePopup(); } @@ -166,6 +176,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam private class PopupAction implements ActionListener { + @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(UICheckListPopup.COMMIT_EVENT)) { selectedValues = popup.getSelectedValues(); @@ -292,13 +303,15 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam } public void addActionListener(ActionListener listener) { - if (!listeners.contains(listener)) + if (!listeners.contains(listener)) { listeners.add(listener); + } } public void removeActionListener(ActionListener listener) { - if (listeners.contains(listener)) + if (listeners.contains(listener)) { listeners.remove(listener); + } } protected void fireActionPerformed(ActionEvent e) { @@ -307,6 +320,10 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam } } + public void setSelectedValues(Map map) { + popup.setSelectedValue(map); + } + /** * 简单的测试demo * @param args diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java index da9aec981..8054a29ea 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java @@ -1,5 +1,7 @@ package com.fr.design.gui.iscrollbar; +import com.fr.design.constants.UIConstants; +import com.fr.stable.StringUtils; import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -20,7 +22,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; - import javax.swing.BoundedRangeModel; import javax.swing.InputMap; import javax.swing.JComponent; @@ -38,8 +39,6 @@ import javax.swing.event.ChangeListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ScrollBarUI; import javax.swing.plaf.UIResource; - -import com.fr.design.constants.UIConstants; import sun.swing.DefaultLookup; /** @@ -148,6 +147,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * * @param c */ + @Override public void installUI(JComponent c) { scrollbar = (JScrollBar) c; thumbRect = new Rectangle(0, 0, 0, 0); @@ -163,6 +163,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * * @param c */ + @Override public void uninstallUI(JComponent c) { scrollbar = (JScrollBar) c; uninstallListeners(); @@ -357,6 +358,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo /** * 只画Thumb */ + @Override public void paint(Graphics g, JComponent c) { Rectangle thumbBounds = getThumbBounds(); if (thumbBounds.intersects(g.getClipBounds())) { @@ -380,6 +382,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * @see #getMaximumSize * @see #getMinimumSize */ + @Override public Dimension getPreferredSize(JComponent c) { return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(scrollBarWidth, 48) : new Dimension(48, scrollBarWidth); } @@ -390,6 +393,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * @see #getMinimumSize * @see #getPreferredSize */ + @Override public Dimension getMaximumSize(JComponent c) { return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); } @@ -937,6 +941,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo private transient int direction = +1; + @Override public void mouseReleased(MouseEvent e) { isPressing = false; if (isDragging) { @@ -968,6 +973,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * one page. If there is no thumb then page up if the mouse is in the * upper half of the track. */ + @Override public void mousePressed(MouseEvent e) { boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e); if (SwingUtilities.isRightMouseButton(e) || isMiddle) { @@ -1313,7 +1319,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); - if ("model" == propertyName) { + if (StringUtils.equals("model", propertyName)) { BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue(); oldModel.removeChangeListener(modelListener); @@ -1329,4 +1335,4 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo } } } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java new file mode 100644 index 000000000..8c5f0e154 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -0,0 +1,77 @@ +package com.fr.design.gui.itree.filetree; + +import com.fr.base.FRContext; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.mainframe.App; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * Created by alex sung on 2019/7/23. + */ +public class FileNodeConstants { + + private static List supportFileType; + private static ReadWriteLock rwl = new ReentrantReadWriteLock(); + + private FileNodeConstants() { + } + + static { + initSupportedTypes(); + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent pluginEvent) { + initSupportedTypes(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext pluginContext) { + return pluginContext.contain(PluginModule.ExtraDesign); + } + }); + } + + private static void addAppExtensions(String[] extensions) { + for (int i = 0, size = extensions.length; i < size; i++) { + if (!supportFileType.contains(extensions[i])) { + supportFileType.add(extensions[i]); + } + } + } + + private static void initSupportedTypes() { + try { + rwl.writeLock().lock(); + supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); + //通过插件扩展的 + Set apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); + for (App app : apps) { + addAppExtensions(app.defaultExtensions()); + } + } finally { + rwl.writeLock().unlock(); + } + } + + public static String[] getSupportFileTypes() { + try { + rwl.readLock().lock(); + return supportFileType.toArray(new String[0]); + } finally { + rwl.readLock().unlock(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java index 69875a97f..3b37f4358 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java @@ -1,10 +1,11 @@ package com.fr.design.gui.itree.filetree; -import com.fr.base.BaseUtils; import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.project.ProjectConstants; +import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JTree; @@ -29,7 +30,8 @@ import java.util.Stack; * File Tree. */ public class JFileTree extends AbstractFileTree { - protected FileFilter fileFilter; + + private FileFilter fileFilter; public JFileTree() { this(null); @@ -68,11 +70,11 @@ public class JFileTree extends AbstractFileTree { DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); rootTreeNode.removeAllChildren(); - for (int k = 0; k < rootFiles.length; k++) { - DefaultMutableTreeNode node = new DefaultMutableTreeNode(new RootFile(rootFiles[k])); + for (File rootFile : rootFiles) { + DefaultMutableTreeNode node = new DefaultMutableTreeNode(new RootFile(rootFile)); rootTreeNode.add(node); - if (rootFiles[k].isDirectory()) { + if (rootFile.isDirectory()) { node.add(new DefaultMutableTreeNode(Boolean.TRUE)); } } @@ -93,6 +95,7 @@ public class JFileTree extends AbstractFileTree { this.fileFilter = fileFilter; } + @Nullable public File getSelectedFile() { TreePath selectedTreePath = this.getSelectionPath(); if (selectedTreePath == null) { @@ -140,7 +143,7 @@ public class JFileTree extends AbstractFileTree { File rootFile = rootLocalFile.getFile(); // 是父子关系,开始找孩子. if (AbstractFileTree.isParentFile(rootFile, currentFile)) { - Stack nameStack = new Stack(); // 将所有的名字加入Stack. + Stack nameStack = new Stack<>(); // 将所有的名字加入Stack. while (true) { if (ComparatorUtils.equals(rootFile, currentFile)) { break; @@ -153,7 +156,7 @@ public class JFileTree extends AbstractFileTree { } DefaultMutableTreeNode curChildTreeNode = rootChildTreeNode; while (!nameStack.isEmpty()) { - String name = (String) nameStack.pop(); + String name = nameStack.pop(); this.expandTreeNode(curChildTreeNode); for (int j = 0; j < curChildTreeNode.getChildCount(); j++) { DefaultMutableTreeNode tmpChildTreeNode = @@ -198,9 +201,8 @@ public class JFileTree extends AbstractFileTree { if (files == null) { return new FileDirectoryNode[0]; } - List fileNodeList = new ArrayList(); - for (int k = 0; k < files.length; k++) { - File tmpFile = files[k]; + List fileNodeList = new ArrayList<>(); + for (File tmpFile : files) { // 文件属性为隐藏的话 不放入列表 if (tmpFile.isHidden()) { continue; @@ -256,7 +258,7 @@ public class JFileTree extends AbstractFileTree { // 得到本地tree图标 Icon tmpIcon = view.getSystemIcon(currentFile); if (currentFile.isDirectory() && fBuf.length() > 0) { - tmpIcon = BaseUtils.readIcon("/com/fr/design/images/gui/folder.png"); + tmpIcon = IOUtils.readIcon("/com/fr/design/images/gui/folder.png"); } this.setIcon(tmpIcon); this.setName(null); @@ -299,6 +301,7 @@ public class JFileTree extends AbstractFileTree { */ @Override public int compare(FileDirectoryNode v1, FileDirectoryNode v2) { + //noinspection Duplicates if (v1.isDirectory()) { if (v2.isDirectory()) { return v1.getName().toLowerCase().compareTo(v2.getName().toLowerCase()); diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java index 51af636aa..b1f641b3b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java @@ -228,7 +228,7 @@ public class TemplateFileTree extends EnvFileTree { if (fileNodes == null) { fileNodes = new FileNode[0]; } - Arrays.sort(fileNodes, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); + Arrays.sort(fileNodes, new FileNodeComparator(FileNodeConstants.getSupportFileTypes())); return fileNodes; } diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index d906cc39e..38097c2d9 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -217,6 +217,18 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个靠左空边框面板,间隔小,firsthgap 为0 + * + * @return JPanel对象 + */ + public static JPanel createTinyHGapFlowInnerContainer_M_Pane_First0() { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new FRLeftFlowLayout(0, 5, 0)); + return jp; + } + /** * 创建一个靠左空边框面板,间隔中等 * diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleCustomDefinePane.java new file mode 100644 index 000000000..62257fde5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleCustomDefinePane.java @@ -0,0 +1,39 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; + +import javax.swing.*; + +public class DefaultMobileStyleCustomDefinePane extends MobileStyleCustomDefinePane { + + + public DefaultMobileStyleCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + public void populateBean(MobileStyle ob) { + + } + + @Override + public MobileStyle updateBean() { + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } + + @Override + protected void init() { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileWidgetStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileWidgetStyleProvider.java new file mode 100644 index 000000000..b1710ff14 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileWidgetStyleProvider.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.form.ui.mobile.DefaultMobileStyle; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.locale.InterProviderFactory; + +public class DefaultMobileWidgetStyleProvider extends AbstractMobileWidgetStyleProvider { + + @Override + public Class classForMobileStyle() { + return DefaultMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return DefaultMobileStyleCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return null; + } + + @Override + public String displayName() { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleCustomDefinePane.java new file mode 100644 index 000000000..91729eb96 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleCustomDefinePane.java @@ -0,0 +1,22 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; + +import javax.swing.*; + +public abstract class MobileStyleCustomDefinePane extends BasicBeanPane { + + protected Widget widget; + + public MobileStyleCustomDefinePane(Widget widget) { + this.widget = widget; + init(); + } + + protected abstract JPanel createPreviewPane(); + + protected abstract void init(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java new file mode 100644 index 000000000..82e189943 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java @@ -0,0 +1,115 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.general.FRFont; +import com.fr.invoke.Reflect; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +public class MobileStyleDefinePane extends BasicBeanPane { + + private Widget widget; + private MobileStyleCustomDefinePane customBeanPane; + private Class mobileStyleClazz; + private NewColorSelectBox colorSelectBox; + + MobileStyleDefinePane(Widget widget, Class customBeanPaneClass, + Class mobileStyleClazz) { + this.widget = widget; + this.customBeanPane = Reflect.on(customBeanPaneClass).create(widget).get(); + this.mobileStyleClazz = mobileStyleClazz; + init(); + } + + @Override + public void populateBean(MobileStyle ob) { + this.customBeanPane.populateBean(ob); + colorSelectBox.setSelectObject(ob.getBackground()); + } + + @Override + public MobileStyle updateBean() { + MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get(); + this.widget.setMobileStyle(mobileStyle); + this.customBeanPane.updateBean(); + mobileStyle.setBackground(colorSelectBox.getSelectObject()); + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } + + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + createGeneralPane(); + createCustomPane(); + } + + private void createGeneralPane() { + createPreviewPane(); + createBackgroundPane(); + } + + private void createPreviewPane() { + JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane(); + if(mobileStylePreviewPane != null) { + JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"), null); + titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, new Color(0x2f8ef100))); + previewPane.setBorder(titledBorder); + previewPane.setPreferredSize(new Dimension(500, 83)); + previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER); + this.add(previewPane, BorderLayout.NORTH); + } + } + + private void createBackgroundPane() { + + JPanel backgroundPane = new JPanel(); + backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); + backgroundPane.setPreferredSize(new Dimension(500, 65)); + + TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"), null); + titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE)); + backgroundPane.setBorder(titledBorder); + + UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); + colorSelectLabel.setPreferredSize(new Dimension(65, 20)); + + colorSelectBox = new NewColorSelectBox(152); + colorSelectBox.addSelectChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + + backgroundPane.add(colorSelectLabel); + backgroundPane.add(colorSelectBox); + + this.add(backgroundPane, BorderLayout.NORTH); + } + + private void createCustomPane() { + JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); + titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE)); + configPane.setBorder(titledBorder); + + configPane.add(this.customBeanPane, BorderLayout.CENTER); + + this.add(configPane, BorderLayout.CENTER); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java new file mode 100644 index 000000000..d0e949fa9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java @@ -0,0 +1,136 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.MobileWidgetStyleProvider; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Map; + +public class MobileStylePane extends BasicPane { + + private Widget widget; + private DefaultListModel listModel; + private JPanel right; + private CardLayout card; + private JList styleList; + private Map> map = new HashMap<>(); + + public MobileStylePane(Widget widget) { + if(widget instanceof WScaleLayout) { + this.widget = ((CRBoundsWidget)((WScaleLayout) widget).getBoundsWidget()).getWidget(); + } else { + this.widget = widget; + } + init(); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + public void populate(MobileStyle mobileStyle) { + if(mobileStyle != null) { + MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders(); + for(int i = 0; i < styleProviders.length; i ++) { + if(mobileStyle.getClass() == styleProviders[i].classForMobileStyle()) { + String displayName = styleProviders[i].displayName(); + styleList.setSelectedIndex(i); + map.get(displayName).populateBean(mobileStyle); + card.show(right, displayName); + return; + } + } + } + styleList.setSelectedIndex(0); + } + + public MobileStyle update() { + return map.get(styleList.getSelectedValue()).updateBean(); + } + + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + listModel = new DefaultListModel<>(); + card = new CardLayout(); + right = FRGUIPaneFactory.createCardLayout_S_Pane(); + right.setLayout(card); + MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders(); + for(MobileWidgetStyleProvider styleProvider: styleProviders) { + this.addProvider2View(styleProvider); + } + this.addWestList(); + this.addCenterConfig(); + } + + private void addWestList() { + styleList = new JList<>(listModel); + styleList.setCellRenderer(render); + styleList.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + String selectedValue = (String)styleList.getSelectedValue(); + card.show(right, selectedValue); + } + }); + JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + westPane.add(styleList, BorderLayout.CENTER); + westPane.setPreferredSize(new Dimension(100, 500)); + this.add(westPane, BorderLayout.WEST); + } + + private void addCenterConfig() { + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel attrConfPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + centerPane.setPreferredSize(new Dimension(500, 500)); + attrConfPane.add(right, BorderLayout.CENTER); + centerPane.add(attrConfPane, BorderLayout.CENTER); + this.add(centerPane, BorderLayout.CENTER); + } + + private void addProvider2View(MobileWidgetStyleProvider styleProvider) { + String displayName = styleProvider.displayName(); + Class appearanceClazz = styleProvider.classForWidgetAppearance(); + Class mobileStyleClazz = styleProvider.classForMobileStyle(); + + listModel.addElement(displayName); + try { + BasicBeanPane mobileStyleBasicBeanPane = new MobileStyleDefinePane(widget, appearanceClazz, mobileStyleClazz); + right.add(displayName, mobileStyleBasicBeanPane); + map.put(displayName, mobileStyleBasicBeanPane); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + private static ListCellRenderer render = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof MobileStyle) { + MobileStyle l = (MobileStyle) value; + this.setText(l.toString()); + } + return this; + } + }; + + private MobileWidgetStyleProvider[] getMobileWidgetStyleProviders() { + DefaultMobileWidgetStyleProvider defaultMobileWidgetStyleProvider = new DefaultMobileWidgetStyleProvider(); + MobileWidgetStyleProvider[] styleProviders = ExtraDesignClassManager.getInstance().getMobileStyleOfWidget(widget.getXType()); + styleProviders = ArrayUtils.insert(0, styleProviders, defaultMobileWidgetStyleProvider); + return styleProviders; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java index 724a9c949..214156ef3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java @@ -11,6 +11,8 @@ import com.fr.design.web.CustomIconPane; import com.fr.form.ui.WidgetInfoConfig; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import com.fr.stable.StringUtils; + import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; @@ -33,6 +35,7 @@ import java.util.ArrayList; public class TabIconConfigPane extends JPanel { private UIButton editIconButton; + private UIButton deleteIconButton; private String curIconName; private IconButton selectIconButton; private ArrayList iconButtons = new ArrayList(); @@ -43,7 +46,7 @@ public class TabIconConfigPane extends JPanel { public void initComp(int count) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + JPanel panel = FRGUIPaneFactory.createTinyHGapFlowInnerContainer_M_Pane_First0(); panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); editIconButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); @@ -63,12 +66,28 @@ public class TabIconConfigPane extends JPanel { curIconName = cip.update(); setShowIconImage(); TabIconConfigPane.this.repaint(); + deleteIconButton.setEnabled(true); } }); editDialog.setVisible(true); } }); editIconButton.setEnabled(false); + + deleteIconButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Delete")); + deleteIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); + deleteIconButton.setPreferredSize(new Dimension(62, 20)); + panel.add(deleteIconButton); + deleteIconButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + curIconName = ""; + setShowIconImage(); + TabIconConfigPane.this.repaint(); + deleteIconButton.setEnabled(false); + } + }); + deleteIconButton.setEnabled(false); + this.add(panel, BorderLayout.CENTER); JPanel northPane = new JPanel(); @@ -163,6 +182,7 @@ public class TabIconConfigPane extends JPanel { public void actionPerformed(ActionEvent evt) { selectIconButton = this; editIconButton.setEnabled(true); + deleteIconButton.setEnabled(StringUtils.isNotEmpty(this.getIconName())); TabIconConfigPane.this.repaint();// repaint } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileStyleEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileStyleEditor.java new file mode 100644 index 000000000..e18e8e49d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileStyleEditor.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.mobile.ui.MobileStylePane; +import com.fr.design.mainframe.widget.wrappers.MobileStyleWrapper; +import com.fr.form.ui.mobile.MobileStyle; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; + +public class AccessibleMobileStyleEditor extends UneditableAccessibleEditor { + + private MobileStylePane stylePane; + private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); + + public AccessibleMobileStyleEditor(MobileStylePane stylePane) { + super(new MobileStyleWrapper()); + this.stylePane = stylePane; + } + + @Override + protected void showEditorPane() { + stylePane.setPreferredSize(DEFAULT_DIMENSION); + BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + setValue(stylePane.update()); + fireStateChanged(); + } + }); + stylePane.populate((MobileStyle) getValue()); + dlg.setVisible(true); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileStyleWrapper.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileStyleWrapper.java new file mode 100644 index 000000000..a8ceb7c46 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileStyleWrapper.java @@ -0,0 +1,26 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.locale.InterProviderFactory; + +public class MobileStyleWrapper implements Encoder, Decoder { + @Override + public Object decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + + } + + @Override + public String encode(Object v) { + if (v == null) { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); + } + return v.toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java index 57fa7bb33..29a8a7deb 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java @@ -1,6 +1,5 @@ package com.fr.design.report.fit.menupane; -import com.fr.base.BaseUtils; import com.fr.design.actions.JTemplateAction; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionAdapter; @@ -8,18 +7,17 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; +import com.fr.general.IOUtils; import com.fr.report.fit.FitProvider; import com.fr.report.fit.ReportFitAttr; import javax.swing.KeyStroke; -import java.awt.Dimension; import java.awt.event.ActionEvent; /** * Created by Administrator on 2015/7/6 0006. */ public class ReportFitAttrAction extends JTemplateAction { - private static final Dimension MEDIUM = new Dimension(430, 400); private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() { @Override public char getMnemonic() { @@ -67,7 +65,7 @@ public class ReportFitAttrAction extends JTemplateAction { } this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/reportfit/fit.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/reportfit/fit.png")); } /** @@ -75,6 +73,7 @@ public class ReportFitAttrAction extends JTemplateAction { * * @param e 事件 */ + @Override public void actionPerformed(ActionEvent e) { final JTemplate jwb = getEditingComponent(); if (jwb == null) { @@ -93,14 +92,13 @@ public class ReportFitAttrAction extends JTemplateAction { private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane attrPane) { attrPane.populateBean(fitAttr); - UIDialog dialog = attrPane.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + UIDialog dialog = attrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { wbTpl.setReportFitAttr(attrPane.updateBean()); jwb.fireTargetModified(); } }); - dialog.setSize(MEDIUM); dialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java b/designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java index 556fa5113..4da324f29 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java @@ -80,22 +80,21 @@ public abstract class FileDownloader extends SwingWorker URLConnection connection = url.openConnection(); int total = connection.getContentLength(); item.setTotalLength(total); - InputStream reader = connection.getInputStream(); File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName())); StableUtils.makesureFileExist(tempFile); - FileOutputStream writer = new FileOutputStream(tempFile); - byte[] buffer = new byte[UpdateConstants.BYTE]; - int bytesRead = 0; - int totalBytesRead = 0; - while ((bytesRead = reader.read(buffer)) != -1) { - writer.write(buffer, 0, bytesRead); - buffer = new byte[UpdateConstants.BYTE]; - totalBytesRead += bytesRead; - item.setDownloadLength(totalBytesRead); - publish(item); + try ( InputStream reader = connection.getInputStream(); + FileOutputStream writer = new FileOutputStream(tempFile)) { + byte[] buffer = new byte[UpdateConstants.BYTE]; + int bytesRead = 0; + int totalBytesRead = 0; + while ((bytesRead = reader.read(buffer)) != -1) { + writer.write(buffer, 0, bytesRead); + buffer = new byte[UpdateConstants.BYTE]; + totalBytesRead += bytesRead; + item.setDownloadLength(totalBytesRead); + publish(item); + } } - reader.close(); - writer.close(); } /** diff --git a/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java b/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java index 906b71412..48c151488 100644 --- a/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java +++ b/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java @@ -82,15 +82,12 @@ public class DirectoryOperationFactory { } private static void copy(String path1, String path2) throws IOException { - DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1))); - DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2))); - byte[] date = new byte[in.available()]; - - in.read(date); - out.write(date); - - in.close(); - out.close(); + try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1))); + DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)))) { + byte[] date = new byte[in.available()]; + in.read(date); + out.write(date); + } } /** diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java index 41bba0f4f..d782428ce 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java @@ -1,5 +1,6 @@ package com.fr.design.update.ui.dialog; +import com.fr.log.FineLoggerFactory; import java.io.File; import java.io.FileInputStream; @@ -11,12 +12,12 @@ import java.io.FileInputStream; * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * EncodingDetect.java
* 自动获取文件的编码 * @author Mata * @since Create on 2018-08-23 - * @version 1.0 + * @version 1.0 */ public class EncodingDetect { /** @@ -25,11 +26,11 @@ public class EncodingDetect { * @return 文件的编码 */ public static String getJavaEncode(File file){ - BytesEncodingDetect s = new BytesEncodingDetect(); + BytesEncodingDetect s = new BytesEncodingDetect(); String fileCode = BytesEncodingDetect.javaname[s.detectEncoding(file)]; return fileCode; } - + } @@ -75,17 +76,13 @@ class BytesEncodingDetect extends Encoding { * type. The encoding type with the highest probability is returned. */ public int detectEncoding(File testfile) { - FileInputStream chinesefile; - byte[] rawtext; - rawtext = new byte[(int) testfile.length()]; - try { - chinesefile = new FileInputStream(testfile); - chinesefile.read(rawtext); - chinesefile.close(); - } catch (Exception e) { - System.err.println("Error: " + e); - } - return detectEncoding(rawtext); + byte[] rawtext = new byte[(int) testfile.length()]; + try (FileInputStream chinesefile = new FileInputStream(testfile)) { + chinesefile.read(rawtext); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return detectEncoding(rawtext); } /** @@ -647,7 +644,7 @@ class BytesEncodingDetect extends Encoding { * (byte)0xDF) == rawtext[i]) { // Two bytes if (i+1 < rawtextlen && (rawtext[i+1] & (byte)0xBF) == rawtext[i+1]) { * goodbytes += 2; i++; } } else if ((rawtext[i] & (byte)0xEF) == rawtext[i]) { // Three bytes if (i+2 < rawtextlen && * (rawtext[i+1] & (byte)0xBF) == rawtext[i+1] && (rawtext[i+2] & (byte)0xBF) == rawtext[i+2]) { goodbytes += 3; i+=2; } } } - * + * * score = (int)(100 * ((float)goodbytes/(float)rawtext.length)); // An all ASCII file is also a good UTF8 file, but I'd * rather it // get identified as ASCII. Can delete following 3 lines otherwise if (goodbytes == asciibytes) { score = 0; } // * If not above 90, reduce to zero to prevent coincidental matches if (score > 90) { return score; } else { return 0; } @@ -4551,5 +4548,5 @@ class BytesEncodingDetect extends Encoding { nicename[ASCII] = "ASCII"; nicename[OTHER] = "OTHER"; } - + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index e59cc09ff..525077d62 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -35,6 +35,7 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; 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; @@ -362,10 +363,10 @@ public class UpdateMainDialog extends UIDialog { add(jarVersionInfoPane, BorderLayout.NORTH); //海外版本不显示更新信息 - if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)){ + if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) { add(jarUpdateInfoPane, BorderLayout.CENTER); add(updateActionPane, BorderLayout.SOUTH); - }else { + } else { add(updateActionPane, BorderLayout.CENTER); } @@ -468,30 +469,28 @@ public class UpdateMainDialog extends UIDialog { return; } if (cacheFile.exists()) { - InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8"); - BufferedReader br = new BufferedReader(streamReader); - String readStr, updateTimeStr; - - while ((readStr = br.readLine()) != null) { - String[] updateInfo = readStr.split("\\t"); - if (updateInfo.length == 2) { - updateTimeStr = updateInfo[0]; - Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr); - //形如 Build#release-2018.07.31.03.03.52.80 - String currentNO = GeneralUtils.readBuildNO(); - Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); - if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) { - if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) { - continue; + try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8"); + BufferedReader br = new BufferedReader(streamReader)) { + String readStr, updateTimeStr; + while ((readStr = br.readLine()) != null) { + String[] updateInfo = readStr.split("\\t"); + if (updateInfo.length == 2) { + updateTimeStr = updateInfo[0]; + Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr); + //形如 Build#release-2018.07.31.03.03.52.80 + String currentNO = GeneralUtils.readBuildNO(); + Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); + if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) { + if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) { + continue; + } + } + if (isValidLogInfo(updateInfo[1])) { + updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)}); } - } - if (isValidLogInfo(updateInfo[1])) { - updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)}); } } } - br.close(); - streamReader.close(); } } @@ -515,16 +514,15 @@ public class UpdateMainDialog extends UIDialog { if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) { return; } - OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), "UTF-8"); - BufferedWriter bufferWriter = new BufferedWriter(writerStream); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject jo = (JSONObject) jsonArray.get(i); - bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); - bufferWriter.newLine(); - bufferWriter.flush(); + try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), EncodeConstants.ENCODING_UTF_8); + BufferedWriter bufferWriter = new BufferedWriter(writerStream)) { + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jo = (JSONObject) jsonArray.get(i); + bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); + bufferWriter.newLine(); + bufferWriter.flush(); + } } - bufferWriter.close(); - writerStream.close(); lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS; lastUpdateCacheTime = endTime; cacheProperty.updateProperty("updateTime", lastUpdateCacheTime); @@ -636,6 +634,7 @@ public class UpdateMainDialog extends UIDialog { /** * 获取当前jar的md5 + * * @param currentJAR * @return */ diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index befe47c55..b31209381 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -67,8 +67,7 @@ public class DesignUtils { * @return 启动了返回true */ public static boolean isStarted() { - try { - new Socket("localhost", port); + try (Socket socket = new Socket("localhost", port)) { return true; } catch (Exception ignored) { } @@ -116,6 +115,7 @@ public class DesignUtils { * @param startPort 端口 * @param suffixs 文件后缀 */ + @SuppressWarnings("squid:S2095") public static void createListeningServer(final int startPort, final String[] suffixs) { ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener")); service.execute(new Runnable() { diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index 74a499030..0231963b9 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -433,7 +433,7 @@ public class CustomIconPane extends BasicPane { JPanel imagePane = new JPanel(); imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0)); showImageLabel = new UILabel(); - showImageLabel.setPreferredSize(new Dimension(20, 20)); + showImageLabel.setPreferredSize(new Dimension(50, 50)); imagePane.add(showImageLabel); imagePane.add(browseButton); Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name") + ":"), nameTextField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon") + ":"), imagePane}}; @@ -450,12 +450,12 @@ public class CustomIconPane extends BasicPane { if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) { String path = jf.getSelectedFile().getAbsolutePath(); - // 将图片转化到16 × 16大小 + // 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储 Image image = BaseUtils.readImage(path); - BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH, - IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); + BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), + Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = bufferedImage.createGraphics(); - g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); + g2d.drawImage(image, 0, 0, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), null); bufferedImage.flush(); g2d.dispose(); iconImage = bufferedImage; diff --git a/designer-base/src/main/java/com/fr/env/LocalEnvPane.java b/designer-base/src/main/java/com/fr/env/LocalEnvPane.java index eaabd0a9a..6f191dd1e 100644 --- a/designer-base/src/main/java/com/fr/env/LocalEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/LocalEnvPane.java @@ -6,9 +6,9 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itree.filetree.JFileTree; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.file.filter.OnlyShowDirectoryFileFilter; - import com.fr.stable.StringUtils; import javax.swing.JPanel; @@ -33,8 +33,9 @@ public class LocalEnvPane extends BasicBeanPane { JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(northPane, BorderLayout.NORTH); - northPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Location") + ":"), BorderLayout.WEST); - northPane.add(pathTextField = new UITextField(), BorderLayout.CENTER); + northPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Location") + ":"), BorderLayout.WEST); + pathTextField = new UITextField(); + northPane.add(pathTextField, BorderLayout.CENTER); // 删除选择文件按钮 添加JFileTree @@ -54,19 +55,23 @@ public class LocalEnvPane extends BasicBeanPane { @Override public void valueChanged(TreeSelectionEvent e) { - pathTextField.setText(localEnvTree.getSelectedFile().getPath()); + File selectFile = localEnvTree.getSelectedFile(); + if (selectFile == null) { + return; + } + pathTextField.setText(selectFile.getPath()); } }); UITextArea description = new UITextArea(); centerPane.add(description, BorderLayout.SOUTH); - description.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Env_Des1")); + description.setText(Toolkit.i18nText("Fine-Design_Basic_Env_Des1")); description.setEditable(false); } @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Location"); + return Toolkit.i18nText("Fine-Design_Basic_Location"); } @Override diff --git a/designer-base/src/main/resources/com/fr/design/images/dialog/watermark/watermark_background_en.png b/designer-base/src/main/resources/com/fr/design/images/dialog/watermark/watermark_background_en.png new file mode 100644 index 000000000..38054513c Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/dialog/watermark/watermark_background_en.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportcolumns/col_en.png b/designer-base/src/main/resources/com/fr/design/images/reportcolumns/col_en.png index 14f73966d..3b3b1cc8c 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/reportcolumns/col_en.png and b/designer-base/src/main/resources/com/fr/design/images/reportcolumns/col_en.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/reportcolumns/row_en.png b/designer-base/src/main/resources/com/fr/design/images/reportcolumns/row_en.png index 7c66662a2..76328cf7d 100644 Binary files a/designer-base/src/main/resources/com/fr/design/images/reportcolumns/row_en.png and b/designer-base/src/main/resources/com/fr/design/images/reportcolumns/row_en.png differ diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java new file mode 100644 index 000000000..67f082456 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java @@ -0,0 +1,51 @@ +package com.fr.design.gui.itree.filetree; + +import com.fr.base.extension.FileExtension; +import com.fr.base.io.BaseBook; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.mainframe.AbstractAppProvider; +import com.fr.design.mainframe.App; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; +import com.fr.stable.fun.mark.Mutable; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashSet; +import java.util.Set; + +/** + * Created by alex sung on 2019/7/25. + */ +public class FileNodeConstantsTest { + @Test + public void supportFileTypesTest(){ + ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); + Set apps = new HashSet(){{add(new MockCptxApp());}}; + EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); + EasyMock.replay(extra); + + Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size()); + App app = (App) extra.getArray(App.MARK_STRING).iterator().next(); + Assert.assertEquals("cptx", app.defaultExtensions()[0]); + } + + private class MockCptxApp extends AbstractAppProvider{ + @Override + public String[] defaultExtensions() { + return new String[] {FileExtension.CPTX.getExtension()}; + } + + @Override + public JTemplate openTemplate(FILE tplFile) { + return null; + } + + @Override + public BaseBook asIOFile(FILE tplFile) { + return null; + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java index bea3beba9..8849cc17c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java @@ -64,7 +64,7 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { } public void addSiteInfo(String siteKind, String localDir, double megaBits) { - + if (new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), localDir)).exists()) { //本地有这个资源,不下载 return; @@ -86,12 +86,14 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { initDialog(); dialog.addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { //取消下载 result = false; exitDialog(); } + @Override public void windowOpened(WindowEvent e) { downloadAndInstallPluginDependenceFile(); exitDialog(); @@ -119,25 +121,22 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { - InputStream reader = httpClient.getResponseStream(); String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); File file = new File(temp); StableUtils.makesureFileExist(file); - FileOutputStream writer = new FileOutputStream(temp); - byte[] buffer = new byte[PluginConstants.BYTES_NUM]; - int bytesRead; - while ((bytesRead = reader.read(buffer)) > 0 && result) { - writer.write(buffer, 0, bytesRead); - buffer = new byte[PluginConstants.BYTES_NUM]; - - currentBytesRead += bytesRead; - setProgress(currentBytesRead); + try (InputStream reader = httpClient.getResponseStream(); + FileOutputStream writer = new FileOutputStream(temp)) { + byte[] buffer = new byte[PluginConstants.BYTES_NUM]; + int bytesRead; + while ((bytesRead = reader.read(buffer)) > 0 && result) { + writer.write(buffer, 0, bytesRead); + buffer = new byte[PluginConstants.BYTES_NUM]; + + currentBytesRead += bytesRead; + setProgress(currentBytesRead); + } + writer.flush(); } - reader.close(); - writer.flush(); - writer.close(); - - if (result) { //安装文件 IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir)); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java index 10664b340..bbce11d9f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java @@ -20,7 +20,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpClient; -import com.fr.geojson.helper.GEOJSONHelper; import com.fr.plugin.chart.base.GisLayer; import com.fr.plugin.chart.base.ViewCenter; import com.fr.plugin.chart.map.VanChartMapPlot; @@ -576,7 +575,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { mapDataTree.changeRootNode(this.getRootNode()); if(samePlotChange) { - String nodePath = GEOJSONHelper.getDefaultJSONURL(); + String nodePath = ChartGEOJSONHelper.getDefaultJSONURL(); mapPlot.setGeoUrl(nodePath); mapDataTree.setSelectNodePath(nodePath); selectTreePath = mapDataTree.getSelectionPath(); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index 9aa9e5ab9..f2fc29ad5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -24,6 +24,7 @@ import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; +import com.fr.general.act.BorderPacker; import java.awt.Component; import java.awt.Dimension; @@ -284,7 +285,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { backupBound.x -= rec.x; backupBound.y -= rec.y; XWCardLayout cardLayout = mainLayout.getCardPart(); - LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); + BorderPacker style = cardLayout.toData().getBorderStyle(); XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart(); Dimension titleDimension = xwCardTitleLayout.getSize(); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java index b1ca803c6..9b8effd0a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java @@ -7,18 +7,16 @@ package com.fr.design.designer.beans.adapters.layout; import com.fr.design.beans.GroupModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; -import com.fr.design.mainframe.widget.editors.ParameterEditor; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; +import com.fr.general.act.BorderPacker; import java.awt.*; @@ -90,7 +88,7 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { // TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了 private int adjustY(int y, XWTabFitLayout tabLayout) { XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); - LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); + BorderPacker style = cardLayout.toData().getBorderStyle(); y = y - this.getParaEditorYOffset(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { y = y - WCardMainBorderLayout.TAB_HEIGHT; diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 046663102..fdefc019a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -11,6 +11,8 @@ import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.WidgetValue; import com.fr.form.ui.container.WTitleLayout; import com.fr.general.ComparatorUtils; +import com.fr.general.act.BorderPacker; +import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; import com.fr.stable.StringUtils; @@ -41,7 +43,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } protected void initStyle() { - LayoutBorderStyle style = toData().getBorderStyle(); + BorderPacker style = toData().getBorderStyle(); initBorderStyle(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { initTitleStyle(style); @@ -52,7 +54,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ // 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框 protected void initBorderStyle() { - LayoutBorderStyle style = toData().getBorderStyle(); + BorderPacker style = toData().getBorderStyle(); if (style != null && style.getBorder() != Constants.LINE_NONE) { this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius())); } else { @@ -74,8 +76,8 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ * 设置样式为标题样式时,对应组件加上标题 * @param style 样式 */ - protected void initTitleStyle(LayoutBorderStyle style){ - if (style.getTitle() == null) { + protected void initTitleStyle(BorderPacker style){ + if (style.getTitle() == null || style.getTitle().getTextObject() == null) { return; } XWTitleLayout parent = (XWTitleLayout) this.getParent(); @@ -100,25 +102,25 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ /** * 更新标题控件所有的样式 */ - private void updateTitleWidgetStyle(Label title, LayoutBorderStyle style) { + private void updateTitleWidgetStyle(Label title, BorderPacker style) { //标题的边框样式目前是取对应的控件的边框样式 title.setBorder(style.getBorder()); title.setColor(style.getColor()); // title.setCorner(style.isCorner()); - WidgetTitle wTitle = style.getTitle(); + TitlePacker wTitle = style.getTitle(); //设置成随机不重复的, 不然都用一个名字的话, 联动只能联动一个 - title.setWidgetName(wTitle.TITLE_NAME_INDEX + this.toData().getWidgetName()); + title.setWidgetName(WidgetTitle.TITLE_NAME_INDEX + this.toData().getWidgetName()); title.setWidgetValue(getTitleValue(wTitle)); title.setFont(wTitle.getFrFont()); title.setTextalign(wTitle.getPosition()); title.setBackground(wTitle.getBackground()); } - private WidgetValue getTitleValue(WidgetTitle wTitle){ + private WidgetValue getTitleValue(TitlePacker wTitle){ String content = String.valueOf(wTitle.getTextObject()); - Object vlaue = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content; - return new WidgetValue(vlaue); + Object value = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content; + return new WidgetValue(value); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index 29ce253f5..14a5e3c96 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -339,4 +339,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator { public boolean isSupportShared() { return true; } + + @Override + public boolean supportMobileStyle() { + return false; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index b7d7b3a45..bef18f96f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -3,7 +3,6 @@ */ package com.fr.design.designer.creator; -import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; @@ -591,6 +590,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return; } + /** + * 是否支持定义移动端样式,默认true + * @return 是否支持定义移动端样式 + */ + public boolean supportMobileStyle() { + return true; + } + /** * 获取当前组件自定义的属性表tab * diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index 480412287..ec06a1597 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -121,6 +121,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return ArrayUtils.add(extraTableEditor, reportFitEditor); } + @Override + public boolean supportMobileStyle() { + return false; + } + private CRPropertyDescriptor getReportFitEditor() { this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); FitProvider wbTpl = designer.getTarget(); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java index 45764e746..9044d6c3c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java @@ -572,4 +572,9 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme return false; } + @Override + public boolean supportMobileStyle() { + return false; + } + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java index a7b74d0fd..ff67634e4 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java @@ -42,6 +42,7 @@ public class XWBorderLayout extends XLayoutContainer { * 默认名称 * @return 名称 */ + @Override public String createDefaultName() { return "border"; } @@ -50,6 +51,7 @@ public class XWBorderLayout extends XLayoutContainer { * 转化成相应 WBorderLayout * @return 相应 WBorderLayout */ + @Override public WBorderLayout toData() { return (WBorderLayout) data; } @@ -62,6 +64,7 @@ public class XWBorderLayout extends XLayoutContainer { * 初始大小 * @return 初始大小 */ + @Override public Dimension initEditorSize() { return new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT); } @@ -71,15 +74,18 @@ public class XWBorderLayout extends XLayoutContainer { * @return 属性名 * @throws java.beans.IntrospectionException 抛错 */ + @Override public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { return new CRPropertyDescriptor[] { - new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")) + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")), + new CRPropertyDescriptor("customTitleName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Title")) }; } /** * 将WLayout转换为XLayoutContainer */ + @Override public void convert() { isRefreshing = true; WBorderLayout wb = this.toData(); @@ -101,6 +107,7 @@ public class XWBorderLayout extends XLayoutContainer { * 设计界面中有组件添加时,要通知WLayout容器重新paint * @param e 事件 */ + @Override public void componentAdded(ContainerEvent e) { if (isRefreshing) { return; @@ -158,6 +165,7 @@ public class XWBorderLayout extends XLayoutContainer { /** * 重新计算大小 */ + @Override public void recalculateChildrenSize() { Dimension d = getSize(); WBorderLayout layout = toData(); @@ -173,6 +181,7 @@ public class XWBorderLayout extends XLayoutContainer { * @param comp 组件 * @param constraints 方位 */ + @Override public void add(Component comp, Object constraints) { super.add(comp, constraints); if (comp == null) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java index 1db5e4045..5225a3b4f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java @@ -179,4 +179,9 @@ public class XWScaleLayout extends DedicateLayoutContainer { } return super.getWidgetPropertyUIProviders(); } + + @Override + public boolean supportMobileStyle() { + return true; + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 72d0669c8..dc555e5d1 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -22,31 +22,20 @@ import com.fr.design.mainframe.JForm; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.CardSwitchButton; -import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WTabTextDirection; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.Background; +import com.fr.general.act.BorderPacker; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; - +import com.fr.general.act.TitlePacker; import com.fr.general.cardtag.TemplateStyle; import com.fr.stable.unit.PT; -import javax.swing.Action; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.plaf.basic.BasicLabelUI; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; +import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; import java.util.ArrayList; @@ -308,7 +297,7 @@ public class XCardSwitchButton extends XButton { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; CardSwitchButton button = (CardSwitchButton) this.toData(); - WidgetTitle widgetTitle = getWidgetTitle(); + TitlePacker widgetTitle = getWidgetTitle(); drawBackground(button, widgetTitle); drawTitle(button, widgetTitle); Dimension panelSize = this.getContentLabel().getSize(); @@ -322,7 +311,7 @@ public class XCardSwitchButton extends XButton { } //画背景 - private void drawBackground(CardSwitchButton button, WidgetTitle widgetTitle){ + private void drawBackground(CardSwitchButton button, TitlePacker widgetTitle){ Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground(); TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle(); //获取当前tab的index @@ -340,7 +329,7 @@ public class XCardSwitchButton extends XButton { } //画标题 - private void drawTitle(CardSwitchButton button, WidgetTitle widgetTitle) { + private void drawTitle(CardSwitchButton button, TitlePacker widgetTitle) { String titleText = button.getText(); this.setButtonText(titleText); FRFont font = widgetTitle.getFrFont(); @@ -351,11 +340,11 @@ public class XCardSwitchButton extends XButton { } - private WidgetTitle getWidgetTitle() { + private TitlePacker getWidgetTitle() { if (this.cardLayout == null) { initRelateLayout(); } - LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); + BorderPacker style = this.cardLayout.toData().getBorderStyle(); return style.getTitle(); } @@ -463,7 +452,7 @@ public class XCardSwitchButton extends XButton { String titleText = button.getText(); java.util.List verticalTextList = new ArrayList(); StringBuilder titleStringBuf = new StringBuilder(); - WidgetTitle title = getWidgetTitle(); + TitlePacker title = getWidgetTitle(); FRFont font = title.getFrFont(); FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST); FontMetrics fm = GraphHelper.getFontMetrics(newFont); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 107e31ed1..c91d34654 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -25,7 +25,6 @@ import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; -import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WLayout; @@ -33,7 +32,9 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.act.BorderPacker; import com.fr.general.ComparatorUtils; +import com.fr.general.act.TitlePacker; import com.fr.general.cardtag.DefaultTemplateStyle; import com.fr.general.cardtag.TemplateStyle; import com.fr.stable.ArrayUtils; @@ -165,7 +166,7 @@ public class XWCardLayout extends XLayoutContainer { WCardMainBorderLayout border = new WCardMainBorderLayout(); XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension); //将子WCardBorder的style设置到父容器上 - LayoutBorderStyle style = (this.toData()).getBorderStyle(); + BorderPacker style = (this.toData()).getBorderStyle(); border.setBorderStyle(style); this.setBackupParent(xMainBorder); XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder); @@ -397,13 +398,13 @@ public class XWCardLayout extends XLayoutContainer { //初始化样式 @Override protected void initStyle() { - LayoutBorderStyle style = toData().getBorderStyle(); + BorderPacker style = toData().getBorderStyle(); initBorderTitleStyle(style); initBorderStyle(); clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)); } - private void initBorderTitleStyle(LayoutBorderStyle style) { + private void initBorderTitleStyle(BorderPacker style) { //初始化默认标题样式 if (!initFlag) { return; @@ -411,7 +412,7 @@ public class XWCardLayout extends XLayoutContainer { style.setType(LayoutBorderStyle.TITLE); style.setBorder(Constants.LINE_THIN); - WidgetTitle widgetTitle = style.getTitle(); + TitlePacker widgetTitle = style.getTitle(); widgetTitle.setBackground(ColorBackground.getInstance(TITLE_COLOR)); initFlag = false; } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index c7f235154..edbabeadf 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -38,6 +38,7 @@ import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; +import com.fr.general.act.BorderPacker; import com.fr.share.ShareConstants; import com.fr.stable.Constants; @@ -164,7 +165,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout { String tabpaneName = cardLayout.getWidgetName(); if (!wCardTagLayout.isNewTab()) { wCardTagLayout.setWidgetName(tabpaneName); - LayoutBorderStyle borderStyle = cardLayout.getBorderStyle(); + BorderPacker borderStyle = cardLayout.getBorderStyle(); if(borderStyle != null){ //新tab默认都有标题 borderStyle.setType(LayoutBorderStyle.TITLE); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 1b9d2690e..77282f63f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -27,21 +27,18 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.CardSwitchButton; -import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; -import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.act.BorderPacker; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.cardtag.DefaultTemplateStyle; import javax.swing.border.Border; -import java.awt.Dimension; -import java.awt.FontMetrics; -import java.awt.Rectangle; +import java.awt.*; import java.awt.event.ContainerEvent; import java.awt.event.MouseEvent; import java.util.HashMap; @@ -363,9 +360,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { if (this.cardLayout == null) { initCardLayout(); } - LayoutBorderStyle borderStyle = this.cardLayout.toData().getBorderStyle(); - WidgetTitle title = borderStyle.getTitle(); - FRFont f = title.getFrFont(); + BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle(); + FRFont f = borderStyle.getTitle().getFrFont(); FontMetrics fm = GraphHelper.getFontMetrics(f); switch (wCardTagLayout.getTextDirection()) { diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileStylePropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileStylePropertyUI.java new file mode 100644 index 000000000..831f558cb --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileStylePropertyUI.java @@ -0,0 +1,36 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWScaleLayout; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.design.widget.ui.designer.mobile.MobileWidgetStyleDefinePane; + +public class MobileStylePropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public MobileStylePropertyUI(XCreator xCreator) { + if(xCreator instanceof XWScaleLayout) { + this.xCreator = xCreator.getEditingChildCreator(); + } else { + this.xCreator = xCreator; + } + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new MobileWidgetStyleDefinePane(xCreator); + } + + @Override + public String tableTitle() { + return null; + } +} diff --git a/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java b/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java index 03499286d..60cc6d21f 100644 --- a/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java +++ b/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileOthersPane.java @@ -18,6 +18,7 @@ public class FormMobileOthersPane extends BasicBeanPane { private MobileRadioCheckPane appearRefreshCheckPane; // 页面再现时刷新 private MobileRadioCheckPane promptWhenLeaveWithoutSubmitCheckPane; // 数据未提交离开提示 + private MobileRadioCheckPane allowDoubleClickOrZoomCheckPane; // 允许双击/双指缩放 public FormMobileOthersPane() { this.initComponents(); @@ -32,6 +33,8 @@ public class FormMobileOthersPane extends BasicBeanPane { contentPane.add(appearRefreshCheckPane, BorderLayout.WEST); promptWhenLeaveWithoutSubmitCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Prompt_When_Leave_Without_Submit")); contentPane.add(promptWhenLeaveWithoutSubmitCheckPane, BorderLayout.CENTER); + allowDoubleClickOrZoomCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("允许双击/双指缩放")); + contentPane.add(allowDoubleClickOrZoomCheckPane, BorderLayout.EAST); borderPane.add(contentPane); this.add(borderPane); } @@ -43,6 +46,7 @@ public class FormMobileOthersPane extends BasicBeanPane { } this.appearRefreshCheckPane.populateBean(ob.isAppearRefresh()); this.promptWhenLeaveWithoutSubmitCheckPane.populateBean(ob.isPromptWhenLeaveWithoutSubmit()); + this.allowDoubleClickOrZoomCheckPane.populateBean(ob.isAllowDoubleClickOrZoom()); } @Override @@ -55,6 +59,7 @@ public class FormMobileOthersPane extends BasicBeanPane { if(mobileAttr != null) { mobileAttr.setAppearRefresh(this.appearRefreshCheckPane.updateBean()); mobileAttr.setPromptWhenLeaveWithoutSubmit(this.promptWhenLeaveWithoutSubmitCheckPane.updateBean()); + mobileAttr.setAllowDoubleClickOrZoom(this.allowDoubleClickOrZoomCheckPane.updateBean()); } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java index a70431700..cf460f9ce 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java @@ -38,32 +38,17 @@ import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.WidgetTitle; import com.fr.general.Background; import com.fr.general.FRFont; - +import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; -import javax.swing.AbstractButton; -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JToggleButton; +import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.basic.BasicToggleButtonUI; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -546,7 +531,7 @@ public class LayoutBorderPane extends BasicPane { style.setColor(currentLineColorPane.getColor()); style.setBackground(backgroundPane.update()); style.setAlpha((float)(numberDragPane.updateBean()/maxNumber)); - WidgetTitle title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); + TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); title.setTextObject(formulaPane.updateBean()); FRFont frFont = title.getFrFont(); frFont = frFont.applySize((Integer)fontSizeComboBox.getSelectedItem()); @@ -644,10 +629,10 @@ public class LayoutBorderPane extends BasicPane { } protected void populateTitle(){ - WidgetTitle widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle(); + TitlePacker widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle(); widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; - populateFourmula(widgetTitle); + populateFormula(widgetTitle); populateFont(widgetTitle); underline.addMouseListener(new MouseAdapter() { @@ -683,7 +668,7 @@ public class LayoutBorderPane extends BasicPane { paintPreviewPane(); } - protected void populateFont(WidgetTitle widgetTitle){ + protected void populateFont(TitlePacker widgetTitle){ FRFont frFont = widgetTitle.getFrFont(); this.fontSizeComboBox.setSelectedItem(frFont.getSize()); this.fontSizeComboBox.addItemListener(new ItemListener() { @@ -756,7 +741,7 @@ public class LayoutBorderPane extends BasicPane { } - private void populateFourmula(WidgetTitle widgetTitle) { + private void populateFormula(TitlePacker widgetTitle) { this.formulaPane.populateBean(widgetTitle.getTextObject().toString()); this.formulaPane.getUITextField().getDocument() .addDocumentListener(new DocumentListener() { diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java index 3d649f3b9..33470a33b 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java @@ -7,10 +7,10 @@ import com.fr.base.background.ColorBackground; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.gui.itextarea.UITextArea; import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.WidgetTitle; import com.fr.general.Background; import com.fr.general.FRFont; +import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; import javax.swing.JPanel; @@ -126,7 +126,7 @@ public class LayoutBorderPreviewPane extends JPanel{ g2d.setColor(new Color(237, 237, 237)); } g2d.setFont(frFont.applyResolutionNP(resolution)); - WidgetTitle title = borderStyle.getTitle(); + TitlePacker title = borderStyle.getTitle(); String paintText = title.getTextObject().toString(); int startX1 = 0; int startY = 0; @@ -158,7 +158,7 @@ public class LayoutBorderPreviewPane extends JPanel{ GraphHelper.draw(g,double2, borderStyle.getBorder()); } - private void drawTabBack(Graphics2D g2d, Graphics g, WidgetTitle title, FontMetrics fm, int startX1, int startY){ + private void drawTabBack(Graphics2D g2d, Graphics g, TitlePacker title, FontMetrics fm, int startX1, int startY){ Dimension d = getSize(); String paintText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title")+TAB_ZERO; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java index af17389be..8195fbb50 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java @@ -7,6 +7,7 @@ import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.EventPropertyTable; +import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; @@ -172,8 +173,12 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() { FormSelection selection = designer.getSelectionModel().getSelection(); WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null; - if (selection != null && selection.getSelectedCreator() != null) { + XCreator xCreator = selection.getSelectedCreator(); + if (selection != null && xCreator != null) { embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); + if(!designer.getDesignerMode().isFormParameterEditor() && xCreator.supportMobileStyle()) { + embeddedPropertyUIProviders = ArrayUtils.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator)); + } } Set set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); return ArrayUtils.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()])); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java index 500d42a1c..bc69bbd1a 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java @@ -1,16 +1,20 @@ package com.fr.design.widget.ui.designer; +import com.fr.design.designer.IntervalConstants; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.widget.FRWidgetFactory; import com.fr.form.ui.ButtonGroup; - -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SpinnerNumberModel; +import java.awt.Component; public class ButtonGroupDictPane extends JPanel { @@ -26,16 +30,23 @@ public class ButtonGroupDictPane extends JPanel { * */ public void initComponents() { - - - this.setLayout(FRGUIPaneFactory.createBorderLayout()); adaptiveCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Adaptive"), true); adaptiveCheckbox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - this.columnLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":"); + UILabel dictLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")); + this.columnLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":", dictLabel.getPreferredSize().width); columnSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); - - JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{adaptiveCheckbox, columnLabel, columnSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}}; + Component[][] components = { + new Component[] {adaptiveCheckbox, null}, + new Component[] {columnLabel, columnSpinner}, + }; + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.add(jPanel); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java index 41ea1c1c7..06a14c25a 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java @@ -107,7 +107,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify public void populateBean(WCardTagLayout ob) { //标题背景和字体属性设置在WCardLayout上做兼容 XLayoutContainer topLayout = creator.getTopLayout(); - LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle(); + LayoutBorderStyle layoutBorderStyle = (LayoutBorderStyle) ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle(); displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); @@ -125,7 +125,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify //标题背景和字体属性设置在WCardLayout上做兼容 XLayoutContainer topLayout = creator.getTopLayout(); XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart(); - LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle(); + LayoutBorderStyle layoutBorderStyle = (LayoutBorderStyle) xCardLayout.toData().getBorderStyle(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); FRFont titleFont = frFontPane.update(frFont); layoutBorderStyle.getTitle().setFrFont(titleFont); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java index b91e1d7b6..bfd0ea7ea 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java @@ -11,7 +11,8 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.MobileWidgetListPane; import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.widget.ui.designer.mobile.component.MobileComponentAdvancePane; +import com.fr.design.widget.ui.designer.mobile.component.MobileComponentFrozenPane; +import com.fr.design.widget.ui.designer.mobile.component.MobileComponentMarginPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane; import com.fr.form.ui.RichStyleWidgetProvider; import com.fr.form.ui.container.WFitLayout; @@ -30,8 +31,11 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { private AttributeChangeListener changeListener; private UICheckBox appRelayoutCheck; private MobileWidgetListPane mobileWidgetListPane; - private MobileComponentAdvancePane advancePane; + private MobileComponentMarginPane marginPane; private MobileComponentLayoutIntervalPane intervalPane; + private MobileComponentFrozenPane frozenPane; + private UIExpandablePane advancePane; + private UIExpandablePane layoutPane; public BodyMobileDefinePane(XCreator xCreator) { this.bodyCreator = xCreator; @@ -89,16 +93,23 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { private JPanel createNorthPane() { JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); holder.add(getMobilePropertyPane(), BorderLayout.NORTH); - - advancePane = new MobileComponentAdvancePane(FormBodyPaddingAttrMark.XML_TAG); + marginPane = new MobileComponentMarginPane(FormBodyPaddingAttrMark.XML_TAG); intervalPane = new MobileComponentLayoutIntervalPane(FormBodyPaddingAttrMark.XML_TAG); + frozenPane = new MobileComponentFrozenPane(); + JPanel wrapLayoutPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wrapLayoutPane.add(intervalPane, BorderLayout.NORTH); + wrapLayoutPane.add(frozenPane, BorderLayout.CENTER); + advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, marginPane); + layoutPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, wrapLayoutPane); //高级 holder.add(advancePane, BorderLayout.CENTER); //布局 - holder.add(intervalPane, BorderLayout.SOUTH); + holder.add(layoutPane, BorderLayout.SOUTH); - advancePane.setVisible(!shouldHidePadding(designer)); - intervalPane.setVisible(!shouldHidePadding(designer)); + boolean flag = !shouldHidePadding(designer); + advancePane.setVisible(flag); + layoutPane.setVisible(flag); + frozenPane.setVisible(appRelayoutCheck.isSelected()); return holder; } @@ -137,13 +148,12 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { public void populate(FormDesigner designer) { this.designer = designer; appRelayoutCheck.setSelected(FormDesignerUtils.isAppRelayout(designer)); - // 数据 populate 完成后,再设置监听 this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); - - advancePane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); + marginPane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); intervalPane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); + frozenPane.populate(designer.getSelectionModel().getSelection().getSelectedCreator()); } @Override @@ -152,15 +162,19 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { setAppRelayout(appRelayoutCheck.isSelected()); boolean appPaddingVisible = appRelayout || !FormDesignerUtils.isBodyAbsolute(designer); advancePane.setVisible(appPaddingVisible); - intervalPane.setVisible(appPaddingVisible); + layoutPane.setVisible(appPaddingVisible); + frozenPane.setVisible(appRelayout); mobileWidgetListPane.updateToDesigner(); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); if (advancePane.isVisible()) { - advancePane.update((RichStyleWidgetProvider) getBodyCreator().toData()); + marginPane.update((RichStyleWidgetProvider) getBodyCreator().toData()); } - if (intervalPane.isVisible()) { + if (layoutPane.isVisible()) { intervalPane.update((RichStyleWidgetProvider) getBodyCreator().toData()); } + if (appRelayout) { + frozenPane.update(designer.getSelectionModel().getSelection().getSelectedCreator()); + } } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java index b9ae12e20..a91ebd749 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java @@ -48,6 +48,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { private AttributeChangeListener changeListener; private UILabel tipLabel; private UICheckBox allowFullCheckBox;//允许全屏 + private UICheckBox functionalWhenUnactivatedCheckBox;//组件未激活时可使用组件内功能 public ChartEditorDefinePane(XCreator xCreator) { this.xCreator = xCreator; @@ -88,6 +89,8 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { panel.add(unavailableTipLabel, BorderLayout.NORTH); allowFullCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Full_Screen")); panel.add(allowFullCheckBox); + functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated")); + panel.add(functionalWhenUnactivatedCheckBox); return panel; } @@ -98,19 +101,21 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { tipLabel.setForeground(Color.gray); updateTipLabel(); allowFullCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Full_Screen")); + functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated")); Component[][] components = new Component[][]{ new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Zoom_In_Logic"), SwingConstants.LEFT), new UILabel(ChartMobileFitAttrState.PROPORTION.description())}, new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Zoom_Out_Logic"), SwingConstants.LEFT), zoomOutComboBox}, new Component[] {tipLabel, null}, - new Component[] {allowFullCheckBox} + new Component[] {allowFullCheckBox, null}, + new Component[] {functionalWhenUnactivatedCheckBox, null} }; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p}; + double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p,f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -154,6 +159,8 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { BaseChartEditor chartEditor = (BaseChartEditor)xCreator.toData(); boolean allowFullScreen = chartEditor.getMobileAttr().isAllowFullScreen(); this.allowFullCheckBox.setSelected(allowFullScreen); + boolean isFunctionalWhenUnactivated = chartEditor.getMobileAttr().isFunctionalWhenUnactivated(); + this.functionalWhenUnactivatedCheckBox.setSelected(isFunctionalWhenUnactivated); this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); @@ -188,8 +195,10 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { mobileAttr.setZoomInAttr(ChartMobileFitAttrState.PROPORTION); mobileAttr.setZoomOutAttr((ChartMobileFitAttrState) ((Item) zoomOutComboBox.getSelectedItem()).getValue()); mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); + mobileAttr.setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); }else { mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); + mobileAttr.setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); } DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java index 9e833f0ae..5f255bb60 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java @@ -29,10 +29,10 @@ import java.awt.Component; /** * 报表块-移动端属性面板 - * + *

* Created by fanglei on 2017/8/8. */ -public class ElementCaseDefinePane extends MobileWidgetDefinePane{ +public class ElementCaseDefinePane extends MobileWidgetDefinePane { private static final double MAX_HEIGHT_LIMIT = 0.8; private static final Item[] ITEMS = { new Item(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL), @@ -50,8 +50,9 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ private UISpinner maxHeightSpinner; // 最大高度Spinner private AttributeChangeListener changeListener; private UICheckBox allowFullCheckBox; + private UICheckBox functionalWhenUnactivatedCheckBox; - public ElementCaseDefinePane (XCreator xCreator) { + public ElementCaseDefinePane(XCreator xCreator) { this.xCreator = xCreator; } @@ -87,19 +88,22 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ allowFullCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Full_Screen")); + functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated")); + Component[][] components = new Component[][]{ new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Horizontal"), SwingConstants.LEFT), hComboBox}, new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Vertical"), SwingConstants.LEFT), vComboBox}, new Component[] {heightRestrictCheckBox, null}, - new Component[] {allowFullCheckBox}, + new Component[] {allowFullCheckBox, null}, + new Component[] {functionalWhenUnactivatedCheckBox, null}, new Component[] {maxHeightLabel, maxHeightSpinner} }; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p}; - double[] columnSize = {p,f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; - final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); + double[] rowSize = {p, p, p, p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); panelWrapper.add(panel, BorderLayout.NORTH); @@ -131,14 +135,15 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ public void populate(FormDesigner designer) { this.designer = designer; this.addAttributeChangeListener(changeListener); - ElementCaseEditor elementCaseEditor = (ElementCaseEditor)xCreator.toData(); - this.hComboBox.setSelectedItem(new Item (elementCaseEditor.getHorziontalAttr().description(), elementCaseEditor.getHorziontalAttr())); - this.vComboBox.setSelectedItem(new Item (elementCaseEditor.getVerticalAttr().description(), elementCaseEditor.getVerticalAttr())); + ElementCaseEditor elementCaseEditor = (ElementCaseEditor) xCreator.toData(); + this.hComboBox.setSelectedItem(new Item(elementCaseEditor.getHorziontalAttr().description(), elementCaseEditor.getHorziontalAttr())); + this.vComboBox.setSelectedItem(new Item(elementCaseEditor.getVerticalAttr().description(), elementCaseEditor.getVerticalAttr())); this.heightRestrictCheckBox.setSelected(elementCaseEditor.isHeightRestrict()); this.maxHeightLabel.setVisible(elementCaseEditor.isHeightRestrict()); this.maxHeightSpinner.setVisible(elementCaseEditor.isHeightRestrict()); this.maxHeightSpinner.setValue(elementCaseEditor.getHeightPercent()); this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen()); + this.functionalWhenUnactivatedCheckBox.setSelected(elementCaseEditor.isFunctionalWhenUnactivated()); } @Override @@ -147,22 +152,24 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ String globalName = this.getGlobalName(); switch (globalName) { case "hComboBox": - ((ElementCaseEditor)xCreator.toData()).setHorziontalAttr(((MobileFitAttrState)((Item)hComboBox.getSelectedItem()).getValue())); + ((ElementCaseEditor) xCreator.toData()).setHorziontalAttr(((MobileFitAttrState) ((Item) hComboBox.getSelectedItem()).getValue())); break; case "vComboBox": - ((ElementCaseEditor)xCreator.toData()).setVerticalAttr(((MobileFitAttrState)((Item)vComboBox.getSelectedItem()).getValue())); + ((ElementCaseEditor) xCreator.toData()).setVerticalAttr(((MobileFitAttrState) ((Item) vComboBox.getSelectedItem()).getValue())); break; case "heightRestrictCheckBox": boolean isHeightRestrict = heightRestrictCheckBox.isSelected(); - ((ElementCaseEditor)xCreator.toData()).setHeightRestrict(isHeightRestrict); + ((ElementCaseEditor) xCreator.toData()).setHeightRestrict(isHeightRestrict); maxHeightSpinner.setVisible(isHeightRestrict); maxHeightLabel.setVisible(isHeightRestrict); break; case "maxHeightSpinner": - ((ElementCaseEditor)xCreator.toData()).setHeightPercent(maxHeightSpinner.getValue()); + ((ElementCaseEditor) xCreator.toData()).setHeightPercent(maxHeightSpinner.getValue()); break; case "allowFullCheckBox": - ((ElementCaseEditor)xCreator.toData()).setAllowFullScreen(allowFullCheckBox.isSelected()); + ((ElementCaseEditor) xCreator.toData()).setAllowFullScreen(allowFullCheckBox.isSelected()); + case "functionalWhenUnactivatedCheckBox": + ((ElementCaseEditor) xCreator.toData()).setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); } } @@ -172,6 +179,7 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ this.heightRestrictCheckBox.setGlobalName("heightRestrictCheckBox"); this.maxHeightSpinner.setGlobalName("maxHeightSpinner"); this.allowFullCheckBox.setGlobalName("allowFullCheckBox"); + this.functionalWhenUnactivatedCheckBox.setGlobalName("functionalWhenUnactivatedCheckBox"); } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java new file mode 100644 index 000000000..fb6f81fe5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java @@ -0,0 +1,85 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.widget.accessibles.AccessibleMobileStyleEditor; +import com.fr.design.mainframe.mobile.ui.MobileStylePane; +import com.fr.form.ui.mobile.MobileStyle; + +import javax.swing.*; +import java.awt.*; + +public class MobileWidgetStyleDefinePane extends MobileWidgetDefinePane { + + private XCreator xCreator; + private AccessibleMobileStyleEditor mobileStyleEditor; + private AttributeChangeListener changeListener; + + public MobileWidgetStyleDefinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public void setPreferredSize(Dimension dimension) { + super.setPreferredSize(dimension); + } + + @Override + public void initPropertyGroups(Object source) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template")); + mobileStyleEditor = new AccessibleMobileStyleEditor(new MobileStylePane(this.xCreator.toData())); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{label, mobileStyleEditor}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_LARGE + ); + JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); + holder.add(jPanel, BorderLayout.NORTH); + + this.add(holder, BorderLayout.NORTH); + } + + @Override + public void populate(FormDesigner designer) { + mobileStyleEditor.setValue(xCreator.toData().getMobileStyle()); + this.bindListeners2Widgets(); + this.addAttributeChangeListener(changeListener); + } + + @Override + public void update() { + xCreator.toData().setMobileStyle((MobileStyle) mobileStyleEditor.getValue()); + DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 30); + } + + @Override + public Dimension getMaximumSize() { + return new Dimension(400, 200); + } + + private void bindListeners2Widgets() { + reInitAllListeners(); + this.changeListener = new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + } + }; + } + + private void reInitAllListeners() { + initListener(this); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java index 8a795b887..5cf7f74f7 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java @@ -4,6 +4,7 @@ import com.fr.base.iofile.attr.FormTabPaddingAttrMark; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; @@ -13,7 +14,7 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor; import com.fr.design.mainframe.widget.accessibles.MobileTemplateStylePane; -import com.fr.design.widget.ui.designer.mobile.component.MobileComponentAdvancePane; +import com.fr.design.widget.ui.designer.mobile.component.MobileComponentMarginPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.general.cardtag.mobile.MobileTemplateStyle; @@ -27,7 +28,7 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { private FormDesigner designer; // 当前设计器 private AccessibleTemplateStyleEditor templateStyleEditor; private AttributeChangeListener changeListener; - private MobileComponentAdvancePane advancePane; + private MobileComponentMarginPane marginPane; private MobileComponentLayoutIntervalPane intervalPane; public TabMobileWidgetDefinePane(XCreator xCreator) { @@ -61,12 +62,14 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); holder.add(jPanel, BorderLayout.NORTH); if (!shouldHidePadding(designer)) { - advancePane = new MobileComponentAdvancePane(FormTabPaddingAttrMark.XML_TAG); + marginPane = new MobileComponentMarginPane(FormTabPaddingAttrMark.XML_TAG); intervalPane = new MobileComponentLayoutIntervalPane(FormTabPaddingAttrMark.XML_TAG); + UIExpandablePane advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, marginPane); + UIExpandablePane layoutPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, intervalPane); //高级 holder.add(advancePane, BorderLayout.CENTER); //布局 - holder.add(intervalPane, BorderLayout.SOUTH); + holder.add(layoutPane, BorderLayout.SOUTH); } this.add(holder, BorderLayout.NORTH); @@ -78,8 +81,8 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { // 数据 populate 完成后,再设置监听 this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); - if (advancePane != null) {//业务层面可以写成shouldHidePadding但是这样写应该性能差点 - advancePane.populate((WCardTagLayout) xCreator.toData()); + if (marginPane != null) {//业务层面可以写成shouldHidePadding但是这样写应该性能差点 + marginPane.populate((WCardTagLayout) xCreator.toData()); } if (intervalPane != null) { intervalPane.populate((WCardTagLayout) xCreator.toData()); @@ -90,8 +93,8 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { public void update() { ((WCardTagLayout) xCreator.toData()).setMobileTemplateStyle((MobileTemplateStyle) templateStyleEditor.getValue()); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 - if (advancePane != null) { - advancePane.update((WCardTagLayout) xCreator.toData()); + if (marginPane != null) { + marginPane.update((WCardTagLayout) xCreator.toData()); } if (intervalPane != null) { intervalPane.update((WCardTagLayout) xCreator.toData()); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java new file mode 100644 index 000000000..0d5ce4b71 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java @@ -0,0 +1,92 @@ +package com.fr.design.widget.ui.designer.mobile.component; + +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icombocheckbox.UIComboCheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WSortLayout; +import com.fr.stable.ArrayUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Hades + * @date 2019/8/14 + */ +public class MobileComponentFrozenPane extends BasicPane { + + private UIComboCheckBox uiComboCheckBox; + + public MobileComponentFrozenPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + UILabel frozenLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Frozen")); + uiComboCheckBox = new UIComboCheckBox(initData()); + JPanel wrapJPanel = UIComponentUtils.wrapWithBorderLayoutPane(uiComboCheckBox); + Component[][] components = new Component[][]{ + new Component[]{frozenLabel, wrapJPanel} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 10, 0)); + JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); + holder.add(centerPane, BorderLayout.NORTH); + this.add(holder, BorderLayout.NORTH); + } + + private String[] initData() { + FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + Widget selectedModel = selectedCreator != null ? selectedCreator.toData() : null; + + if (selectedModel == null || !selectedModel.acceptType(WSortLayout.class)) { + return ArrayUtils.EMPTY_STRING_ARRAY; + } + + List widgetList = ((WSortLayout) selectedModel).getNonContainerWidgetList(); + return widgetList.toArray(new String[0]); + } + + public void update(XCreator xCreator) { + List selected = new ArrayList<>(); + WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + Object[] values = uiComboCheckBox.getSelectedValues(); + for (Object widgetName : values) { + selected.add((String) widgetName); + } + wSortLayout.updateFrozenWidgets(selected); + } + + public void populate(XCreator xCreator) { + WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + List all = wSortLayout.getNonContainerWidgetList(); + List selected = wSortLayout.getFrozenWidgets(); + Map map = new LinkedHashMap<>(); + for (String value : selected) { + map.put(value, true); + } + all.removeAll(selected); + for (String value : all) { + map.put(value, false); + } + uiComboCheckBox.setSelectedValues(map); + } + + @Override + protected String title4PopupWindow() { + return "ComponentFrozenPane"; + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentLayoutIntervalPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentLayoutIntervalPane.java index 5a565373d..169b014a0 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentLayoutIntervalPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentLayoutIntervalPane.java @@ -3,7 +3,6 @@ package com.fr.design.widget.ui.designer.mobile.component; import com.fr.base.iofile.attr.AttrMarkFactory; import com.fr.base.iofile.attr.FormBodyPaddingAttrMark; import com.fr.design.designer.IntervalConstants; -import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; @@ -29,24 +28,17 @@ public class MobileComponentLayoutIntervalPane extends XmlRelationedBasicPane { super(xmlTag); this.setLayout(FRGUIPaneFactory.createBorderLayout()); UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")); - - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}}; componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, FormBodyPaddingAttrMark.DEFAULT_SIZE); - JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel); + JPanel componentIntervalPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel); Component[][] components = new Component[][]{ - new Component[]{intervalLabel, componentIntervelPane} + new Component[]{intervalLabel, componentIntervalPane} }; - JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0)); + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 10, 0)); JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); holder.add(centerPane, BorderLayout.NORTH); - UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, holder); - this.add(layoutExpandablePane, BorderLayout.NORTH); + this.add(holder, BorderLayout.NORTH); } @Override diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentAdvancePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentMarginPane.java similarity index 77% rename from designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentAdvancePane.java rename to designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentMarginPane.java index f94d57907..7a1bb34ee 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentAdvancePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentMarginPane.java @@ -2,7 +2,6 @@ package com.fr.design.widget.ui.designer.mobile.component; import com.fr.base.iofile.attr.AttrMarkFactory; import com.fr.base.iofile.attr.FormBodyPaddingAttrMark; -import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.widget.ui.designer.XmlRelationedBasicPane; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; @@ -13,20 +12,19 @@ import java.awt.BorderLayout; /** * 只有内边距设置的高级设置 */ -public class MobileComponentAdvancePane extends XmlRelationedBasicPane { +public class MobileComponentMarginPane extends XmlRelationedBasicPane { private PaddingBoundPane paddingBound; - public MobileComponentAdvancePane(String xmlTag) { + public MobileComponentMarginPane(String xmlTag) { super(xmlTag); this.setLayout(FRGUIPaneFactory.createBorderLayout()); paddingBound = new PaddingBoundPane(FormBodyPaddingAttrMark.DEFAULT_SIZE, FormBodyPaddingAttrMark.DEFAULT_SIZE, FormBodyPaddingAttrMark.DEFAULT_SIZE, FormBodyPaddingAttrMark.DEFAULT_SIZE); - UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, paddingBound); - this.add(advanceExpandablePane, BorderLayout.NORTH); + this.add(paddingBound, BorderLayout.NORTH); } @Override protected String title4PopupWindow() { - return "ComponentAdvancePane"; + return "ComponentMarginPane"; } public void update(RichStyleWidgetProvider marginWidget) { diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java index 4fc591e7d..85b602c42 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java @@ -24,6 +24,7 @@ import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -34,6 +35,7 @@ import java.awt.event.ActionListener; public class BiasTextPainterCellEditor extends AbstractCellEditor { private BiasTextPainterPane biasTextPainterPane = null; + private static final double MULTIPLE = 1.5; /** * Constructor. @@ -84,8 +86,10 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { Window parentWindow = SwingUtilities.getWindowAncestor(grid); this.biasTextPainterPane = new BiasTextPainterPane(); + Dimension dimension = this.biasTextPainterPane.getPreferredSize(); + Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * MULTIPLE)); this.biasTextPainterPane.populate(biasTextPainter); - return this.biasTextPainterPane.showSmallWindow(parentWindow, new DialogActionAdapter() { + return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() { @Override public void doOk() { @@ -96,7 +100,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { public void doCancel() { BiasTextPainterCellEditor.this.fireEditingCanceled(); } - }); + }, wrapDimension); } public static class BiasTextPainterPane extends BasicPane { @@ -142,7 +146,6 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { group.add(choice2); choicePane.add(choice1); -// choicePane.add(new UILabel(" ")); choicePane.add(choice2); centerPane.add(choicePane, BorderLayout.SOUTH); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 148929495..25c8a493e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -54,7 +54,6 @@ import java.util.concurrent.TimeUnit; /** * @author neil - * * @date: 2015-4-8-下午5:11:46 */ public class InformationCollector implements XMLReadable, XMLWriter { @@ -83,17 +82,17 @@ public class InformationCollector implements XMLReadable, XMLWriter { private String lastTime; private StartStopTime current = new StartStopTime(); - public static InformationCollector getInstance(){ + public static InformationCollector getInstance() { if (collector == null) { collector = new InformationCollector(); - readEncodeXMLFile(collector, collector.getInfoFile()); + readEncodeXMLFile(collector, collector.getInfoFile()); } return collector; } - private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile){ + private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) { if (xmlFile == null || !xmlFile.exists()) { return; } @@ -110,22 +109,22 @@ public class InformationCollector implements XMLReadable, XMLWriter { } xmlInputStream.close(); } catch (FileNotFoundException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (XMLStreamException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException{ + private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { InputStream encodeInputStream = new FileInputStream(xmlFile); String encodeContent = IOUtils.inputStream2String(encodeInputStream); return DesUtils.getDecString(encodeContent); } - private long getLastTimeMillis(){ + private long getLastTimeMillis() { if (StringUtils.isEmpty(this.lastTime)) { return 0; } @@ -138,7 +137,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { } - private JSONObject getJSONContentAsByte(){ + private JSONObject getJSONContentAsByte() { JSONObject content = new JSONObject(); JSONArray startStopArray = new JSONArray(); @@ -159,7 +158,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { return content; } - private void sendUserInfo(){ + private void sendUserInfo() { long currentTime = new Date().getTime(); long lastTime = getLastTimeMillis(); @@ -178,7 +177,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - if (success){ + if (success) { this.reset(); } } @@ -186,13 +185,13 @@ public class InformationCollector implements XMLReadable, XMLWriter { /** * 收集开始使用时间,发送信息 */ - public void collectStartTime(){ + public void collectStartTime() { this.current.setStartDate(dateToString()); sendUserInfoInOtherThread(); } - private void sendUserInfoInOtherThread(){ + private void sendUserInfoInOtherThread() { if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { return; } @@ -209,67 +208,57 @@ public class InformationCollector implements XMLReadable, XMLWriter { }, SEND_DELAY, TimeUnit.MILLISECONDS); } - /** - * 收集结束使用时间 - */ - public void collectStopTime(){ + /** + * 收集结束使用时间 + */ + public void collectStopTime() { this.current.setStopDate(dateToString()); } - private String dateToString(){ + private String dateToString() { DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); return df.format(new Date()); } - private void reset(){ + private void reset() { this.startStop.clear(); this.lastTime = dateToString(); } - private File getInfoFile() { - return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); - } - - /** - * 保存xml文件 - */ - public void saveXMLFile() { - File xmlFile = this.getInfoFile(); - try{ - ByteArrayOutputStream out = new ByteArrayOutputStream(); + private File getInfoFile() { + return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); + } + + /** + * 保存xml文件 + */ + public void saveXMLFile() { + File xmlFile = this.getInfoFile(); + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLTools.writeOutputStreamXML(this, out); out.flush(); out.close(); String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8); String encodeCotent = DesUtils.getEncString(fileContent); writeEncodeContentToFile(encodeCotent, xmlFile); - }catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } - } + } /** * 将文件内容写到输出流中 */ - private static void writeEncodeContentToFile(String fileContent, File file){ - BufferedWriter bw = null; - try { - FileOutputStream fos = new FileOutputStream(file); - OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); - bw = new BufferedWriter(osw); + private static void writeEncodeContentToFile(String fileContent, File file) { + try (FileOutputStream fos = new FileOutputStream(file); + OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); + BufferedWriter bw = new BufferedWriter(osw)) { bw.write(fileContent); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } finally { - if(bw != null){ - try { - bw.close(); - } catch (IOException e) { - } - } + FineLoggerFactory.getLogger().error(e.getMessage(), e); } - } @Override @@ -284,56 +273,56 @@ public class InformationCollector implements XMLReadable, XMLWriter { writer.end(); } - private void writeStartStopList(XMLPrintWriter writer){ + private void writeStartStopList(XMLPrintWriter writer) { //启停 - writer.startTAG(XML_START_STOP_LIST); - for (int i = 0; i < startStop.size(); i++) { - startStop.get(i).writeXML(writer); + writer.startTAG(XML_START_STOP_LIST); + for (int i = 0; i < startStop.size(); i++) { + startStop.get(i).writeXML(writer); } - writer.end(); + writer.end(); } - private void writeTag(String tag, String content, XMLPrintWriter writer){ + private void writeTag(String tag, String content, XMLPrintWriter writer) { if (StringUtils.isEmpty(content)) { return; } - writer.startTAG(tag); - writer.textNode(content); - writer.end(); + writer.startTAG(tag); + writer.textNode(content); + writer.end(); } @Override public void readXML(XMLableReader reader) { - if (reader.isChildNode()) { - String name = reader.getTagName(); - if (XML_START_STOP_LIST.equals(name)) { - readStartStopList(reader); - } else if(XML_LAST_TIME.equals(name)){ - readLastTime(reader); + if (reader.isChildNode()) { + String name = reader.getTagName(); + if (XML_START_STOP_LIST.equals(name)) { + readStartStopList(reader); + } else if (XML_LAST_TIME.equals(name)) { + readLastTime(reader); } - } + } } - private void readLastTime(XMLableReader reader){ + private void readLastTime(XMLableReader reader) { String tmpVal; if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { this.lastTime = tmpVal; } } - private void readStartStopList(XMLableReader reader){ - startStop.clear(); + private void readStartStopList(XMLableReader reader) { + startStop.clear(); reader.readXMLObject(new XMLReadable() { - public void readXML(XMLableReader reader) { - if (XML_START_STOP.equals(reader.getTagName())) { - StartStopTime startStopTime = new StartStopTime(); - reader.readXMLObject(startStopTime); - startStop.add(startStopTime); - } - } - }); + public void readXML(XMLableReader reader) { + if (XML_START_STOP.equals(reader.getTagName())) { + StartStopTime startStopTime = new StartStopTime(); + reader.readXMLObject(startStopTime); + startStop.add(startStopTime); + } + } + }); } private class StartStopTime implements XMLReadable, XMLWriter { @@ -358,14 +347,14 @@ public class InformationCollector implements XMLReadable, XMLWriter { } public void writeXML(XMLPrintWriter writer) { - writer.startTAG(XML_START_STOP); - if (StringUtils.isNotEmpty(startDate)) { - writer.attr(ATTR_START, this.startDate); + writer.startTAG(XML_START_STOP); + if (StringUtils.isNotEmpty(startDate)) { + writer.attr(ATTR_START, this.startDate); } - if (StringUtils.isNotEmpty(stopDate)) { - writer.attr(ATTR_STOP, this.stopDate); + if (StringUtils.isNotEmpty(stopDate)) { + writer.attr(ATTR_STOP, this.stopDate); } - writer.end(); + writer.end(); } public void readXML(XMLableReader reader) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 07136bc1e..e5cb04b0f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -95,10 +95,6 @@ import com.fr.stable.module.Module; import com.fr.stable.project.ProjectConstants; import com.fr.web.controller.ViewRequestConstants; import com.fr.workspace.WorkContext; - -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JPanel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.FileOutputStream; @@ -106,6 +102,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; /** * JWorkBook used to edit WorkBook. @@ -1103,9 +1102,8 @@ public class JWorkBook extends JTemplate { // 弹出输入参数 java.util.Map parameterMap = inputParameters(tpl); - try { - String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath()); - FileOutputStream fileOutputStream = new FileOutputStream(fullPath); + String fullPath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), newFile.getPath()); + try (FileOutputStream fileOutputStream = new FileOutputStream(fullPath)) { EmbeddedTableDataExporter exporter = new EmbeddedTableDataExporter(); exporter.export(fileOutputStream, tpl, parameterMap); } catch (Exception e1) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 1057d9286..dd5a01349 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -15,6 +15,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; +import com.fr.general.GeneralContext; import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpToolbox; import com.fr.json.JSON; @@ -33,6 +34,25 @@ public class AlphaFineHelper { public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")); private static AlphaFineDialog alphaFineDialog; private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com"; + + private AlphaFineHelper() { + + } + + /** + * 根据国际化调整配置 + */ + public static void switchConfig4Locale() { + + AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); + if (!GeneralContext.isChineseEnv()) { + manager.setSearchOnLine(false); + manager.setContainDocument(false); + manager.setContainPlugin(false); + manager.setContainRecommend(false); + manager.setNeedIntelligentCustomerService(false); + } + } /** * 弹出alphafine搜索面板 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index ddd3bc0fc..a902d0e00 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -27,21 +27,20 @@ import java.net.URLEncoder; * Created by XiaXiang on 2017/3/27. */ public class PluginSearchManager implements AlphaFineSearchProvider { - private static volatile PluginSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList; + private PluginSearchManager() { + + } public static PluginSearchManager getInstance() { - if (instance == null) { - synchronized (PluginSearchManager.class) { - if (instance == null) { - instance = new PluginSearchManager(); - } - } - } - return instance; + return Holder.INSTANCE; + + } + private static class Holder { + private static final PluginSearchManager INSTANCE = new PluginSearchManager(); } private static boolean isCompatibleCurrentEnv(String envVersion) { @@ -105,7 +104,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"))); return lessModelList; } - SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); if(noConnectList != null){ return noConnectList; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index e15c5b966..05267220b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -25,22 +25,22 @@ import java.util.List; * Created by XiaXiang on 2017/3/31. */ public class RecommendSearchManager implements AlphaFineSearchProvider { - private static volatile RecommendSearchManager instance; private SearchResult modelList = new SearchResult(); private SearchResult recommendModelList = new SearchResult(); private SearchResult complementAdviceModelList; private SearchResult moreModelList = new SearchResult(); + private RecommendSearchManager() { + + } + public static RecommendSearchManager getInstance() { - if (instance == null) { - synchronized (RecentSearchManager.class) { - if (instance == null) { - instance = new RecommendSearchManager(); - } - } - } - return instance; + return Holder.INSTANCE; + } + + private static class Holder { + private static final RecommendSearchManager INSTANCE = new RecommendSearchManager(); } @Override @@ -51,7 +51,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { if (ArrayUtils.isEmpty(searchText)) { return new SearchResult(); } - SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); if (noConnectList != null) { return noConnectList; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java index 40c37341c..c9622193c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java @@ -13,18 +13,18 @@ import java.util.regex.Pattern; * Created by alex.sung on 2018/8/3. */ public class SegmentationManager { - private static volatile SegmentationManager segmentationManager = null; private static final int MAX_CHINESE_CHARACTERS_NUM = 4; + private SegmentationManager() { + + } + public static SegmentationManager getInstance() { - if (segmentationManager == null) { - synchronized (SegmentationManager.class) { - if (segmentationManager == null) { - segmentationManager = new SegmentationManager(); - } - } - } - return segmentationManager; + return Holder.INSTANCE; + } + + private static class Holder { + private static final SegmentationManager INSTANCE = new SegmentationManager(); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java index 1754b1284..f353573b4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java @@ -18,19 +18,19 @@ import com.fr.third.org.apache.commons.codec.digest.DigestUtils; * Created by alex.sung on 2018/8/3. */ public class SimilarSearchManager implements AlphaFineSearchProvider { - private static volatile SimilarSearchManager instance; private SearchResult lessModelList; private SearchResult moreModelList = new SearchResult(); + private SimilarSearchManager() { + + } + public static SimilarSearchManager getInstance() { - if (instance == null) { - synchronized (SimilarSearchManager.class) { - if (instance == null) { - instance = new SimilarSearchManager(); - } - } - } - return instance; + return Holder.INSTANCE; + } + + private static class Holder { + private static final SimilarSearchManager INSTANCE = new SimilarSearchManager(); } @Override @@ -40,7 +40,7 @@ public class SimilarSearchManager implements AlphaFineSearchProvider { if (ArrayUtils.isEmpty(searchText)) { return new SearchResult(); } - SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance); + SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); if (noConnectList != null) { return noConnectList; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index d22bcf75b..4e733c7b1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -2,14 +2,17 @@ package com.fr.design.mainframe.errorinfo; import com.fr.base.FRContext; import com.fr.general.IOUtils; -import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.stable.EncodeConstants; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.core.UUID; - -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.util.Date; @@ -124,13 +127,14 @@ public class ErrorInfo { String content = jo.toString(); String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); - try { + FileOutputStream out = null; + try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { StableUtils.makesureFileExist(file); - FileOutputStream out = new FileOutputStream(file); - InputStream in = new ByteArrayInputStream(content.getBytes(EncodeConstants.ENCODING_UTF_8)); + out = new FileOutputStream(file); IOUtils.copyBinaryTo(in, out); - out.close(); } catch (IOException ignore) { + } finally { + IOUtils.close(out); } } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java index 4497a0b28..358672d23 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java @@ -19,7 +19,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.UUID; +import java.util.zip.ZipOutputStream; /** * @author alex sung @@ -52,13 +54,15 @@ public class FileEntityBuilder { return null; } File zipFile = null; + ZipOutputStream zipOut = null; try { zipFile = new File(pathName + ".zip"); - java.util.zip.ZipOutputStream zipOut = new java.util.zip.ZipOutputStream(new FileOutputStream(zipFile)); + zipOut = new ZipOutputStream(new FileOutputStream(zipFile)); IOUtils.zip(zipOut, new File(pathName)); - zipOut.close(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + IOUtils.close(zipOut); } return zipFile; } @@ -67,18 +71,18 @@ public class FileEntityBuilder { if (jsonArray.size() == 0) { return; } - try { - String content = jsonArray.toString(); + FileOutputStream out = null; + String content = jsonArray.toString(); + try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { String fileName = String.valueOf(UUID.randomUUID()); File file = new File(folderName + File.separator + fileName + ".json"); StableUtils.makesureFileExist(file); - FileOutputStream out = new FileOutputStream(file); - InputStream in = new ByteArrayInputStream(content.getBytes(EncodeConstants.ENCODING_UTF_8)); + out = new FileOutputStream(file); IOUtils.copyBinaryTo(in, out); - in.close(); - out.close(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + IOUtils.close(out); } } diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java index fff627e04..4062e0dbe 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java @@ -1,6 +1,5 @@ package com.fr.design.report; -import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UITitledBorder; @@ -15,14 +14,27 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; +import com.fr.general.IOUtils; import com.fr.report.stable.WorkSheetAttr; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ColumnRow; import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SpinnerNumberModel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -87,6 +99,7 @@ public class ReportColumnsPane extends BasicPane{ }; onOffButtonGroup = new UIButtonGroup(textArray) { + @Override protected void initButton(UIToggleButton labelButton) { labelButton.setSize(new Dimension(60,20)); labelButton.setPreferredSize(new Dimension(60, 20)); @@ -190,7 +203,7 @@ public class ReportColumnsPane extends BasicPane{ JPanel sampleLablePane = new JPanel(new GridLayout(1,2)); sampleLablePane.setPreferredSize(new Dimension(524, 130)); JPanel rPane = new JPanel(); - UILabel rLabel = new UILabel(BaseUtils.readIcon("/com/fr/design/images/reportcolumns/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Row_Icon_File_Name"))); + UILabel rLabel = new UILabel(IOUtils.readIcon("/com/fr/design/images/reportcolumns/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Row_Icon_File_Name"))); rLabel.setBorder(BorderFactory.createEmptyBorder(5,45,0,49)); rPane.add(rLabel); rowButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportColumns_Columns_Horizontally")); @@ -198,7 +211,7 @@ public class ReportColumnsPane extends BasicPane{ rPane.add(rowButton); sampleLablePane.add(rPane); JPanel cPane = new JPanel(); - UILabel cLabel = new UILabel(BaseUtils.readIcon("/com/fr/design/images/reportcolumns/col.png")); + UILabel cLabel = new UILabel(IOUtils.readIcon("/com/fr/design/images/reportcolumns/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Col_Icon_File_Name"))); cLabel.setBorder(BorderFactory.createEmptyBorder(5,49,0,49)); cPane.add(cLabel); colButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportColumns_Columns_Vertically")); @@ -552,6 +565,7 @@ public class ReportColumnsPane extends BasicPane{ /** * 判断输入是否合法 */ + @Override public void checkValid() throws Exception { String repeatText = repeatColDataTextField.getText().trim(); if(StringUtils.isEmpty(repeatText)){ diff --git a/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java b/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java index 35c7da06d..4f88dcaef 100644 --- a/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/mobile/MobileOthersPane.java @@ -18,6 +18,9 @@ public class MobileOthersPane extends BasicBeanPane { private MobileRadioCheckPane appearRefreshCheckPane; // 页面再现时刷新 + // 允许双击/双指缩放 + private MobileRadioCheckPane allowDoubleClickOrZoomCheckPane; + public MobileOthersPane() { this.initComponents(); } @@ -29,6 +32,8 @@ public class MobileOthersPane extends BasicBeanPane { contentPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L1, 0, 0)); appearRefreshCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Appear_Refresh")); contentPane.add(appearRefreshCheckPane, BorderLayout.WEST); + allowDoubleClickOrZoomCheckPane = new MobileRadioCheckPane(com.fr.design.i18n.Toolkit.i18nText("允许双击/双指缩放")); + contentPane.add(allowDoubleClickOrZoomCheckPane, BorderLayout.CENTER); borderPane.add(contentPane); this.add(borderPane); } @@ -39,6 +44,7 @@ public class MobileOthersPane extends BasicBeanPane { ob = new ElementCaseMobileAttr(); } this.appearRefreshCheckPane.populateBean(ob.isAppearRefresh()); + this.allowDoubleClickOrZoomCheckPane.populateBean(ob.isAllowDoubleClickOrZoom()); } @Override @@ -50,6 +56,7 @@ public class MobileOthersPane extends BasicBeanPane { public void updateBean(ElementCaseMobileAttr mobileAttr) { if(mobileAttr != null) { mobileAttr.setAppearRefresh(this.appearRefreshCheckPane.updateBean()); + mobileAttr.setAllowDoubleClickOrZoom(this.allowDoubleClickOrZoomCheckPane.updateBean()); } } diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java index 756b36ad2..2df2e9f2a 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java @@ -48,6 +48,7 @@ import com.fr.report.web.button.write.AppendRowButton; import com.fr.report.web.button.write.DeleteRowButton; import com.fr.stable.bridge.BridgeMark; import com.fr.stable.bridge.StableFactory; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.Map; @@ -60,7 +61,9 @@ import java.util.Map; * Time : 上午11:17 */ public class WidgetDefinePaneFactory { + private static Map, Appearance> defineMap = new HashMap, Appearance>(); + private static Map, Appearance> pluginDefineMap = ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap(); static { defineMap.put(NumberEditor.class, new Appearance(NumberEditorDefinePane.class, WidgetConstants.NUMBER + "")); @@ -91,24 +94,32 @@ public class WidgetDefinePaneFactory { defineMap.put(AppendRowButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + "")); defineMap.put(DeleteRowButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + "")); defineMap.put(TreeNodeToggleButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + "")); - defineMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap()); } private WidgetDefinePaneFactory() { } + @Nullable public static RN createWidgetDefinePane(Widget widget, Operator operator) { + Appearance dn = defineMap.get(widget.getClass()); - DataModify definePane = null; - try { - definePane = (DataModify) dn.getDefineClass().newInstance(); - definePane.populateBean(widget); - operator.did(definePane.dataUI(), dn.getDisplayName()); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + // 再走一遍插件。 + if (dn == null) { + dn = pluginDefineMap.get(widget.getClass()); } - return new RN(definePane, dn.getDisplayName()); + if (dn != null) { + DataModify definePane = null; + try { + definePane = (DataModify) dn.getDefineClass().newInstance(); + definePane.populateBean(widget); + operator.did(definePane.dataUI(), dn.getDisplayName()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return new RN(definePane, dn.getDisplayName()); + } + return null; } public static class RN { diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/ButtonGroupDictPane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/ButtonGroupDictPane.java index 5d456d9b7..049168da1 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/ButtonGroupDictPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/ButtonGroupDictPane.java @@ -18,6 +18,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleDictionaryEditor; +import com.fr.design.widget.FRWidgetFactory; import com.fr.form.ui.ButtonGroup; @@ -42,23 +43,28 @@ public class ButtonGroupDictPane extends JPanel { adaptiveCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Adaptive"), true); adaptiveCheckbox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); adaptiveCheckbox.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { columnSpinner.setVisible(!adaptiveCheckbox.isSelected()); columnLabel.setVisible(!adaptiveCheckbox.isSelected()); } }); - this.columnLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":"); + UILabel dictLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")); + this.columnLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":", dictLabel.getPreferredSize().width); columnSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1)); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double rowSize[] = {p, p}; - double columnSize[] = {p, p, f}; - Component[][] n_components = { - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")), dictPane, null}, - {adaptiveCheckbox, columnLabel, columnSpinner} + double[] rowSize = {p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; + Component[][] components = { + new Component[] {dictLabel, dictPane}, + new Component[] {adaptiveCheckbox, null}, + new Component[] {columnLabel, columnSpinner} }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.add(panel); diff --git a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index 26271037b..693722812 100644 --- a/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -32,11 +32,20 @@ import com.fr.stable.ColumnRowGroup; import com.fr.stable.StringUtils; import com.fr.write.DMLConfigJob; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JDialog; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dialog; import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.List; public class SmartInsertDBManipulationPane extends DBManipulationPane { private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1); @@ -115,6 +124,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { * * @param evt 事件对象 */ + @Override public void actionPerformed(ActionEvent evt) { BasicPane bPane = new BasicPane() { @Override @@ -131,6 +141,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { double f = TableLayout.FILL; bPane.add(TableLayoutHelper.createTableLayoutPane(coms, new double[]{p, p}, new double[]{p, f}), BorderLayout.NORTH); BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(SmartInsertDBManipulationPane.this), new DialogActionAdapter() { + @Override public void doOk() { int row_offset = ((Number) rowSpinner.getValue()).intValue(); int column_offset = ((Number) columnSpinner.getValue()).intValue(); @@ -177,6 +188,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { * * @param evt 事件s */ + @Override public void actionPerformed(ActionEvent evt) { showCellWindow(false); } @@ -192,6 +204,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { * * @param e 事件s */ + @Override public void actionPerformed(ActionEvent e) { showCellWindow(true); } @@ -268,6 +281,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { * * @throws Exception */ + @Override public void checkValid() throws Exception { KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); int cnt = model.getRowCount(); @@ -294,6 +308,10 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { // 单元格组要记录下之前的选中情况 private CellSelection oriCellSelection = null; + private List newAdd = new ArrayList(); + + private List oldAdd = new ArrayList(); + public SmartJTablePane4DB(KeyColumnTableModel model, ElementCasePane actionReportPane) { this(model, actionReportPane, false); } @@ -347,6 +365,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { * * @throws Exception */ + @Override public void checkValid() throws Exception { SmartInsertDBManipulationPane.this.checkValid(); } @@ -402,19 +421,21 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { // 要考虑多选的情况 要结合之前的看看 可能是增加 也可能需要减少 ColumnRowGroup add = new ColumnRowGroup(); - int removeCount = 0; if (oriCellSelection != null && isSameStartPoint(cellselection, oriCellSelection)) { - removeCount = dealDragSelection(add, cellselection); + dealDragSelection(add, cellselection, newValue); } else if (cellselection.getSelectedType() == CellSelection.CHOOSE_ROW || cellselection.getSelectedType() == CellSelection.CHOOSE_COLUMN) { dealSelectColRow(add, cellselection); } else { - add.addColumnRow(ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow())); + ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); + String allColumnRow = columnRow.toString(); + if (!allColumnRow.contains(columnRow.toString())) { + add.addColumnRow(columnRow); + } + } if (add.getSize() > 0) { newValue.addAll(add); - } else if (removeCount > 0) { - newValue.splice(newValue.getSize() - removeCount, removeCount); } kcv.cv.obj = newValue; @@ -424,6 +445,32 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { oriCellSelection = cellselection; } + private void dealDragSelection(ColumnRowGroup add, CellSelection cellselection, ColumnRowGroup newValue) { + int c = cellselection.getColumn(); + int cs = cellselection.getColumnSpan(); + int r = cellselection.getRow(); + int rs = cellselection.getRowSpan(); + String allColumnRow = newValue.toString(); + newAdd.clear(); + for (int i = 0; i < cs; i++) { + for (int j = 0; j < rs; j++) { + ColumnRow columnRow = ColumnRow.valueOf(c + i, r + j); + if (!allColumnRow.contains(columnRow.toString())) { + add.addColumnRow(columnRow); + } + newAdd.add(columnRow.toString()); + } + } + int oldSize = oldAdd.size(); + int newSize = newAdd.size(); + if (oldSize > newSize && oldAdd.containsAll(newAdd)) { + int diff = oldSize - newSize; + newValue.splice(newValue.getSize() - diff, diff); + } + oldAdd.clear(); + oldAdd.addAll(newAdd); + } + private ColumnRowGroup getColumnRowGroupValue(Object oriValue) { ColumnRowGroup newValue = new ColumnRowGroup(); if (oriValue instanceof ColumnRowGroup) { @@ -438,26 +485,6 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { return cs1.getColumn() == cs2.getColumn() && cs1.getRow() == cs2.getRow(); } - private int dealDragSelection(ColumnRowGroup add, CellSelection cellselection) { - int removeCount = 0; - if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() + 1) { - for (int i = 0; i < cellselection.getColumnSpan(); i++) { - add.addColumnRow(ColumnRow.valueOf( - cellselection.getColumn() + i, cellselection.getRow() + cellselection.getRowSpan() - 1)); - } - } else if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() - 1) { - removeCount = cellselection.getColumnSpan(); - } else if (cellselection.getColumnSpan() == oriCellSelection.getColumnSpan() + 1) { - for (int i = 0; i < cellselection.getRowSpan(); i++) { - add.addColumnRow(ColumnRow.valueOf( - cellselection.getColumn() + cellselection.getColumnSpan() - 1, cellselection.getRow() + i)); - } - } else if (cellselection.getColumnSpan() == oriCellSelection.getColumnSpan() - 1) { - removeCount = cellselection.getRowSpan(); - } - return removeCount; - } - private void dealSelectColRow(ColumnRowGroup add, CellSelection se) { int c = se.getColumn(), cs = se.getColumnSpan(), r = se.getRow(), rs = se.getRowSpan(); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index ff0f9221e..31e818b3e 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -43,6 +43,7 @@ import com.fr.design.mainframe.InformationCollector; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetToolBarPane; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.bbs.BBSGuestPane; import com.fr.design.mainframe.bbs.UserInfoPane; import com.fr.design.mainframe.form.FormECCompositeProvider; @@ -125,8 +126,9 @@ public class DesignerActivator extends Activator { DesignerSocketIO.update(); UserInfoPane.getInstance().updateBBSUserInfo(); storePassport(); + AlphaFineHelper.switchConfig4Locale(); } - + private void loadLogAppender() { logHandler = new LogHandler() { final DesignerLogAppender logAppender = new DesignerLogAppender(); diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java new file mode 100644 index 000000000..21df0da47 --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java @@ -0,0 +1,50 @@ +package com.fr.design.mainframe.alphafine; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.general.GeneralContext; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + +@RunWith(PowerMockRunner.class) +public class AlphaFineHelperTest { + + @Test + @PrepareForTest({GeneralContext.class, DesignerEnvManager.class}) + @SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper") + public void testSwitchConfig4Locale() throws Exception { + + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.isChineseEnv()).andReturn(true).times(1).andReturn(false).times(1); + + AlphaFineConfigManager mockConfig = EasyMock.partialMockBuilder(AlphaFineConfigManager.class).createMock(); + Whitebox.setInternalState(mockConfig,"searchOnLine", true); + EasyMock.replay(mockConfig); + + DesignerEnvManager manager = EasyMock.mock(DesignerEnvManager.class); + EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(mockConfig).anyTimes(); + + EasyMock.replay(manager); + + PowerMock.mockStatic(DesignerEnvManager.class); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes(); + + PowerMock.replayAll(); + + AlphaFineHelper.switchConfig4Locale(); + AlphaFineConfigManager config = manager.getAlphaFineConfigManager(); + Assert.assertEquals(true, config.isSearchOnLine()); + + AlphaFineHelper.switchConfig4Locale(); + Assert.assertEquals(false, config.isSearchOnLine()); + + + } +} \ No newline at end of file diff --git a/designer-realize/src/test/java/com/fr/design/widget/WidgetDefinePaneFactoryTest.java b/designer-realize/src/test/java/com/fr/design/widget/WidgetDefinePaneFactoryTest.java new file mode 100644 index 000000000..a7b0c46b6 --- /dev/null +++ b/designer-realize/src/test/java/com/fr/design/widget/WidgetDefinePaneFactoryTest.java @@ -0,0 +1,66 @@ +package com.fr.design.widget; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.data.DataCreatorUI; +import com.fr.design.widget.ui.ButtonDefinePane; +import com.fr.form.ui.Button; +import com.fr.form.ui.Widget; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.HashMap; +import java.util.Map; + +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.swing.*") +public class WidgetDefinePaneFactoryTest { + + @Test + @PrepareForTest({ExtraDesignClassManager.class, WidgetDefinePaneFactory.class}) + public void testCreateWidgetDefinePane() throws Exception { + + Map, Appearance> map = new HashMap<>(); + ExtraDesignClassManager mockDesignManager = EasyMock.mock(ExtraDesignClassManager.class); + EasyMock.expect(mockDesignManager.getCellWidgetOptionsMap()).andReturn(map).anyTimes(); + EasyMock.replay(mockDesignManager); + + PowerMock.mockStatic(ExtraDesignClassManager.class); + EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(mockDesignManager).anyTimes(); + PowerMock.replayAll(ExtraDesignClassManager.class); + + Button mockWidget = EasyMock.mock(Button.class); + EasyMock.replay(mockWidget); + + ButtonDefinePane mockPane = EasyMock.mock(ButtonDefinePane.class); + mockPane.populateBean(EasyMock.anyObject(Button.class)); + EasyMock.expectLastCall(); + EasyMock.replay(mockPane); + + + Operator mockOperator = EasyMock.mock(Operator.class); + mockOperator.did(EasyMock.anyObject(DataCreatorUI.class), EasyMock.anyString()); + EasyMock.replay(mockOperator); + + WidgetDefinePaneFactory.RN rn1 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator); + Assert.assertNull(rn1); + + Appearance appearance = new Appearance(ButtonDefinePane.class, "test"); + map.put(mockWidget.getClass(), appearance); + + WidgetDefinePaneFactory.RN rn2 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator); + Assert.assertNotNull(rn2); + + map.clear(); + + WidgetDefinePaneFactory.RN rn3 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator); + Assert.assertNull(rn3); + } + + +} \ No newline at end of file diff --git a/designer-sdk/pom.xml b/designer-sdk/pom.xml index 9702536e2..2fb53e1dc 100644 --- a/designer-sdk/pom.xml +++ b/designer-sdk/pom.xml @@ -17,10 +17,5 @@ designer-realize 10.0 - - com.fr.report - sdk-base - 10.0 - \ No newline at end of file diff --git a/designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java b/designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java deleted file mode 100644 index ea60edf74..000000000 --- a/designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.fr.sdk.designer; - -import com.fr.config.activator.ConfigurationActivator; -import com.fr.design.env.DesignerWorkspaceGenerator; -import com.fr.design.env.RemoteDesignerWorkspaceInfo; -import com.fr.log.FineLoggerFactory; -import com.fr.module.Activator; -import com.fr.module.Module; -import com.fr.module.tool.ActivatorToolBox; -import com.fr.report.ReportActivator; -import com.fr.report.RestrictionActivator; -import com.fr.report.module.ReportBaseActivator; -import com.fr.scheduler.SchedulerActivator; -import com.fr.sdk.server.shell.ModuleShell; -import com.fr.serialization.SerializationActivator; -import com.fr.stable.StringUtils; -import com.fr.startup.WorkspaceRegister; -import com.fr.store.StateServerActivator; -import com.fr.workspace.WorkContext; -import com.fr.workspace.connect.WorkspaceConnectionInfo; -import com.fr.workspace.engine.WorkspaceActivator; -import com.fr.workspace.server.ServerWorkspaceRegister; - -/** - * 设计器SDK模块工具类,用来放一些设计器相关插件开发过程中常用的工具函数 - */ -public class FineDesignUtils { - - /** - * 创建一个连接远程服务器的模块 - * @param remoteUrl 远程服务器地址 - * @param username 用户名 - * @param password 密码 - * @return 模块代理对象 使用ModuleShell的start和stop控制模块启停 - */ - public static ModuleShell createRemoteServerModule(String remoteUrl, String username, String password) { - return createRemoteServerModule(remoteUrl, username, password, StringUtils.EMPTY, StringUtils.EMPTY); - } - - /** - * 创建一个连接远程服务器的模块 - * @param remoteUrl 远程服务器地址 - * @param username 用户名 - * @param password 密码 - * @param certPath https证书路径 - * @param certSecretKey 证书秘钥 - * @return 模块代理对象 使用ModuleShell的start和stop控制模块启停 - */ - public static ModuleShell createRemoteServerModule(final String remoteUrl, final String username, final String password, final String certPath, final String certSecretKey) { - Module module = ActivatorToolBox.simpleLink( - new WorkspaceActivator(), - new SerializationActivator(), - new Activator() { - @Override - public void start() { - WorkspaceConnectionInfo connectionInfo = new WorkspaceConnectionInfo(remoteUrl, username, password, certPath, certSecretKey); - try { - WorkContext.switchTo(DesignerWorkspaceGenerator.generate(RemoteDesignerWorkspaceInfo.create(connectionInfo))); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(),e); - } - } - - @Override - public void stop() { - - } - }, - new ConfigurationActivator(), - new StateServerActivator(), - new SchedulerActivator(), - new ReportBaseActivator(), - new RestrictionActivator(), - new ReportActivator(), - new WorkspaceRegister(), - new ServerWorkspaceRegister() - ); - return new ModuleShell(module); - } -} \ No newline at end of file diff --git a/designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java b/designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java deleted file mode 100644 index ec210321b..000000000 --- a/designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fr.sdk; - -import junit.framework.TestCase; - -public class FineDesignUtilsTest extends TestCase { - -} \ No newline at end of file