Browse Source

REPORT-40001 【预定义样式】应该是我们修改某个样式,就显示在样式最前

research/11.0
kerry 4 years ago
parent
commit
e3c78dc4cc
  1. 3
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 30
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java
  3. 70
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java
  4. 17
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java
  5. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

3
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -51,6 +51,7 @@ import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut;
import com.fr.design.preview.PagePreview;
import com.fr.design.utils.DesignUtils;
import com.fr.design.write.submit.DBManipulationInWidgetEventPane;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.file.FILE;
@ -1353,7 +1354,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
predefinedBtn.setText(getTemplatePredefinedStyle());
setPredefinedButtonSize(predefinedBtn);
this.fireTargetModified();
this.repaint();
DesignUtils.refreshDesignerFrame();
}
public String getTemplatePredefinedStyle(){

30
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java

@ -28,6 +28,9 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Created by kerry on 2020-08-26
@ -245,7 +248,8 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
return false;
}
config.add(previewObject);
ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config);
PredefinedStyleConfig sortedConfig = resortConfigStyles(previewObject, config);
ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(sortedConfig);
selectPane.refreshPane();
return true;
}
@ -275,4 +279,28 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
return true;
}
private PredefinedStyleConfig resortConfigStyles(PredefinedStyle priorityStyle, PredefinedStyleConfig config){
PredefinedStyleConfig sortedConfig = new PredefinedStyleConfig();
PredefinedStyle defaultStyle = config.getDefaultPredefinedStyle();
if (defaultStyle != null) {
sortedConfig.add(defaultStyle);
config.removeStyle(defaultStyle.getStyleName());
sortedConfig.setDefaultPredefinedStyle(defaultStyle.getStyleName());
}
if (priorityStyle != null && !priorityStyle.isDefaultStyle()) {
sortedConfig.add(priorityStyle);
config.removeStyle(priorityStyle.getStyleName());
}
Iterator<PredefinedStyle> iterator = config.getPredefinedStyleIterator();
while (iterator.hasNext()) {
PredefinedStyle entry = iterator.next();
sortedConfig.add(entry);
}
sortedConfig.setCompatibleStyleName(config.getCompatibleStyleName());
return sortedConfig;
}
}

70
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java

@ -6,6 +6,7 @@ import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.config.predefined.PredefinedCellStyleConfig;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.controlpane.JListControlPane;
@ -15,6 +16,8 @@ import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.FormatPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane;
@ -83,8 +86,16 @@ public class CellStyleListControlPane extends JListControlPane {
@Override
public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePane.class)};
return new NameableCreator[]{
new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePaneNoBorder.class) {
@Override
public boolean acceptDefaultNameObject(Object ob) {
return ((PredefinedCellStyle) ob).isDefaultStyle();
}
},
new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePane.class)};
}
@Override
@ -113,13 +124,45 @@ public class CellStyleListControlPane extends JListControlPane {
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
shortCutFactory.addItemShortCut(),
createAddItemShortCut4JControlPane(),
new RemoveItemShortCut4JControlPane(new RemoveItemAction())
};
}
public class RemoveItemShortCut4JControlPane extends ShortCut4JControlPane {
private static class CustomPredefinedStylePaneNoBorder extends CustomPredefinedStylePane {
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new AlignmentPane());
return paneList;
}
}
private ShortCut4JControlPane createAddItemShortCut4JControlPane (){
ShortCut shortCut = shortCutFactory.createAddItemUpdateAction(new NameableCreator[]{
new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePane.class)});
return new AddItemShortCut4JControlPane(shortCut);
}
private class AddItemShortCut4JControlPane extends ShortCut4JControlPane{
AddItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut;
}
@Override
public void checkEnable() {
this.shortCut.setEnabled(true);
}
}
private class RemoveItemShortCut4JControlPane extends ShortCut4JControlPane {
RemoveItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut;
}
@ -180,6 +223,25 @@ public class CellStyleListControlPane extends JListControlPane {
}
return null;
}
/**
*
* @param ob
* @return
*/
public Object acceptObject2Populate(Object ob) {
if (ob instanceof NameObject) {
ob = ((NameObject) ob).getObject();
}
if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptDefaultNameObject(ob)) {
doSthChanged4Icon(ob);
return ob;
}
return null;
}
public boolean acceptDefaultNameObject(Object ob) {
return !((PredefinedCellStyle) ob).isDefaultStyle();
}
}

17
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java

@ -49,14 +49,6 @@ public class CustomPredefinedStylePane extends MultiTabPane<PredefinedCellStyle>
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}
public static CustomPredefinedStylePane createPredefinedStylePane() {
return new CustomPredefinedStylePane();
}
public static CustomPredefinedStylePane createDefaultPredefinedStylePane() {
return new CustomPredefinedStylePaneNoBorder();
}
/**
* @return
*/
@ -172,16 +164,7 @@ public class CustomPredefinedStylePane extends MultiTabPane<PredefinedCellStyle>
}
private static class CustomPredefinedStylePaneNoBorder extends CustomPredefinedStylePane {
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new AlignmentPane());
return paneList;
}
}
/**
* 预览Style的面板

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -12,6 +12,7 @@ import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.properties.items.FRFitConstraintsItems;
import com.fr.design.designer.properties.items.FRLayoutTypeItems;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
@ -194,11 +195,14 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
try {
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) {
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body");
String predefinedName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED);
Component[] components = xWFitLayout.getComponents();
xWFitLayout.removeAll();
layout.resetStyle();
layout.setNameBackground(NameFormBackground.createPredefinedStyle(predefinedName));
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent();
xwAbsoluteBodyLayout.initWidgetPredefinedInfo(predefinedName);
xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0);
for (Component component : components) {
XCreator xCreator = (XCreator) component;

Loading…
Cancel
Save