diff --git a/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java b/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java index fa602c8bd..d68bd7757 100644 --- a/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java +++ b/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java @@ -102,12 +102,23 @@ public class CellElementPropertyPane extends DockingView { return element; } + public void removeAll() { + this.remove(titlePane); + this.remove(cellElementEditPane); + } + + public void reInit(ElementCasePane ePane) { + this.add(titlePane, BorderLayout.NORTH); + this.add(cellElementEditPane, BorderLayout.CENTER); + cellElementEditPane.populate(ePane); + } + public void populate(ElementCasePane ePane) { TemplateElementCase elementCase = ePane.getEditingElementCase(); if (elementCase == null) { return; } - cellElementEditPane.populate(ePane); + ePane.getSelection().populatePropertyPane(ePane); } @Override diff --git a/designer/src/com/fr/grid/selection/CellSelection.java b/designer/src/com/fr/grid/selection/CellSelection.java index c08f87088..458d9fd29 100644 --- a/designer/src/com/fr/grid/selection/CellSelection.java +++ b/designer/src/com/fr/grid/selection/CellSelection.java @@ -18,6 +18,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane.Clear; import com.fr.design.mainframe.JTemplate; @@ -684,4 +685,9 @@ public class CellSelection extends Selection { editor.populate(tc); return editor; } + + @Override + public void populatePropertyPane(ElementCasePane ePane) { + CellElementPropertyPane.getInstance().reInit(ePane); + } } \ No newline at end of file diff --git a/designer/src/com/fr/grid/selection/FloatSelection.java b/designer/src/com/fr/grid/selection/FloatSelection.java index 0c1b1fcb0..5f0be878c 100644 --- a/designer/src/com/fr/grid/selection/FloatSelection.java +++ b/designer/src/com/fr/grid/selection/FloatSelection.java @@ -20,6 +20,7 @@ import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.designer.TargetComponent; +import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.design.mainframe.ElementCasePane; @@ -230,4 +231,9 @@ public class FloatSelection extends Selection { editor.populate(tc); return editor; } + + @Override + public void populatePropertyPane(ElementCasePane ePane) { + CellElementPropertyPane.getInstance().removeAll(); + } } \ No newline at end of file diff --git a/designer/src/com/fr/grid/selection/Selection.java b/designer/src/com/fr/grid/selection/Selection.java index e7466b365..c12dda83b 100644 --- a/designer/src/com/fr/grid/selection/Selection.java +++ b/designer/src/com/fr/grid/selection/Selection.java @@ -87,6 +87,8 @@ public abstract class Selection implements FCloneable, Serializable , Selectable // //////////////////////////Just4CellSelection/////////////////////////////// public abstract boolean containsColumnRow(ColumnRow cr); + + public abstract void populatePropertyPane(ElementCasePane ePane); @Override diff --git a/designer_base/src/com/fr/design/formula/FormulaPane.java b/designer_base/src/com/fr/design/formula/FormulaPane.java index 260ca917b..9aec1972a 100644 --- a/designer_base/src/com/fr/design/formula/FormulaPane.java +++ b/designer_base/src/com/fr/design/formula/FormulaPane.java @@ -22,10 +22,8 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import com.fr.parser.FRLexer; import com.fr.parser.FRParser; -import com.fr.plugin.ExtraClassManager; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; -import com.fr.stable.fun.mark.Mutable; import com.fr.stable.script.Expression; import javax.swing.*; @@ -618,13 +616,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ functionTypeListModel.addElement(FunctionConstants.ALL); functionTypeListModel.addElement(FunctionConstants.CUSTOM); functionTypeListModel.addElement(FunctionConstants.PLUGIN); - //hugh:自定义函数分组 - Set groups = ExtraClassManager.getInstance().getArray(FunctionGroup.MARK_STRING); - if(!groups.isEmpty()){ - for(Mutable group : groups){ - functionTypeListModel.addElement(group); - } - } + + //hugh: 从函数分组插件中添加分组 + FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel); } private void initFunctionNameListCellRenderer(){ diff --git a/designer_base/src/com/fr/design/formula/FunctionConstants.java b/designer_base/src/com/fr/design/formula/FunctionConstants.java index 372409583..8a0675897 100644 --- a/designer_base/src/com/fr/design/formula/FunctionConstants.java +++ b/designer_base/src/com/fr/design/formula/FunctionConstants.java @@ -11,6 +11,7 @@ import com.fr.stable.EncodeConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.fun.FunctionDefContainer; import com.fr.stable.fun.mark.Mutable; import com.fr.stable.script.Function; import com.fr.stable.script.FunctionDef; @@ -24,8 +25,49 @@ import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import javax.swing.DefaultListModel; + public abstract class FunctionConstants { + + /** + * 将函数分组插件中的函数添加到对应的列表中 + * @param listModel + */ + public static void addFunctionGroupFromPlugins(DefaultListModel listModel){ + //hugh:自定义函数分组 + Set containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); + if(!containers.isEmpty()){ + for(Mutable container : containers){ + listModel.addElement(createFunctionGroup((FunctionDefContainer)container)); + } + } + } + + /** + * 创建一个新的分组 + * @param container + * @return + */ + private static FunctionGroup createFunctionGroup(final FunctionDefContainer container){ + return new FunctionGroup() { + @Override + public String getGroupName() { + return container.getGroupName(); + } + @Override + public NameAndDescription[] getDescriptions() { + FunctionDef[] fs = container.getFunctionDefs(); + int count = fs.length; + FunctionDefNAD[] nads = new FunctionDefNAD[count]; + for (int i = 0; i < count; i ++) { + nads[i] = new FunctionDefNAD(fs[i]); + } + return nads; + } + }; + } + public static FunctionGroup PLUGIN = new FunctionGroup() { @Override public String getGroupName() { @@ -98,10 +140,10 @@ public abstract class FunctionConstants { Collections.addAll(all, PLUGIN.getDescriptions()); Collections.addAll(all, CUSTOM.getDescriptions()); //hugh:自定义函数分组 - Set groups = ExtraClassManager.getInstance().getArray(FunctionGroup.MARK_STRING); - if(!groups.isEmpty()){ - for(Mutable group : groups){ - Collections.addAll(all, ((FunctionGroup)group).getDescriptions()); + Set containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); + if(!containers.isEmpty()){ + for(Mutable container : containers){ + Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions()); } } java.util.Collections.sort(all, NameAndDescriptionComparator); diff --git a/designer_base/src/com/fr/design/formula/FunctionGroup.java b/designer_base/src/com/fr/design/formula/FunctionGroup.java index b2d181b12..4764454ed 100644 --- a/designer_base/src/com/fr/design/formula/FunctionGroup.java +++ b/designer_base/src/com/fr/design/formula/FunctionGroup.java @@ -2,10 +2,6 @@ package com.fr.design.formula; public interface FunctionGroup { - - int CURRENT_LEVEL = 1; - String MARK_STRING = "FunctionGroup"; - String getGroupName(); NameAndDescription[] getDescriptions(); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java b/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java deleted file mode 100644 index 674339362..000000000 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fr.design.fun.impl; - -import com.fr.design.formula.FunctionDefNAD; -import com.fr.design.formula.FunctionGroup; -import com.fr.design.formula.NameAndDescription; -import com.fr.stable.fun.mark.API; -import com.fr.stable.fun.mark.Mutable; -import com.fr.stable.script.FunctionDef; - - -@API(level = FunctionGroup.CURRENT_LEVEL) -public abstract class AbstractFunctionGroup implements Mutable, FunctionGroup { - - @Override - public int currentAPILevel() { - return CURRENT_LEVEL; - } - - @Override - public String mark4Provider() { - return getClass().getName(); - } - - @Override - public NameAndDescription[] getDescriptions() { - FunctionDef[] funcs = getFunctionDefs(); - int count = funcs.length; - FunctionDefNAD[] nads = new FunctionDefNAD[count]; - for (int i = 0; i < count; i ++) { - nads[i] = new FunctionDefNAD(funcs[i]); - } - return nads; - } - - public FunctionDef[] getFunctionDefs(){ - return new FunctionDef[0]; - } -} diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index fdfaaa0dc..6c55ee045 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -47,6 +47,7 @@ public class XCardSwitchButton extends XButton { //设置的图片类型 private static final String COLORBACKGROUNDTYPE = "ColorBackground"; private static final String DEFAULTTYPE = "default"; + private static final String DEFAULT_FONT_NAME = "SimSun"; //默认颜色 public static final Color NORMAL_GRAL = new Color(236,236,236); @@ -65,6 +66,7 @@ public class XCardSwitchButton extends XButton { private static final int FONT_SIZE_ADJUST = 2; private static final int SIDE_OFFSET = 57; + private static final int FONT_SIZE = 9; private XWCardLayout cardLayout; private XWCardTagLayout tagLayout; @@ -251,7 +253,9 @@ public class XCardSwitchButton extends XButton { Point position = button.getLocation(); int width = button.getWidth(); int height = button.getHeight(); - + + ey = ey % DEFAULT_BUTTON_HEIGHT; + // 鼠标进入按钮右侧删除图标区域 double recX = position.getX() + (width - RIGHT_OFFSET); double recY = position.getY() + (height - TOP_OFFSET); @@ -318,6 +322,9 @@ public class XCardSwitchButton extends XButton { // 标题部分 WidgetTitle title = style.getTitle(); FRFont font = button.getFont(); + if (font == null) { + font = FRFont.getInstance(DEFAULT_FONT_NAME, 0, FONT_SIZE); + } FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST); UILabel label = this.getContentLabel(); label.setFont(newFont); @@ -337,6 +344,12 @@ public class XCardSwitchButton extends XButton { //删除tab布局 private void deleteTabLayout(SelectionModel selectionModel,FormDesigner designer){ + String titleName = this.getContentLabel().getText(); + int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”", + Inter.getLocText("FR-Designer_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION); + if (value != JOptionPane.OK_OPTION) { + return; + } XLayoutContainer mainLayout = this.cardLayout.getBackupParent(); if(mainLayout != null){ selectionModel.setSelectedCreator(mainLayout); @@ -363,7 +376,7 @@ public class XCardSwitchButton extends XButton { XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); String tempText = tempCard.getText(); - Font f = ((CardSwitchButton)this.toData()).getFont(); + Font f = tempCard.getFont(); FontMetrics fm = GraphHelper.getFontMetrics(f); cardWidth.put(i,fm.stringWidth(tempText)); cardHeight.put(i,fm.getHeight()); @@ -387,9 +400,12 @@ public class XCardSwitchButton extends XButton { this.tagLayout.getComponent(i).setBounds(rectangle); Dimension dimension = new Dimension(); dimension.setSize(cardWidth, cardHeight); + XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); CardSwitchButton cardSwitchButton = (CardSwitchButton) temp.toData(); FRFont frFont = cardSwitchButton.getFont(); - XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); + if (frFont == null) { + frFont = FRFont.getInstance(DEFAULT_FONT_NAME, 0, FONT_SIZE); + } UILabel label = temp.getContentLabel(); label.setSize(dimension); label.setFont(frFont.applyResolutionNP(ScreenResolution.getScreenResolution())); diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index e9d7b58c3..ccdf7dd07 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -45,6 +45,9 @@ public class XWTabFitLayout extends XWFitLayout { // tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件 // 这里先将拖拽之前的宽高先做备份 private static final Color NORMAL_GRAL = new Color(236,236,236); + private static final String DEFAULT_FONT_NAME = "SimSun"; + public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12); + public final static FRFont DEFAULT_FRFT = FRFont.getInstance(DEFAULT_FONT_NAME, 0, 9); private Dimension referDim; private Background initialBackground; private Background overBackground; @@ -229,16 +232,24 @@ public class XWTabFitLayout extends XWFitLayout { boolean isStyle = ((WTabFitLayout) data).isCustomStyle(); Background bg; bg = ColorBackground.getInstance(NORMAL_GRAL); + CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData(); if (!isStyle) { this.xCardSwitchButton.setCustomStyle(false); this.xCardSwitchButton.setSelectBackground(bg); + this.xCardSwitchButton.getLabel().setFont(DEFAULTFT); + cardSwitchButton.setInitialBackground(null); + cardSwitchButton.setClickBackground(null); + cardSwitchButton.setOverBackground(null); + cardSwitchButton.setFont(DEFAULT_FRFT); } else { - CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData(); Background initialBackground = cardSwitchButton.getInitialBackground(); bg = initialBackground == null ? bg : initialBackground; this.xCardSwitchButton.setSelectBackground(bg); this.xCardSwitchButton.setCustomStyle(true); cardSwitchButton.setCustomStyle(true); + if (font != null) { + cardSwitchButton.setFont(font); + } } }