diff --git a/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java b/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java index 2bb026159f..7533cb133a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java @@ -1,6 +1,7 @@ package com.fr.design.actions.file; import java.awt.event.ActionEvent; +import java.io.File; import java.util.List; import com.fr.base.BaseUtils; @@ -11,6 +12,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; import com.fr.file.FILEFactory; +import com.fr.file.FileFILE; /** * Open Resent MenuDef. @@ -68,7 +70,12 @@ public class OpenRecentReportMenuDef extends MenuDef { * @param e 事件 */ public void actionPerformed(ActionEvent e) { - DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(this.getPath())); + File file = new File(this.getPath()); + if (file.exists()) { + DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file)); + } else { + DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(this.getPath())); + } } public String getPath() { diff --git a/designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java b/designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java new file mode 100644 index 0000000000..3e4e001a8f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java @@ -0,0 +1,23 @@ +package com.fr.design.cell; + +import com.fr.design.designer.TargetComponent; +import com.fr.design.dialog.BasicPane; + +import javax.swing.JPanel; + +/** + * @author zack + * @version 10.0 + * Created by zack on 2020/7/14 + */ +public abstract class AbstractCellElementPropertyPane extends BasicPane implements CellElementPropertyComponent { + @Override + public JPanel toPanel() { + return this; + } + + @Override + public boolean accept(TargetComponent tc) { + return true; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java b/designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java new file mode 100644 index 0000000000..b3e6f41674 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java @@ -0,0 +1,34 @@ +package com.fr.design.cell; + +import com.fr.design.designer.TargetComponent; + +import javax.swing.JPanel; + +/** + * 单元格属性配置面板接口 + * @author zack + * @version 10.0 + * Created by zack on 2020/7/14 + */ +public interface CellElementPropertyComponent { + + /** + * 判断当前编辑的对象是否显示当前实现 + * @param tc + * @return + */ + boolean accept(TargetComponent tc); + + /** + * 加载数据 + * @param tc + */ + void populate(TargetComponent tc); + + /** + * 返回当前属性面板,默认返回this + * @return + */ + JPanel toPanel(); + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java index e8bc8e39ab..5ba801ca89 100644 --- a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java @@ -446,7 +446,16 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp * @param srcName 数据集来源(比如报表块,就是报表块的名称) * @param tableDataSource 数据集 */ + public Map addTableData(String srcName, TableDataSource tableDataSource, boolean isCover) { + return new HashMap<>(0); + } + public Map addTableData(String srcName, TableDataSource tableDataSource) { - return new HashMap<>(0); + return addTableData(srcName, tableDataSource, false); + } + + public void removeTableData(String sourceName) { + } + } diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java index 27724450bb..57c7e23a13 100644 --- a/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java @@ -1,5 +1,6 @@ package com.fr.design.data; +import com.fr.data.TableDataSource; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; import com.fr.stable.StringUtils; @@ -10,6 +11,7 @@ import com.fr.stable.StringUtils; * Created by hades on 2020/4/27 */ public abstract class BasicTableDataUtils { + private static final String SEPARATOR = "-"; private static final int LEN = 2; @@ -33,4 +35,19 @@ public abstract class BasicTableDataUtils { } return false; } + + public static String getTableDataName(boolean isCover, TableDataSource tds, String tdName, String srcName, boolean isDsNameRepeaded) { + if (isCover) { + return srcName + SEPARATOR + tdName; + } + if (tds.getTableData(tdName) != null || isDsNameRepeaded) {//如果有同名的就拼上来源名称 + tdName = srcName + SEPARATOR + tdName; + } + int i = 0; + while (tds.getTableData(tdName) != null) { + i++;//如果拼上名字后依然已经存在就加编号 + tdName += i; + } + return tdName; + } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 531e128484..a2cc5b7d28 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -9,6 +9,7 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.BasicTableDataTreePane; +import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.StoreProcedureWorkerListener; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; @@ -59,7 +60,7 @@ import java.util.Map; public class TableDataTreePane extends BasicTableDataTreePane { private static TableDataTreePane singleton = new TableDataTreePane(); - + public static final int PLUGIN_LISTENER_PRIORITY = 1; public synchronized static BasicTableDataTreePane getInstance(DesignModelAdapter tc) { @@ -96,10 +97,10 @@ public class TableDataTreePane extends BasicTableDataTreePane { addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); createAddMenuDef(); - + // 创建插件监听 createPluginListener(); - + editAction = new EditAction(); removeAction = new RemoveAction(); previewTableDataAction = new PreviewTableDataAction(dataTree); @@ -139,27 +140,27 @@ public class TableDataTreePane extends BasicTableDataTreePane { new TableDataTreeDragSource(dataTree, DnDConstants.ACTION_COPY); checkButtonEnabled(); } - + private void createPluginListener() { - + //菜单栏监听 GeneralContext.listenPluginRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) { - + @Override public void on(PluginEvent event) { - + addMenuDef.clearShortCuts(); createAddMenuDef(); } }, new PluginFilter() { - + @Override public boolean accept(PluginContext context) { - + return context.contain(PluginModule.ExtraDesign); } }); - + //监听数据集插件 GeneralContext.listenPluginRunningChanged(new PluginEventListener() { @Override @@ -188,8 +189,8 @@ public class TableDataTreePane extends BasicTableDataTreePane { } }); } - - + + protected void checkButtonEnabled() { super.checkButtonEnabled(editAction, previewTableDataAction, removeAction, op, dataTree); } @@ -339,10 +340,11 @@ public class TableDataTreePane extends BasicTableDataTreePane { /** * 合并数据集 - * @param srcName 数据集来源(比如报表块,就是报表块的名称) + * + * @param srcName 数据集来源(比如报表块,就是报表块的名称) * @param tableDataSource 数据集 */ - public Map addTableData(String srcName, TableDataSource tableDataSource) { + public Map addTableData(String srcName, TableDataSource tableDataSource, boolean isCover) { Map tdNameMap = new HashMap<>(); allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook()); DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); @@ -352,14 +354,8 @@ public class TableDataTreePane extends BasicTableDataTreePane { String tdName = (String) tdIterator.next(); String oldName = tdName; TableData td = tableDataSource.getTableData(tdName); - if (tds.getTableData(tdName) != null || isDsNameRepeaded(tdName)) {//如果有同名的就拼上来源名称 - tdName = srcName + tdName; - } - int i = 0; - while (tds.getTableData(tdName) != null) { - i++;//如果拼上名字后依然已经存在就加编号 - tdName += i; - } + boolean isDsNameRepeaded = isDsNameRepeaded(tdName); + tdName = BasicTableDataUtils.getTableDataName(isCover, tds, tdName, srcName, isDsNameRepeaded); tds.putTableData(tdName, td); if (!ComparatorUtils.equals(oldName, tdName)) { tdNameMap.put(oldName, tdName); @@ -367,8 +363,19 @@ public class TableDataTreePane extends BasicTableDataTreePane { } tc.parameterChanged(); dataTree.refresh(); - return Collections.unmodifiableMap(tdNameMap); + return Collections.unmodifiableMap(tdNameMap); } + + @Override + public void removeTableData(String sourceName) { + TableDataSource tds = tc.getBook(); + tds.removeTableData(sourceName); + dataTree.refresh(); + } + + + + public void addDataPane(final AbstractTableDataPane uPanel, String paneName) { final NamePane nPanel = uPanel.asNamePane(); nPanel.setObjectName(paneName); diff --git a/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java b/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java index 227333cd08..82f7a81445 100644 --- a/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java @@ -4,8 +4,10 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.stable.fun.mark.Immutable; /** + * 单元格属性面板扩展接口,接口基本逻辑不通且不符合接口设计规范,单元格属性扩展可以使用CellPropertyPaneProvider * Created by zhouping on 2015/11/11. */ +@Deprecated public interface CellAttributeProvider extends Immutable{ String MARK_STRING = "CellAttributeProvider"; diff --git a/designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java new file mode 100644 index 0000000000..0100f4b2cf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java @@ -0,0 +1,18 @@ +package com.fr.design.fun; + +import com.fr.design.cell.CellElementPropertyComponent; + +/** + * 单元格设置(属性)扩展接口 + * @author zack + * @version 10.0 + * Created by zack on 2020/7/14 + */ +public interface CellPropertyPaneProvider extends PropertyItemPaneProvider { + + /** + * 构造单元格属性面板,面板实现需要使用单例模式实现 + * @return 面板类 + */ + CellElementPropertyComponent getSingletonCelPropertyPane(); +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java new file mode 100644 index 0000000000..ba1c71d5f3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java @@ -0,0 +1,15 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.CellPropertyPaneProvider; +import com.fr.stable.fun.mark.API; + +/** + * Created by zhouping on 2015/11/11. + */ +@API(level = CellPropertyPaneProvider.CURRENT_LEVEL) +public abstract class AbstractCellPropertyPaneProvider extends AbstractPropertyItemPaneProvider implements CellPropertyPaneProvider { + + public int currentAPILevel() { + return CellPropertyPaneProvider.CURRENT_LEVEL; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index b2ea7be11f..35ab552f51 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -227,8 +227,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { itemBean.getEnableModes()); UIButton button = propertyItem.getButton(); List buttonListeners = itemBean.getButtonListeners(); - for (ActionListener buttonListener : buttonListeners) { - button.addActionListener(buttonListener); + if (buttonListeners != null) { + for (ActionListener buttonListener : buttonListeners) { + button.addActionListener(buttonListener); + } } propertyItemMap.put(key, propertyItem); diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 96e722d116..43c3f43ad8 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -12,6 +12,7 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.NodeAuthProcessor; import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; @@ -916,7 +917,8 @@ public class FILEChooserPane extends BasicPane { try { access = FRContext.getOrganizationOperator().canAccess(selectedFile.getPath()); if (selectedFile.isEnvFile() && selectedFile instanceof FileNodeFILE) { - access = access && ((FileNodeFILE) selectedFile).hasFullAuth(); + FileNodeFILE fileNodeFILE = ((FileNodeFILE) selectedFile); + access = access && fileNodeFILE.hasFullAuth() && NodeAuthProcessor.getInstance().checkFileNodeAuth(new FileNode(fileNodeFILE.getPath(), fileNodeFILE.isDirectory())); } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java b/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java index acd47a3c11..7391924ac2 100644 --- a/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java +++ b/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java @@ -1,6 +1,9 @@ package com.fr.design.data; +import com.fr.base.TableData; +import com.fr.data.TableDataSource; import junit.framework.TestCase; +import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; @@ -41,4 +44,26 @@ public class BasicTableDataUtilsTest extends TestCase { Assert.assertFalse(result12); } -} \ No newline at end of file + + @Test + public void testGetTableDataName() { + TableDataSource source = EasyMock.mock(TableDataSource.class); + TableData tableData = EasyMock.mock(TableData.class); + EasyMock.expect(source.getTableData("ds1")).andReturn(tableData).anyTimes(); + EasyMock.expect(source.getTableData("test-ds1")).andReturn(tableData).anyTimes(); + EasyMock.expect(source.getTableData("test-ds11")).andReturn(null).anyTimes(); + EasyMock.replay(source, tableData); + Assert.assertEquals("test-ds1", BasicTableDataUtils.getTableDataName(true, source, "ds1", "test", false)); + Assert.assertEquals("test-ds11", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", false)); + + source = EasyMock.mock(TableDataSource.class); + EasyMock.expect(source.getTableData("ds1")).andReturn(null).anyTimes(); + EasyMock.expect(source.getTableData("test-ds1")).andReturn(null).anyTimes(); + EasyMock.replay(source); + Assert.assertEquals("test-ds1", BasicTableDataUtils.getTableDataName(true, source, "ds1", "test", false)); + Assert.assertEquals("ds1", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", false)); + Assert.assertEquals("test-ds1", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", true)); + + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java index e7a7ab929b..e09362cb64 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java @@ -52,7 +52,7 @@ public class ColorSchemeComboBox extends UIComboBox { this.setRenderer(new ColorSchemeCellRenderer()); } - private Map getColorSchemesFromConfig() { + protected Map getColorSchemesFromConfig() { Map colorSchemes = new LinkedHashMap<>(); ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); @@ -92,7 +92,14 @@ public class ColorSchemeComboBox extends UIComboBox { } public void refresh() { - this.colorSchemes = getColorSchemesFromConfig(); + refresh(null); + } + + public void refresh(Map colorSchemes) { + if (colorSchemes == null) { + colorSchemes = getColorSchemesFromConfig(); + } + this.colorSchemes = colorSchemes; this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); } @@ -149,7 +156,7 @@ public class ColorSchemeComboBox extends UIComboBox { return colorSchemes.keySet(); } - public class ColorInfo { + public static class ColorInfo { private List colors; diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java new file mode 100644 index 0000000000..f2f5c3cf6f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java @@ -0,0 +1,142 @@ +package com.fr.design.module; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.Utils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.controlpane.JListControlPane; +import com.fr.design.gui.controlpane.NameObjectCreator; +import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.controlpane.ShortCut4JControlPane; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.menu.ShortCut; +import com.fr.general.NameObject; +import com.fr.stable.Nameable; + +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.util.ArrayList; +import java.util.Iterator; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-07-08 + */ +public class ChartPreStyleListPane extends JListControlPane { + + ChartPreStyleManagerPane chartPreStyleManagerPane; + + public ChartPreStyleListPane(ChartPreStyleManagerPane chartPreStyleManagerPane) { + super(); + this.chartPreStyleManagerPane = chartPreStyleManagerPane; + initListener(); + } + + /** + * 创建有名字的creator + * + * @return 有名字的creator数组 + */ + @Override + public NameableCreator[] createNameableCreators() { + return new NameableCreator[]{ + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle_Duplicate"), + ChartColorMatching.class, ChartPreStylePane.class) + }; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle"); + } + + @Override + public BasicBeanPane createPaneByCreators(NameableCreator creator) { + return new ChartPreStylePane() { + @Override + protected void refreshWhenStyleChange(ChartColorMatching preStyle) { + super.refreshWhenStyleChange(preStyle); + chartPreStyleManagerPane.refreshDefaultColorBox(); + } + }; + } + + + protected ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + shortCutFactory.addItemShortCut(), + createRemoveItemShortCut(), + shortCutFactory.copyItemShortCut(), + shortCutFactory.moveUpItemShortCut(), + shortCutFactory.moveDownItemShortCut(), + shortCutFactory.sortItemShortCut() + }; + } + + private ShortCut4JControlPane createRemoveItemShortCut() { + ShortCut4JControlPane shortCut4JControlPane = shortCutFactory.removeItemShortCut(); + //替换删除按钮的check事件。 + ShortCut shortCut = shortCut4JControlPane.getShortCut(); + shortCut4JControlPane = new MoreThanOneShortCut(shortCut); + return shortCut4JControlPane; + } + + public void initListener() { + nameableList.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + chartPreStyleManagerPane.refreshDefaultColorBox(); + } + }); + nameableList.addModNameActionListener(new ModNameActionListener() { + @Override + public void nameModed(int index, String oldName, String newName) { + chartPreStyleManagerPane.refreshDefaultColorBox(oldName, newName); + } + }); + } + + public void populateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance().mirror(); + ArrayList list = new ArrayList(); + + Iterator keys = config.names(); + while (keys.hasNext()) { + Object key = keys.next(); + ChartColorMatching value = (ChartColorMatching) config.getPreStyle(key); + + list.add(new NameObject(Utils.objectToString(key), value)); + } + + Nameable[] values = (Nameable[]) list.toArray(new Nameable[list.size()]); + populate(values); + + if (config.containsName(config.getCurrentStyle())) { + this.setSelectedName(config.getCurrentStyle()); + } + } + + public void updateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + + Nameable[] values = update(); + config.clearAllPreStyle(); + + for (Nameable value : values) { + config.putPreStyle(value.getName(), ((NameObject) value).getObject()); + } + } + + private class MoreThanOneShortCut extends ShortCut4JControlPane { + public MoreThanOneShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + + @Override + public void checkEnable() { + this.shortCut.setEnabled(nameableList.getModel().getSize() > 1); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java index abae5118b3..44b504ef3f 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java @@ -2,72 +2,114 @@ package com.fr.design.module; import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; -import com.fr.base.Utils; -import com.fr.design.gui.controlpane.JListControlPane; -import com.fr.design.gui.controlpane.NameObjectCreator; -import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import java.util.ArrayList; +import javax.swing.JPanel; import java.util.Iterator; - +import java.util.LinkedHashMap; +import java.util.Map; +import java.awt.BorderLayout; +import java.awt.Dimension; /** * 图表预定义管理 界面, 在工具栏-服务器管理中. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-8-21 下午02:33:48 */ -public class ChartPreStyleManagerPane extends JListControlPane { - - @Override - /** - * 创建有名字的creator - * @return 有名字的creator数组 - */ - public NameableCreator[] createNameableCreators() { - return new NameableCreator[]{ - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle_Duplicate"), - ChartColorMatching.class, ChartPreStylePane.class) - }; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle"); - } - - public void populateBean() { - ChartPreStyleConfig config = ChartPreStyleConfig.getInstance().mirror(); - ArrayList list = new ArrayList(); - - Iterator keys = config.names(); - while(keys.hasNext()) { - Object key = keys.next(); - ChartColorMatching value = (ChartColorMatching) config.getPreStyle(key); - - list.add(new NameObject(Utils.objectToString(key), value)); - } - - Nameable[] values = (Nameable[])list.toArray(new Nameable[list.size()]); - populate(values); - - if(config.containsName(config.getCurrentStyle())) { - this.setSelectedName(config.getCurrentStyle()); - } - } - - public void updateBean() { - ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); - - config.setCurrentStyle(getSelectedName()); - - Nameable[] values = update(); - config.clearAllPreStyle(); - - for (Nameable value : values) { - config.putPreStyle(value.getName(), ((NameObject) value).getObject()); - } - } +public class ChartPreStyleManagerPane extends BasicPane { + + private ColorSchemeComboBox defaultColorBox; + + private ChartPreStyleListPane chartPreStyleListPane; + + public ChartPreStyleManagerPane() { + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel colorBoxPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + + chartPreStyleListPane = new ChartPreStyleListPane(this); + + initDefaultColorBox(); + colorBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Default_Color_Scheme") + ":")); + colorBoxPane.add(defaultColorBox); + + this.add(colorBoxPane, BorderLayout.NORTH); + this.add(chartPreStyleListPane, BorderLayout.CENTER); + } + + private void initDefaultColorBox() { + Map colorSchemes = new LinkedHashMap<>(); + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + Iterator names = config.names(); + while (names.hasNext()) { + Object key = names.next(); + ColorSchemeComboBox.ColorInfo colorInfo = new ColorSchemeComboBox.ColorInfo(); + ChartColorMatching colorMatching = (ChartColorMatching) config.getPreStyle(key); + colorInfo.setGradient(colorMatching.getGradient()); + colorInfo.setColors(colorMatching.getColorList()); + colorSchemes.put(colorMatching.getId(), colorInfo); + } + defaultColorBox = new ColorSchemeComboBox(colorSchemes); + defaultColorBox.setPreferredSize(new Dimension(TableLayout4VanChartHelper.EDIT_AREA_WIDTH, 20)); + } + + private void refreshColorSchemes() { + Nameable[] nameables = chartPreStyleListPane.update(); + Map colorSchemes = new LinkedHashMap<>(); + for (Nameable value : nameables) { + String name = value.getName(); + ChartColorMatching colorMatching = (ChartColorMatching) ((NameObject) value).getObject(); + ColorSchemeComboBox.ColorInfo colorInfo = new ColorSchemeComboBox.ColorInfo(); + colorInfo.setGradient(colorMatching.getGradient()); + colorInfo.setColors(colorMatching.getColorList()); + colorSchemes.put(name, colorInfo); + } + defaultColorBox.refresh(colorSchemes); + } + + public void refreshDefaultColorBox() { + Object selectedItem = defaultColorBox.getSelectedItem(); + refreshColorSchemes(); + defaultColorBox.setSelectedItem(selectedItem); + } + + public void refreshDefaultColorBox(String oldName, String newName) { + Object selectedItem = defaultColorBox.getSelectedItem(); + if (ComparatorUtils.equals(selectedItem, oldName)) { + selectedItem = newName; + } + refreshColorSchemes(); + defaultColorBox.setSelectedItem(selectedItem); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles"); + } + + public void populateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + String currentStyle = config.getCurrentStyle(); + defaultColorBox.setSelectedItem(currentStyle); + chartPreStyleListPane.populateBean(); + } + public void updateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + config.setCurrentStyle(GeneralUtils.objectToString(defaultColorBox.getSelectedItem())); + chartPreStyleListPane.updateBean(); + } } diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java index 5bd4c38978..9cce2be7c3 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java @@ -80,7 +80,7 @@ public class ChartPreStylePane extends BasicBeanPane { } } - private void refreshWhenStyleChange(ChartColorMatching preStyle) { + protected void refreshWhenStyleChange(ChartColorMatching preStyle) { if(chartComponent != null) { demoPlot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle)); chartComponent.reset(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index 85aff83629..b239583418 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -50,10 +50,10 @@ public class VanChartAlertValuePane extends BasicBeanPane { private static final double LINE_WIDTH_DEFAULT_VALUE = 1; private UIButtonGroup alertAxis; - protected TinyFormulaPane alertValue; - protected LineTypeComboBox alertLineStyle;//线型 + private TinyFormulaPane alertValue; + private LineTypeComboBox alertLineStyle;//线型 private UISpinner lineWidthSpinner;//线宽 - protected ColorSelectBox alertLineColor; + private ColorSelectBox alertLineColor; private UIButtonGroup alertTextPosition; private TinyFormulaPane alertText; @@ -67,6 +67,22 @@ public class VanChartAlertValuePane extends BasicBeanPane { initComponents(); } + public TinyFormulaPane getAlertValue() { + return alertValue; + } + + public LineTypeComboBox getAlertLineStyle() { + return alertLineStyle; + } + + public UISpinner getLineWidthSpinner() { + return lineWidthSpinner; + } + + public ColorSelectBox getAlertLineColor() { + return alertLineColor; + } + private void initComponents() { alertValue = new TinyFormulaPane(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAlertValuePane.java index 4459d96816..80e836834d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAlertValuePane.java @@ -1,7 +1,7 @@ package com.fr.van.chart.designer.style.background.radar; import com.fr.design.gui.ilable.UILabel; - +import com.fr.design.i18n.Toolkit; import com.fr.van.chart.designer.style.background.VanChartAlertValuePane; import java.awt.Component; @@ -14,9 +14,10 @@ public class VanChartRadarAlertValuePane extends VanChartAlertValuePane { protected Component[][] getTopPaneComponents() { return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value")),alertValue}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),alertLineStyle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),alertLineColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Value")), getAlertValue()}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), getAlertLineStyle()}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), getLineWidthSpinner()}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), getAlertLineColor()}, }; } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 1209310f66..a930deb231 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -306,12 +306,12 @@ public class SelectionModel { // 清除被选中的组件 selection.reset(); } + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); + setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); - setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); // 触发事件 - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); designer.repaint(); } } 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 f4554069e3..dcb6938836 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 @@ -298,7 +298,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo @Override public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) { if (!DesignerMode.isAuthorityEditing()) { - if (isDedicateContainer()) { + if (isDedicateContainer() && this.getComponentCount() > 0) { // 图表块和报表块由于控件树处不显示,但对应的属性表要显示,此处处理下 XCreator child = ((XLayoutContainer) this).getXCreator(0); return child.createToolPane(jform, formEditor); @@ -408,7 +408,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo public Component getParentShow(){ return this.getParent(); } - + /** * 重置组件的名称 * @@ -418,18 +418,18 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo public void resetCreatorName(String name) { toData().setWidgetName(name); } - + /** * 遍历所有命名相关的组件到集合中 * * @param xCreators 集合 */ public void traversalNameRelatedXCreators(Set xCreators) { - + xCreators.add(this); int componentCount = getComponentCount(); for (int i = 0; i < componentCount; i++) { - + Component component = getComponent(i); if (component instanceof XCreator) { XCreator xCreator = (XCreator) component; @@ -439,7 +439,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } } - + /** * 重置组件的可见性 * @@ -448,7 +448,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo public void resetVisible(boolean visible) { toData().setVisible(visible); } - + /** * 返回编辑的子组件,scale为其内部组件 * @return 组件 @@ -804,4 +804,4 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 06cb19d0ae..e13748719b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -105,7 +105,7 @@ public class FormCreatorDropTarget extends DropTarget { SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); SharableWidgetProvider bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); if (sharableEditor != null && bindInfo != null) { - Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource()); + Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource(), true); //合并数据集之后,可能会有数据集名称变化,做一下联动 //共享的组件拿的时候都是克隆的,这边改拖拽中克隆的对象而非新克隆对象,上面这个新克隆的对象只是为了拿数据集 for (Map.Entry entry : tdNameMap.entrySet()) { diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index b3a78d34d9..a8f4b2ac1a 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -258,6 +258,7 @@ public class RichTextToolBar extends BasicPane{ boolean isSub = RichTextToolBar.this.subPane.isSelected(); MutableAttributeSet attr = new SimpleAttributeSet(); if (!isSub && RichTextToolBar.this.superPane.isSelected()) { + RichTextToolBar.this.superPane.setSelected(false); StyleConstants.setSuperscript(attr, false); } // 调用setCharacterAttributes函数设置文本区选择文本的字体 @@ -273,6 +274,7 @@ public class RichTextToolBar extends BasicPane{ // 调用setCharacterAttributes函数设置文本区选择文本的字体 MutableAttributeSet attr = new SimpleAttributeSet(); if (!isSuper && RichTextToolBar.this.subPane.isSelected()) { + RichTextToolBar.this.subPane.setSelected(false); StyleConstants.setSubscript(attr, false); } StyleConstants.setSuperscript(attr, !isSuper); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java index 7324300eba..1716fb4765 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java @@ -4,9 +4,13 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.cell.CellElementPropertyComponent; import com.fr.design.fun.BackgroundQuickUIProvider; import com.fr.design.fun.CellAttributeProvider; +import com.fr.design.fun.CellPropertyPaneProvider; import com.fr.design.fun.PresentKindProvider; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; @@ -31,6 +35,7 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Dimension; +import java.util.Set; /** @@ -156,6 +161,7 @@ public class CellElementPropertyPane extends DockingView { return; } ePane.getSelection().populatePropertyPane(ePane); + populateExtraCellProperties(ePane); } @Override @@ -188,5 +194,29 @@ public class CellElementPropertyPane extends DockingView { EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_CELL_ATTR); EastRegionContainerPane.getInstance().setWindow2PreferWidth(); } + private void populateExtraCellProperties(ElementCasePane ePane) { + if (ePane == null) { + return; + } + Selection selection = ePane.getSelection(); + if (selection instanceof CellSelection) { + //单元格属性,限定下是选中单个单元格 + TemplateElementCase elementCase = ePane.getEditingElementCase(); + if (elementCase != null) { + Set itemPaneProviders = ExtraDesignClassManager.getInstance().getArray(PropertyItemPaneProvider.XML_TAG); + if (itemPaneProviders != null) { + for (PropertyItemPaneProvider itemPaneProvider : itemPaneProviders) { + if(itemPaneProvider instanceof CellPropertyPaneProvider){ + CellPropertyPaneProvider cellPropertyPaneProvider = (CellPropertyPaneProvider) itemPaneProvider; + CellElementPropertyComponent cellElementPropertyPane = cellPropertyPaneProvider.getSingletonCelPropertyPane(); + if (cellElementPropertyPane != null && cellElementPropertyPane.accept(ePane)) { + cellElementPropertyPane.populate(ePane); + } + } + } + } + } + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index 22ab323443..83a1c08501 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -28,7 +28,6 @@ import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; - import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.page.ReportSettingsProvider; @@ -82,6 +81,7 @@ public class ElementCasePaneDelegate extends ElementCasePane { } CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); + QuickEditorRegion.getInstance().populate(getCurrentEditor()); JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); // 模板初始化完成后,才能初始化超级链接面板 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 37d6a639f3..a430faeec1 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 @@ -238,6 +238,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { dlg.setModal(false); dlg.setVisible(true); + dlg.setAlwaysOnTop(true); } private void showDialogAfterAddCellAction() { diff --git a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java index 088026ba70..019b4cdeea 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java @@ -1,5 +1,6 @@ package com.fr.quickeditor; +import com.fr.base.GraphHelper; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.file.HistoryTemplateListPane; @@ -49,7 +50,6 @@ public abstract class CellQuickEditor extends QuickEditor { protected static final Dimension LABEL_DIMENSION = new Dimension(60, 20); protected static final int VGAP = 10, HGAP = 8, VGAP_INNER = 3; - private static final int INSERT_CONTENT_LABEL_WIDTH = 60; /** * 滚动条相关配置 @@ -208,7 +208,7 @@ public abstract class CellQuickEditor extends QuickEditor { private JPanel initTopContent() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = {INSERT_CONTENT_LABEL_WIDTH, f}; + double[] columnSize = {GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; double[] rowSize = {p, p}; UILabel cellLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell")); UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element"));