diff --git a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java index af4bc8a9be..393f217ce7 100644 --- a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java @@ -3,13 +3,13 @@ package com.fr.design.cell; import com.fr.base.NameStyle; import com.fr.base.ScreenResolution; import com.fr.base.Style; +import com.fr.general.IOUtils; import javax.swing.JPanel; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Toolkit; +import java.awt.image.BufferedImage; /** * @author Starryi @@ -18,7 +18,7 @@ import java.awt.Toolkit; */ public class CellStylePreviewPane extends JPanel { - private static final Image transparentBackgroundImage = Toolkit.getDefaultToolkit().createImage(CellStylePreviewPane.class.getResource("/com/fr/design/images/transparent_background.png")); + private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png"); private final float transparentBackgroundWidth; private final float transparentBackgroundHeight; private String paintText = "Report"; @@ -38,7 +38,7 @@ public class CellStylePreviewPane extends JPanel { } @Override - public void paintComponent(Graphics g) { + public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; int resolution = ScreenResolution.getScreenResolution(); diff --git a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java index 347dd768f5..709fdece73 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java +++ b/designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java @@ -2,9 +2,12 @@ package com.fr.design.gui.itoolbar; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.JTemplate; + import java.awt.Component; import java.awt.FlowLayout; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import javax.swing.JToolBar; public class UIToolbar extends JToolBar { @@ -35,13 +38,18 @@ public class UIToolbar extends JToolBar { } } - public void refreshUIToolBar() { - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (template != null) { - for (int i = 0; i < getComponentCount(); i++) { - Component component = getComponents()[i]; - component.setEnabled(template.checkEnable()); - } + public Map getComponentState() { + Map componentState = new HashMap<>(); + for (int i = 0; i < getComponentCount(); i++) { + Component component = getComponent(i); + componentState.put(component, component.isEnabled()); + } + return componentState; + } + + public static void resetComponentState(Map componentState) { + for (Component component : componentState.keySet()) { + component.setEnabled(componentState.get(component)); } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java index b7499fc149..8f9a8503da 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java @@ -303,13 +303,16 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { return; } JPanel container = this; - for (JComponent component: components) { + for (int i = 0; i < components.length; i++) { + JComponent component = components[i]; if (component != null) { container.add(component, BorderLayout.NORTH); - JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout()); - nextContainer.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); - container.add(nextContainer, BorderLayout.CENTER); - container = nextContainer; + component.setBorder(BorderFactory.createEmptyBorder(i == 0 ? 0 : IntervalConstants.INTERVAL_L1, 0, 0, 0)); + if (i < components.length - 1) { + JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout()); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; + } } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index 36507cf37d..d31b5ede09 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -19,10 +19,14 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.border.MatteBorder; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Insets; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + /** * @author shine @@ -96,7 +100,7 @@ public class CenterRegionContainerPane extends JPanel { } - private ToolBarMenuDock getToolBarMenuDock() { + public ToolBarMenuDock getToolBarMenuDock() { return DesignerContext.getDesignerFrame().getToolBarMenuDock(); } @@ -267,12 +271,13 @@ public class CenterRegionContainerPane extends JPanel { return centerTemplateCardPane; } - protected void refreshUIToolBar() { + public Map getToolbarComponentState() { + Map toolbarComponentState = new HashMap<>(); if (toolbarComponent instanceof UIToolbar) { - ((UIToolbar ) toolbarComponent).refreshUIToolBar(); + toolbarComponentState.putAll(((UIToolbar) toolbarComponent).getComponentState()); } - combineUp.refreshUIToolBar(); - getToolBarMenuDock().updateEnable(); + toolbarComponentState.putAll(combineUp.getComponentState()); + return toolbarComponentState; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 786deb8927..ae67275bea 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -361,14 +361,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } public DesktopCardPane getCenterTemplateCardPane() { - return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane(); } - public void refreshUIToolBar() { - CenterRegionContainerPane.getInstance().refreshUIToolBar(); - } - /** * 初始menuPane的方法 方便OEM时修改该组件 */ @@ -1040,7 +1035,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt != null) { + if (jt != null) { DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index 0e26ff3ded..0c10ac2e12 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -10,11 +10,14 @@ import com.fr.design.data.BasicTableDataTreePane; import com.fr.design.dialog.BasicPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.gui.itoolbar.UIToolbar; import javax.swing.JComponent; import javax.swing.JLayeredPane; import java.awt.BorderLayout; import java.awt.Component; +import java.util.HashMap; +import java.util.Map; /** @@ -33,6 +36,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener private TransparentPane transparentPane = new TransparentPane(); private OpenLoadingPane loadingPane = new OpenLoadingPane(); private OpenFailedPane failedPane = new OpenFailedPane(); + + Map backUpToolbarComponentState = new HashMap<>(); + private JLayeredPane layeredPane = new JLayeredPane() { @Override public void doLayout() { @@ -103,7 +109,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } private void showOpenStatus() { - DesignerContext.getDesignerFrame().refreshUIToolBar(); + forbidToolBar(); DesignerFrameFileDealerPane.getInstance().stateChange(); EastRegionContainerPane.getInstance().updateAllPropertyPane(); JComponent downPane = WestRegionContainerPane.getInstance().getDownPane(); @@ -120,9 +126,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } public void showCover() { + forbidToolBar(); transparentPane.start(); layeredPane.moveToFront(transparentPane); - DesignerContext.getDesignerFrame().refreshUIToolBar(); EastRegionContainerPane.getInstance().updateAllPropertyPane(); JComponent downPane = WestRegionContainerPane.getInstance().getDownPane(); if (downPane instanceof BasicTableDataTreePane) { @@ -132,6 +138,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } public void hideCover() { + recoverToolBar(); transparentPane.stop(); layeredPane.moveToFront(component); EastRegionContainerPane.getInstance().updateAllPropertyPane(); @@ -142,6 +149,22 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener } } + private void forbidToolBar() { + CenterRegionContainerPane centerRegionContainerPane = CenterRegionContainerPane.getInstance(); + backUpToolbarComponentState = centerRegionContainerPane.getToolbarComponentState(); + for (Component component : backUpToolbarComponentState.keySet()) { + component.setEnabled(false); + } + centerRegionContainerPane.getToolBarMenuDock().updateEnable(); + } + + private void recoverToolBar() { + UIToolbar.resetComponentState(backUpToolbarComponentState); + backUpToolbarComponentState.clear(); + CenterRegionContainerPane centerRegionContainerPane = CenterRegionContainerPane.getInstance(); + centerRegionContainerPane.getToolBarMenuDock().updateEnable(); + } + protected JTemplate getSelectedJTemplate() { return component; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java index 7fcfd7310a..543df64eb0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java @@ -37,8 +37,9 @@ import java.awt.event.MouseEvent; * Created by Starryi on 2021/8/13 */ public class TemplateThemeBlock extends JPanel { - public static final int HEIGHT = 150; - public static final int THUMBNAIL_HEIGHT = 125; + public static final int INFO_HEIGHT = 30; + public static final int CONTENT_WIDTH = ThemeThumbnail.WIDTH; + public static final int CONTENT_HEIGHT = ThemeThumbnail.HEIGHT + INFO_HEIGHT; private static final Color HOVERING_BORDER_COLOR = new Color(65, 155, 249); private final String name; @@ -97,13 +98,14 @@ public class TemplateThemeBlock extends JPanel { private void initializePane() { setLayout(FRGUIPaneFactory.createBorderLayout()); - setPreferredSize(new Dimension(getPreferredSize().width, HEIGHT)); + setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); setBackground(Color.WHITE); thumbnailPane.setBackground(Color.WHITE); - thumbnailPane.setPreferredSize(new Dimension(getPreferredSize().width, THUMBNAIL_HEIGHT)); + thumbnailPane.setPreferredSize(new Dimension(ThemeThumbnail.WIDTH, ThemeThumbnail.HEIGHT)); JPanel infoPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + infoPane.setPreferredSize(new Dimension(CONTENT_WIDTH, INFO_HEIGHT)); infoPane.setBackground(Color.WHITE); infoPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L7,0,IntervalConstants.INTERVAL_L7)); @@ -129,6 +131,8 @@ public class TemplateThemeBlock extends JPanel { } } thumbnailPane.setThumbnail(image); + invalidate(); + repaint(); } public T getTheme() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java index 4930335126..fca01386c4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.theme; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeConfig; +import com.fr.base.theme.settings.ThemeThumbnail; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.event.ChangeEvent; @@ -29,7 +30,9 @@ import java.util.Map; public class TemplateThemeListPane extends BasicPane { public static final int BLOCK_COUNT_ROW_LINE = 3; public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1; - public static final int CONTENT_WIDTH = 630; + public static final int CONTENT_WIDTH = TemplateThemeBlock.CONTENT_WIDTH * BLOCK_COUNT_ROW_LINE + BLOCK_GAP * (BLOCK_COUNT_ROW_LINE - 1) + 10; + public static final int BLOCK_ROWS_PER_PAGE = 3; + public static final int CONTENT_HEIGHT = TemplateThemeBlock.CONTENT_HEIGHT * BLOCK_ROWS_PER_PAGE + BLOCK_GAP * (BLOCK_ROWS_PER_PAGE + 1); public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10; private final AsyncThemeFetcher asyncThemeFetcher; @@ -59,7 +62,7 @@ public class TemplateThemeListPane extends BasicPane { private void initializePane() { setLayout(FRGUIPaneFactory.createBorderLayout()); - setPreferredSize(new Dimension(CONTENT_WIDTH, getPreferredSize().height)); + setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); contentListPane.setBorder(BorderFactory.createEmptyBorder(BLOCK_GAP, 0, BLOCK_GAP, 0)); contentListPane.setLayout(new GridLayout(0, BLOCK_COUNT_ROW_LINE, BLOCK_GAP, BLOCK_GAP)); @@ -173,7 +176,10 @@ public class TemplateThemeListPane extends BasicPane { } case UPDATE: { if (existingBlock != null) { + fillContentListPane(); asyncFetchTheme(themeName); + validate(); + repaint(); } break; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java index bf93c6345a..be9dec1600 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -17,15 +17,12 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; -import com.fr.design.mainframe.theme.edit.CellStyleListEditPane; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ToolBarDef; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.transaction.CallBackAdaptor; -import com.fr.transaction.Configurations; -import com.fr.transaction.WorkerFacade; import javax.swing.BorderFactory; import javax.swing.JOptionPane; @@ -55,6 +52,8 @@ import static com.fr.design.i18n.Toolkit.i18nText; * Created by Starryi on 2021/8/13 */ public class TemplateThemeManagePane extends BasicPane { + public static final int CONTENT_WIDTH = TemplateThemeListPane.CONTENT_WIDTH + 10; + public static final int CONTENT_HEIGHT = TemplateThemeListPane.CONTENT_HEIGHT + 37; private final RemoveThemeAction removeAction; private final UIButton setTheme4NewTemplateButton; @@ -94,6 +93,7 @@ public class TemplateThemeManagePane extends BasicPane private void initializePane() { setLayout(FRGUIPaneFactory.createBorderLayout()); setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); + setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); add(createActionsContainer(), BorderLayout.NORTH); @@ -102,7 +102,6 @@ public class TemplateThemeManagePane extends BasicPane nextContainer.add(new JSeparator(), BorderLayout.NORTH); - themeListPane.setPreferredSize(new Dimension(themeListPane.getPreferredSize().width, 490)); themeListPane.setSelectedChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java index 153929707d..19885763cc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java @@ -43,17 +43,9 @@ public abstract class TemplateThemePreviewPane extends int thumbnailWidth = ThemeThumbnail.WIDTH; int thumbnailHeight = ThemeThumbnail.HEIGHT; - float thumbnailAspect = 1.0F * thumbnailWidth / thumbnailHeight; int width = getWidth(); int height = getHeight(); - float aspect = 1.0F * width / height; - - if (thumbnailAspect > aspect) { - height = (int) (width / thumbnailAspect); - } else { - width = (int) (height * thumbnailAspect); - } try { // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java index 31762e72e6..f306fcacfc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java @@ -10,11 +10,13 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.TemplateThemeManagePane; import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -25,13 +27,12 @@ import java.awt.event.ActionListener; * Created by Starryi on 2021/8/13 */ public class TemplateThemeManageDialog extends TemplateThemeDialog { - public static final int CONTENT_WIDTH = 660; - public static final int CONTENT_HEIGHT = 570; private final TemplateThemeManageDialogContentPane contentPane; public TemplateThemeManageDialog(Window parent) { - super(parent, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + super(parent, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title"), + TemplateThemeManageDialogContentPane.CONTENT_WIDTH, TemplateThemeManageDialogContentPane.CONTENT_HEIGHT); contentPane = new TemplateThemeManageDialogContentPane(); setContentPane(createDialogContentPane(contentPane, new UIButton[]{ createCompleteButton() })); @@ -55,12 +56,16 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { } public static class TemplateThemeManageDialogContentPane extends JPanel { + public static final int CONTENT_WIDTH = TemplateThemeManagePane.CONTENT_WIDTH + 24; + public static final int CONTENT_HEIGHT = TemplateThemeManagePane.CONTENT_HEIGHT + 40; + private final TemplateThemeManagePane formThemesManagerPane; private final TemplateThemeManagePane reportThemesManagerPane; public TemplateThemeManageDialogContentPane() { setLayout(FRGUIPaneFactory.createBorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); UITabbedPane tabbedPane = new UITabbedPane(); add(tabbedPane, BorderLayout.NORTH); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java index a1db7f5651..7974097b58 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java @@ -4,15 +4,7 @@ import com.fr.base.theme.TemplateTheme; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.theme.TemplateThemeProfilePane; -import com.fr.file.FILE; -import com.fr.file.FILEChooserPane; -import com.fr.file.FileFILE; -import com.fr.file.filter.ChooseFileFilter; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.ListSet; -import com.fr.stable.xml.XMLPrintWriter; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -21,10 +13,6 @@ import java.awt.Dimension; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; import java.util.List; /** @@ -47,9 +35,6 @@ public class TemplateThemeProfileDialog extends Templat content.add(profilePane, BorderLayout.CENTER); setContentPane(createDialogContentPane(content, new UIButton[]{ - // 用于视觉设计师导出内置主题文件,发布前关闭 - // 后续由产品经理决定是否开启此功能 - createExportButton(profilePane), profilePane.createSaveButton(), profilePane.createSaveAsButton(this), createCancelButton() @@ -58,63 +43,6 @@ public class TemplateThemeProfileDialog extends Templat currentVisibleProfilePane = profilePane; } - private void exportTheme(T theme) { - FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, true, new ChooseFileFilter() { - @Override - public boolean accept(FILE f) { - return f.isDirectory(); - } - - @Override - public String getDescription() { - return "export theme to xml"; - } - - @Override - public boolean containsExtension(String extension) { - return true; - } - - @Override - public String toString() { - return getDescription(); - } - }); - fileChooser.setCurrentDirectory(new FileFILE(new File("~/"))); - fileChooser.setFileNameTextField(theme.getName(), ".xml"); - FILE exportedFile = null; - - int result = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), ".xml"); - if (result == FILEChooserPane.JOPTIONPANE_OK_OPTION || result == FILEChooserPane.OK_OPTION) { - exportedFile = fileChooser.getSelectedFILE(); - } - if (exportedFile == null) { - return; - } - - try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(exportedFile.getPath()))) { - XMLPrintWriter writer = XMLPrintWriter.create(bos); - theme.writeXML(writer); - writer.flush(); - writer.close(); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - public UIButton createExportButton(TemplateThemeProfilePane profilePane) { - UIButton exportButton = new UIButton(); - exportButton.setText(Toolkit.i18nText("Fine-Design_Basic_Export")); - exportButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - T theme = profilePane.updateBean(); - theme.getImageIdList().setIdList(new ListSet<>()); - exportTheme(theme); - } - }); - return exportButton; - } - private UIButton createCancelButton() { UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); button.addActionListener(new ActionListener() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java index e4f4b5fd27..9c9f9220e4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java @@ -27,8 +27,8 @@ import java.awt.event.ActionListener; */ public class TemplateThemeUsingDialog extends TemplateThemeDialog { - public static final int CONTENT_WIDTH = 660; - public static final int CONTENT_HEIGHT = 515; + public static final int CONTENT_WIDTH = TemplateThemeListPane.CONTENT_WIDTH + 42; + public static final int CONTENT_HEIGHT = TemplateThemeListPane.CONTENT_HEIGHT + 23; private final TemplateThemeListPane themeListPane; private final ThemedTemplate currentTemplate; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java index b8fc31b6d5..6b12c37d47 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java @@ -229,7 +229,7 @@ public class CellStyleListEditPane extends JListControlPane { if (selectModel != null) { NameObject selectNameObject = (NameObject) selectModel.wrapper; ThemedCellStyle cellStyle = (ThemedCellStyle) (selectNameObject.getObject()); - this.shortCut.setEnabled(cellStyle.isRemovable() && !cellStyle.isDefault4New()); + this.shortCut.setEnabled(cellStyle.isRemovable() && !cellStyle.isUse4Default()); } else { this.shortCut.setEnabled(false); } @@ -266,9 +266,13 @@ public class CellStyleListEditPane extends JListControlPane { cellStyle.setName(menuName); cellStyle.setStyle(Style.getInstance()); cellStyle.setRemovable(true); - cellStyle.setImmutable(true); - cellStyle.setDefault4Absent(false); - cellStyle.setDefault4New(false); + cellStyle.setUse4Default(false); + cellStyle.setUse4BigTitle(false); + cellStyle.setUse4SmallTitle(false); + cellStyle.setUse4Header(false); + cellStyle.setUse4MainText(false); + cellStyle.setUse4SupportInfo(false); + cellStyle.setUse4HighlightText(false); return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle); } @@ -285,7 +289,7 @@ public class CellStyleListEditPane extends JListControlPane { } public boolean acceptNameObject(Object ob) { - return !((ThemedCellStyle) ob).isDefault4New(); + return !((ThemedCellStyle) ob).isUse4Default(); } } @@ -297,7 +301,7 @@ public class CellStyleListEditPane extends JListControlPane { @Override public boolean acceptNameObject(Object ob) { - return ((ThemedCellStyle) ob).isDefault4New(); + return ((ThemedCellStyle) ob).isUse4Default(); } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java index cf9822aba8..715c3f2503 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java @@ -4,38 +4,35 @@ import com.fr.base.Style; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.base.theme.settings.ThemedCellStyleList; -import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.theme.preview.ThemePreviewed; import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; -import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; -import javax.swing.JPanel; import java.util.List; public abstract class AbstractECPreviewPane extends UINoOpaquePanel implements ThemePreviewed { protected Style getReportHeaderStyle(ThemedCellStyleList cellStyleList) { - return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); + return getCellStyle(cellStyleList.getUse4Header()); } protected Style getMainContentStyle(ThemedCellStyleList cellStyleList) { - return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); + return getCellStyle(cellStyleList.getUse4MainText()); } protected Style getHighLightStyle(ThemedCellStyleList cellStyleList) { - return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); + return getCellStyle(cellStyleList.getUse4HighlightText()); } protected Style getSmallTitleStyle(ThemedCellStyleList cellStyleList) { - return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Small_Title")); + return getCellStyle(cellStyleList.getUse4SmallTitle()); } - private Style getCellStyle(ThemedCellStyleList cellStyleList, String styleName) { - ThemedCellStyle cellStyle = cellStyleList.find(styleName); - if (cellStyle == null) { + private Style getCellStyle(ThemedCellStyle themedCellStyle) { + if (themedCellStyle == null) { return Style.DEFAULT_STYLE; } - return cellStyle.getStyle(); + Style style = themedCellStyle.getStyle(); + return style != null ? style : Style.DEFAULT_STYLE; } protected void refresh(List list, Style style) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java index 67d8c0b2a2..67be5cc9aa 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java @@ -34,7 +34,7 @@ public class DefaultThemedTemplateCellElementCase { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { TemplateTheme theme = template.getTemplateTheme(); - ThemedCellStyle themedCellStyle = theme.getCellStyleList().getDefaultCellStyle4New(); + ThemedCellStyle themedCellStyle = theme.getCellStyleList().getUse4Default(); if (themedCellStyle != null) { NameStyle nameStyle = NameStyle.getPassiveInstance(themedCellStyle.getName(), themedCellStyle.getStyle()); cellElement.setStyle(nameStyle); diff --git a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java index f47a4f88e7..51a79bbad9 100644 --- a/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java +++ b/designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java @@ -70,7 +70,6 @@ public class SaveWorker extends SwingWorker { this.template.setSaving(false); // 恢复界面 if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { - DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover(); } DesignerFrameFileDealerPane.getInstance().stateChange(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index 540c707d49..1ed4c6cca2 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -31,6 +31,7 @@ public class FormSpacingLineDrawer { private FormDesigner designer; private XCreator hoverCreator = null; + private XCreator selectedCreator = null; private Rectangle selectedRec; private Rectangle hoveredRec; private boolean isMouseMoveEvent = false; @@ -40,19 +41,19 @@ public class FormSpacingLineDrawer { } public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { - XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); - if (creator != null) { + selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if (selectedCreator != null) { this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); } this.isMouseMoveEvent = isMouseMoveEvent; } public void draw(Graphics g) { - if (!isDrawSpacingLine()) { + if (!isMouseMoveEvent || selectedCreator == null || hoverCreator == null) { return; } - if (!hoverCreator.isParentAbsolute()) { + if (!isDrawSpacingLine()) { return; } @@ -137,15 +138,15 @@ public class FormSpacingLineDrawer { } private boolean isSelectedParaComponent() { - return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); + return designer.getParaComponent() == selectedCreator; } private boolean isSelectedRootComponent() { - return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); + return designer.isRoot(selectedCreator); } private boolean isSelectedForm() { - return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; + return selectedCreator.getParent() == null; } private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { @@ -158,33 +159,33 @@ public class FormSpacingLineDrawer { } // 当前组件是否在参数面板里面 - private boolean isCompInPara(XCreator creator) { + private boolean isCompInBody(XCreator creator) { XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); + return container != null && !container.acceptType(XWParameterLayout.class); + } - boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class); - boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); - - return xCreatorAccept || containerAccept; + private boolean isSelectedCompInBody() { + return isCompInBody(selectedCreator); } - private boolean isBodyAbsoluteLayout() { - return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); + private boolean isHoveredCompInBody() { + return isCompInBody(hoverCreator); } - private boolean isSelectedCompInPara() { - return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator()); + private boolean isCompInBody() { + return isSelectedCompInBody() && isHoveredCompInBody(); } - private boolean isHoveredCompInPara() { - return isCompInPara(hoverCreator); + private boolean isBodyAbsoluteLayout() { + return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); } - private boolean isSelectedCompOrHoveredCompInPara() { - return isSelectedCompInPara() || isHoveredCompInPara(); + private boolean isInAbsoluteLayout() { + return isBodyAbsoluteLayout() && hoverCreator.isParentAbsolute() && selectedCreator.isParentAbsolute(); } private boolean isDrawSpacingLine() { - return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; + return isInAbsoluteLayout() && !isSelectedRootPane() && isCompInBody(); } private AbstractFormParallelLine[] getNearestHorizontalSide() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 9d03edbc07..784a3b690d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -39,6 +39,7 @@ import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.FormAdaptiveConfigUIProcessor; import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; @@ -1199,13 +1200,25 @@ public class JForm extends JTemplate implements BaseJForm { getTarget().setTemplateTheme(newTheme, compatible); - fireTargetModified(shouldCreateUndoState); - reportComposite.setSelectedIndex(reportComposite.getSelectedIndex()); - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); - DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() == this) { + fireTargetModified(shouldCreateUndoState); + reportComposite.setSelectedIndex(reportComposite.getSelectedIndex()); + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); + DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } super.setTemplateTheme(newTheme, compatible); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java index eb6f5484e4..53fe811dbb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/ThemedCellStyleListPane.java @@ -22,11 +22,11 @@ import javax.swing.JPanel; import javax.swing.ListCellRenderer; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.io.Serializable; import java.util.List; @@ -44,21 +44,17 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane imp styleList.setCellRenderer(new RadioButtonListCellRenderer()); styleList.setOpaque(false); styleList.setBackground(null); - setLayout(FRGUIPaneFactory.createBorderLayout()); - add(styleList, BorderLayout.CENTER); - setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER)); - - styleList.addMouseListener(new MouseAdapter() { + styleList.addListSelectionListener(new ListSelectionListener() { @Override - public void mouseClicked(MouseEvent e) { - int clickedNumber = e.getClickCount(); - if (clickedNumber == 1) { - if (changeListener != null) { - changeListener.stateChanged(new ChangeEvent(styleList)); - } + public void valueChanged(ListSelectionEvent e) { + if (changeListener != null) { + changeListener.stateChanged(new ChangeEvent(styleList)); } } }); + setLayout(FRGUIPaneFactory.createBorderLayout()); + add(styleList, BorderLayout.CENTER); + setBorder(BorderFactory.createEmptyBorder(0 ,LEFT_BORDER, 0, RIGHT_BORDER)); DesignerContext.setDesignerBean("predefinedStyle", this); }