Browse Source

REPORT-22869 19fdc接口——预定义样式支持更多配置

persist/11.0
kerry 5 years ago
parent
commit
db5cd5b6e3
  1. 33
      designer-realize/src/main/java/com/fr/design/style/StylePane.java
  2. 22
      designer-realize/src/main/java/com/fr/design/style/preference/PreferenceConfigProvider.java
  3. 32
      designer-realize/src/main/java/com/fr/design/style/preference/PreferenceTabConfig.java
  4. 29
      designer-realize/src/main/java/com/fr/design/style/preference/impl/AbstractPreferenceConfigProvider.java
  5. 33
      designer-realize/src/main/java/com/fr/design/style/preference/impl/AbstractPreferenceTabConfig.java

33
designer-realize/src/main/java/com/fr/design/style/StylePane.java

@ -8,16 +8,20 @@ import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.core.StyleUtils; import com.fr.base.core.StyleUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.style.background.BackgroundPane; import com.fr.design.style.background.BackgroundPane;
import com.fr.design.style.preference.PreferenceConfigProvider;
import com.fr.design.style.preference.PreferenceTabConfig;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
@ -38,6 +42,8 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.util.List;
import java.util.Set;
/** /**
* Style Pane. * Style Pane.
@ -48,6 +54,7 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
private static final int FONT_INDEX = 2; private static final int FONT_INDEX = 2;
private static final int BORDER_INDEX = 3; private static final int BORDER_INDEX = 3;
private static final int BACKGROUND_INDEX = 4; private static final int BACKGROUND_INDEX = 4;
private static final int NEXT_TAB_INDEX = 5;
private ElementCasePane reportPane; private ElementCasePane reportPane;
protected Style editing; protected Style editing;
private NameStyle globalStyle; private NameStyle globalStyle;
@ -56,9 +63,17 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
private FRFontPane frFontPane = null; private FRFontPane frFontPane = null;
private BorderPane borderPane = null; private BorderPane borderPane = null;
private BackgroundPane backgroundPane = null; private BackgroundPane backgroundPane = null;
private static List<PreferenceTabConfig> configList = PluginSandboxCollections.newSandboxList();
private PreivewArea previewArea; private PreivewArea previewArea;
private JPanel previewPane; private JPanel previewPane;
static {
Set<PreferenceConfigProvider> preferenceConfigProviders = ExtraDesignClassManager.getInstance().getArray(PreferenceConfigProvider.XML_TAG);
for (PreferenceConfigProvider provider : preferenceConfigProviders) {
configList.addAll(provider.getConfigList());
}
}
/** /**
* Constructor * Constructor
*/ */
@ -84,6 +99,9 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); mainTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
for (PreferenceTabConfig config : configList) {
mainTabbedPane.addTab(config.tabName(), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
}
mainTabbedPane.addChangeListener(tabChangeActionListener); mainTabbedPane.addChangeListener(tabChangeActionListener);
this.setPreferredSize(new Dimension(450, 480)); this.setPreferredSize(new Dimension(450, 480));
} }
@ -344,6 +362,9 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
if (this.backgroundPane != null) { if (this.backgroundPane != null) {
this.backgroundPane.populate(editing.getBackground()); this.backgroundPane.populate(editing.getBackground());
} }
for(PreferenceTabConfig tabConfig : configList){
tabConfig.populateTabConfig(this.editing);
}
updatePreviewArea(); updatePreviewArea();
} }
@ -378,6 +399,9 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
if (this.backgroundPane != null) { if (this.backgroundPane != null) {
style = style.deriveBackground(this.backgroundPane.update()); style = style.deriveBackground(this.backgroundPane.update());
} }
for(PreferenceTabConfig tabConfig : configList){
style = tabConfig.updateTabConfig();
}
return style; return style;
} }
@ -401,6 +425,9 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
tabbedPane.setComponentAt(selectedIndex, StylePane.this.getBorderPane()); tabbedPane.setComponentAt(selectedIndex, StylePane.this.getBorderPane());
} else if (selectedIndex == BACKGROUND_INDEX) { } else if (selectedIndex == BACKGROUND_INDEX) {
tabbedPane.setComponentAt(selectedIndex, StylePane.this.getBackgroundPane()); tabbedPane.setComponentAt(selectedIndex, StylePane.this.getBackgroundPane());
} else if (configList.size() + NEXT_TAB_INDEX > selectedIndex && configList.get(selectedIndex - NEXT_TAB_INDEX) != null) {
tabbedPane.setComponentAt(selectedIndex, configList.get(selectedIndex - NEXT_TAB_INDEX).tabComponent(StylePane.this));
configList.get(selectedIndex - NEXT_TAB_INDEX).populateTabConfig(StylePane.this.editing);
} }
} }
updatePreviewArea(); updatePreviewArea();
@ -419,7 +446,7 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
/** /**
* 预览Style的面板 * 预览Style的面板
* *
* @author richer * @author richer
*/ */
public static class PreivewArea extends JComponent { public static class PreivewArea extends JComponent {
@ -461,7 +488,7 @@ public class StylePane extends BasicBeanPane<Style> implements ChangeListener {
} }
} }

