diff --git a/designer/src/com/fr/design/expand/ExpandFatherPane.java b/designer/src/com/fr/design/expand/ExpandFatherPane.java index ea863dd811..d71035fcf3 100644 --- a/designer/src/com/fr/design/expand/ExpandFatherPane.java +++ b/designer/src/com/fr/design/expand/ExpandFatherPane.java @@ -1,191 +1,208 @@ -package com.fr.design.expand; - -import com.fr.base.BaseUtils; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.event.GlobalNameListener; -import com.fr.design.event.GlobalNameObserver; -import com.fr.design.gui.columnrow.ColumnRowPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.general.Inter; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.design.selection.SelectionEvent; -import com.fr.design.selection.SelectionListener; -import com.fr.stable.ColumnRow; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -public abstract class ExpandFatherPane extends JPanel implements GlobalNameObserver { - - private UIComboBox comboBox; - private ColumnRowPane customParentColumnRowPane; - private ElementCasePane ePane; - private SelectionListener gridSelectionChangeListener; - private CellSelection oldSelection; - private String expandFatherName = ""; - private GlobalNameListener globalNameListener = null; - private boolean isAlreadyAddListener = false; - private final JPanel customPane; - - public ExpandFatherPane() { - this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL)); - comboBox = new UIComboBox(new String[]{ - Inter.getLocText("FR-Designer_None"), - Inter.getLocText("FR-Designer_DEFAULT"), - Inter.getLocText("FR-Designer_Custom")}); - final CardLayout cardLayout = new CardLayout(); - customPane = new JPanel(cardLayout); - customParentColumnRowPane = new ColumnRowPane() { - - @Override - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 20); - } - - public void setGlobalName() { - if (shouldResponseNameListener()) { - globalNameListener.setGlobalName(expandFatherName); - } - } - }; - - UIButton imageButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/select.png")); - imageButton.setPreferredSize(new Dimension(24, 20)); - JPanel cc = new JPanel(new BorderLayout(LayoutConstants.HGAP_SMALL, 0)); - cc.add(customParentColumnRowPane, BorderLayout.CENTER); - cc.add(imageButton, BorderLayout.EAST); - customPane.add(cc, "content"); - customPane.add(new JPanel(), "none"); - customPane.setPreferredSize(new Dimension(0, 0) ); - this.add(comboBox, BorderLayout.NORTH); - this.add(customPane, BorderLayout.CENTER); - - comboBox.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - if(comboBox.getSelectedIndex() == 2){ - customPane.setPreferredSize(new Dimension(100, 20) ); - cardLayout.show(customPane,"content"); - }else { - cardLayout.show(customPane,"none"); - customPane.setPreferredSize(new Dimension(0, 0) ); - } -// cardLayout.show(customPane, comboBox.getSelectedIndex() == 2 ? "content" : "none"); - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(expandFatherName); - } - } - }); - imageButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - - if (ePane == null || isAlreadyAddListener) { - return; - } - oldSelection = (CellSelection) ePane.getSelection(); - ePane.getGrid().setNotShowingTableSelectPane(false); - ePane.setEditable(false); - ePane.repaint(10); - - gridSelectionChangeListener = new SelectionListener() { - - @Override - public void selectionChanged(SelectionEvent e) { - Selection selection = ePane.getSelection(); - if (selection instanceof CellSelection) { - CellSelection cellselection = (CellSelection) selection; - ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); - ePane.setOldSelecton(oldSelection); - customParentColumnRowPane.setColumnRow(cr); - } - ePane.removeSelectionChangeListener(gridSelectionChangeListener); - isAlreadyAddListener = false; - ePane.getGrid().setNotShowingTableSelectPane(true); - ePane.setEditable(true); - ePane.repaint(); - } - }; - ePane.addSelectionChangeListener(gridSelectionChangeListener); - isAlreadyAddListener = true; - } - }); - comboBox.setSelectedIndex(1); - } - - /** - * @param listener 观察者监听事件 - */ - public void registerNameListener(GlobalNameListener listener) { - globalNameListener = listener; - } - - /** - * @return - */ - public boolean shouldResponseNameListener() { - return true; - } - - protected abstract ColumnRow getColumnRow(CellExpandAttr cellExpandAttr); - - protected abstract boolean isParentDefault(CellExpandAttr cellExpandAttr); - - public void populate(CellExpandAttr cellExpandAttr) { - ColumnRow columnRow = getColumnRow(cellExpandAttr); - if (isParentDefault(cellExpandAttr)) { - comboBox.setSelectedIndex(1); - this.customParentColumnRowPane.populate(ColumnRow.valueOf(0, 0)); - } else if (ColumnRow.validate(columnRow)) { - comboBox.setSelectedIndex(2); - this.customParentColumnRowPane.populate(columnRow); - } else { - comboBox.setSelectedIndex(0); - this.customParentColumnRowPane.populate(ColumnRow.valueOf(0, 0)); - } - } - - - public void setGlobalName(String name) { - expandFatherName = name; - this.comboBox.setGlobalName(name); - } - - protected abstract void setValue(CellExpandAttr cellExpandAttr, boolean isDefault, ColumnRow columnRow); - - public void update(CellExpandAttr cellExpandAttr) { - if (cellExpandAttr == null) { - cellExpandAttr = new CellExpandAttr(); - } - int i = comboBox.getSelectedIndex(); - switch (i) { - case 1: - setValue(cellExpandAttr, true, null); - break; - case 2: - setValue(cellExpandAttr, false, this.customParentColumnRowPane.update()); - break; - default: - setValue(cellExpandAttr, false, null); - break; - } - } - - public void setElementCasePane(ElementCasePane ePane) { - this.ePane = ePane; - } - - +package com.fr.design.expand; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.event.GlobalNameListener; +import com.fr.design.event.GlobalNameObserver; +import com.fr.design.gui.columnrow.ColumnRowPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.selection.SelectionEvent; +import com.fr.design.selection.SelectionListener; +import com.fr.general.Inter; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.Selection; +import com.fr.report.cell.cellattr.CellExpandAttr; +import com.fr.stable.ColumnRow; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public abstract class ExpandFatherPane extends JPanel implements GlobalNameObserver { + + public UIComboBox comboBox; + private ColumnRowPane customParentColumnRowPane; + private ElementCasePane ePane; + private SelectionListener gridSelectionChangeListener; + private CellSelection oldSelection; + private String expandFatherName = ""; + private GlobalNameListener globalNameListener = null; + private boolean isAlreadyAddListener = false; + public JPanel customPane; + private CardLayout cardLayout; + + public ExpandFatherPane() { + this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL)); + comboBox = new UIComboBox(new String[]{ + Inter.getLocText("FR-Designer_None"), + Inter.getLocText("FR-Designer_DEFAULT"), + Inter.getLocText("FR-Designer_Custom")}); + cardLayout = new CardLayout(); + customPane = new JPanel(cardLayout); + customParentColumnRowPane = new ColumnRowPane() { + + @Override + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 20); + } + + public void setGlobalName() { + if (shouldResponseNameListener()) { + globalNameListener.setGlobalName(expandFatherName); + } + } + }; + + UIButton imageButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/select.png")); + imageButton.setPreferredSize(new Dimension(24, 20)); + JPanel cc = new JPanel(new BorderLayout(LayoutConstants.HGAP_SMALL, 0)); + cc.add(customParentColumnRowPane, BorderLayout.CENTER); + cc.add(imageButton, BorderLayout.EAST); + customPane.add(cc, "content"); + customPane.add(new JPanel(), "none"); + customPane.setPreferredSize(new Dimension(0, 0)); + this.add(comboBox, BorderLayout.NORTH); + this.add(customPane, BorderLayout.CENTER); + + comboBox.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (comboBox.getSelectedIndex() == 2) { + customPane.setPreferredSize(new Dimension(100, 20)); + cardLayout.show(customPane, "content"); + } else { + cardLayout.show(customPane, "none"); + customPane.setPreferredSize(new Dimension(0, 0)); + } +// cardLayout.show(customPane, comboBox.getSelectedIndex() == 2 ? "content" : "none"); + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(expandFatherName); + } + } + }); + imageButton.addActionListener(imageActionListener); + comboBox.setSelectedIndex(1); + } + + ItemListener comboBoxItemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (comboBox.getSelectedIndex() == 2) { + customPane.setPreferredSize(new Dimension(100, 20)); + cardLayout.show(customPane, "content"); + } else { + cardLayout.show(customPane, "none"); + customPane.setPreferredSize(new Dimension(0, 0)); + } +// cardLayout.show(customPane, comboBox.getSelectedIndex() == 2 ? "content" : "none"); + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(expandFatherName); + } + } + }; + + ActionListener imageActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (ePane == null || isAlreadyAddListener) { + return; + } + oldSelection = (CellSelection) ePane.getSelection(); + ePane.getGrid().setNotShowingTableSelectPane(false); + ePane.setEditable(false); + ePane.repaint(10); + + gridSelectionChangeListener = new SelectionListener() { + + @Override + public void selectionChanged(SelectionEvent e) { + Selection selection = ePane.getSelection(); + if (selection instanceof CellSelection) { + CellSelection cellselection = (CellSelection) selection; + ColumnRow cr = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); + ePane.setOldSelecton(oldSelection); + customParentColumnRowPane.setColumnRow(cr); + } + ePane.removeSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = false; + ePane.getGrid().setNotShowingTableSelectPane(true); + ePane.setEditable(true); + ePane.repaint(); + } + }; + ePane.addSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = true; + } + }; + + + /** + * @param listener 观察者监听事件 + */ + public void registerNameListener(GlobalNameListener listener) { + globalNameListener = listener; + } + + /** + * @return + */ + public boolean shouldResponseNameListener() { + return true; + } + + protected abstract ColumnRow getColumnRow(CellExpandAttr cellExpandAttr); + + protected abstract boolean isParentDefault(CellExpandAttr cellExpandAttr); + + public void populate(CellExpandAttr cellExpandAttr) { + ColumnRow columnRow = getColumnRow(cellExpandAttr); + if (isParentDefault(cellExpandAttr)) { + comboBox.setSelectedIndex(1); + this.customParentColumnRowPane.populate(ColumnRow.valueOf(0, 0)); + } else if (ColumnRow.validate(columnRow)) { + comboBox.setSelectedIndex(2); + this.customParentColumnRowPane.populate(columnRow); + } else { + comboBox.setSelectedIndex(0); + this.customParentColumnRowPane.populate(ColumnRow.valueOf(0, 0)); + } + } + + + public void setGlobalName(String name) { + expandFatherName = name; + this.comboBox.setGlobalName(name); + } + + protected abstract void setValue(CellExpandAttr cellExpandAttr, boolean isDefault, ColumnRow columnRow); + + public void update(CellExpandAttr cellExpandAttr) { + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + } + int i = comboBox.getSelectedIndex(); + switch (i) { + case 1: + setValue(cellExpandAttr, true, null); + break; + case 2: + setValue(cellExpandAttr, false, this.customParentColumnRowPane.update()); + break; + default: + setValue(cellExpandAttr, false, null); + break; + } + } + + public void setElementCasePane(ElementCasePane ePane) { + this.ePane = ePane; + } + + } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java b/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java index 96ca02a5e3..1e79ee5ad0 100644 --- a/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java +++ b/designer/src/com/fr/design/mainframe/CellElementPropertyPane.java @@ -101,7 +101,7 @@ public class CellElementPropertyPane extends DockingView { title.setHorizontalAlignment(SwingConstants.CENTER); title.setVerticalAlignment(SwingConstants.CENTER); titlePane.add(title, BorderLayout.CENTER); - titlePane.setBorder(BorderFactory.createEmptyBorder(0,0,1,0)); + titlePane.setBorder(BorderFactory.createEmptyBorder(10,0,1,0)); // this.add(titlePane, BorderLayout.NORTH); this.add(cellElementEditPane, BorderLayout.CENTER); diff --git a/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java b/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java index 4cf88436c2..df2cbca539 100644 --- a/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java +++ b/designer/src/com/fr/design/mainframe/CellWidgetPropertyPane.java @@ -12,6 +12,7 @@ import com.fr.form.ui.Widget; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.privilege.finegrain.WidgetPrivilegeControl; import com.fr.report.cell.DefaultTemplateCellElement; @@ -85,10 +86,9 @@ public class CellWidgetPropertyPane extends BasicPane { } - public void populate(ElementCasePane ePane) { - - + public void reInit(ElementCasePane ePane){ cellEditorDefPane = new WidgetPane(ePane); + this.removeAll(); this.add(cellEditorDefPane, BorderLayout.CENTER); CellSelection cs = (CellSelection) ePane.getSelection(); @@ -102,6 +102,11 @@ public class CellWidgetPropertyPane extends BasicPane { this.populate(editCellElement); } + public void populate(ElementCasePane ePane) { + Selection editingSelection = ePane.getSelection(); + editingSelection.populateWidgetPropertyPane(ePane); + } + public void update() { if (cellElement == null) {// 利用默认的CellElement. return; diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index a9ecc8e504..16fa43c77a 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -64,6 +64,7 @@ import com.fr.privilege.finegrain.WorkSheetPrivilegeControl; import com.fr.report.ReportHelper; import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.TemplateElementCase; +import com.fr.report.poly.PolyWorkSheet; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; @@ -109,9 +110,17 @@ public class JWorkBook extends JTemplate { @Override public void refreshEastPropertiesPane() { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); - EastRegionContainerPane.getInstance().replaceCellElementPane(getEastUpPane()); - EastRegionContainerPane.getInstance().replaceCellAttrPane(getEastDownPane()); + if (isEditingPolySheet()) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.POLY); + } else { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + EastRegionContainerPane.getInstance().replaceCellElementPane(getEastUpPane()); + EastRegionContainerPane.getInstance().replaceCellAttrPane(getEastDownPane()); + } + } + + private boolean isEditingPolySheet() { + return template.getReport(getEditingReportIndex()) instanceof PolyWorkSheet; } @Override diff --git a/designer/src/com/fr/design/mainframe/ReportFloatPane.java b/designer/src/com/fr/design/mainframe/ReportFloatPane.java index fe191f948d..85ecc85bf3 100644 --- a/designer/src/com/fr/design/mainframe/ReportFloatPane.java +++ b/designer/src/com/fr/design/mainframe/ReportFloatPane.java @@ -43,17 +43,18 @@ public class ReportFloatPane extends JPanel { topToolBar.setLayout(new BorderLayout()); insertFloatMenu = createInsertToolBar(); topToolBar.add(createButtonUI()); - topToolBar.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 0)); + UILabel emptyLabel = new UILabel(); + emptyLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = {p, f}; + double[] columnSize = {p, p, p, f}; double[] rowSize = {p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(" " + Inter.getLocText("FR-Designer_Add_FloatElement")), topToolBar}, + new Component[]{new UILabel(), new UILabel(Inter.getLocText("FR-Designer_Add_FloatElement")), emptyLabel, topToolBar}, }; JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 10)); + leftTopPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0, 13)); this.add(leftTopPane, BorderLayout.NORTH); } diff --git a/designer/src/com/fr/design/mainframe/SheetNameTabPane.java b/designer/src/com/fr/design/mainframe/SheetNameTabPane.java index 6a1997053e..173bd9cd4f 100644 --- a/designer/src/com/fr/design/mainframe/SheetNameTabPane.java +++ b/designer/src/com/fr/design/mainframe/SheetNameTabPane.java @@ -23,6 +23,7 @@ import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; @@ -553,6 +554,9 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse for (int i = scrollIndex; i <= lastOneIndex; i++) { int textWidth = widthArray[i]; if (evtX >= textX && evtX < textX + textWidth) { + if (getSelectedIndex() != i) { + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); + } setSelectedIndex(i); isBlank = false; reportComposite.setComposite(); diff --git a/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java b/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java index 8bcb0540df..f0ee3937c6 100644 --- a/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java +++ b/designer/src/com/fr/design/mainframe/cell/CellElementEditPane.java @@ -1,194 +1,207 @@ -package com.fr.design.mainframe.cell; - -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.dialog.BasicPane; -import com.fr.design.fun.CellAttributeProvider; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.gui.ibutton.UIHeadGroup; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itabpane.TitleChangeListener; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.mainframe.cell.settingpane.*; -import com.fr.design.utils.DesignUtils; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.report.cell.CellElement; -import com.fr.report.cell.DefaultTemplateCellElement; -import com.fr.report.cell.TemplateCellElement; -import com.fr.report.elementcase.TemplateElementCase; - -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - -/** - * the new 单元格属性表 !!!:只对当前选中的设置面板进行数据的populate和update操作 - * - * @author zhou - * @since 2012-5-8下午12:18:53 - */ -public class CellElementEditPane extends BasicPane { - private static int TIME_GAP = 80; - private List paneList; - private TemplateCellElement cellelement; - private ElementCasePane ePane; - private UIHeadGroup tabsHeaderIconPane; - - private boolean isEditing; - private int PaneListIndex; - private CardLayout card; - private JPanel center; - private JPanel downTitle; - private JPanel title; - private UILabel titlename; - private TitleChangeListener titleChangeListener = null; - - private CellAttributeProvider cellAttributeProvider = null; - - - public CellElementEditPane() { - setLayout(new BorderLayout()); - initPaneList(); - String[] iconArray = new String[paneList.size()]; - card = new CardLayout(); - center = new JPanel(card); - for (int i = 0; i < paneList.size(); i++) { - AbstractCellAttrPane pane = paneList.get(i); - iconArray[i] = pane.getIconPath(); - center.add(pane, pane.title4PopupWindow()); - } - - tabsHeaderIconPane = new UIHeadGroup(iconArray) { - @Override - public void tabChanged(int index) { - card.show(center, paneList.get(index).title4PopupWindow()); - paneList.get(index).populateBean(cellelement, ePane);// 设置面板变了,也要populate - paneList.get(index).addAttributeChangeListener(listener); - if (titleChangeListener != null) { - titleChangeListener.fireTitleChange(getSelectedTabName()); - } - } - }; - tabsHeaderIconPane.setNeedLeftRightOutLine(false); - - downTitle = new JPanel(); - downTitle.setLayout(new BorderLayout()); - downTitle.add(tabsHeaderIconPane, BorderLayout.NORTH); - downTitle.add(center, BorderLayout.CENTER); - - this.add(downTitle, BorderLayout.CENTER); - - } - - - public void setSelectedIndex(String... id) { - String firstid = id[0]; - for (int i = 0; i < paneList.size(); i++) { - if (ComparatorUtils.equals(firstid, paneList.get(i).title4PopupWindow())) { - tabsHeaderIconPane.setSelectedIndex(i); - if (id.length == 2) { - paneList.get(i).setSelectedByIds(1, id); - } - break; - } - } - } - - public void populate(ElementCasePane elementCasePane) { - if (isEditing) { - isEditing = false; - return; - } - if (elementCasePane == null) { - return; - } - this.ePane = elementCasePane; - Selection selection = ePane.getSelection(); - final TemplateElementCase elementCase = ePane.getEditingElementCase(); - if (elementCase != null && selection instanceof CellSelection) { - CellSelection cs = (CellSelection) selection; - // isSelectedOneCell()方法放在外面这儿一起算,因为它是比较耗时间的 - // 如果直接只传递elementCasePane,那么每个AbstratCellAttrPane都要算一次,很浪费时间 - - CellElement cellElement = elementCase.getCellElement(cs.getColumn(), cs.getRow()); - if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); - //默认选中的是A1单元格,所以若是A1单元格没有加到列表时要加上,否则在聚合报表时会出错 - if (cs.isSelectedOneCell(elementCasePane) && (cs.getColumn() + cs.getRow() == 0)) { - elementCase.addCellElement((TemplateCellElement) cellElement); - } - } - - cellelement = (TemplateCellElement) cellElement; - // 这儿只对当前选中的面板populate - paneList.get(tabsHeaderIconPane.getSelectedIndex()).populateBean(cellelement, ePane); - paneList.get(tabsHeaderIconPane.getSelectedIndex()).addAttributeChangeListener(listener); - } - } - - AttributeChangeListener listener = new AttributeChangeListener() { - @Override - public void attributeChange() { - boolean isChooseFatherPane = ComparatorUtils.equals(paneList.get(tabsHeaderIconPane.getSelectedIndex()).getGlobalName(), Inter.getLocText("FR-Designer_LeftParent")) || - ComparatorUtils.equals(paneList.get(tabsHeaderIconPane.getSelectedIndex()).getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell")); - boolean isChooseExpandPane = ComparatorUtils.equals(paneList.get(tabsHeaderIconPane.getSelectedIndex()).getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")); - if (isChooseExpandPane || isChooseFatherPane) { - ePane.setSupportDefaultParentCalculate(true); - } - - if (ePane.getSelection() instanceof CellSelection) { - isEditing = true; - if (ePane.isSelectedOneCell()) { - paneList.get(tabsHeaderIconPane.getSelectedIndex()).updateBean(); - ePane.fireTargetModified(); - } else { - paneList.get(tabsHeaderIconPane.getSelectedIndex()).updateBeans(); - ePane.fireTargetModified(); - } - } else { - DesignUtils.errorMessage(Inter.getLocText(new String[]{"FR-Designer_Not_use_a_cell_attribute_table_editing", "FR-Designer_Float_Element"}) + "!"); - } - ePane.setSupportDefaultParentCalculate(false); - } - }; - - public String getSelectedTabName() { - return paneList.get(tabsHeaderIconPane.getSelectedIndex()).title4PopupWindow(); - } - - /** - * 添加TitleChangeListener - * - * @param titleChangeListener titleChangeListener 监听 - */ - public void addTitleChangeListner(TitleChangeListener titleChangeListener) { - this.titleChangeListener = titleChangeListener; - } - - @Override - protected String title4PopupWindow() { - return Inter.getLocText("FR-Designer_CellElement_Property_Table"); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(240, 340); - } - - private void initPaneList() { - paneList = new ArrayList(); - paneList.add(new CellExpandAttrPane()); - paneList.add(new CellStylePane()); - paneList.add(new CellPresentPane()); - paneList.add(new CellOtherSetPane()); - - cellAttributeProvider = ExtraDesignClassManager.getInstance().getSingle(CellAttributeProvider.MARK_STRING); - if (cellAttributeProvider != null) { - paneList.add((AbstractCellAttrPane) cellAttributeProvider.createCellAttributePane()); - } - } - +package com.fr.design.mainframe.cell; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.CellAttributeProvider; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ibutton.UIHeadGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itabpane.TitleChangeListener; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.cell.settingpane.*; +import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.Selection; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.elementcase.TemplateElementCase; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +/** + * the new 单元格属性表 !!!:只对当前选中的设置面板进行数据的populate和update操作 + * + * @author zhou + * @since 2012-5-8下午12:18:53 + */ +public class CellElementEditPane extends BasicPane { + private static int TIME_GAP = 80; + private List paneList; + private TemplateCellElement cellelement; + private ElementCasePane ePane; + private UIHeadGroup tabsHeaderIconPane; + + private boolean isEditing; + private int PaneListIndex; + private CardLayout card; + private JPanel center; + private JPanel downTitle; + private JPanel title; + private UILabel titlename; + private TitleChangeListener titleChangeListener = null; + + private CellAttributeProvider cellAttributeProvider = null; + + + public static void main(String[] args){ + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(new BorderLayout()); + content.add(new CellElementEditPane(), BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(290, 400); + jf.setVisible(true); + } + + public CellElementEditPane() { + setLayout(new BorderLayout()); + initPaneList(); + String[] iconArray = new String[paneList.size()]; + card = new CardLayout(); + center = new JPanel(card); + for (int i = 0; i < paneList.size(); i++) { + AbstractCellAttrPane pane = paneList.get(i); + iconArray[i] = pane.getIconPath(); + center.add(pane, pane.title4PopupWindow()); + } + + tabsHeaderIconPane = new UIHeadGroup(iconArray) { + @Override + public void tabChanged(int index) { + card.show(center, paneList.get(index).title4PopupWindow()); + paneList.get(index).populateBean(cellelement, ePane);// 设置面板变了,也要populate + paneList.get(index).addAttributeChangeListener(listener); + if (titleChangeListener != null) { + titleChangeListener.fireTitleChange(getSelectedTabName()); + } + } + }; + tabsHeaderIconPane.setNeedLeftRightOutLine(false); + + downTitle = new JPanel(); + downTitle.setLayout(new BorderLayout()); + downTitle.add(tabsHeaderIconPane, BorderLayout.NORTH); + center.setBorder(BorderFactory.createEmptyBorder(0, -10, 0, -10)); + downTitle.add(center, BorderLayout.CENTER); + + this.add(downTitle, BorderLayout.CENTER); + + } + + + public void setSelectedIndex(String... id) { + String firstid = id[0]; + for (int i = 0; i < paneList.size(); i++) { + if (ComparatorUtils.equals(firstid, paneList.get(i).title4PopupWindow())) { + tabsHeaderIconPane.setSelectedIndex(i); + if (id.length == 2) { + paneList.get(i).setSelectedByIds(1, id); + } + break; + } + } + } + + public void populate(ElementCasePane elementCasePane) { + if (isEditing) { + isEditing = false; + return; + } + if (elementCasePane == null) { + return; + } + this.ePane = elementCasePane; + Selection selection = ePane.getSelection(); + final TemplateElementCase elementCase = ePane.getEditingElementCase(); + if (elementCase != null && selection instanceof CellSelection) { + CellSelection cs = (CellSelection) selection; + // isSelectedOneCell()方法放在外面这儿一起算,因为它是比较耗时间的 + // 如果直接只传递elementCasePane,那么每个AbstratCellAttrPane都要算一次,很浪费时间 + + CellElement cellElement = elementCase.getCellElement(cs.getColumn(), cs.getRow()); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); + //默认选中的是A1单元格,所以若是A1单元格没有加到列表时要加上,否则在聚合报表时会出错 + if (cs.isSelectedOneCell(elementCasePane) && (cs.getColumn() + cs.getRow() == 0)) { + elementCase.addCellElement((TemplateCellElement) cellElement); + } + } + + cellelement = (TemplateCellElement) cellElement; + // 这儿只对当前选中的面板populate + paneList.get(tabsHeaderIconPane.getSelectedIndex()).populateBean(cellelement, ePane); + paneList.get(tabsHeaderIconPane.getSelectedIndex()).addAttributeChangeListener(listener); + } + } + + AttributeChangeListener listener = new AttributeChangeListener() { + @Override + public void attributeChange() { + boolean isChooseFatherPane = ComparatorUtils.equals(paneList.get(tabsHeaderIconPane.getSelectedIndex()).getGlobalName(), Inter.getLocText("FR-Designer_LeftParent")) || + ComparatorUtils.equals(paneList.get(tabsHeaderIconPane.getSelectedIndex()).getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell")); + boolean isChooseExpandPane = ComparatorUtils.equals(paneList.get(tabsHeaderIconPane.getSelectedIndex()).getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")); + if (isChooseExpandPane || isChooseFatherPane) { + ePane.setSupportDefaultParentCalculate(true); + } + + if (ePane.getSelection() instanceof CellSelection) { + isEditing = true; + if (ePane.isSelectedOneCell()) { + paneList.get(tabsHeaderIconPane.getSelectedIndex()).updateBean(); + ePane.fireTargetModified(); + } else { + paneList.get(tabsHeaderIconPane.getSelectedIndex()).updateBeans(); + ePane.fireTargetModified(); + } + } else { + DesignUtils.errorMessage(Inter.getLocText(new String[]{"FR-Designer_Not_use_a_cell_attribute_table_editing", "FR-Designer_Float_Element"}) + "!"); + } + ePane.setSupportDefaultParentCalculate(false); + } + }; + + public String getSelectedTabName() { + return paneList.get(tabsHeaderIconPane.getSelectedIndex()).title4PopupWindow(); + } + + /** + * 添加TitleChangeListener + * + * @param titleChangeListener titleChangeListener 监听 + */ + public void addTitleChangeListner(TitleChangeListener titleChangeListener) { + this.titleChangeListener = titleChangeListener; + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_CellElement_Property_Table"); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(240, 340); + } + + private void initPaneList() { + paneList = new ArrayList(); + paneList.add(new CellExpandAttrPane()); + paneList.add(new CellStylePane()); + paneList.add(new CellPresentPane()); + paneList.add(new CellOtherSetPane()); + + cellAttributeProvider = ExtraDesignClassManager.getInstance().getSingle(CellAttributeProvider.MARK_STRING); + if (cellAttributeProvider != null) { + paneList.add((AbstractCellAttrPane) cellAttributeProvider.createCellAttributePane()); + } + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 9de87e092c..2f0398701b 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -1,242 +1,253 @@ -package com.fr.design.mainframe.cell.settingpane; - -import com.fr.base.BaseUtils; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.expand.ExpandLeftFatherPane; -import com.fr.design.expand.ExpandUpFatherPane; -import com.fr.design.expand.SortExpandAttrPane; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.foldablepane.UIExpandablePane; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.report.cell.DefaultTemplateCellElement; -import com.fr.report.cell.TemplateCellElement; -import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.report.elementcase.TemplateElementCase; -import com.fr.stable.Constants; - -import javax.swing.*; -import java.awt.*; - -/** - * 单元格扩展属性面板,是属性表面板的一个种类 - */ -public class CellExpandAttrPane extends AbstractCellAttrPane { - private UIButtonGroup expandDirectionButton; - private ExpandLeftFatherPane leftFatherPane; - private ExpandUpFatherPane rightFatherPane; - private UICheckBox horizontalExpandableCheckBox; - private UICheckBox verticalExpandableCheckBox; - private SortExpandAttrPane sortAfterExpand; - private JPanel layoutPane; - private JPanel basicPane; - private JPanel seniorPane; - - /** - * - * @return - */ - public JPanel createContentPane() { - String[] nameArray = {Inter.getLocText("ExpandD-Not_Expand"), Inter.getLocText("Utils-Top_to_Bottom"), Inter.getLocText("Utils-Left_to_Right")}; - Icon[] iconArray = { - BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), - BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png"), - BaseUtils.readIcon("/com/fr/design/images/expand/landspace.png") - }; - Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT}; - expandDirectionButton = new UIButtonGroup(iconArray, valueArray); - expandDirectionButton.setAllToolTips(nameArray); - leftFatherPane = new ExpandLeftFatherPane(); - rightFatherPane = new ExpandUpFatherPane(); - horizontalExpandableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable")); - verticalExpandableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable")); - sortAfterExpand = new SortExpandAttrPane(); - initAllNames(); - return layoutPane(); - } - - - public static void main(String[] args){ -// JFrame jf = new JFrame("test"); -// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -// JPanel content = (JPanel) jf.getContentPane(); -// content.setLayout(new BorderLayout()); -// content.add(new CellExpandAttrPane().layoutPane(), BorderLayout.CENTER); -// GUICoreUtils.centerWindow(jf); -// jf.setSize(290, 400); -// jf.setVisible(true); - } - - private void initAllNames() { - expandDirectionButton.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")); - leftFatherPane.setGlobalName(Inter.getLocText("FR-Designer_LeftParent")); - rightFatherPane.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell")); - horizontalExpandableCheckBox.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expandable")); - verticalExpandableCheckBox.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expandable")); - } - - private JPanel layoutPane() { - layoutPane = new JPanel(new BorderLayout()); - basicPane = new JPanel(); - seniorPane = new JPanel(); - basicPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"),290,24,basicPane()); - seniorPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"),290,24,seniorPane()); - layoutPane.add(basicPane,BorderLayout.NORTH); - layoutPane.add(seniorPane,BorderLayout.CENTER); - return layoutPane; - } - - private JPanel basicPane(){ - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")+" ", SwingConstants.LEFT), expandDirectionButton}, - new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_LeftParent"), SwingConstants.LEFT), leftFatherPane}, - new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell"), SwingConstants.LEFT), rightFatherPane}, - }; - double[] rowSize = {p, p, p, p, p, p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1},{1, 1}, {1, 3}, {1, 3}}; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); - } - - private JPanel seniorPane() { - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{horizontalExpandableCheckBox, null}, - new Component[]{verticalExpandableCheckBox, null}, - new Component[]{new UILabel(" "+Inter.getLocText("FR-Designer_ExpendSort"), SwingConstants.RIGHT), sortAfterExpand}, - }; - double[] rowSize = {p, p, p, p, p, p, p, p}; - double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 3}, {1, 3}}; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); - } - - - - @Override - protected void populateBean() { - this.leftFatherPane.setElementCasePane(elementCasePane); - this.rightFatherPane.setElementCasePane(elementCasePane); - CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (cellExpandAttr == null) { - cellExpandAttr = new CellExpandAttr(); - cellElement.setCellExpandAttr(cellExpandAttr); - } - expandDirectionButton.setSelectedItem(cellExpandAttr.getDirection()); - this.leftFatherPane.populate(cellExpandAttr); - this.rightFatherPane.populate(cellExpandAttr); - switch (cellExpandAttr.getExtendable()) { - case CellExpandAttr.Both_EXTENDABLE: - horizontalExpandableCheckBox.setSelected(true); - verticalExpandableCheckBox.setSelected(true); - break; - case CellExpandAttr.Vertical_EXTENDABLE: - horizontalExpandableCheckBox.setSelected(false); - verticalExpandableCheckBox.setSelected(true); - break; - case CellExpandAttr.Horizontal_EXTENDABLE: - horizontalExpandableCheckBox.setSelected(true); - verticalExpandableCheckBox.setSelected(false); - break; - default: { - horizontalExpandableCheckBox.setSelected(false); - verticalExpandableCheckBox.setSelected(false); - } - } - - sortAfterExpand.populate(cellExpandAttr); - } - - - @Override - public String getIconPath() { -// return "com/fr/design/images/expand/cellAttr.gif"; - return Inter.getLocText("FR-Designer_Expand"); - } - - - @Override - public void updateBean(TemplateCellElement cellElement) { - CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); - if (cellExpandAttr == null) { - cellExpandAttr = new CellExpandAttr(); - cellElement.setCellExpandAttr(cellExpandAttr); - } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Expand_Direction"))) { - cellExpandAttr.setDirection(expandDirectionButton.getSelectedItem()); - } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_LeftParent"))) { - this.leftFatherPane.update(cellExpandAttr); - } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell"))) { - this.rightFatherPane.update(cellExpandAttr); - } - - - // extendable - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD-Expandable"))) { - if (horizontalExpandableCheckBox.isSelected()) { - if (verticalExpandableCheckBox.isSelected()) { - cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); - } else { - cellExpandAttr.setExtendable(CellExpandAttr.Horizontal_EXTENDABLE); - } - } else { - if (verticalExpandableCheckBox.isSelected()) { - cellExpandAttr.setExtendable(CellExpandAttr.Vertical_EXTENDABLE); - } else { - cellExpandAttr.setExtendable(CellExpandAttr.None_EXTENDABLE); - } - } - } - - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("ExpandD-Sort_After_Expand"))) { - sortAfterExpand.update(cellExpandAttr); - } - - } - - /** - * - */ - public void updateBeans() { - TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - // 需要先行后列地增加新元素。 - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); - elementCase.addCellElement(cellElement); - } - updateBean(cellElement); - } - } - } - } - - /** - * - * @return - */ - public String title4PopupWindow() { - return Inter.getLocText("ExpandD-Expand_Attribute"); - } - - +package com.fr.design.mainframe.cell.settingpane; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.expand.ExpandLeftFatherPane; +import com.fr.design.expand.ExpandUpFatherPane; +import com.fr.design.expand.SortExpandAttrPane; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellExpandAttr; +import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.Constants; + +import javax.swing.*; +import java.awt.*; + +/** + * 单元格扩展属性面板,是属性表面板的一个种类 + */ +public class CellExpandAttrPane extends AbstractCellAttrPane { + private static final int SENIOR_HORIZONTAL_GAP = 12; + private static final int BASIC_HORIZONTAL_GAP = 20; + private UIButtonGroup expandDirectionButton; + private ExpandLeftFatherPane leftFatherPane; + private ExpandUpFatherPane rightFatherPane; + private UICheckBox horizontalExpandableCheckBox; + private UICheckBox verticalExpandableCheckBox; + private SortExpandAttrPane sortAfterExpand; + private JPanel layoutPane; + private JPanel basicPane; + private JPanel seniorPane; + + /** + * @return + */ + public JPanel createContentPane() { + String[] nameArray = {Inter.getLocText("ExpandD-Not_Expand"), Inter.getLocText("Utils-Top_to_Bottom"), Inter.getLocText("Utils-Left_to_Right")}; + Icon[] iconArray = { + BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), + BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png"), + BaseUtils.readIcon("/com/fr/design/images/expand/landspace.png") + }; + Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT}; + expandDirectionButton = new UIButtonGroup(iconArray, valueArray); + expandDirectionButton.setAllToolTips(nameArray); + leftFatherPane = new ExpandLeftFatherPane(); + rightFatherPane = new ExpandUpFatherPane(); + horizontalExpandableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable")); + verticalExpandableCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable")); + sortAfterExpand = new SortExpandAttrPane(); + initAllNames(); + return layoutPane(); + } + + + public static void main(String[] args) { + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(new BorderLayout()); + content.add(new CellExpandAttrPane().layoutPane(), BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(290, 400); + jf.setVisible(true); + } + + private void initAllNames() { + expandDirectionButton.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction")); + leftFatherPane.setGlobalName(Inter.getLocText("FR-Designer_LeftParent")); + rightFatherPane.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell")); + horizontalExpandableCheckBox.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expandable")); + verticalExpandableCheckBox.setGlobalName(Inter.getLocText("FR-Designer_ExpandD_Expandable")); + } + + private JPanel layoutPane() { + layoutPane = new JPanel(new BorderLayout()); + basicPane = new JPanel(); + seniorPane = new JPanel(); + basicPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), 290, 24, basicPane()); + seniorPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 290, 24, seniorPane()); + layoutPane.add(basicPane, BorderLayout.NORTH); + layoutPane.add(seniorPane, BorderLayout.CENTER); + return layoutPane; + } + + private JPanel basicPane() { + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + UILabel direction = new UILabel(Inter.getLocText("FR-Designer_ExpandD_Expand_Direction"), SwingConstants.LEFT); +// JPanel directionPane = new JPanel(new BorderLayout()); +// directionPane.add(direction, BorderLayout.NORTH); + UILabel left = new UILabel(Inter.getLocText("FR-Designer_LeftParent"), SwingConstants.LEFT); + JPanel leftPane = new JPanel(new BorderLayout()); + leftPane.add(left, BorderLayout.NORTH); + UILabel up = new UILabel(Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell"), SwingConstants.LEFT); + JPanel upPane = new JPanel(new BorderLayout()); + upPane.add(up, BorderLayout.NORTH); + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{direction, expandDirectionButton}, + new Component[]{leftPane, leftFatherPane}, + new Component[]{upPane, rightFatherPane}, + }; + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, BASIC_HORIZONTAL_GAP, LayoutConstants.VGAP_LARGE); + } + + private JPanel seniorPane() { + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + UILabel expendSort = new UILabel(Inter.getLocText("FR-Designer_ExpendSort"), SwingConstants.LEFT); + JPanel expendSortPane = new JPanel(new BorderLayout()); + expendSortPane.add(expendSort, BorderLayout.NORTH); + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{horizontalExpandableCheckBox, null}, + new Component[]{verticalExpandableCheckBox, null}, + new Component[]{expendSortPane, sortAfterExpand}, + }; + double[] rowSize = {p, p, p, p, p, p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 3}, {1, 3}}; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, SENIOR_HORIZONTAL_GAP, LayoutConstants.VGAP_LARGE); + } + + + @Override + protected void populateBean() { + this.leftFatherPane.setElementCasePane(elementCasePane); + this.rightFatherPane.setElementCasePane(elementCasePane); + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + expandDirectionButton.setSelectedItem(cellExpandAttr.getDirection()); + this.leftFatherPane.populate(cellExpandAttr); + this.rightFatherPane.populate(cellExpandAttr); + switch (cellExpandAttr.getExtendable()) { + case CellExpandAttr.Both_EXTENDABLE: + horizontalExpandableCheckBox.setSelected(true); + verticalExpandableCheckBox.setSelected(true); + break; + case CellExpandAttr.Vertical_EXTENDABLE: + horizontalExpandableCheckBox.setSelected(false); + verticalExpandableCheckBox.setSelected(true); + break; + case CellExpandAttr.Horizontal_EXTENDABLE: + horizontalExpandableCheckBox.setSelected(true); + verticalExpandableCheckBox.setSelected(false); + break; + default: { + horizontalExpandableCheckBox.setSelected(false); + verticalExpandableCheckBox.setSelected(false); + } + } + + sortAfterExpand.populate(cellExpandAttr); + } + + + @Override + public String getIconPath() { +// return "com/fr/design/images/expand/cellAttr.gif"; + return Inter.getLocText("FR-Designer_Expand"); + } + + + @Override + public void updateBean(TemplateCellElement cellElement) { + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr == null) { + cellExpandAttr = new CellExpandAttr(); + cellElement.setCellExpandAttr(cellExpandAttr); + } + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Expand_Direction"))) { + cellExpandAttr.setDirection(expandDirectionButton.getSelectedItem()); + } + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_LeftParent"))) { + this.leftFatherPane.update(cellExpandAttr); + } + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD_Up_Father_Cell"))) { + this.rightFatherPane.update(cellExpandAttr); + } + + + // extendable + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_ExpandD-Expandable"))) { + if (horizontalExpandableCheckBox.isSelected()) { + if (verticalExpandableCheckBox.isSelected()) { + cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); + } else { + cellExpandAttr.setExtendable(CellExpandAttr.Horizontal_EXTENDABLE); + } + } else { + if (verticalExpandableCheckBox.isSelected()) { + cellExpandAttr.setExtendable(CellExpandAttr.Vertical_EXTENDABLE); + } else { + cellExpandAttr.setExtendable(CellExpandAttr.None_EXTENDABLE); + } + } + } + + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("ExpandD-Sort_After_Expand"))) { + sortAfterExpand.update(cellExpandAttr); + } + + } + + /** + * + */ + public void updateBeans() { + TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + int cellRectangleCount = cs.getCellRectangleCount(); + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + // 需要先行后列地增加新元素。 + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + elementCase.addCellElement(cellElement); + } + updateBean(cellElement); + } + } + } + } + + /** + * @return + */ + public String title4PopupWindow() { + return Inter.getLocText("ExpandD-Expand_Attribute"); + } + + } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index ce03519315..be997ae0b5 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -1,130 +1,130 @@ -package com.fr.design.mainframe.cell.settingpane; - -import java.awt.*; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import com.fr.base.Style; -import com.fr.design.mainframe.cell.settingpane.style.StylePane; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.Inter; -import com.fr.report.cell.DefaultTemplateCellElement; -import com.fr.report.cell.TemplateCellElement; -import com.fr.report.elementcase.TemplateElementCase; - -/** - * @author zhou - * @since 2012-5-11下午3:59:39 - */ -public class CellStylePane extends AbstractCellAttrPane { - private StylePane stylePane; - - @Override - public JPanel createContentPane() { - JPanel content = new JPanel(new BorderLayout()); - stylePane = new StylePane(); - content.add(stylePane, BorderLayout.CENTER); - stylePane.addPredefinedChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - attributeChanged(); - } - }); - stylePane.addCustomTabChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - adjustValues();// 里面的Tab切换后要及时调整滚动条,因为一些界面可能不需要滚动条 - } - }); - return content; - } - - public static void main(String[] args){ -// JFrame jf = new JFrame("test"); -// jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -// JPanel content = (JPanel) jf.getContentPane(); -// content.setLayout(new BorderLayout()); -// content.add(new CellStylePane().createContentPane(), BorderLayout.CENTER); -// GUICoreUtils.centerWindow(jf); -// jf.setSize(290, 400); -// jf.setVisible(true); - } - - @Override - public String getIconPath() { -// return "com/fr/design/images/m_format/cell.png"; - return Inter.getLocText("FR-Designer_Style"); - } - - - @Override - public void updateBean(TemplateCellElement cellElement) { - cellElement.setStyle(stylePane.updateBean()); - } - - @Override - public void updateBeans() { - if (stylePane.getSelectedIndex() == 1) { - Style s = stylePane.updateBean(); - TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); - elementCase.addCellElement(cellElement); - } - cellElement.setStyle(s); - } - } - } - } else { - TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); - elementCase.addCellElement(cellElement); - } - Style style = cellElement.getStyle(); - if (style == null) { - style = style.DEFAULT_STYLE; - } - style = stylePane.updateStyle(style); - cellElement.setStyle(style); - } - } - } - stylePane.updateBorder();// border必须特别处理 - } - } - - @Override - protected void populateBean() { - stylePane.populateBean(cellElement.getStyle()); - stylePane.dealWithBorder(elementCasePane); - } - - @Override - public String title4PopupWindow() { - return Inter.getLocText(Inter.getLocText("FR-Designer_Style")); - } - - public void setSelectedByIds(int level, String... id) { - stylePane.setSelctedByName(id[level]); - } - +package com.fr.design.mainframe.cell.settingpane; + +import com.fr.base.Style; +import com.fr.design.mainframe.cell.settingpane.style.StylePane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.elementcase.TemplateElementCase; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * @author zhou + * @since 2012-5-11下午3:59:39 + */ +public class CellStylePane extends AbstractCellAttrPane { + private StylePane stylePane; + + @Override + public JPanel createContentPane() { + JPanel content = new JPanel(new BorderLayout()); + stylePane = new StylePane(); + content.add(stylePane, BorderLayout.CENTER); + stylePane.addPredefinedChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + attributeChanged(); + } + }); + stylePane.addCustomTabChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + adjustValues();// 里面的Tab切换后要及时调整滚动条,因为一些界面可能不需要滚动条 + } + }); +// content.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); + return content; + } + + public static void main(String[] args) { + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(new BorderLayout()); + content.add(new CellStylePane().createContentPane(), BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(290, 400); + jf.setVisible(true); + } + + @Override + public String getIconPath() { +// return "com/fr/design/images/m_format/cell.png"; + return Inter.getLocText("FR-Designer_Style"); + } + + + @Override + public void updateBean(TemplateCellElement cellElement) { + cellElement.setStyle(stylePane.updateBean()); + } + + @Override + public void updateBeans() { + if (stylePane.getSelectedIndex() == 1) { + Style s = stylePane.updateBean(); + TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + int cellRectangleCount = cs.getCellRectangleCount(); + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + elementCase.addCellElement(cellElement); + } + cellElement.setStyle(s); + } + } + } + } else { + TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + int cellRectangleCount = cs.getCellRectangleCount(); + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + elementCase.addCellElement(cellElement); + } + Style style = cellElement.getStyle(); + if (style == null) { + style = style.DEFAULT_STYLE; + } + style = stylePane.updateStyle(style); + cellElement.setStyle(style); + } + } + } + stylePane.updateBorder();// border必须特别处理 + } + } + + @Override + protected void populateBean() { + stylePane.populateBean(cellElement.getStyle()); + stylePane.dealWithBorder(elementCasePane); + } + + @Override + public String title4PopupWindow() { + return Inter.getLocText(Inter.getLocText("FR-Designer_Style")); + } + + public void setSelectedByIds(int level, String... id) { + stylePane.setSelctedByName(id[level]); + } + } \ No newline at end of file diff --git a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index 019417c098..ecc22aae72 100644 --- a/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer/src/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -1,170 +1,170 @@ -package com.fr.design.mainframe.cell.settingpane.style; - -import com.fr.base.CellBorderStyle; -import com.fr.base.NameStyle; -import com.fr.base.Style; -import com.fr.design.actions.utils.ReportActionUtils; -import com.fr.design.dialog.BasicPane; -import com.fr.design.dialog.MultiTabPane; -import com.fr.design.gui.ibutton.FiveButtonLayout; -import com.fr.design.gui.style.*; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.style.BorderUtils; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.Inter; -import com.fr.stable.Constants; - -import javax.swing.*; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - - -/** - * 哎,复杂的原型图导致复杂的画法。非我所愿也 - * - * @author zhou - * @since 2012-5-24上午10:36:10 - */ -public class CustomStylePane extends MultiTabPane