22
designer-realize/src/main/java/com/fr/design/style/preference/PreferenceConfigProvider.java

@ -0,0 +1,22 @@
package com.fr.design.style.preference;
import com.fr.stable.fun.mark.Mutable;
import java.util.List;
/**
* Created by kerry on 2019-11-04
*/
public interface PreferenceConfigProvider extends Mutable {
String XML_TAG = "PreferenceConfigProvider";
int CURRENT_LEVEL = 1;
/**
* 获取tab配置项
* @return tab配置项
*/
List<PreferenceTabConfig> getConfigList();
}

32
designer-realize/src/main/java/com/fr/design/style/preference/PreferenceTabConfig.java

@ -0,0 +1,32 @@
package com.fr.design.style.preference;
import com.fr.base.Style;
import javax.swing.JComponent;
import javax.swing.event.ChangeListener;
/**
* Created by kerry on 2019-11-04
*/
public interface PreferenceTabConfig {
/**
* @return tab的标题
*/
String tabName();
/**
* @param changeListener 需要添加的listener
* @return tab对应的component
*/
JComponent tabComponent(ChangeListener changeListener);
/**
* @return 更新后的样式
*/
Style updateTabConfig();
/**
* @param style 待渲染的样式
*/
void populateTabConfig(Style style);
}

29
designer-realize/src/main/java/com/fr/design/style/preference/impl/AbstractPreferenceConfigProvider.java

@ -0,0 +1,29 @@
package com.fr.design.style.preference.impl;
import com.fr.design.style.preference.PreferenceConfigProvider;
import com.fr.design.style.preference.PreferenceTabConfig;
import com.fr.stable.fun.mark.API;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2019-11-04
*/
@API(level = PreferenceConfigProvider.CURRENT_LEVEL)
public abstract class AbstractPreferenceConfigProvider implements PreferenceConfigProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public List<PreferenceTabConfig> getConfigList() {
return new ArrayList<PreferenceTabConfig>();
}
}

33
designer-realize/src/main/java/com/fr/design/style/preference/impl/AbstractPreferenceTabConfig.java

@ -0,0 +1,33 @@
package com.fr.design.style.preference.impl;
import com.fr.base.Style;
import com.fr.design.style.preference.PreferenceTabConfig;
import com.fr.stable.StringUtils;
import javax.swing.JComponent;
import javax.swing.event.ChangeListener;
/**
* Created by kerry on 2019-11-04
*/
public abstract class AbstractPreferenceTabConfig implements PreferenceTabConfig {
@Override
public String tabName() {
return StringUtils.EMPTY;
}
@Override
public JComponent tabComponent(ChangeListener changeListener) {
return null;
}
@Override
public Style updateTabConfig() {
return null;
}
@Override
public void populateTabConfig(Style style) {
}
}
Loading…
Cancel
Save