forked from fanruan/design
Browse Source
* commit 'd48d3ec615d148c0e15f48bf50c9a09fc8ffddf1': REPORT-2897 9.0设计器修改 去掉空格,放个空的uilabel做对齐 REPORT-2897 9.0设计器修改 视觉微调 REPORT-2897 9.0设计器修改 去掉空格,放个空的uilabel做对齐 REPORT-2897 9.0设计器修改 去掉空格,放个空的uilabel做对齐 REPORT-2897 9.0设计器修改 视觉优化master
kerry
7 years ago
25 changed files with 3672 additions and 3634 deletions
@ -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; |
||||
} |
||||
|
||||
|
||||
} |
@ -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<AbstractCellAttrPane> 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<AbstractCellAttrPane>(); |
||||
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<AbstractCellAttrPane> 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<AbstractCellAttrPane>(); |
||||
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()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -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<Byte> 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<Byte>(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<Byte> 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<Byte>(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"); |
||||
} |
||||
|
||||
|
||||
} |
@ -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]); |
||||
} |
||||
|
||||
} |
@ -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<Style> { |
||||
private static final int LENGTH_FOUR = 4; |
||||
private static final int THREE_INDEX = 3; |
||||
private static final int TWO_INDEX = 2; |
||||
private static final int ONE_INDEX = 1; |
||||
private String[] NameArray; |
||||
private ElementCasePane reportPane; |
||||
private BackgroundPane backgroundPane = null; |
||||
|
||||
|
||||
public CustomStylePane() { |
||||
super(); |
||||
tabPane.setOneLineTab(true); |
||||
tabPane.setLayout(new FiveButtonLayout(1)); |
||||
} |
||||
|
||||
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 CustomStylePane(), BorderLayout.CENTER); |
||||
GUICoreUtils.centerWindow(jf); |
||||
jf.setSize(290, 400); |
||||
jf.setVisible(true); |
||||
} |
||||
|
||||
/** |
||||
* @return |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText(new String[]{"Custom", "Style"}); |
||||
} |
||||
|
||||
/** |
||||
* for ScrollBar |
||||
* |
||||
* @param l |
||||
*/ |
||||
public void addTabChangeListener(ChangeListener l) { |
||||
if (tabPane != null) { |
||||
tabPane.addChangeListener(l); |
||||
} |
||||
if (backgroundPane != null) { |
||||
backgroundPane.addChangeListener(l); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public void reset() { |
||||
populateBean(null); |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* |
||||
*/ |
||||
public void populateBean(Style ob) { |
||||
for (int i = 0; i < paneList.size(); i++) { |
||||
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* |
||||
*/ |
||||
public Style updateBean() { |
||||
return updateStyle(ReportActionUtils.getCurrentStyle(reportPane)); |
||||
} |
||||
|
||||
/** |
||||
* @param style |
||||
* @return |
||||
*/ |
||||
public Style updateStyle(Style style) { |
||||
return ((AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex())).update(style);//只更新当前选中面板的样式
|
||||
} |
||||
|
||||
|
||||
public boolean isBorderPaneSelected() { |
||||
return tabPane.getSelectedIndex() == TWO_INDEX; |
||||
} |
||||
|
||||
/** |
||||
* @param ePane |
||||
*/ |
||||
public void dealWithBorder(ElementCasePane ePane) { |
||||
this.reportPane = ePane; |
||||
Object[] fourObjectArray = BorderUtils.createCellBorderObject(reportPane); |
||||
|
||||
if (fourObjectArray != null && fourObjectArray.length % LENGTH_FOUR == 0) { |
||||
if (fourObjectArray.length == LENGTH_FOUR) { |
||||
((BorderPane) paneList.get(ONE_INDEX)).populateBean((CellBorderStyle) fourObjectArray[0], ((Boolean) fourObjectArray[1]).booleanValue(), ((Integer) fourObjectArray[2]).intValue(), |
||||
(Color) fourObjectArray[THREE_INDEX]); |
||||
} else { |
||||
((BorderPane) paneList.get(ONE_INDEX)).populateBean(new CellBorderStyle(), Boolean.TRUE, Constants.LINE_NONE, |
||||
(Color) fourObjectArray[THREE_INDEX]); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public void updateBorder() { |
||||
BorderUtils.update(reportPane, ((BorderPane) paneList.get(TWO_INDEX)).update()); |
||||
} |
||||
|
||||
/** |
||||
* @param ob |
||||
* @return |
||||
*/ |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof Style && !(ob instanceof NameStyle); |
||||
} |
||||
|
||||
@Override |
||||
protected List<BasicPane> initPaneList() { |
||||
paneList = new ArrayList<BasicPane>(); |
||||
paneList.add(new FormatPane()); |
||||
paneList.add(new BorderPane()); |
||||
paneList.add(new AlignmentPane()); |
||||
// paneList.add(new FRFontPane());
|
||||
// paneList.add(backgroundPane = new BackgroundPane());
|
||||
return paneList; |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* |
||||
*/ |
||||
public void updateBean(Style ob) { |
||||
|
||||
} |
||||
|
||||
|
||||
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<Style> { |
||||
private static final int LENGTH_FOUR = 4; |
||||
private static final int THREE_INDEX = 3; |
||||
private static final int TWO_INDEX = 2; |
||||
private static final int ONE_INDEX = 1; |
||||
private String[] NameArray; |
||||
private ElementCasePane reportPane; |
||||
private BackgroundPane backgroundPane = null; |
||||
|
||||
|
||||
public CustomStylePane() { |
||||
super(); |
||||
tabPane.setOneLineTab(true); |
||||
tabPane.setLayout(new FiveButtonLayout(1)); |
||||
} |
||||
|
||||
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 CustomStylePane(), BorderLayout.CENTER); |
||||
GUICoreUtils.centerWindow(jf); |
||||
jf.setSize(250, 400); |
||||
jf.setVisible(true); |
||||
} |
||||
|
||||
/** |
||||
* @return |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText(new String[]{"Custom", "Style"}); |
||||
} |
||||
|
||||
/** |
||||
* for ScrollBar |
||||
* |
||||
* @param l |
||||
*/ |
||||
public void addTabChangeListener(ChangeListener l) { |
||||
if (tabPane != null) { |
||||
tabPane.addChangeListener(l); |
||||
} |
||||
if (backgroundPane != null) { |
||||
backgroundPane.addChangeListener(l); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public void reset() { |
||||
populateBean(null); |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* |
||||
*/ |
||||
public void populateBean(Style ob) { |
||||
for (int i = 0; i < paneList.size(); i++) { |
||||
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* |
||||
*/ |
||||
public Style updateBean() { |
||||
return updateStyle(ReportActionUtils.getCurrentStyle(reportPane)); |
||||
} |
||||
|
||||
/** |
||||
* @param style |
||||
* @return |
||||
*/ |
||||
public Style updateStyle(Style style) { |
||||
return ((AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex())).update(style);//只更新当前选中面板的样式
|
||||
} |
||||
|
||||
|
||||
public boolean isBorderPaneSelected() { |
||||
return tabPane.getSelectedIndex() == TWO_INDEX; |
||||
} |
||||
|
||||
/** |
||||
* @param ePane |
||||
*/ |
||||
public void dealWithBorder(ElementCasePane ePane) { |
||||
this.reportPane = ePane; |
||||
Object[] fourObjectArray = BorderUtils.createCellBorderObject(reportPane); |
||||
|
||||
if (fourObjectArray != null && fourObjectArray.length % LENGTH_FOUR == 0) { |
||||
if (fourObjectArray.length == LENGTH_FOUR) { |
||||
((BorderPane) paneList.get(ONE_INDEX)).populateBean((CellBorderStyle) fourObjectArray[0], ((Boolean) fourObjectArray[1]).booleanValue(), ((Integer) fourObjectArray[2]).intValue(), |
||||
(Color) fourObjectArray[THREE_INDEX]); |
||||
} else { |
||||
((BorderPane) paneList.get(ONE_INDEX)).populateBean(new CellBorderStyle(), Boolean.TRUE, Constants.LINE_NONE, |
||||
(Color) fourObjectArray[THREE_INDEX]); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public void updateBorder() { |
||||
BorderUtils.update(reportPane, ((BorderPane) paneList.get(TWO_INDEX)).update()); |
||||
} |
||||
|
||||
/** |
||||
* @param ob |
||||
* @return |
||||
*/ |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof Style && !(ob instanceof NameStyle); |
||||
} |
||||
|
||||
@Override |
||||
protected List<BasicPane> initPaneList() { |
||||
paneList = new ArrayList<BasicPane>(); |
||||
paneList.add(new FormatPane()); |
||||
paneList.add(new BorderPane()); |
||||
paneList.add(new AlignmentPane()); |
||||
// paneList.add(new FRFontPane());
|
||||
// paneList.add(backgroundPane = new BackgroundPane());
|
||||
return paneList; |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* |
||||
*/ |
||||
public void updateBean(Style ob) { |
||||
|
||||
} |
||||
|
||||
|
||||
} |
@ -1,155 +1,157 @@
|
||||
package com.fr.design.mainframe.cell.settingpane.style; |
||||
|
||||
import com.fr.base.ConfigManager; |
||||
import com.fr.base.NameStyle; |
||||
import com.fr.base.ScreenResolution; |
||||
import com.fr.base.Style; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.DesignerBean; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.*; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.Iterator; |
||||
|
||||
public class PredefinedStylePane extends FurtherBasicBeanPane<NameStyle> implements DesignerBean { |
||||
|
||||
private DefaultListModel defaultListModel; |
||||
private JList styleList; |
||||
private ChangeListener changeListener; |
||||
|
||||
public PredefinedStylePane() { |
||||
defaultListModel = new DefaultListModel(); |
||||
styleList = new JList(defaultListModel); |
||||
DefaultListCellRenderer render = new DefaultListCellRenderer() { |
||||
private Style nameStyle; |
||||
|
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
|
||||
if (value instanceof Style) { |
||||
this.nameStyle = (Style) value; |
||||
this.setText(" "); |
||||
} |
||||
this.setPreferredSize(new Dimension(210, 22)); |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
|
||||
if (nameStyle == null) { |
||||
return; |
||||
} |
||||
String text = "abcedfgh"; |
||||
if (nameStyle instanceof NameStyle) { |
||||
text = ((NameStyle) nameStyle).getName(); |
||||
} |
||||
Style.paintBackground((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1); |
||||
Style.paintContent((Graphics2D) g, text, nameStyle, getWidth() - 1, getHeight() - 1, ScreenResolution.getScreenResolution()); |
||||
Style.paintBorder((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1); |
||||
} |
||||
|
||||
}; |
||||
styleList.setCellRenderer(render); |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.add(styleList, BorderLayout.CENTER); |
||||
|
||||
styleList.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
int clickedNumber = e.getClickCount(); |
||||
if (clickedNumber == 1) { |
||||
if (changeListener != null) { |
||||
changeListener.stateChanged(new ChangeEvent(styleList)); |
||||
} |
||||
} |
||||
// 如果点击次数大于2认为发生双击,弹出编辑界面
|
||||
// if (clickedNumber >= 2) {
|
||||
// }
|
||||
} |
||||
}); |
||||
|
||||
DesignerContext.setDesignerBean("predefinedStyle", this); |
||||
} |
||||
|
||||
/** |
||||
* 添加改变监听 |
||||
* |
||||
* @param changeListener 监听事件 |
||||
*/ |
||||
public void addChangeListener(ChangeListener changeListener) { |
||||
this.changeListener = changeListener; |
||||
} |
||||
|
||||
/** |
||||
* 重置 |
||||
*/ |
||||
public void reset() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(NameStyle ob) { |
||||
refreshBeanElement(); |
||||
for (int i = 0; i < defaultListModel.getSize(); i++) { |
||||
if (ComparatorUtils.equals(ob, defaultListModel.get(i))) { |
||||
styleList.setSelectedIndex(i); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public NameStyle updateBean() { |
||||
return (NameStyle) styleList.getSelectedValue(); |
||||
} |
||||
|
||||
/** |
||||
* 获取面板标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText(new String[]{"PageSetup-Predefined", "Style"}); |
||||
} |
||||
|
||||
/** |
||||
* 是否可以接纳对象 |
||||
* |
||||
* @param ob 组件对象 |
||||
* @return 是否可以接纳对象 |
||||
*/ |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof NameStyle; |
||||
} |
||||
|
||||
/** |
||||
* 刷新组件对象 |
||||
*/ |
||||
public void refreshBeanElement() { |
||||
defaultListModel.removeAllElements(); |
||||
if (ConfigManager.getProviderInstance().hasStyle()) { |
||||
Iterator iterato = ConfigManager.getProviderInstance().getStyleNameIterator(); |
||||
while (iterato.hasNext()) { |
||||
String name = (String) iterato.next(); |
||||
NameStyle nameStyle = NameStyle.getInstance(name); |
||||
defaultListModel.addElement(nameStyle); |
||||
} |
||||
} |
||||
styleList.setModel(defaultListModel); |
||||
GUICoreUtils.repaint(this); |
||||
|
||||
} |
||||
|
||||
package com.fr.design.mainframe.cell.settingpane.style; |
||||
|
||||
import com.fr.base.ConfigManager; |
||||
import com.fr.base.NameStyle; |
||||
import com.fr.base.ScreenResolution; |
||||
import com.fr.base.Style; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.DesignerBean; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
import java.awt.*; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.Iterator; |
||||
|
||||
public class PredefinedStylePane extends FurtherBasicBeanPane<NameStyle> implements DesignerBean { |
||||
|
||||
private DefaultListModel defaultListModel; |
||||
private JList styleList; |
||||
private ChangeListener changeListener; |
||||
|
||||
public PredefinedStylePane() { |
||||
defaultListModel = new DefaultListModel(); |
||||
styleList = new JList(defaultListModel); |
||||
DefaultListCellRenderer render = new DefaultListCellRenderer() { |
||||
private Style nameStyle; |
||||
|
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
|
||||
if (value instanceof Style) { |
||||
this.nameStyle = (Style) value; |
||||
this.setText(" "); |
||||
} |
||||
this.setPreferredSize(new Dimension(210, 22)); |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
|
||||
if (nameStyle == null) { |
||||
return; |
||||
} |
||||
String text = "abcedfgh"; |
||||
if (nameStyle instanceof NameStyle) { |
||||
text = ((NameStyle) nameStyle).getName(); |
||||
} |
||||
Style.paintBackground((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1); |
||||
Style.paintContent((Graphics2D) g, text, nameStyle, getWidth() - 1, getHeight() - 1, ScreenResolution.getScreenResolution()); |
||||
Style.paintBorder((Graphics2D) g, nameStyle, getWidth() - 1, getHeight() - 1); |
||||
} |
||||
|
||||
}; |
||||
styleList.setCellRenderer(render); |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.add(styleList, BorderLayout.CENTER); |
||||
this.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); |
||||
|
||||
styleList.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
int clickedNumber = e.getClickCount(); |
||||
if (clickedNumber == 1) { |
||||
if (changeListener != null) { |
||||
changeListener.stateChanged(new ChangeEvent(styleList)); |
||||
} |
||||
} |
||||
// 如果点击次数大于2认为发生双击,弹出编辑界面
|
||||
// if (clickedNumber >= 2) {
|
||||
// }
|
||||
} |
||||
}); |
||||
|
||||
DesignerContext.setDesignerBean("predefinedStyle", this); |
||||
} |
||||
|
||||
/** |
||||
* 添加改变监听 |
||||
* |
||||
* @param changeListener 监听事件 |
||||
*/ |
||||
public void addChangeListener(ChangeListener changeListener) { |
||||
this.changeListener = changeListener; |
||||
} |
||||
|
||||
/** |
||||
* 重置 |
||||
*/ |
||||
public void reset() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(NameStyle ob) { |
||||
refreshBeanElement(); |
||||
for (int i = 0; i < defaultListModel.getSize(); i++) { |
||||
if (ComparatorUtils.equals(ob, defaultListModel.get(i))) { |
||||
styleList.setSelectedIndex(i); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public NameStyle updateBean() { |
||||
return (NameStyle) styleList.getSelectedValue(); |
||||
} |
||||
|
||||
/** |
||||
* 获取面板标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText(new String[]{"PageSetup-Predefined", "Style"}); |
||||
} |
||||
|
||||
/** |
||||
* 是否可以接纳对象 |
||||
* |
||||
* @param ob 组件对象 |
||||
* @return 是否可以接纳对象 |
||||
*/ |
||||
public boolean accept(Object ob) { |
||||
return ob instanceof NameStyle; |
||||
} |
||||
|
||||
/** |
||||
* 刷新组件对象 |
||||
*/ |
||||
public void refreshBeanElement() { |
||||
defaultListModel.removeAllElements(); |
||||
if (ConfigManager.getProviderInstance().hasStyle()) { |
||||
Iterator iterato = ConfigManager.getProviderInstance().getStyleNameIterator(); |
||||
while (iterato.hasNext()) { |
||||
String name = (String) iterato.next(); |
||||
NameStyle nameStyle = NameStyle.getInstance(name); |
||||
defaultListModel.addElement(nameStyle); |
||||
} |
||||
} |
||||
styleList.setModel(defaultListModel); |
||||
GUICoreUtils.repaint(this); |
||||
|
||||
} |
||||
|
||||
} |
@ -1,109 +1,115 @@
|
||||
package com.fr.design.present; |
||||
|
||||
import com.fr.base.present.DictPresent; |
||||
import com.fr.base.present.FormulaPresent; |
||||
import com.fr.base.present.Present; |
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.fun.PresentKindProvider; |
||||
import com.fr.design.gui.frpane.UIComboBoxPane; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.general.Inter; |
||||
import com.fr.report.cell.cellattr.BarcodePresent; |
||||
import com.fr.report.cell.cellattr.CurrencyLinePresent; |
||||
|
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author zhou |
||||
* @since 2012-5-31上午11:22:28 |
||||
*/ |
||||
public class PresentPane extends UIComboBoxPane<Present> { |
||||
private DictPresentPane dictPresentPane; |
||||
private List<String> keys; |
||||
private List<String> displays; |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Present"); |
||||
} |
||||
|
||||
public void setSelectedByName(String radioName) { |
||||
jcb.setSelectedItem(radioName); |
||||
} |
||||
|
||||
/** |
||||
* 增加tab改变监听事件 |
||||
* @param l 监听事件 |
||||
*/ |
||||
public void addTabChangeListener(ItemListener l) { |
||||
super.addTabChangeListener(l); |
||||
dictPresentPane.addTabChangeListener(l); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Present ob) { |
||||
if(ob == null) { |
||||
dictPresentPane.reset(); |
||||
} |
||||
super.populateBean(ob); |
||||
} |
||||
|
||||
@Override |
||||
protected List<FurtherBasicBeanPane<? extends Present>> initPaneList() { |
||||
if (keys == null) { |
||||
keys = new ArrayList<>(); |
||||
} |
||||
if (displays == null) { |
||||
displays = new ArrayList<>(); |
||||
} |
||||
List<FurtherBasicBeanPane<? extends Present>> paneList = new ArrayList<>(); |
||||
FurtherBasicBeanPane<Present> none = new NonePresentPane(); |
||||
paneList.add(none); |
||||
keys.add("NOPRESENT"); |
||||
displays.add(none.title4PopupWindow()); |
||||
|
||||
paneList.add(dictPresentPane = new DictPresentPane()); |
||||
keys.add(DictPresent.class.getName()); |
||||
displays.add(dictPresentPane.title4PopupWindow()); |
||||
|
||||
FurtherBasicBeanPane<BarcodePresent> bar = new BarCodePane(); |
||||
paneList.add(bar); |
||||
keys.add(BarcodePresent.class.getName()); |
||||
displays.add(bar.title4PopupWindow()); |
||||
|
||||
FurtherBasicBeanPane<FormulaPresent> formula = new FormulaPresentPane(); |
||||
paneList.add(formula); |
||||
keys.add(FormulaPresent.class.getName()); |
||||
displays.add(formula.title4PopupWindow()); |
||||
|
||||
FurtherBasicBeanPane<CurrencyLinePresent> currency = new CurrencyLinePane(); |
||||
paneList.add(currency); |
||||
keys.add(CurrencyLinePresent.class.getName()); |
||||
displays.add(currency.title4PopupWindow()); |
||||
|
||||
Set<PresentKindProvider> providers = ExtraDesignClassManager.getInstance().getArray(PresentKindProvider.MARK_STRING); |
||||
for (PresentKindProvider provider : providers) { |
||||
FurtherBasicBeanPane<? extends Present> extra = provider.appearanceForPresent(); |
||||
paneList.add(extra); |
||||
keys.add(provider.kindOfPresent().getName()); |
||||
displays.add(extra.title4PopupWindow()); |
||||
} |
||||
return paneList; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox createComboBox() { |
||||
return new DictionaryComboBox<>(keys.toArray(new String[keys.size()]), displays.toArray(new String[displays.size()])); |
||||
} |
||||
|
||||
@Override |
||||
protected void addComboBoxItem(List<FurtherBasicBeanPane<? extends Present>> cards, int index) { |
||||
// 初始化的时候已经加了,所以这里不用加了
|
||||
} |
||||
package com.fr.design.present; |
||||
|
||||
import com.fr.base.present.DictPresent; |
||||
import com.fr.base.present.FormulaPresent; |
||||
import com.fr.base.present.Present; |
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.fun.PresentKindProvider; |
||||
import com.fr.design.gui.frpane.UIComboBoxPane; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.general.Inter; |
||||
import com.fr.report.cell.cellattr.BarcodePresent; |
||||
import com.fr.report.cell.cellattr.CurrencyLinePresent; |
||||
|
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author zhou |
||||
* @since 2012-5-31上午11:22:28 |
||||
*/ |
||||
public class PresentPane extends UIComboBoxPane<Present> { |
||||
private DictPresentPane dictPresentPane; |
||||
private List<String> keys; |
||||
private List<String> displays; |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Present"); |
||||
} |
||||
|
||||
public void setSelectedByName(String radioName) { |
||||
jcb.setSelectedItem(radioName); |
||||
} |
||||
|
||||
/** |
||||
* 增加tab改变监听事件 |
||||
* @param l 监听事件 |
||||
*/ |
||||
public void addTabChangeListener(ItemListener l) { |
||||
super.addTabChangeListener(l); |
||||
dictPresentPane.addTabChangeListener(l); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(Present ob) { |
||||
if(ob == null) { |
||||
dictPresentPane.reset(); |
||||
} |
||||
super.populateBean(ob); |
||||
} |
||||
|
||||
@Override |
||||
protected List<FurtherBasicBeanPane<? extends Present>> initPaneList() { |
||||
if (keys == null) { |
||||
keys = new ArrayList<>(); |
||||
} |
||||
if (displays == null) { |
||||
displays = new ArrayList<>(); |
||||
} |
||||
List<FurtherBasicBeanPane<? extends Present>> paneList = new ArrayList<>(); |
||||
FurtherBasicBeanPane<Present> none = new NonePresentPane(); |
||||
paneList.add(none); |
||||
keys.add("NOPRESENT"); |
||||
displays.add(none.title4PopupWindow()); |
||||
|
||||
dictPresentPane = new DictPresentPane(); |
||||
dictPresentPane.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); |
||||
paneList.add(dictPresentPane); |
||||
keys.add(DictPresent.class.getName()); |
||||
displays.add(dictPresentPane.title4PopupWindow()); |
||||
|
||||
FurtherBasicBeanPane<BarcodePresent> bar = new BarCodePane(); |
||||
bar.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); |
||||
paneList.add(bar); |
||||
keys.add(BarcodePresent.class.getName()); |
||||
displays.add(bar.title4PopupWindow()); |
||||
|
||||
FurtherBasicBeanPane<FormulaPresent> formula = new FormulaPresentPane(); |
||||
formula.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); |
||||
paneList.add(formula); |
||||
keys.add(FormulaPresent.class.getName()); |
||||
displays.add(formula.title4PopupWindow()); |
||||
|
||||
FurtherBasicBeanPane<CurrencyLinePresent> currency = new CurrencyLinePane(); |
||||
currency.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); |
||||
paneList.add(currency); |
||||
keys.add(CurrencyLinePresent.class.getName()); |
||||
displays.add(currency.title4PopupWindow()); |
||||
|
||||
Set<PresentKindProvider> providers = ExtraDesignClassManager.getInstance().getArray(PresentKindProvider.MARK_STRING); |
||||
for (PresentKindProvider provider : providers) { |
||||
FurtherBasicBeanPane<? extends Present> extra = provider.appearanceForPresent(); |
||||
paneList.add(extra); |
||||
keys.add(provider.kindOfPresent().getName()); |
||||
displays.add(extra.title4PopupWindow()); |
||||
} |
||||
return paneList; |
||||
} |
||||
|
||||
@Override |
||||
protected UIComboBox createComboBox() { |
||||
return new DictionaryComboBox<>(keys.toArray(new String[keys.size()]), displays.toArray(new String[displays.size()])); |
||||
} |
||||
|
||||
@Override |
||||
protected void addComboBoxItem(List<FurtherBasicBeanPane<? extends Present>> cards, int index) { |
||||
// 初始化的时候已经加了,所以这里不用加了
|
||||
} |
||||
} |
@ -1,222 +1,230 @@
|
||||
package com.fr.design.widget; |
||||
|
||||
import com.fr.design.data.DataCreatorUI; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.TreeSettingPane; |
||||
import com.fr.design.gui.ibutton.UIHeadGroup; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.design.present.dict.DictionaryPane; |
||||
import com.fr.design.widget.ui.BasicWidgetPropertySettingPane; |
||||
import com.fr.form.event.Listener; |
||||
import com.fr.form.ui.NoneWidget; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.util.ArrayList; |
||||
|
||||
/* |
||||
* carl :单独弄出来 |
||||
*/ |
||||
public class CellWidgetCardPane extends BasicPane { |
||||
//当前的编辑器属性定义面板
|
||||
private DataModify<? extends Widget> currentEditorDefinePane; |
||||
//属性配置切换面板
|
||||
private ArrayList<JPanel> paneList; |
||||
private JPanel center; |
||||
private UIHeadGroup tabsHeaderIconPane; |
||||
private CardLayout tabbedPane; |
||||
private BasicWidgetPropertySettingPane widgetPropertyPane; |
||||
|
||||
//通用属性容器
|
||||
private JPanel attriTabPane; |
||||
private JPanel attriCardPane; |
||||
private CardLayout attriCardLayout; |
||||
|
||||
//数字字典属性容器
|
||||
private JPanel dictTabPane; |
||||
private JPanel dictCardPane; |
||||
private CardLayout dictCardLayout; |
||||
|
||||
//构建树属性容器
|
||||
private JPanel treeTabPane; |
||||
|
||||
//事件属性容器
|
||||
private JPanel eventTabPane; |
||||
private WidgetEventPane eventPane; |
||||
|
||||
private ElementCasePane pane; |
||||
|
||||
public CellWidgetCardPane(ElementCasePane pane) { |
||||
this.pane = pane; |
||||
} |
||||
|
||||
private void initComponents(ElementCasePane pane) { |
||||
this.removeAll(); |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
//k
|
||||
tabbedPane = new CardLayout(); |
||||
center = new JPanel(tabbedPane); |
||||
this.add(center, BorderLayout.CENTER); |
||||
|
||||
attriTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
eventTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
initPaneList(); |
||||
eventPane = new WidgetEventPane(pane); |
||||
eventTabPane.add(eventPane, BorderLayout.CENTER); |
||||
//k
|
||||
center.add(attriTabPane, Inter.getLocText("FR-Designer_Attribute")); |
||||
center.add(eventTabPane, Inter.getLocText("FR-Designer_Form_Editing_Listeners")); |
||||
final String [] tabTitles = new String[]{Inter.getLocText("FR-Designer_Attribute"), Inter.getLocText("FR-Designer_Form_Editing_Listeners")}; |
||||
|
||||
tabsHeaderIconPane = new UIHeadGroup(tabTitles) { |
||||
@Override |
||||
public void tabChanged(int index) { |
||||
tabbedPane.show(center, tabTitles[index]); |
||||
} |
||||
}; |
||||
tabsHeaderIconPane.setNeedLeftRightOutLine(false); |
||||
this.add(tabsHeaderIconPane, BorderLayout.NORTH); |
||||
|
||||
//数据字典
|
||||
dictTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
dictCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
dictTabPane.add(dictCardPane, BorderLayout.CENTER); |
||||
dictCardLayout = new CardLayout(); |
||||
dictCardPane.setLayout(dictCardLayout); |
||||
|
||||
//构建树
|
||||
treeTabPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
|
||||
widgetPropertyPane = new BasicWidgetPropertySettingPane(); |
||||
|
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane("基本", 280, 20, widgetPropertyPane); |
||||
|
||||
attriTabPane.add(uiExpandablePane, BorderLayout.NORTH); |
||||
|
||||
attriCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
attriTabPane.add(attriCardPane, BorderLayout.CENTER); |
||||
attriCardLayout = (CardLayout) attriCardPane.getLayout(); |
||||
this.setPreferredSize(new Dimension(600, 450)); |
||||
} |
||||
|
||||
private void initPaneList(){ |
||||
paneList = new ArrayList<JPanel>(); |
||||
paneList.add(attriTabPane); |
||||
paneList.add(eventPane); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Widget"; |
||||
} |
||||
|
||||
public void populate(Widget cellWidget) { |
||||
initComponents(pane); |
||||
// super.populate(cellWidget);
|
||||
currentEditorDefinePane = null; |
||||
|
||||
if (cellWidget instanceof NoneWidget) { |
||||
// this.tabbedPane.setEnabled(false);
|
||||
} else { |
||||
// this.tabbedPane.setEnabled(true);
|
||||
} |
||||
|
||||
WidgetDefinePaneFactory.RN rn = WidgetDefinePaneFactory.createWidgetDefinePane(cellWidget, new Operator() { |
||||
@Override |
||||
public void did(DataCreatorUI ui, String cardName) { |
||||
if (ui == null) { |
||||
removeDictAttriPane(); |
||||
removeTreeAttriPane(); |
||||
} |
||||
if (ui instanceof DictionaryPane) { |
||||
removeDictAttriPane(); |
||||
removeTreeAttriPane(); |
||||
showDictPane(ui, cardName); |
||||
} else if (ui instanceof TreeSettingPane) { |
||||
removeDictAttriPane(); |
||||
removeTreeAttriPane(); |
||||
showTreePane(ui); |
||||
} |
||||
} |
||||
}); |
||||
DataModify<? extends Widget> definePane = rn.getDefinePane(); |
||||
attriCardPane.add(definePane.toSwingComponent(), rn.getCardName()); |
||||
attriCardLayout.show(attriCardPane, rn.getCardName()); |
||||
currentEditorDefinePane = definePane; |
||||
eventPane.populate(cellWidget); |
||||
widgetPropertyPane.populate(cellWidget); |
||||
tabsHeaderIconPane.setSelectedIndex(0); |
||||
} |
||||
|
||||
private void showDictPane(DataCreatorUI ui, String cardName) { |
||||
dictCardPane.removeAll(); |
||||
dictCardPane.add(ui.toSwingComponent(), cardName); |
||||
dictCardLayout.show(dictCardPane, cardName); |
||||
addDictAttriPane(); |
||||
} |
||||
|
||||
private void showTreePane(DataCreatorUI ui) { |
||||
treeTabPane.removeAll(); |
||||
treeTabPane.add(ui.toSwingComponent()); |
||||
addTreeAttriPane(); |
||||
} |
||||
|
||||
public Widget update() { |
||||
if (currentEditorDefinePane == null) { |
||||
return null; |
||||
} |
||||
Widget widget = currentEditorDefinePane.updateBean(); |
||||
if (widget == null) { |
||||
return null; |
||||
} |
||||
widgetPropertyPane.update(widget); |
||||
// super.update(widget);
|
||||
|
||||
Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(); |
||||
widget.clearListeners(); |
||||
for (Listener l : listener) { |
||||
widget.addListener(l); |
||||
} |
||||
|
||||
return widget; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
/** |
||||
*检查 |
||||
*/ |
||||
public void checkValid() throws Exception { |
||||
currentEditorDefinePane.checkValid(); |
||||
eventPane.checkValid(); |
||||
} |
||||
|
||||
|
||||
private void addDictAttriPane() { |
||||
center.add(this.dictTabPane, Inter.getLocText("FR-Designer_DS_Dictionary")); |
||||
reInitHeaderPane(this.dictTabPane); |
||||
} |
||||
|
||||
private void addTreeAttriPane() { |
||||
center.add(this.dictTabPane, Inter.getLocText("FR-Designer_Create_Tree")); |
||||
reInitHeaderPane(this.treeTabPane); |
||||
} |
||||
|
||||
private void removeDictAttriPane() { |
||||
center.remove(this.dictTabPane); |
||||
} |
||||
|
||||
private void removeTreeAttriPane() { |
||||
center.remove(this.treeTabPane); |
||||
} |
||||
|
||||
private void reInitHeaderPane(JPanel jPanel){ |
||||
paneList.add(jPanel); |
||||
// tabsHeaderIconPane = new
|
||||
} |
||||
|
||||
} |
||||
package com.fr.design.widget; |
||||
|
||||
import com.fr.design.data.DataCreatorUI; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.TreeSettingPane; |
||||
import com.fr.design.gui.ibutton.UIHeadGroup; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.design.present.dict.DictionaryPane; |
||||
import com.fr.design.widget.ui.BasicWidgetPropertySettingPane; |
||||
import com.fr.form.event.Listener; |
||||
import com.fr.form.ui.NoneWidget; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.util.ArrayList; |
||||
|
||||
/* |
||||
* carl :单独弄出来 |
||||
*/ |
||||
public class CellWidgetCardPane extends BasicPane { |
||||
//当前的编辑器属性定义面板
|
||||
private DataModify<? extends Widget> currentEditorDefinePane; |
||||
//属性配置切换面板
|
||||
private ArrayList<JPanel> paneList; |
||||
private JPanel center; |
||||
private UIHeadGroup tabsHeaderIconPane; |
||||
private CardLayout tabbedPane; |
||||
private BasicWidgetPropertySettingPane widgetPropertyPane; |
||||
|
||||
//通用属性容器
|
||||
private JPanel attriTabPane; |
||||
private JPanel attriCardPane; |
||||
private CardLayout attriCardLayout; |
||||
|
||||
//数字字典属性容器
|
||||
private JPanel dictTabPane; |
||||
private JPanel dictCardPane; |
||||
private CardLayout dictCardLayout; |
||||
|
||||
//构建树属性容器
|
||||
private JPanel treeTabPane; |
||||
|
||||
//事件属性容器
|
||||
private JPanel eventTabPane; |
||||
private WidgetEventPane eventPane; |
||||
|
||||
private ElementCasePane pane; |
||||
|
||||
public CellWidgetCardPane(ElementCasePane pane) { |
||||
this.pane = pane; |
||||
// this.initComponents(pane);
|
||||
} |
||||
|
||||
public BasicWidgetPropertySettingPane initBasicWidgetPropertyPane() { |
||||
return new BasicWidgetPropertySettingPane(); |
||||
} |
||||
|
||||
|
||||
private void initComponents(ElementCasePane pane) { |
||||
|
||||
this.removeAll(); |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
//k
|
||||
tabbedPane = new CardLayout(); |
||||
center = new JPanel(tabbedPane); |
||||
this.add(center, BorderLayout.CENTER); |
||||
|
||||
attriTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
eventTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
initPaneList(); |
||||
eventPane = new WidgetEventPane(pane); |
||||
eventTabPane.add(eventPane, BorderLayout.CENTER); |
||||
//k
|
||||
center.add(attriTabPane, Inter.getLocText("FR-Designer_Attribute")); |
||||
center.add(eventTabPane, Inter.getLocText("FR-Designer_Form_Editing_Listeners")); |
||||
final String[] tabTitles = new String[]{Inter.getLocText("FR-Designer_Attribute"), Inter.getLocText("FR-Designer_Form_Editing_Listeners")}; |
||||
|
||||
tabsHeaderIconPane = new UIHeadGroup(tabTitles) { |
||||
@Override |
||||
public void tabChanged(int index) { |
||||
tabbedPane.show(center, tabTitles[index]); |
||||
} |
||||
}; |
||||
tabsHeaderIconPane.setNeedLeftRightOutLine(false); |
||||
this.add(tabsHeaderIconPane, BorderLayout.NORTH); |
||||
|
||||
//数据字典
|
||||
dictTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
dictCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
dictTabPane.add(dictCardPane, BorderLayout.CENTER); |
||||
dictCardLayout = new CardLayout(); |
||||
dictCardPane.setLayout(dictCardLayout); |
||||
|
||||
//构建树
|
||||
treeTabPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
|
||||
widgetPropertyPane = new BasicWidgetPropertySettingPane(); |
||||
|
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), 280, 24, widgetPropertyPane); |
||||
|
||||
attriTabPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
attriTabPane.add(uiExpandablePane, BorderLayout.NORTH); |
||||
|
||||
attriCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||
attriTabPane.add(attriCardPane, BorderLayout.CENTER); |
||||
attriCardLayout = (CardLayout) attriCardPane.getLayout(); |
||||
this.setPreferredSize(new Dimension(600, 450)); |
||||
} |
||||
|
||||
private void initPaneList() { |
||||
paneList = new ArrayList<JPanel>(); |
||||
paneList.add(attriTabPane); |
||||
paneList.add(eventPane); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Widget"; |
||||
} |
||||
|
||||
public void populate(Widget cellWidget) { |
||||
initComponents(pane); |
||||
// super.populate(cellWidget);
|
||||
currentEditorDefinePane = null; |
||||
|
||||
if (cellWidget instanceof NoneWidget) { |
||||
// this.tabbedPane.setEnabled(false);
|
||||
} else { |
||||
// this.tabbedPane.setEnabled(true);
|
||||
} |
||||
|
||||
WidgetDefinePaneFactory.RN rn = WidgetDefinePaneFactory.createWidgetDefinePane(cellWidget, new Operator() { |
||||
@Override |
||||
public void did(DataCreatorUI ui, String cardName) { |
||||
if (ui == null) { |
||||
removeDictAttriPane(); |
||||
removeTreeAttriPane(); |
||||
} |
||||
if (ui instanceof DictionaryPane) { |
||||
removeDictAttriPane(); |
||||
removeTreeAttriPane(); |
||||
showDictPane(ui, cardName); |
||||
} else if (ui instanceof TreeSettingPane) { |
||||
removeDictAttriPane(); |
||||
removeTreeAttriPane(); |
||||
showTreePane(ui); |
||||
} |
||||
} |
||||
}); |
||||
DataModify<? extends Widget> definePane = rn.getDefinePane(); |
||||
attriCardPane.add(definePane.toSwingComponent(), rn.getCardName()); |
||||
attriCardLayout.show(attriCardPane, rn.getCardName()); |
||||
currentEditorDefinePane = definePane; |
||||
eventPane.populate(cellWidget); |
||||
widgetPropertyPane.populate(cellWidget); |
||||
tabsHeaderIconPane.setSelectedIndex(0); |
||||
} |
||||
|
||||
private void showDictPane(DataCreatorUI ui, String cardName) { |
||||
dictCardPane.removeAll(); |
||||
dictCardPane.add(ui.toSwingComponent(), cardName); |
||||
dictCardLayout.show(dictCardPane, cardName); |
||||
addDictAttriPane(); |
||||
} |
||||
|
||||
private void showTreePane(DataCreatorUI ui) { |
||||
treeTabPane.removeAll(); |
||||
treeTabPane.add(ui.toSwingComponent()); |
||||
addTreeAttriPane(); |
||||
} |
||||
|
||||
public Widget update() { |
||||
if (currentEditorDefinePane == null) { |
||||
return null; |
||||
} |
||||
Widget widget = currentEditorDefinePane.updateBean(); |
||||
if (widget == null) { |
||||
return null; |
||||
} |
||||
widgetPropertyPane.update(widget); |
||||
// super.update(widget);
|
||||
|
||||
Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(); |
||||
widget.clearListeners(); |
||||
for (Listener l : listener) { |
||||
widget.addListener(l); |
||||
} |
||||
|
||||
return widget; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
/** |
||||
*检查 |
||||
*/ |
||||
public void checkValid() throws Exception { |
||||
currentEditorDefinePane.checkValid(); |
||||
eventPane.checkValid(); |
||||
} |
||||
|
||||
|
||||
private void addDictAttriPane() { |
||||
center.add(this.dictTabPane, Inter.getLocText("FR-Designer_DS_Dictionary")); |
||||
reInitHeaderPane(this.dictTabPane); |
||||
} |
||||
|
||||
private void addTreeAttriPane() { |
||||
center.add(this.dictTabPane, Inter.getLocText("FR-Designer_Create_Tree")); |
||||
reInitHeaderPane(this.treeTabPane); |
||||
} |
||||
|
||||
private void removeDictAttriPane() { |
||||
center.remove(this.dictTabPane); |
||||
} |
||||
|
||||
private void removeTreeAttriPane() { |
||||
center.remove(this.treeTabPane); |
||||
} |
||||
|
||||
private void reInitHeaderPane(JPanel jPanel) { |
||||
paneList.add(jPanel); |
||||
// tabsHeaderIconPane = new
|
||||
} |
||||
|
||||
} |
||||
|
@ -1,274 +1,287 @@
|
||||
package com.fr.design.widget; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.fun.WidgetDesignHandler; |
||||
import com.fr.design.gui.core.WidgetOption; |
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.design.mainframe.CellWidgetPropertyPane; |
||||
import com.fr.design.widget.btn.ButtonConstants; |
||||
import com.fr.form.ui.Button; |
||||
import com.fr.form.ui.*; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* CellEditorDef Pane. |
||||
*/ |
||||
public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener { |
||||
|
||||
private EditorTypeComboBox editorTypeComboBox; |
||||
private CellWidgetCardPane cellEditorCardPane; |
||||
private boolean shouldFireSelectedEvent = true; |
||||
protected JPanel northPane; |
||||
|
||||
public WidgetPane() { |
||||
this(null); |
||||
} |
||||
|
||||
/** |
||||
* Constructor |
||||
*/ |
||||
public WidgetPane(ElementCasePane pane) { |
||||
this.initComponents(pane); |
||||
} |
||||
|
||||
protected void initComponents(ElementCasePane pane) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
northPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); |
||||
this.add(northPane, BorderLayout.NORTH); |
||||
|
||||
northPane.add(new UILabel(Inter.getLocText("FR-Designer_Type") + ":")); |
||||
editorTypeComboBox = new EditorTypeComboBox(pane != null); |
||||
editorTypeComboBox.setPreferredSize(new Dimension(150, 30)); |
||||
editorTypeComboBox.setMaximumRowCount(16); |
||||
northPane.add(editorTypeComboBox); |
||||
editorTypeComboBox.addItemListener(this); |
||||
|
||||
cellEditorCardPane = new CellWidgetCardPane(pane); |
||||
this.add(cellEditorCardPane, BorderLayout.CENTER); |
||||
this.addAttributeChangeListener(listener); |
||||
} |
||||
|
||||
protected JPanel createContentPane(){ |
||||
return new JPanel(); |
||||
} |
||||
|
||||
|
||||
|
||||
AttributeChangeListener listener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
CellWidgetPropertyPane.getInstance().update(); |
||||
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 状态改变 |
||||
* |
||||
* @param e 事件对象 |
||||
*/ |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
Widget oldWidget = update(); |
||||
Widget selectedItem = editorTypeComboBox.getCellWidget(); |
||||
WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getSingle(WidgetDesignHandler.XML_TAG); |
||||
if (handler != null) { |
||||
handler.transferWidgetProperties(oldWidget, selectedItem); |
||||
} |
||||
if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { |
||||
populate(selectedItem); |
||||
return; |
||||
} |
||||
if (shouldFireSelectedEvent) { |
||||
populateWidgetConfig(selectedItem); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Widget"); |
||||
} |
||||
|
||||
public void populate(Widget widget) { |
||||
if (widget == null) { |
||||
return; |
||||
} |
||||
|
||||
if (widget instanceof NameWidget) { |
||||
String name = ((NameWidget) widget).getName(); |
||||
shouldFireSelectedEvent = false; |
||||
editorTypeComboBox.setSelectedItem(new Item(name, name)); |
||||
shouldFireSelectedEvent = true; |
||||
cellEditorCardPane.populate(widget); |
||||
return; |
||||
} |
||||
|
||||
Class clazz = widget.getClass(); |
||||
if (ArrayUtils.contains(ButtonConstants.CLASSES4BUTTON, clazz)) { |
||||
clazz = Button.class; |
||||
} |
||||
cellEditorCardPane.populate(widget); |
||||
|
||||
shouldFireSelectedEvent = false; |
||||
editorTypeComboBox.setSelectedItemByWidgetClass(clazz); |
||||
shouldFireSelectedEvent = true; |
||||
|
||||
removeAttributeChangeListener(); |
||||
initAllListeners(); |
||||
this.addAttributeChangeListener(listener); |
||||
|
||||
} |
||||
|
||||
public Widget update() { |
||||
return cellEditorCardPane.update(); |
||||
} |
||||
|
||||
protected void populateWidgetConfig(Widget widget) { |
||||
this.populate(widget); |
||||
} |
||||
|
||||
|
||||
private static class EditorTypeComboBox extends UIComboBox { |
||||
|
||||
private Item item = new Item(Inter.getLocText("Widget-User_Defined"), |
||||
Inter.getLocText("Widget-User_Defined")); |
||||
|
||||
public EditorTypeComboBox(boolean userDefined) { |
||||
this.setEditable(false); |
||||
this.setModel(new DefaultComboBoxModel(getWidgetsName(userDefined))); |
||||
this.setRenderer(new UIComboBoxRenderer() { |
||||
public Component getListCellRendererComponent(JList list, |
||||
Object value, int index, boolean isSelected, |
||||
boolean cellHasFocus) { |
||||
if (value == item) { |
||||
UILabel label = new UILabel(Inter |
||||
.getLocText("Widget-User_Defined") |
||||
+ " ————"); |
||||
label.setEnabled(false); |
||||
return label; |
||||
} |
||||
return super.getListCellRendererComponent(list, value, |
||||
index, isSelected, cellHasFocus); |
||||
} |
||||
}); |
||||
this.setPreferredSize(new Dimension(100, 20)); |
||||
} |
||||
|
||||
public void setSelectedItemByWidgetClass(Class clazz) { |
||||
WidgetOption[] options = getWidgetOptions(); |
||||
for (int i = 0, l = this.getModel().getSize(); i < l; i++) { |
||||
Item item = (Item) this.getModel().getElementAt(i); |
||||
if (item.getValue() instanceof Integer |
||||
&& options[(Integer) item.getValue()].widgetClass() == clazz) { |
||||
this.setSelectedItem(item); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void setSelectedItem(Object anObject) { |
||||
if (anObject == item) { |
||||
return; |
||||
} |
||||
super.setSelectedItem(anObject); |
||||
} |
||||
|
||||
private Vector getWidgetsName(boolean userDefined) { |
||||
|
||||
WidgetOption[] reportWidgetInstance = getWidgetOptions(); |
||||
Vector<Item> items = new Vector<Item>(); |
||||
for (int i = 0, l = reportWidgetInstance.length; i < l; i++) { |
||||
items.add(new Item(reportWidgetInstance[i].optionName(), i)); |
||||
} |
||||
WidgetManagerProvider manager = WidgetManager.getProviderInstance(); |
||||
java.util.Iterator<String> nameIt = manager.getWidgetConfigNameIterator(); |
||||
if (userDefined && nameIt.hasNext()) { |
||||
items.add(item); |
||||
while (nameIt.hasNext()) { |
||||
String name = nameIt.next(); |
||||
items.add(new Item(name, name)); |
||||
} |
||||
} |
||||
|
||||
return items; |
||||
} |
||||
|
||||
public Widget getCellWidget() { |
||||
Item item = (Item) this.getSelectedItem(); |
||||
if (item.getValue() instanceof Integer) { |
||||
return getWidgetOptions()[(Integer) item.getValue()].createWidget(); |
||||
} else if (item.getValue() instanceof String) { |
||||
return new NameWidget((String) item.getValue()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private WidgetOption[] getWidgetOptions() { |
||||
return (WidgetOption[]) ArrayUtils.addAll(WidgetOption.getReportWidgetInstance(), ExtraDesignClassManager.getInstance().getCellWidgetOptions()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 校验 |
||||
* |
||||
* @throws Exception 抛出异常 |
||||
*/ |
||||
public void checkValid() throws Exception { |
||||
this.cellEditorCardPane.checkValid(); |
||||
} |
||||
|
||||
public static class Item { |
||||
private String name; |
||||
private Object value; |
||||
|
||||
|
||||
public Item(String name, Object value) { |
||||
this.name = name; |
||||
this.value = value; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
/** |
||||
* 转化成字符串形式 |
||||
* |
||||
* @return 返回字符串 |
||||
*/ |
||||
public String toString() { |
||||
return name; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
return o instanceof Item |
||||
&& ComparatorUtils.equals(((Item) o).value, value) |
||||
&& ComparatorUtils.equals(((Item) o).name, name); |
||||
} |
||||
} |
||||
public String getIconPath(){ |
||||
return ""; |
||||
} |
||||
|
||||
package com.fr.design.widget; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.fun.WidgetDesignHandler; |
||||
import com.fr.design.gui.core.WidgetOption; |
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.CellWidgetPropertyPane; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.design.widget.btn.ButtonConstants; |
||||
import com.fr.form.ui.Button; |
||||
import com.fr.form.ui.*; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* CellEditorDef Pane. |
||||
*/ |
||||
public class WidgetPane extends AbstractAttrNoScrollPane implements ItemListener { |
||||
|
||||
private EditorTypeComboBox editorTypeComboBox; |
||||
private CellWidgetCardPane cellEditorCardPane; |
||||
private boolean shouldFireSelectedEvent = true; |
||||
protected JPanel northPane; |
||||
|
||||
public WidgetPane() { |
||||
this(null); |
||||
} |
||||
|
||||
/** |
||||
* Constructor |
||||
*/ |
||||
public WidgetPane(ElementCasePane pane) { |
||||
this.initComponents(pane); |
||||
} |
||||
|
||||
protected void initComponents(ElementCasePane pane) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
|
||||
editorTypeComboBox = new EditorTypeComboBox(pane != null); |
||||
editorTypeComboBox.setPreferredSize(new Dimension(155, 30)); |
||||
editorTypeComboBox.setMaximumRowCount(16); |
||||
|
||||
UILabel emptyLabel = new UILabel(); |
||||
emptyLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {p, p, f}; |
||||
double[] rowSize = {p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Inter.getLocText(new String[]{"FR-Designer_Selection", "FR-Designer_Widget"})), emptyLabel, editorTypeComboBox}, |
||||
}; |
||||
northPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
northPane.setBorder(BorderFactory.createEmptyBorder(12, 10, 10, 15)); |
||||
this.add(northPane, BorderLayout.NORTH); |
||||
|
||||
editorTypeComboBox.addItemListener(this); |
||||
|
||||
cellEditorCardPane = new CellWidgetCardPane(pane); |
||||
this.add(cellEditorCardPane, BorderLayout.CENTER); |
||||
this.addAttributeChangeListener(listener); |
||||
} |
||||
|
||||
protected JPanel createContentPane() { |
||||
return new JPanel(); |
||||
} |
||||
|
||||
|
||||
AttributeChangeListener listener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
CellWidgetPropertyPane.getInstance().update(); |
||||
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 状态改变 |
||||
* |
||||
* @param e 事件对象 |
||||
*/ |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
Widget oldWidget = update(); |
||||
Widget selectedItem = editorTypeComboBox.getCellWidget(); |
||||
WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getSingle(WidgetDesignHandler.XML_TAG); |
||||
if (handler != null) { |
||||
handler.transferWidgetProperties(oldWidget, selectedItem); |
||||
} |
||||
if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) { |
||||
populate(selectedItem); |
||||
return; |
||||
} |
||||
if (shouldFireSelectedEvent) { |
||||
populateWidgetConfig(selectedItem); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Widget"); |
||||
} |
||||
|
||||
public void populate(Widget widget) { |
||||
if (widget == null) { |
||||
return; |
||||
} |
||||
|
||||
if (widget instanceof NameWidget) { |
||||
String name = ((NameWidget) widget).getName(); |
||||
shouldFireSelectedEvent = false; |
||||
editorTypeComboBox.setSelectedItem(new Item(name, name)); |
||||
shouldFireSelectedEvent = true; |
||||
cellEditorCardPane.populate(widget); |
||||
return; |
||||
} |
||||
|
||||
Class clazz = widget.getClass(); |
||||
if (ArrayUtils.contains(ButtonConstants.CLASSES4BUTTON, clazz)) { |
||||
clazz = Button.class; |
||||
} |
||||
cellEditorCardPane.populate(widget); |
||||
|
||||
shouldFireSelectedEvent = false; |
||||
editorTypeComboBox.setSelectedItemByWidgetClass(clazz); |
||||
shouldFireSelectedEvent = true; |
||||
|
||||
removeAttributeChangeListener(); |
||||
initAllListeners(); |
||||
this.addAttributeChangeListener(listener); |
||||
|
||||
} |
||||
|
||||
public Widget update() { |
||||
return cellEditorCardPane.update(); |
||||
} |
||||
|
||||
protected void populateWidgetConfig(Widget widget) { |
||||
this.populate(widget); |
||||
} |
||||
|
||||
|
||||
private static class EditorTypeComboBox extends UIComboBox { |
||||
|
||||
private Item item = new Item(Inter.getLocText("Widget-User_Defined"), |
||||
Inter.getLocText("Widget-User_Defined")); |
||||
|
||||
public EditorTypeComboBox(boolean userDefined) { |
||||
this.setEditable(false); |
||||
this.setModel(new DefaultComboBoxModel(getWidgetsName(userDefined))); |
||||
this.setRenderer(new UIComboBoxRenderer() { |
||||
public Component getListCellRendererComponent(JList list, |
||||
Object value, int index, boolean isSelected, |
||||
boolean cellHasFocus) { |
||||
if (value == item) { |
||||
UILabel label = new UILabel(Inter |
||||
.getLocText("Widget-User_Defined") |
||||
+ " ————"); |
||||
label.setEnabled(false); |
||||
return label; |
||||
} |
||||
return super.getListCellRendererComponent(list, value, |
||||
index, isSelected, cellHasFocus); |
||||
} |
||||
}); |
||||
this.setPreferredSize(new Dimension(100, 20)); |
||||
} |
||||
|
||||
public void setSelectedItemByWidgetClass(Class clazz) { |
||||
WidgetOption[] options = getWidgetOptions(); |
||||
for (int i = 0, l = this.getModel().getSize(); i < l; i++) { |
||||
Item item = (Item) this.getModel().getElementAt(i); |
||||
if (item.getValue() instanceof Integer |
||||
&& options[(Integer) item.getValue()].widgetClass() == clazz) { |
||||
this.setSelectedItem(item); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void setSelectedItem(Object anObject) { |
||||
if (anObject == item) { |
||||
return; |
||||
} |
||||
super.setSelectedItem(anObject); |
||||
} |
||||
|
||||
private Vector getWidgetsName(boolean userDefined) { |
||||
|
||||
WidgetOption[] reportWidgetInstance = getWidgetOptions(); |
||||
Vector<Item> items = new Vector<Item>(); |
||||
for (int i = 0, l = reportWidgetInstance.length; i < l; i++) { |
||||
items.add(new Item(reportWidgetInstance[i].optionName(), i)); |
||||
} |
||||
WidgetManagerProvider manager = WidgetManager.getProviderInstance(); |
||||
java.util.Iterator<String> nameIt = manager.getWidgetConfigNameIterator(); |
||||
if (userDefined && nameIt.hasNext()) { |
||||
items.add(item); |
||||
while (nameIt.hasNext()) { |
||||
String name = nameIt.next(); |
||||
items.add(new Item(name, name)); |
||||
} |
||||
} |
||||
|
||||
return items; |
||||
} |
||||
|
||||
public Widget getCellWidget() { |
||||
Item item = (Item) this.getSelectedItem(); |
||||
if (item.getValue() instanceof Integer) { |
||||
return getWidgetOptions()[(Integer) item.getValue()].createWidget(); |
||||
} else if (item.getValue() instanceof String) { |
||||
return new NameWidget((String) item.getValue()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private WidgetOption[] getWidgetOptions() { |
||||
return (WidgetOption[]) ArrayUtils.addAll(WidgetOption.getReportWidgetInstance(), ExtraDesignClassManager.getInstance().getCellWidgetOptions()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 校验 |
||||
* |
||||
* @throws Exception 抛出异常 |
||||
*/ |
||||
public void checkValid() throws Exception { |
||||
this.cellEditorCardPane.checkValid(); |
||||
} |
||||
|
||||
public static class Item { |
||||
private String name; |
||||
private Object value; |
||||
|
||||
|
||||
public Item(String name, Object value) { |
||||
this.name = name; |
||||
this.value = value; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
/** |
||||
* 转化成字符串形式 |
||||
* |
||||
* @return 返回字符串 |
||||
*/ |
||||
public String toString() { |
||||
return name; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
return o instanceof Item |
||||
&& ComparatorUtils.equals(((Item) o).value, value) |
||||
&& ComparatorUtils.equals(((Item) o).name, name); |
||||
} |
||||
} |
||||
|
||||
public String getIconPath() { |
||||
return ""; |
||||
} |
||||
|
||||
} |
@ -1,70 +1,74 @@
|
||||
package com.fr.design.widget.ui; |
||||
|
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.form.ui.NoneWidget; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class BasicWidgetPropertySettingPane extends BasicPane { |
||||
private ParameterTreeComboBox widgetNameComboBox; |
||||
private UICheckBox enableCheckBox; |
||||
private UICheckBox visibleCheckBox; |
||||
private Widget widget; |
||||
|
||||
public BasicWidgetPropertySettingPane() { |
||||
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
||||
JPanel pane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
pane1.setBorder(BorderFactory.createEmptyBorder(0, -2, 0, 0)); |
||||
this.add(pane1); |
||||
|
||||
JPanel pane2 = FRGUIPaneFactory.createMediumHGapFlowInnerContainer_M_Pane(); |
||||
enableCheckBox = new UICheckBox(Inter.getLocText("Enabled"), true); |
||||
pane2.add(enableCheckBox); |
||||
visibleCheckBox = new UICheckBox(Inter.getLocText("Widget-Visible"), true); |
||||
pane2.add(visibleCheckBox); |
||||
pane1.add(pane2, BorderLayout.NORTH); |
||||
|
||||
JPanel pane3 = FRGUIPaneFactory.createMediumHGapFlowInnerContainer_M_Pane(); |
||||
widgetNameComboBox = new ParameterTreeComboBox(); |
||||
widgetNameComboBox.refreshTree(); |
||||
pane3.add(new UILabel(Inter.getLocText("Form-Widget_Name") + ":")); |
||||
pane3.add(widgetNameComboBox); |
||||
pane1.add(pane3, BorderLayout.CENTER); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "property"; |
||||
} |
||||
|
||||
public void populate(Widget widget){ |
||||
//:jackie
|
||||
if(widget instanceof NoneWidget){ |
||||
this.widget = null; |
||||
GUICoreUtils.setEnabled(this, false); |
||||
return; |
||||
} else{ |
||||
GUICoreUtils.setEnabled(this, true); |
||||
this.widget = widget; |
||||
widgetNameComboBox.setSelectedItem(widget.getWidgetName()); |
||||
enableCheckBox.setSelected(this.widget.isEnabled()); |
||||
visibleCheckBox.setSelected(this.widget.isVisible()); |
||||
} |
||||
} |
||||
|
||||
public void update(Widget widget){ |
||||
if(this.widget == null) |
||||
return ; |
||||
widget.setWidgetName(widgetNameComboBox.getSelectedParameterName()); |
||||
widget.setEnabled(enableCheckBox.isSelected()); |
||||
widget.setVisible(visibleCheckBox.isSelected()); |
||||
} |
||||
package com.fr.design.widget.ui; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.form.ui.NoneWidget; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class BasicWidgetPropertySettingPane extends BasicPane { |
||||
private ParameterTreeComboBox widgetNameComboBox; |
||||
private UICheckBox enableCheckBox; |
||||
private UICheckBox visibleCheckBox; |
||||
private Widget widget; |
||||
|
||||
public BasicWidgetPropertySettingPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
enableCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Visible"), true); |
||||
visibleCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Widget-Visible"), true); |
||||
widgetNameComboBox = new ParameterTreeComboBox(); |
||||
widgetNameComboBox.refreshTree(); |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Form-Widget_Name") + " "), widgetNameComboBox}, |
||||
new Component[]{enableCheckBox, null}, |
||||
new Component[]{visibleCheckBox, null}, |
||||
}; |
||||
double[] rowSize = {p, p, p}; |
||||
double[] columnSize = {p, f}; |
||||
int[][] rowCount = {{1, 1},{1, 1},{1, 1},{1, 1}}; |
||||
JPanel pane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); |
||||
pane.setBorder(BorderFactory.createEmptyBorder(10,0,10,0)); |
||||
|
||||
this.add(pane, BorderLayout.CENTER); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "property"; |
||||
} |
||||
|
||||
public void populate(Widget widget){ |
||||
//:jackie
|
||||
if(widget instanceof NoneWidget){ |
||||
this.widget = null; |
||||
GUICoreUtils.setEnabled(this, false); |
||||
return; |
||||
} else{ |
||||
GUICoreUtils.setEnabled(this, true); |
||||
this.widget = widget; |
||||
widgetNameComboBox.setSelectedItem(widget.getWidgetName()); |
||||
enableCheckBox.setSelected(this.widget.isEnabled()); |
||||
visibleCheckBox.setSelected(this.widget.isVisible()); |
||||
} |
||||
} |
||||
|
||||
public void update(Widget widget){ |
||||
if(this.widget == null) |
||||
return ; |
||||
widget.setWidgetName(widgetNameComboBox.getSelectedParameterName()); |
||||
widget.setEnabled(enableCheckBox.isSelected()); |
||||
widget.setVisible(visibleCheckBox.isSelected()); |
||||
} |
||||
} |
@ -1,164 +1,160 @@
|
||||
package com.fr.design.widget.ui; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
|
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.form.ui.FieldEditor; |
||||
import com.fr.general.Inter; |
||||
|
||||
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> { |
||||
private static final int ALLOW_BLANK_CHECK_BOX_WIDTH = GraphHelper.getLocTextWidth("FR-Designer_Allow_Null") + 30; |
||||
private static final int ALLOW_BLANK_CHECK_BOX_HEIGHT = 30; |
||||
protected UICheckBox allowBlankCheckBox; |
||||
// richer:错误信息,是所有控件共有的属性,所以放到这里来
|
||||
protected UITextField errorMsgTextField; |
||||
protected JPanel validatePane; |
||||
|
||||
public FieldEditorDefinePane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
initErrorMsgPane(); |
||||
JPanel contentPane = this.setFirstContentPane(); |
||||
if (contentPane != null) { |
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, contentPane); |
||||
this.add(uiExpandablePane, BorderLayout.NORTH); |
||||
} |
||||
this.addValidatePane(); |
||||
} |
||||
|
||||
|
||||
protected void initErrorMsgPane() { |
||||
// 错误信息
|
||||
errorMsgTextField = new UITextField(10); |
||||
|
||||
// richer:主要为了方便查看比较长的错误信息
|
||||
errorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { |
||||
|
||||
public void changedUpdate(DocumentEvent e) { |
||||
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); |
||||
} |
||||
|
||||
public void insertUpdate(DocumentEvent e) { |
||||
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); |
||||
} |
||||
|
||||
public void removeUpdate(DocumentEvent e) { |
||||
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(T ob) { |
||||
this.allowBlankCheckBox.setSelected(ob.isAllowBlank()); |
||||
// errorMsgTextField.setEnabled(!allowBlankCheckBox.isSelected());
|
||||
this.errorMsgTextField.setText(ob.getErrorMessage()); |
||||
|
||||
populateSubFieldEditorBean(ob); |
||||
} |
||||
|
||||
protected abstract void populateSubFieldEditorBean(T ob); |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
T e = updateSubFieldEditorBean(); |
||||
|
||||
e.setAllowBlank(this.allowBlankCheckBox.isSelected()); |
||||
e.setErrorMessage(this.errorMsgTextField.getText()); |
||||
|
||||
return e; |
||||
} |
||||
|
||||
protected abstract T updateSubFieldEditorBean(); |
||||
|
||||
protected abstract JPanel setFirstContentPane(); |
||||
|
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
|
||||
} |
||||
|
||||
protected void addValidatePane() { |
||||
validatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
final UILabel uiLabel = new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"); |
||||
errorMsgTextField = new UITextField(10); |
||||
allowBlankCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Allow_Null")); |
||||
allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); |
||||
allowBlankCheckBox.setPreferredSize(new Dimension(ALLOW_BLANK_CHECK_BOX_WIDTH, ALLOW_BLANK_CHECK_BOX_HEIGHT)); |
||||
allowBlankCheckBox.addItemListener(new ItemListener() { |
||||
|
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
boolean isSelected = allowBlankCheckBox.isSelected(); |
||||
uiLabel.setVisible(!isSelected); |
||||
errorMsgTextField.setVisible(!isSelected); |
||||
if(isSelected){ |
||||
uiLabel.setPreferredSize(new Dimension(0, 0)); |
||||
errorMsgTextField.setPreferredSize(new Dimension(0, 0)); |
||||
}else{ |
||||
uiLabel.setPreferredSize(new Dimension(66, 20)); |
||||
errorMsgTextField.setPreferredSize(new Dimension(150, 20)); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{allowBlankCheckBox, null }, |
||||
new Component[]{uiLabel, errorMsgTextField}, |
||||
}; |
||||
double[] rowSize = {p, p}; |
||||
double[] columnSize = {p,f}; |
||||
int[][] rowCount = {{1, 1},{1, 1}}; |
||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, 1); |
||||
validatePane.add(panel, BorderLayout.NORTH); |
||||
|
||||
JPanel contentPane = this.setValidatePane(); |
||||
if (contentPane != null) { |
||||
validatePane.add(contentPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
|
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Validate"), 280, 20, validatePane); |
||||
this.add(uiExpandablePane, BorderLayout.CENTER); |
||||
|
||||
// JPanel firstPane = GUICoreUtils.createFlowPane(new JComponent[]{allowBlankCheckBox}, FlowLayout.LEFT, 5);
|
||||
// validatePane.add(firstPane);
|
||||
// JPanel secondPane = new JPanel(FRGUIPaneFactory.createLabelFlowLayout());
|
||||
// secondPane.add(new UILabel("错误提示" + ":"));
|
||||
// secondPane.add(errorMsgTextField);
|
||||
// JPanel secondPane = GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), errorMsgTextField}, FlowLayout.LEFT, 24);
|
||||
// secondPane.setPreferredSize(new Dimension(400, 23));
|
||||
// validatePane.add(secondPane);
|
||||
} |
||||
|
||||
public JPanel setValidatePane(){ |
||||
return null; |
||||
} |
||||
|
||||
|
||||
|
||||
package com.fr.design.widget.ui; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.form.ui.FieldEditor; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> { |
||||
private static final int ALLOW_BLANK_CHECK_BOX_WIDTH = GraphHelper.getLocTextWidth("FR-Designer_Allow_Null") + 30; |
||||
private static final int ALLOW_BLANK_CHECK_BOX_HEIGHT = 30; |
||||
protected UICheckBox allowBlankCheckBox; |
||||
// richer:错误信息,是所有控件共有的属性,所以放到这里来
|
||||
protected UITextField errorMsgTextField; |
||||
protected JPanel validatePane; |
||||
|
||||
public FieldEditorDefinePane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
initErrorMsgPane(); |
||||
JPanel contentPane = this.setFirstContentPane(); |
||||
if (contentPane != null) { |
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 24, contentPane); |
||||
this.add(uiExpandablePane, BorderLayout.NORTH); |
||||
} |
||||
this.addValidatePane(); |
||||
} |
||||
|
||||
|
||||
protected void initErrorMsgPane() { |
||||
// 错误信息
|
||||
errorMsgTextField = new UITextField(10); |
||||
|
||||
// richer:主要为了方便查看比较长的错误信息
|
||||
errorMsgTextField.getDocument().addDocumentListener(new DocumentListener() { |
||||
|
||||
public void changedUpdate(DocumentEvent e) { |
||||
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); |
||||
} |
||||
|
||||
public void insertUpdate(DocumentEvent e) { |
||||
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); |
||||
} |
||||
|
||||
public void removeUpdate(DocumentEvent e) { |
||||
errorMsgTextField.setToolTipText(errorMsgTextField.getText()); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(T ob) { |
||||
this.allowBlankCheckBox.setSelected(ob.isAllowBlank()); |
||||
// errorMsgTextField.setEnabled(!allowBlankCheckBox.isSelected());
|
||||
this.errorMsgTextField.setText(ob.getErrorMessage()); |
||||
|
||||
populateSubFieldEditorBean(ob); |
||||
} |
||||
|
||||
protected abstract void populateSubFieldEditorBean(T ob); |
||||
|
||||
@Override |
||||
public T updateBean() { |
||||
T e = updateSubFieldEditorBean(); |
||||
|
||||
e.setAllowBlank(this.allowBlankCheckBox.isSelected()); |
||||
e.setErrorMessage(this.errorMsgTextField.getText()); |
||||
|
||||
return e; |
||||
} |
||||
|
||||
protected abstract T updateSubFieldEditorBean(); |
||||
|
||||
protected abstract JPanel setFirstContentPane(); |
||||
|
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
|
||||
} |
||||
|
||||
protected void addValidatePane() { |
||||
validatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
final UILabel uiLabel = new UILabel(Inter.getLocText(new String[]{"FR-Designer_Error", "FR-Designer_Tooltips"})); |
||||
errorMsgTextField = new UITextField(10); |
||||
allowBlankCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Allow_Null")); |
||||
allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); |
||||
allowBlankCheckBox.setPreferredSize(new Dimension(ALLOW_BLANK_CHECK_BOX_WIDTH, ALLOW_BLANK_CHECK_BOX_HEIGHT)); |
||||
allowBlankCheckBox.addItemListener(new ItemListener() { |
||||
|
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
boolean isSelected = allowBlankCheckBox.isSelected(); |
||||
uiLabel.setVisible(!isSelected); |
||||
errorMsgTextField.setVisible(!isSelected); |
||||
if (isSelected) { |
||||
uiLabel.setPreferredSize(new Dimension(0, 0)); |
||||
errorMsgTextField.setPreferredSize(new Dimension(0, 0)); |
||||
} else { |
||||
uiLabel.setPreferredSize(new Dimension(66, 20)); |
||||
errorMsgTextField.setPreferredSize(new Dimension(150, 20)); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{allowBlankCheckBox, null}, |
||||
new Component[]{uiLabel, errorMsgTextField}, |
||||
}; |
||||
double[] rowSize = {p, p}; |
||||
double[] columnSize = {p, f}; |
||||
int[][] rowCount = {{1, 1}, {1, 1}}; |
||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, 1); |
||||
validatePane.add(panel, BorderLayout.NORTH); |
||||
|
||||
JPanel contentPane = this.setValidatePane(); |
||||
if (contentPane != null) { |
||||
validatePane.add(contentPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
|
||||
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Validate"), 280, 24, validatePane); |
||||
this.add(uiExpandablePane, BorderLayout.CENTER); |
||||
|
||||
// JPanel firstPane = GUICoreUtils.createFlowPane(new JComponent[]{allowBlankCheckBox}, FlowLayout.LEFT, 5);
|
||||
// validatePane.add(firstPane);
|
||||
// JPanel secondPane = new JPanel(FRGUIPaneFactory.createLabelFlowLayout());
|
||||
// secondPane.add(new UILabel("错误提示" + ":"));
|
||||
// secondPane.add(errorMsgTextField);
|
||||
// JPanel secondPane = GUICoreUtils.createFlowPane(new JComponent[]{new UILabel(Inter.getLocText(new String[]{"Error", "Tooltips"}) + ":"), errorMsgTextField}, FlowLayout.LEFT, 24);
|
||||
// secondPane.setPreferredSize(new Dimension(400, 23));
|
||||
// validatePane.add(secondPane);
|
||||
} |
||||
|
||||
public JPanel setValidatePane() { |
||||
return null; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,45 +1,70 @@
|
||||
package com.fr.design.widget.ui; |
||||
|
||||
import java.awt.event.KeyListener; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.WaterMark; |
||||
import com.fr.general.Inter; |
||||
|
||||
public class WaterMarkDictPane extends JPanel{ |
||||
|
||||
private UITextField waterMarkTextField; |
||||
|
||||
public WaterMarkDictPane() { |
||||
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder(2,2,2,2)); |
||||
this.add(new UILabel(Inter.getLocText("WaterMark") + ":")); |
||||
waterMarkTextField = new UITextField(13); |
||||
this.add(waterMarkTextField); |
||||
} |
||||
|
||||
public void populate(WaterMark waterMark) { |
||||
this.waterMarkTextField.setText(waterMark.getWaterMark()); |
||||
} |
||||
public void addInputKeyListener(KeyListener kl) { |
||||
this.waterMarkTextField.addKeyListener(kl); |
||||
} |
||||
public void removeInputKeyListener(KeyListener kl) { |
||||
this.waterMarkTextField.removeKeyListener(kl); |
||||
} |
||||
public void update(WaterMark waterMark) { |
||||
waterMark.setWaterMark(this.waterMarkTextField.getText()); |
||||
} |
||||
public void setWaterMark(String waterMark) { |
||||
this.waterMarkTextField.setText(waterMark); |
||||
} |
||||
public String getWaterMark() { |
||||
return this.waterMarkTextField.getText(); |
||||
} |
||||
|
||||
package com.fr.design.widget.ui; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.event.KeyListener; |
||||
|
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.form.ui.WaterMark; |
||||
import com.fr.general.Inter; |
||||
|
||||
public class WaterMarkDictPane extends JPanel { |
||||
|
||||
private UITextField waterMarkTextField; |
||||
|
||||
public WaterMarkDictPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
// this.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
|
||||
// this.add(new UILabel(Inter.getLocText("WaterMark") + ":"));
|
||||
waterMarkTextField = new UITextField(13); |
||||
|
||||
UILabel emptyLabel = new UILabel(); |
||||
emptyLabel.setBorder(BorderFactory.createEmptyBorder(0, 33, 0, 0)); |
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Designer_WaterMark")), emptyLabel, waterMarkTextField}, |
||||
}; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p, p, f}; |
||||
int[][] rowCount = {{1, 1}}; |
||||
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
// JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM);
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0)); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
public void populate(WaterMark waterMark) { |
||||
this.waterMarkTextField.setText(waterMark.getWaterMark()); |
||||
} |
||||
|
||||
public void addInputKeyListener(KeyListener kl) { |
||||
this.waterMarkTextField.addKeyListener(kl); |
||||
} |
||||
|
||||
public void removeInputKeyListener(KeyListener kl) { |
||||
this.waterMarkTextField.removeKeyListener(kl); |
||||
} |
||||
|
||||
public void update(WaterMark waterMark) { |
||||
waterMark.setWaterMark(this.waterMarkTextField.getText()); |
||||
} |
||||
|
||||
public void setWaterMark(String waterMark) { |
||||
this.waterMarkTextField.setText(waterMark); |
||||
} |
||||
|
||||
public String getWaterMark() { |
||||
return this.waterMarkTextField.getText(); |
||||
} |
||||
|
||||
} |
@ -1,77 +1,77 @@
|
||||
package com.fr.quickeditor.floatquick; |
||||
|
||||
import com.fr.base.Style; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.report.SelectImagePane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.FloatQuickEditor; |
||||
import com.fr.report.cell.cellattr.CellImage; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class FloatImageQuickEditor extends FloatQuickEditor { |
||||
|
||||
public FloatImageQuickEditor() { |
||||
super(); |
||||
UIButton editbutton = new UIButton(Inter.getLocText("FR-Designer_Edit")); |
||||
editbutton.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showEditingDialog(); |
||||
} |
||||
}); |
||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
editbutton.setMargin(null); |
||||
editbutton.setOpaque(false); |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{editbutton} |
||||
}; |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {f}; |
||||
double[] rowSize = {p}; |
||||
JPanel pane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 74, 10, 10)); |
||||
this.add(pane, BorderLayout.CENTER); |
||||
|
||||
|
||||
} |
||||
|
||||
private void showEditingDialog() { |
||||
final SelectImagePane imageEditorPane = new SelectImagePane(); |
||||
imageEditorPane.populate(floatElement); |
||||
final Object oldValue = floatElement.getValue(); |
||||
final Style oldStyle = floatElement.getStyle(); |
||||
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
CellImage cellImage = imageEditorPane.update(); |
||||
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { |
||||
floatElement.setValue(cellImage.getImage()); |
||||
floatElement.setStyle(cellImage.getStyle()); |
||||
fireTargetModified(); |
||||
} |
||||
} |
||||
|
||||
}).setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
package com.fr.quickeditor.floatquick; |
||||
|
||||
import com.fr.base.Style; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.report.SelectImagePane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.FloatQuickEditor; |
||||
import com.fr.report.cell.cellattr.CellImage; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class FloatImageQuickEditor extends FloatQuickEditor { |
||||
|
||||
public FloatImageQuickEditor() { |
||||
super(); |
||||
UIButton editbutton = new UIButton(Inter.getLocText("FR-Designer_Edit")); |
||||
editbutton.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showEditingDialog(); |
||||
} |
||||
}); |
||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
editbutton.setMargin(null); |
||||
editbutton.setOpaque(false); |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{editbutton} |
||||
}; |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {f}; |
||||
double[] rowSize = {p}; |
||||
JPanel pane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 78, 10, 17)); |
||||
this.add(pane, BorderLayout.CENTER); |
||||
|
||||
|
||||
} |
||||
|
||||
private void showEditingDialog() { |
||||
final SelectImagePane imageEditorPane = new SelectImagePane(); |
||||
imageEditorPane.populate(floatElement); |
||||
final Object oldValue = floatElement.getValue(); |
||||
final Style oldStyle = floatElement.getStyle(); |
||||
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
CellImage cellImage = imageEditorPane.update(); |
||||
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { |
||||
floatElement.setValue(cellImage.getImage()); |
||||
floatElement.setStyle(cellImage.getStyle()); |
||||
fireTargetModified(); |
||||
} |
||||
} |
||||
|
||||
}).setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
} |
@ -1,127 +1,128 @@
|
||||
package com.fr.quickeditor.floatquick; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Formula; |
||||
import com.fr.base.Style; |
||||
import com.fr.base.TextFormat; |
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.quickeditor.FloatQuickEditor; |
||||
import com.fr.report.ReportHelper; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class FloatStringQuickEditor extends FloatQuickEditor { |
||||
private JTextArea stringTextField; |
||||
private UIButton formulaButton; |
||||
|
||||
// august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置
|
||||
private boolean reserveInResult = false; |
||||
private boolean reserveOnWriteOrAnaly = true; |
||||
|
||||
public FloatStringQuickEditor() { |
||||
super(); |
||||
stringTextField = new JTextArea(); |
||||
initTextField(); |
||||
formulaButton = new UIButton(); |
||||
formulaButton.setPreferredSize(new Dimension(25, 23)); |
||||
formulaButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
||||
formulaButton.addActionListener(getFormulaActionListener); |
||||
JPanel pane = new JPanel(new BorderLayout(5, 0)); |
||||
pane.add(stringTextField, BorderLayout.CENTER); |
||||
pane.add(formulaButton, BorderLayout.EAST); |
||||
formulaButton.setVisible(false); |
||||
this.setLayout(new BorderLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
this.add(pane, BorderLayout.NORTH); |
||||
} |
||||
|
||||
private void initTextField() { |
||||
stringTextField.setFont(new Font("Dialog", Font.PLAIN, 12)); |
||||
stringTextField.setOpaque(true); |
||||
stringTextField.setLineWrap(true); |
||||
stringTextField.setWrapStyleWord(true); |
||||
stringTextField.setMargin(new Insets(5, 5, 5, 5)); |
||||
stringTextField.setBorder(BorderFactory.createLineBorder(Color.gray)); |
||||
stringTextField.setBackground(Color.WHITE); |
||||
} |
||||
|
||||
ActionListener getFormulaActionListener = new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
((ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane()).getGrid().startEditing(); |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
String str = null; |
||||
Object value = floatElement.getValue(); |
||||
if (value == null) { |
||||
str = StringUtils.EMPTY; |
||||
} else if (value instanceof Formula) { |
||||
//MoMeak: 没拆文本框和公式所以需要这么个玩意
|
||||
formulaButton.setVisible(true); |
||||
Formula formula = (Formula) value; |
||||
str = formula.getContent(); |
||||
stringTextField.setLineWrap(false); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 74, 10, 10)); |
||||
reserveInResult = formula.isReserveInResult(); |
||||
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); |
||||
} else { |
||||
str = value.toString(); |
||||
} |
||||
showText(str); |
||||
} |
||||
|
||||
public void showText(String str) { |
||||
stringTextField.getDocument().removeDocumentListener(documentListener); |
||||
stringTextField.setText(str); |
||||
stringTextField.getDocument().addDocumentListener(documentListener); |
||||
} |
||||
|
||||
DocumentListener documentListener = new DocumentListener() { |
||||
|
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
}; |
||||
|
||||
protected void changeReportPaneCell(String tmpText) { |
||||
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { |
||||
Formula textFormula = new Formula(tmpText); |
||||
textFormula.setReserveInResult(reserveInResult); |
||||
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); |
||||
floatElement.setValue(textFormula); |
||||
} else { |
||||
Style style = floatElement.getStyle(); |
||||
if (floatElement != null && style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { |
||||
floatElement.setValue(tmpText); |
||||
} else { |
||||
floatElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); |
||||
} |
||||
} |
||||
fireTargetModified(); |
||||
stringTextField.requestFocus(); |
||||
} |
||||
|
||||
package com.fr.quickeditor.floatquick; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Formula; |
||||
import com.fr.base.Style; |
||||
import com.fr.base.TextFormat; |
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.ElementCasePane; |
||||
import com.fr.quickeditor.FloatQuickEditor; |
||||
import com.fr.report.ReportHelper; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class FloatStringQuickEditor extends FloatQuickEditor { |
||||
private JTextArea stringTextField; |
||||
private UIButton formulaButton; |
||||
|
||||
// august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置
|
||||
private boolean reserveInResult = false; |
||||
private boolean reserveOnWriteOrAnaly = true; |
||||
|
||||
public FloatStringQuickEditor() { |
||||
super(); |
||||
stringTextField = new JTextArea(); |
||||
initTextField(); |
||||
formulaButton = new UIButton(); |
||||
formulaButton.setPreferredSize(new Dimension(25, 23)); |
||||
formulaButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
||||
formulaButton.addActionListener(getFormulaActionListener); |
||||
JPanel pane = new JPanel(new BorderLayout(5, 0)); |
||||
pane.add(stringTextField, BorderLayout.CENTER); |
||||
pane.add(formulaButton, BorderLayout.EAST); |
||||
pane.setBorder(BorderFactory.createEmptyBorder(0,0,0,7)); |
||||
formulaButton.setVisible(false); |
||||
this.setLayout(new BorderLayout()); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
this.add(pane, BorderLayout.NORTH); |
||||
} |
||||
|
||||
private void initTextField() { |
||||
stringTextField.setFont(new Font("Dialog", Font.PLAIN, 12)); |
||||
stringTextField.setOpaque(true); |
||||
stringTextField.setLineWrap(true); |
||||
stringTextField.setWrapStyleWord(true); |
||||
stringTextField.setMargin(new Insets(5, 5, 5, 5)); |
||||
stringTextField.setBorder(BorderFactory.createLineBorder(Color.gray)); |
||||
stringTextField.setBackground(Color.WHITE); |
||||
} |
||||
|
||||
ActionListener getFormulaActionListener = new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
((ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane()).getGrid().startEditing(); |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
String str = null; |
||||
Object value = floatElement.getValue(); |
||||
if (value == null) { |
||||
str = StringUtils.EMPTY; |
||||
} else if (value instanceof Formula) { |
||||
//MoMeak: 没拆文本框和公式所以需要这么个玩意
|
||||
formulaButton.setVisible(true); |
||||
Formula formula = (Formula) value; |
||||
str = formula.getContent(); |
||||
stringTextField.setLineWrap(false); |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 78, 10, 10)); |
||||
reserveInResult = formula.isReserveInResult(); |
||||
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); |
||||
} else { |
||||
str = value.toString(); |
||||
} |
||||
showText(str); |
||||
} |
||||
|
||||
public void showText(String str) { |
||||
stringTextField.getDocument().removeDocumentListener(documentListener); |
||||
stringTextField.setText(str); |
||||
stringTextField.getDocument().addDocumentListener(documentListener); |
||||
} |
||||
|
||||
DocumentListener documentListener = new DocumentListener() { |
||||
|
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
}; |
||||
|
||||
protected void changeReportPaneCell(String tmpText) { |
||||
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { |
||||
Formula textFormula = new Formula(tmpText); |
||||
textFormula.setReserveInResult(reserveInResult); |
||||
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); |
||||
floatElement.setValue(textFormula); |
||||
} else { |
||||
Style style = floatElement.getStyle(); |
||||
if (floatElement != null && style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { |
||||
floatElement.setValue(tmpText); |
||||
} else { |
||||
floatElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); |
||||
} |
||||
} |
||||
fireTargetModified(); |
||||
stringTextField.requestFocus(); |
||||
} |
||||
|
||||
} |
@ -1,184 +1,190 @@
|
||||
/* |
||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||
*/ |
||||
package com.fr.design.constants; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* This class defines the constants used in the designer. |
||||
*/ |
||||
public interface UIConstants { |
||||
|
||||
|
||||
public static final Icon BLACK_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/blank.gif"); |
||||
|
||||
|
||||
public static final int SIZE = 17; |
||||
|
||||
public static final int GAP_NORMAL = 10; // 10px
|
||||
|
||||
/** |
||||
* Cell default cursor. |
||||
*/ |
||||
public static final Cursor CELL_DEFAULT_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( |
||||
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"), |
||||
new Point(16, 16), "CellDefaultCursor"); |
||||
public static final Cursor DRAW_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( |
||||
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"), |
||||
new Point(16, 16), "DrawCursor"); |
||||
|
||||
|
||||
public static final Cursor FORMAT_BRUSH_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( |
||||
BaseUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"), |
||||
new Point(16, 16), "formatBrushCursor"); |
||||
|
||||
/** |
||||
* Border style array. |
||||
*/ |
||||
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ |
||||
Constants.LINE_THIN, //Thin border.
|
||||
Constants.LINE_MEDIUM, //Medium border
|
||||
Constants.LINE_DASH, //dash border
|
||||
Constants.LINE_HAIR, //hair-line border
|
||||
Constants.LINE_HAIR2, //hair-line border
|
||||
Constants.LINE_THICK, //Thick border
|
||||
Constants.LINE_DOUBLE, //double-line border
|
||||
Constants.LINE_DOT, //dot border
|
||||
Constants.LINE_MEDIUM_DASH, //Medium dashed border
|
||||
Constants.LINE_DASH_DOT, //dash-dot border
|
||||
Constants.LINE_MEDIUM_DASH_DOT, //medium dash-dot border
|
||||
Constants.LINE_DASH_DOT_DOT, //dash-dot-dot border
|
||||
Constants.LINE_MEDIUM_DASH_DOT_DOT, //medium dash-dot-dot border
|
||||
Constants.LINE_SLANTED_DASH_DOT, //slanted dash-dot border
|
||||
}; |
||||
public static final Color LINE_COLOR = new Color(153, 153, 153); |
||||
public static final Color FONT_COLOR = new Color(51, 51, 51); |
||||
public static final Color LIGHT_BLUE = new Color(182, 217, 253); |
||||
public static final Color SKY_BLUE = new Color(164, 192, 220); |
||||
public static final Color OCEAN_BLUE = new Color(141, 179, 217); |
||||
public static final Color DARK_BLUE = new Color(0, 88, 144); |
||||
public static final Color NORMAL_BACKGROUND = new Color(212, 212, 216); |
||||
public static final Color TREE_BACKGROUND = new Color(240, 240, 243); |
||||
public static final Color TOOL_PANE_BACKGROUND = new Color(232, 232, 223); |
||||
public static final Color SELECT_TAB = new Color(245, 245, 247); |
||||
public static final Color TOOLBARUI_BACKGROUND = new Color(255, 255, 255); |
||||
public static final Color SHADOW_GREY = new Color(217, 218, 221); |
||||
public static final Color SHADOW_CENTER = new Color(200, 200, 200); |
||||
public static final Color SHADOW_PURPLE = new Color(255, 0, 255); |
||||
public static final Color FLESH_BLUE = new Color(65, 155, 249); |
||||
public static final Color HOVER_BLUE = new Color(0xd2d2d2); |
||||
public static final Color DOTTED_LINE_COLOR = new Color(35, 108, 184); |
||||
public static final Color AUTHORITY_COLOR = new Color(88, 125, 153); |
||||
public static final Color AUTHORITY_BLUE = new Color(0xe2e2e2); |
||||
public static final Color AUTHORITY_DARK_BLUE = new Color(136, 164, 186); |
||||
public static final Color AUTHORITY_PRESS_BLUE = new Color(131, 159, 181); |
||||
public static final Color AUTHORITY_LINE_COLOR = new Color(0, 124, 229); |
||||
public static final Color AUTHORITY_SHEET_DARK = new Color(86, 120, 143); |
||||
public static final Color AUTHORITY_SHEET_LIGHT = new Color(156, 204, 238); |
||||
public static final Color AUTHORITY_SHEET_UNSELECTED = new Color(146, 192, 225); |
||||
public static final Color ATTRIBUTE_PRESS = new Color(0xD8F2FD); |
||||
public static final Color ATTRIBUTE_NORMAL = new Color(0xDADADD); |
||||
public static final Color ATTRIBUTE_HOVER = new Color(0xC9C9CD); |
||||
public static final Color CHECKBOX_HOVER_SELECTED = new Color(0x3394f0); |
||||
public static final Color TEXT_FILED_BORDER_SELECTED = new Color(0x3384f0); |
||||
public static final Color SHEET_NORMAL = new Color(0xc8c8ca); |
||||
public static final Color SELECTED_BACKGROUND = new Color(0xdeedfe); |
||||
public static final Color SELECTED_BORDER_LINE_COLOR = new Color(0x3384f0); |
||||
public static final Color DEFAULT_BG_RULER = new Color(0xffffff); |
||||
public static final Color RULER_LINE_COLOR = new Color(0xababab); |
||||
public static final Color RULER_SCALE_COLOR = new Color(0x4e504f); |
||||
public static final Color PROPERTY_PANE_BACKGROUND = new Color(0xdadadd); |
||||
public static final Color SPLIT_LINE = new Color(201, 198, 184); |
||||
|
||||
|
||||
public static final BufferedImage DRAG_BAR = BaseUtils.readImage("com/fr/design/images/control/bar.png"); |
||||
public static final BufferedImage DRAG_BAR_RIGHT = BaseUtils.readImage("com/fr/design/images/control/barm.png"); |
||||
public static final BufferedImage DRAG_BAR_LEFT = BaseUtils.readImage("com/fr/design/images/control/barl.png"); |
||||
public static final BufferedImage DRAG_UP_NORMAL = BaseUtils.readImage("com/fr/design/images/control/upnor.png"); |
||||
public static final BufferedImage DRAG_UP_PRESS = BaseUtils.readImage("com/fr/design/images/control/uppre.png"); |
||||
public static final BufferedImage DRAG_DOWN_NORMAL = BaseUtils.readImage("com/fr/design/images/control/downnor.png"); |
||||
public static final BufferedImage DRAG_DOWN_PRESS = BaseUtils.readImage("com/fr/design/images/control/downpre.png"); |
||||
public static final BufferedImage DRAG_RIGHT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/rightnor.png"); |
||||
public static final BufferedImage DRAG_RIGHT_PRESS = BaseUtils.readImage("com/fr/design/images/control/rightpre.png"); |
||||
public static final BufferedImage DRAG_LEFT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/leftnor.png"); |
||||
public static final BufferedImage DRAG_LEFT_PRESS = BaseUtils.readImage("com/fr/design/images/control/leftpre.png"); |
||||
public static final BufferedImage DRAG_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png"); |
||||
public static final BufferedImage DRAG_DOT_VERTICAL = BaseUtils.readImage("com/fr/design/images/control/dotv.png"); |
||||
public static final BufferedImage POP_BUTTON_DOWN = BaseUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png"); |
||||
public static final BufferedImage POP_BUTTON_UP = BaseUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png"); |
||||
public static final int MODEL_NORMAL = 0; |
||||
public static final int MODEL_PRESS = 1; |
||||
public static final Icon ARROW_DOWN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"); |
||||
public static final Icon ARROW_UP_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"); |
||||
public static final Icon YES_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/yes.png"); |
||||
public static final Icon CHOOSEN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/select_item.png"); |
||||
public static final Icon PRE_WIDGET_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png"); |
||||
public static final Icon EDIT_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editn.png"); |
||||
public static final Icon EDIT_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editp.png"); |
||||
public static final Icon HIDE_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hiden.png"); |
||||
public static final Icon HIDE_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hidep.png"); |
||||
public static final Icon VIEW_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewn.png"); |
||||
public static final Icon VIEW_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewp.png"); |
||||
public static final Icon RUN_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/run24.png"); |
||||
public static final Icon RUN_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/runs.png"); |
||||
public static final Icon PAGE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png"); |
||||
public static final Icon WRITE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png"); |
||||
public static final Icon ANA_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anab24.png"); |
||||
public static final Icon PAGE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pages.png"); |
||||
public static final Icon WRITE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writes.png"); |
||||
public static final Icon ANA_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); |
||||
public static final Icon REFRESH_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); |
||||
public static final Icon FONT_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); |
||||
public static final Icon HISTORY_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/history.png"); |
||||
public static final Icon DELETE_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/close.png"); |
||||
public static final Icon EDIT_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/edit.png"); |
||||
public static final Icon SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/search.png"); |
||||
public static final Icon CLEAR_ICON = BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"); |
||||
public static final Icon LIST_EDIT_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit.png"); |
||||
public static final Icon LIST_EDIT_WHITE_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit_white.png"); |
||||
public static final Color PRESSED_DARK_GRAY = new Color(127, 127, 127); |
||||
public static final Color GRDIENT_DARK_GRAY = new Color(45, 45, 45); |
||||
public static final Color BARNOMAL = new Color(232, 232, 233); |
||||
public static final int ARC = 0; |
||||
public static final int BUTTON_GROUP_ARC = 6; |
||||
public static final int LARGEARC = 6; |
||||
public static final Stroke BS = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[]{3, 1}, 0); |
||||
public static final Icon PREVIEW_DOWN = BaseUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png"); |
||||
public static final Icon CLOSE_OF_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close.png"); |
||||
public static final Icon CLOSE_OVER_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_over.png"); |
||||
public static final Icon CLOSE_PRESS_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_press.png"); |
||||
public static final int CLOSE_AUTHORITY_HEIGHT_AND_WIDTH = 24; |
||||
|
||||
|
||||
/** |
||||
* 正在加载的界面 |
||||
*/ |
||||
public static final Object PENDING = new Object() { |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return Inter.getLocText("Loading") + "..."; |
||||
} |
||||
}; |
||||
/** |
||||
* 数据库连接失败的界面 |
||||
*/ |
||||
public static final Object CONNECTION_FAILED = new Object() { |
||||
|
||||
public String toString() { |
||||
return Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"}) + "!"; |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 自动补全的默认快捷键,一般来说是 alt + /. |
||||
*/ |
||||
public static final String DEFAULT_AUTO_COMPLETE = "alt + SLASH"; |
||||
/* |
||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||
*/ |
||||
package com.fr.design.constants; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.border.Border; |
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* This class defines the constants used in the designer. |
||||
*/ |
||||
public interface UIConstants { |
||||
|
||||
|
||||
public static final Icon BLACK_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/blank.gif"); |
||||
public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0 ,10, 0, 0); |
||||
public static final Border CELL_ATTR_NORMALBORDER = BorderFactory.createEmptyBorder(0 ,10, 0, 15); |
||||
|
||||
|
||||
public static final int SIZE = 17; |
||||
|
||||
public static final int GAP_NORMAL = 10; // 10px
|
||||
|
||||
/** |
||||
* Cell default cursor. |
||||
*/ |
||||
public static final Cursor CELL_DEFAULT_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( |
||||
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"), |
||||
new Point(16, 16), "CellDefaultCursor"); |
||||
public static final Cursor DRAW_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( |
||||
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"), |
||||
new Point(16, 16), "DrawCursor"); |
||||
|
||||
|
||||
public static final Cursor FORMAT_BRUSH_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor( |
||||
BaseUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"), |
||||
new Point(16, 16), "formatBrushCursor"); |
||||
|
||||
/** |
||||
* Border style array. |
||||
*/ |
||||
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ |
||||
Constants.LINE_THIN, //Thin border.
|
||||
Constants.LINE_MEDIUM, //Medium border
|
||||
Constants.LINE_DASH, //dash border
|
||||
Constants.LINE_HAIR, //hair-line border
|
||||
Constants.LINE_HAIR2, //hair-line border
|
||||
Constants.LINE_THICK, //Thick border
|
||||
Constants.LINE_DOUBLE, //double-line border
|
||||
Constants.LINE_DOT, //dot border
|
||||
Constants.LINE_MEDIUM_DASH, //Medium dashed border
|
||||
Constants.LINE_DASH_DOT, //dash-dot border
|
||||
Constants.LINE_MEDIUM_DASH_DOT, //medium dash-dot border
|
||||
Constants.LINE_DASH_DOT_DOT, //dash-dot-dot border
|
||||
Constants.LINE_MEDIUM_DASH_DOT_DOT, //medium dash-dot-dot border
|
||||
Constants.LINE_SLANTED_DASH_DOT, //slanted dash-dot border
|
||||
}; |
||||
public static final Color LINE_COLOR = new Color(153, 153, 153); |
||||
public static final Color FONT_COLOR = new Color(51, 51, 51); |
||||
public static final Color LIGHT_BLUE = new Color(182, 217, 253); |
||||
public static final Color SKY_BLUE = new Color(164, 192, 220); |
||||
public static final Color OCEAN_BLUE = new Color(141, 179, 217); |
||||
public static final Color DARK_BLUE = new Color(0, 88, 144); |
||||
public static final Color NORMAL_BACKGROUND = new Color(212, 212, 216); |
||||
public static final Color TREE_BACKGROUND = new Color(240, 240, 243); |
||||
public static final Color TOOL_PANE_BACKGROUND = new Color(232, 232, 223); |
||||
public static final Color SELECT_TAB = new Color(245, 245, 247); |
||||
public static final Color TOOLBARUI_BACKGROUND = new Color(255, 255, 255); |
||||
public static final Color SHADOW_GREY = new Color(217, 218, 221); |
||||
public static final Color SHADOW_CENTER = new Color(200, 200, 200); |
||||
public static final Color SHADOW_PURPLE = new Color(255, 0, 255); |
||||
public static final Color FLESH_BLUE = new Color(65, 155, 249); |
||||
public static final Color HOVER_BLUE = new Color(0xd2d2d2); |
||||
public static final Color DOTTED_LINE_COLOR = new Color(35, 108, 184); |
||||
public static final Color AUTHORITY_COLOR = new Color(88, 125, 153); |
||||
public static final Color AUTHORITY_BLUE = new Color(0xe2e2e2); |
||||
public static final Color AUTHORITY_DARK_BLUE = new Color(136, 164, 186); |
||||
public static final Color AUTHORITY_PRESS_BLUE = new Color(131, 159, 181); |
||||
public static final Color AUTHORITY_LINE_COLOR = new Color(0, 124, 229); |
||||
public static final Color AUTHORITY_SHEET_DARK = new Color(86, 120, 143); |
||||
public static final Color AUTHORITY_SHEET_LIGHT = new Color(156, 204, 238); |
||||
public static final Color AUTHORITY_SHEET_UNSELECTED = new Color(146, 192, 225); |
||||
public static final Color ATTRIBUTE_PRESS = new Color(0xD8F2FD); |
||||
public static final Color ATTRIBUTE_NORMAL = new Color(0xDADADD); |
||||
public static final Color ATTRIBUTE_HOVER = new Color(0xC9C9CD); |
||||
public static final Color CHECKBOX_HOVER_SELECTED = new Color(0x3394f0); |
||||
public static final Color TEXT_FILED_BORDER_SELECTED = new Color(0x3384f0); |
||||
public static final Color SHEET_NORMAL = new Color(0xc8c8ca); |
||||
public static final Color SELECTED_BACKGROUND = new Color(0xdeedfe); |
||||
public static final Color SELECTED_BORDER_LINE_COLOR = new Color(0x3384f0); |
||||
public static final Color DEFAULT_BG_RULER = new Color(0xffffff); |
||||
public static final Color RULER_LINE_COLOR = new Color(0xababab); |
||||
public static final Color RULER_SCALE_COLOR = new Color(0x4e504f); |
||||
public static final Color PROPERTY_PANE_BACKGROUND = new Color(0xdadadd); |
||||
public static final Color SPLIT_LINE = new Color(201, 198, 184); |
||||
|
||||
|
||||
public static final BufferedImage DRAG_BAR = BaseUtils.readImage("com/fr/design/images/control/bar.png"); |
||||
public static final BufferedImage DRAG_BAR_RIGHT = BaseUtils.readImage("com/fr/design/images/control/barm.png"); |
||||
public static final BufferedImage DRAG_BAR_LEFT = BaseUtils.readImage("com/fr/design/images/control/barl.png"); |
||||
public static final BufferedImage DRAG_UP_NORMAL = BaseUtils.readImage("com/fr/design/images/control/upnor.png"); |
||||
public static final BufferedImage DRAG_UP_PRESS = BaseUtils.readImage("com/fr/design/images/control/uppre.png"); |
||||
public static final BufferedImage DRAG_DOWN_NORMAL = BaseUtils.readImage("com/fr/design/images/control/downnor.png"); |
||||
public static final BufferedImage DRAG_DOWN_PRESS = BaseUtils.readImage("com/fr/design/images/control/downpre.png"); |
||||
public static final BufferedImage DRAG_RIGHT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/rightnor.png"); |
||||
public static final BufferedImage DRAG_RIGHT_PRESS = BaseUtils.readImage("com/fr/design/images/control/rightpre.png"); |
||||
public static final BufferedImage DRAG_LEFT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/leftnor.png"); |
||||
public static final BufferedImage DRAG_LEFT_PRESS = BaseUtils.readImage("com/fr/design/images/control/leftpre.png"); |
||||
public static final BufferedImage DRAG_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png"); |
||||
public static final BufferedImage DRAG_DOT_VERTICAL = BaseUtils.readImage("com/fr/design/images/control/dotv.png"); |
||||
public static final BufferedImage POP_BUTTON_DOWN = BaseUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png"); |
||||
public static final BufferedImage POP_BUTTON_UP = BaseUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png"); |
||||
public static final BufferedImage DRAG_DOWN_SELECTED_SMALL = BaseUtils.readImage("com/fr/design/images/buttonicon/downSelected.png"); |
||||
public static final BufferedImage DRAG_LEFT_NORMAL_SMALL = BaseUtils.readImage("com/fr/design/images/buttonicon/leftNormal.png"); |
||||
public static final int MODEL_NORMAL = 0; |
||||
public static final int MODEL_PRESS = 1; |
||||
public static final Icon ARROW_DOWN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"); |
||||
public static final Icon ARROW_UP_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"); |
||||
public static final Icon YES_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/yes.png"); |
||||
public static final Icon CHOOSEN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/select_item.png"); |
||||
public static final Icon PRE_WIDGET_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png"); |
||||
public static final Icon EDIT_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editn.png"); |
||||
public static final Icon EDIT_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editp.png"); |
||||
public static final Icon HIDE_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hiden.png"); |
||||
public static final Icon HIDE_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hidep.png"); |
||||
public static final Icon VIEW_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewn.png"); |
||||
public static final Icon VIEW_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewp.png"); |
||||
public static final Icon RUN_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/run24.png"); |
||||
public static final Icon RUN_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/runs.png"); |
||||
public static final Icon PAGE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png"); |
||||
public static final Icon WRITE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png"); |
||||
public static final Icon ANA_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anab24.png"); |
||||
public static final Icon PAGE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pages.png"); |
||||
public static final Icon WRITE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writes.png"); |
||||
public static final Icon ANA_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); |
||||
public static final Icon REFRESH_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); |
||||
public static final Icon FONT_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); |
||||
public static final Icon HISTORY_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/history.png"); |
||||
public static final Icon DELETE_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/close.png"); |
||||
public static final Icon EDIT_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/edit.png"); |
||||
public static final Icon SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/search.png"); |
||||
public static final Icon CLEAR_ICON = BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"); |
||||
public static final Icon LIST_EDIT_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit.png"); |
||||
public static final Icon LIST_EDIT_WHITE_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit_white.png"); |
||||
public static final Color PRESSED_DARK_GRAY = new Color(127, 127, 127); |
||||
public static final Color GRDIENT_DARK_GRAY = new Color(45, 45, 45); |
||||
public static final Color BARNOMAL = new Color(232, 232, 233); |
||||
public static final Color COMPONENT_BACKGROUND_COLOR = new Color(237,237,238); |
||||
public static final int ARC = 0; |
||||
public static final int BUTTON_GROUP_ARC = 6; |
||||
public static final int LARGEARC = 6; |
||||
public static final Stroke BS = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[]{3, 1}, 0); |
||||
public static final Icon PREVIEW_DOWN = BaseUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png"); |
||||
public static final Icon CLOSE_OF_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close.png"); |
||||
public static final Icon CLOSE_OVER_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_over.png"); |
||||
public static final Icon CLOSE_PRESS_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_press.png"); |
||||
public static final int CLOSE_AUTHORITY_HEIGHT_AND_WIDTH = 24; |
||||
|
||||
|
||||
/** |
||||
* 正在加载的界面 |
||||
*/ |
||||
public static final Object PENDING = new Object() { |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return Inter.getLocText("Loading") + "..."; |
||||
} |
||||
}; |
||||
/** |
||||
* 数据库连接失败的界面 |
||||
*/ |
||||
public static final Object CONNECTION_FAILED = new Object() { |
||||
|
||||
public String toString() { |
||||
return Inter.getLocText(new String[]{"Database", "Datasource-Connection_failed"}) + "!"; |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 自动补全的默认快捷键,一般来说是 alt + /. |
||||
*/ |
||||
public static final String DEFAULT_AUTO_COMPLETE = "alt + SLASH"; |
||||
} |
@ -1,144 +1,136 @@
|
||||
package com.fr.design.formula; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Formula; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.event.UIObserver; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* |
||||
* @author zhou |
||||
* @since 2012-6-1下午3:50:37 |
||||
*/ |
||||
public class TinyFormulaPane extends BasicBeanPane<String> implements UIObserver{ |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
protected UITextField formulaTextField; |
||||
protected UIButton formulaTextFieldButton; |
||||
|
||||
public TinyFormulaPane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
|
||||
formulaTextField = new UITextField(); |
||||
formulaTextField.setGlobalName(Inter.getLocText("ExpandD-Sort_After_Expand")); |
||||
|
||||
// 添加一公式编辑器按钮
|
||||
formulaTextFieldButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
||||
formulaTextFieldButton.setToolTipText(Inter.getLocText("FR-Designer_Formula") + "..."); |
||||
formulaTextFieldButton.setPreferredSize(new Dimension(24, 20)); |
||||
formulaTextFieldButton.setOpaque(false); |
||||
formulaTextFieldButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||
formulaTextFieldButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent evt) { |
||||
String text = formulaTextField.getText(); |
||||
|
||||
final UIFormula formulaPane = FormulaFactory.createFormulaPane(); |
||||
formulaPane.populate(new Formula(text)); |
||||
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
Formula fm = formulaPane.update(); |
||||
populateTextField(fm); |
||||
okEvent(); |
||||
} |
||||
}).setVisible(true); |
||||
} |
||||
}); |
||||
initLayout(); |
||||
} |
||||
|
||||
protected void populateTextField(Formula fm) { |
||||
if (fm.getContent().length() <= 1) { |
||||
formulaTextField.setText("$$$"); |
||||
} else { |
||||
formulaTextField.setText(fm.getContent()); |
||||
} |
||||
} |
||||
|
||||
protected void initLayout() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {f }; |
||||
double[] rowSize = { p }; |
||||
|
||||
Component[] components1 = new Component[]{ |
||||
formulaTextFieldButton |
||||
} ; |
||||
JPanel pane = new JPanel(new BorderLayout(0,0)); |
||||
pane.add(formulaTextField,BorderLayout.CENTER); |
||||
pane.add(GUICoreUtils.createFlowPane(components1,FlowLayout.LEFT, LayoutConstants.HGAP_LARGE),BorderLayout.EAST); |
||||
|
||||
Component[][] components2 = new Component[][]{ |
||||
new Component[]{pane} |
||||
}; |
||||
|
||||
JPanel panel= TableLayoutHelper.createTableLayoutPane(components2,rowSize,columnSize) ; |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(panel,BorderLayout.CENTER) ; |
||||
} |
||||
|
||||
/** |
||||
* 公式窗口点击确定后的事件接口 |
||||
*/ |
||||
public void okEvent() { |
||||
|
||||
} |
||||
|
||||
public UITextField getUITextField() { |
||||
return formulaTextField; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(String ob) { |
||||
this.formulaTextField.setText(ob); |
||||
} |
||||
|
||||
@Override |
||||
public String updateBean() { |
||||
return formulaTextField.getText().trim(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("Present-Formula_Present"); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(super.getPreferredSize().width, 20); |
||||
} |
||||
|
||||
@Override |
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
if(formulaTextField != null) { |
||||
formulaTextField.registerChangeListener(listener); |
||||
} |
||||
if(formulaTextFieldButton != null) { |
||||
formulaTextFieldButton.registerChangeListener(listener); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean shouldResponseChangeListener() { |
||||
return true; |
||||
} |
||||
|
||||
package com.fr.design.formula; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Formula; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.event.UIObserver; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* |
||||
* @author zhou |
||||
* @since 2012-6-1下午3:50:37 |
||||
*/ |
||||
public class TinyFormulaPane extends BasicBeanPane<String> implements UIObserver{ |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
protected UITextField formulaTextField; |
||||
protected UIButton formulaTextFieldButton; |
||||
|
||||
public TinyFormulaPane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
|
||||
formulaTextField = new UITextField(); |
||||
formulaTextField.setGlobalName(Inter.getLocText("ExpandD-Sort_After_Expand")); |
||||
|
||||
// 添加一公式编辑器按钮
|
||||
formulaTextFieldButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
||||
formulaTextFieldButton.setToolTipText(Inter.getLocText("FR-Designer_Formula") + "..."); |
||||
formulaTextFieldButton.setPreferredSize(new Dimension(24, 20)); |
||||
formulaTextFieldButton.setOpaque(false); |
||||
formulaTextFieldButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||
formulaTextFieldButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent evt) { |
||||
String text = formulaTextField.getText(); |
||||
|
||||
final UIFormula formulaPane = FormulaFactory.createFormulaPane(); |
||||
formulaPane.populate(new Formula(text)); |
||||
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
Formula fm = formulaPane.update(); |
||||
populateTextField(fm); |
||||
okEvent(); |
||||
} |
||||
}).setVisible(true); |
||||
} |
||||
}); |
||||
initLayout(); |
||||
} |
||||
|
||||
protected void populateTextField(Formula fm) { |
||||
if (fm.getContent().length() <= 1) { |
||||
formulaTextField.setText("$$$"); |
||||
} else { |
||||
formulaTextField.setText(fm.getContent()); |
||||
} |
||||
} |
||||
|
||||
protected void initLayout() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
JPanel pane = new JPanel(new BorderLayout(0,0)); |
||||
JPanel pane1 = new JPanel(new BorderLayout(0,0)); |
||||
pane1.add(formulaTextField, BorderLayout.NORTH); |
||||
pane1.setBorder(BorderFactory.createEmptyBorder(0,0,0,5)); |
||||
pane.add(pane1,BorderLayout.CENTER); |
||||
pane.add(formulaTextFieldButton,BorderLayout.EAST); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(pane,BorderLayout.NORTH) ; |
||||
} |
||||
|
||||
/** |
||||
* 公式窗口点击确定后的事件接口 |
||||
*/ |
||||
public void okEvent() { |
||||
|
||||
} |
||||
|
||||
public UITextField getUITextField() { |
||||
return formulaTextField; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(String ob) { |
||||
this.formulaTextField.setText(ob); |
||||
} |
||||
|
||||
@Override |
||||
public String updateBean() { |
||||
return formulaTextField.getText().trim(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("Present-Formula_Present"); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(super.getPreferredSize().width, 20); |
||||
} |
||||
|
||||
@Override |
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
if(formulaTextField != null) { |
||||
formulaTextField.registerChangeListener(listener); |
||||
} |
||||
if(formulaTextFieldButton != null) { |
||||
formulaTextFieldButton.registerChangeListener(listener); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean shouldResponseChangeListener() { |
||||
return true; |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,398 +1,403 @@
|
||||
package com.fr.design.gui.style; |
||||
|
||||
import com.fr.base.CoreDecimalFormat; |
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.base.Style; |
||||
import com.fr.base.TextFormat; |
||||
import com.fr.data.core.FormatField; |
||||
import com.fr.data.core.FormatField.FormatContents; |
||||
import com.fr.design.border.UIRoundedBorder; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.border.Border; |
||||
import javax.swing.border.TitledBorder; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.text.Format; |
||||
import java.text.SimpleDateFormat; |
||||
|
||||
/** |
||||
* Format pane to edit java.text.Format. |
||||
* |
||||
* @author zhou |
||||
* @since 2012-5-24上午10:57:00 |
||||
*/ |
||||
public class FormatPane extends AbstractBasicStylePane { |
||||
private static final long serialVersionUID = 724330854437726751L; |
||||
|
||||
private static final int LABLE_X = 4; |
||||
private static final int LABLE_Y = 18; |
||||
private static final int LABLE_DELTA_WIDTH = 8; |
||||
private static final int LABLE_HEIGHT = 15; //标签背景的范围
|
||||
private static final int CURRENCY_FLAG_POINT = 6; |
||||
|
||||
private static final Integer[] TYPES = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC, |
||||
FormatContents.DATE, FormatContents.TIME, FormatContents.TEXT}; |
||||
|
||||
private static final Integer[] DATETYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME,}; |
||||
|
||||
private Format format; |
||||
|
||||
private UIComboBox typeComboBox; |
||||
private UIComboBox textField; |
||||
private UILabel sampleLabel; |
||||
private JPanel contentPane; |
||||
private JPanel txtCenterPane; |
||||
private JPanel centerPane; |
||||
private JPanel formatFontPane; |
||||
private FRFontPane frFontPane; |
||||
private boolean isRightFormate; |
||||
private boolean isDate = false; |
||||
private boolean isFormat = false; |
||||
|
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
public FormatPane() { |
||||
this.initComponents(TYPES); |
||||
} |
||||
|
||||
protected void initComponents(Integer[] types) { |
||||
this.setLayout(new BorderLayout(0, 4)); |
||||
iniSampleLable(); |
||||
contentPane = new JPanel(new BorderLayout(0, 4)) { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(super.getPreferredSize().width, 70); |
||||
} |
||||
}; |
||||
typeComboBox = new UIComboBox(types); |
||||
UIComboBoxRenderer render = createComBoxRender(); |
||||
typeComboBox.setRenderer(render); |
||||
typeComboBox.addItemListener(itemListener); |
||||
contentPane.add(sampleLabel, BorderLayout.NORTH); |
||||
centerPane = new JPanel(new CardLayout()); |
||||
centerPane.add(new JPanel(), "hide"); |
||||
centerPane.setPreferredSize(new Dimension(0, 0)); |
||||
centerPane.add(contentPane, "show"); |
||||
formatFontPane = new JPanel(new BorderLayout()); |
||||
formatFontPane.add(centerPane, BorderLayout.NORTH); |
||||
formatFontPane.add(new FRFontPane(), BorderLayout.CENTER); |
||||
txtCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
contentPane.add(txtCenterPane, BorderLayout.CENTER); |
||||
textField = new UIComboBox(FormatField.getInstance().getFormatArray(getFormatContents())); |
||||
textField.addItemListener(textFieldItemListener); |
||||
textField.setEditable(true); |
||||
txtCenterPane.add(textField, BorderLayout.NORTH); |
||||
frFontPane = new FRFontPane(); |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Base_Format") + " ", SwingConstants.LEFT), typeComboBox}, |
||||
new Component[]{null, centerPane}, |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Designer_FRFont"), SwingConstants.LEFT), frFontPane}, |
||||
new Component[]{null, null} |
||||
}; |
||||
double[] rowSize = {p, p, p, p, p}; |
||||
double[] columnSize = {p, f}; |
||||
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 3}, {1, 1}}; |
||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
protected UIComboBoxRenderer createComBoxRender() { |
||||
return new UIComboBoxRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof Integer) { |
||||
label.setText(" " + FormatField.getInstance().getName((Integer) value)); |
||||
} |
||||
return label; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void iniSampleLable() { |
||||
Border innterborder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); |
||||
Font tmpFont = null; |
||||
Border border = BorderFactory.createTitledBorder(innterborder, Inter.getLocText("FR-Base_StyleFormat_Sample"), TitledBorder.LEFT, 0, tmpFont, UIConstants.LINE_COLOR); |
||||
sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
int width = getWidth(); |
||||
Color orignal = g.getColor(); |
||||
g.setColor(getBackground()); |
||||
g.fillRect(LABLE_X, LABLE_Y, width - LABLE_DELTA_WIDTH, LABLE_HEIGHT); |
||||
g.setColor(UIConstants.LINE_COLOR); |
||||
FontMetrics cellFM = g.getFontMetrics(); |
||||
int textWidth = cellFM.stringWidth(getText()); |
||||
GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); |
||||
g.setColor(orignal); |
||||
} |
||||
}; |
||||
sampleLabel.setHorizontalAlignment(UILabel.CENTER); |
||||
sampleLabel.setBorder(border); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
/** |
||||
* 得到合适的大小 |
||||
*/ |
||||
public Dimension getPreferredSize() { |
||||
if (this.typeComboBox.getSelectedIndex() == FormatContents.NULL) { |
||||
return typeComboBox.getPreferredSize(); |
||||
} |
||||
return super.getPreferredSize(); |
||||
} |
||||
|
||||
/** |
||||
* 弹出框标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Text"); |
||||
} |
||||
|
||||
/** |
||||
* Populate |
||||
*/ |
||||
public void populateBean(Format format) { |
||||
this.format = format; |
||||
|
||||
if (format == null) { |
||||
this.typeComboBox.setSelectedIndex(FormatContents.NULL); |
||||
} else { |
||||
if (format instanceof CoreDecimalFormat) { |
||||
// check all value
|
||||
String pattern = ((CoreDecimalFormat) format).toPattern(); |
||||
boolean isCurrency1 = (pattern.length() > 0 && pattern.charAt(0) == '¤'); |
||||
boolean isCurrency2 = (pattern.length() > 0 && pattern.charAt(0) == '$'); |
||||
boolean isCurrency = isCurrency1 || isCurrency2; |
||||
boolean isCurrency4 = (pattern.length() > CURRENCY_FLAG_POINT && ComparatorUtils.equals(pattern.substring(0, CURRENCY_FLAG_POINT), "#,##0;")); |
||||
if (isCurrency || isCurrency4) { |
||||
setPatternComboBoxAndList(FormatContents.CURRENCY, pattern); |
||||
} else if (pattern.endsWith("%")) { |
||||
setPatternComboBoxAndList(FormatContents.PERCENT, pattern); |
||||
} else if (pattern.indexOf("E") > 0) { |
||||
setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern); |
||||
} else { |
||||
setPatternComboBoxAndList(FormatContents.NUMBER, pattern); |
||||
} |
||||
} else if (format instanceof SimpleDateFormat) { // date and time
|
||||
String pattern = ((SimpleDateFormat) format).toPattern(); |
||||
if (!isTimeType(pattern)) { |
||||
setPatternComboBoxAndList(FormatContents.DATE, pattern); |
||||
} else { |
||||
setPatternComboBoxAndList(FormatContents.TIME, pattern); |
||||
} |
||||
} else if (format instanceof TextFormat) { // Text
|
||||
this.typeComboBox.setSelectedItem(FormatContents.TEXT); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 判断是否是数组有模式 |
||||
* |
||||
* @param stringArray 字符串数组 |
||||
* @param pattern 格式 |
||||
* @return 是否是数组有模式 |
||||
*/ |
||||
public static int isArrayContainPattern(String[] stringArray, String pattern) { |
||||
for (int i = 0; i < stringArray.length; i++) { |
||||
if (ComparatorUtils.equals(stringArray[i], pattern)) { |
||||
return i; |
||||
} |
||||
} |
||||
|
||||
return -1; |
||||
} |
||||
|
||||
private void setPatternComboBoxAndList(int formatStyle, String pattern) { |
||||
this.typeComboBox.setSelectedItem(formatStyle); |
||||
int i = isArrayContainPattern(FormatField.getInstance().getFormatArray(formatStyle), pattern); |
||||
if (i == -1) { |
||||
this.textField.setSelectedIndex(0); |
||||
} else { |
||||
this.textField.setSelectedIndex(i); |
||||
} |
||||
} |
||||
|
||||
private boolean isTimeType(String pattern) { |
||||
return pattern.matches(".*[Hhmsa].*"); |
||||
} |
||||
|
||||
/** |
||||
* update |
||||
*/ |
||||
public Format update() { |
||||
String patternString = String.valueOf(textField.getSelectedItem()); |
||||
if (getFormatContents() == FormatContents.TEXT) { |
||||
return FormatField.getInstance().getFormat(getFormatContents(), patternString); |
||||
} |
||||
if (isRightFormate) { |
||||
if (StringUtils.isNotEmpty(patternString)) { |
||||
return FormatField.getInstance().getFormat(getFormatContents(), patternString); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private int getFormatContents() { |
||||
return (Integer) typeComboBox.getSelectedItem(); |
||||
} |
||||
|
||||
/** |
||||
* Refresh preview label. |
||||
*/ |
||||
private void refreshPreviewLabel() { |
||||
this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); |
||||
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); |
||||
try { |
||||
isRightFormate = true; |
||||
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { |
||||
return; |
||||
} |
||||
this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem()))); |
||||
} catch (Exception e) { |
||||
this.sampleLabel.setForeground(Color.red); |
||||
this.sampleLabel.setText(e.getMessage()); |
||||
isRightFormate = false; |
||||
} |
||||
} |
||||
|
||||
private boolean isTextOrNull() { |
||||
int contents = getFormatContents(); |
||||
return contents == FormatContents.TEXT || contents == FormatContents.NULL; |
||||
} |
||||
|
||||
/** |
||||
* Radio selection listener. |
||||
*/ |
||||
ItemListener itemListener = new ItemListener() { |
||||
|
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
int contents = getFormatContents(); |
||||
String[] items = FormatField.getInstance().getFormatArray(contents); |
||||
CardLayout cardLayout = (CardLayout) centerPane.getLayout(); |
||||
|
||||
if (isTextOrNull()) { |
||||
centerPane.setPreferredSize(new Dimension(0, 0)); |
||||
cardLayout.show(centerPane, "hide"); |
||||
} else { |
||||
textField.removeAllItems(); |
||||
for (int i = 0; i < items.length; i++) { |
||||
textField.addItem(items[i]); |
||||
} |
||||
centerPane.setPreferredSize(new Dimension(270, 70)); |
||||
cardLayout.show(centerPane, "show"); |
||||
} |
||||
isFormat = true; |
||||
} |
||||
|
||||
} |
||||
}; |
||||
|
||||
ItemListener textFieldItemListener = new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
isFormat = true; |
||||
refreshPreviewLabel(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
/** |
||||
* populate |
||||
*/ |
||||
public void populateBean(Style style) { |
||||
this.populateBean(style.getFormat()); |
||||
isFormat = false; |
||||
this.frFontPane.populateBean(style.getFRFont()); |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* update |
||||
*/ |
||||
public Style update(Style style) { |
||||
if (isFormat) { |
||||
isFormat = false; |
||||
return style.deriveFormat(this.update()); |
||||
} else { |
||||
return style.deriveFRFont(this.frFontPane.update(style.getFRFont())); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 默认只显示百分比的编辑下拉. |
||||
*/ |
||||
public void justUsePercentFormat() { |
||||
typeComboBox.setEnabled(false); |
||||
this.typeComboBox.setSelectedItem(FormatContents.PERCENT); |
||||
} |
||||
|
||||
public void setForDataSheet() { |
||||
Integer[] otherTypes = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC,}; |
||||
this.typeComboBox = new UIComboBox(otherTypes); |
||||
UIComboBoxRenderer render = new UIComboBoxRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof Integer) { |
||||
label.setText(" " + FormatField.getInstance().getName((Integer) value)); |
||||
} |
||||
return label; |
||||
} |
||||
}; |
||||
typeComboBox.setRenderer(render); |
||||
typeComboBox.addItemListener(itemListener); |
||||
this.add(typeComboBox, BorderLayout.NORTH); |
||||
} |
||||
|
||||
public void setComboBoxModel(boolean isDate) { |
||||
if (this.isDate != isDate) { |
||||
this.isDate = isDate; |
||||
this.typeComboBox.setSelectedIndex(0); |
||||
if (isDate) { |
||||
for (int i = 0; i < DATETYPES.length; i++) { |
||||
this.typeComboBox.addItem(DATETYPES[i]); |
||||
} |
||||
for (int i = 0; i < TYPES.length; i++) { |
||||
this.typeComboBox.removeItemAt(1); |
||||
} |
||||
} else { |
||||
for (int i = 0; i < TYPES.length; i++) { |
||||
this.typeComboBox.addItem(TYPES[i]); |
||||
} |
||||
for (int i = 0; i < DATETYPES.length; i++) { |
||||
this.typeComboBox.removeItemAt(1); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
package com.fr.design.gui.style; |
||||
|
||||
import com.fr.base.CoreDecimalFormat; |
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.base.Style; |
||||
import com.fr.base.TextFormat; |
||||
import com.fr.data.core.FormatField; |
||||
import com.fr.data.core.FormatField.FormatContents; |
||||
import com.fr.design.border.UIRoundedBorder; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.border.Border; |
||||
import javax.swing.border.TitledBorder; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.text.Format; |
||||
import java.text.SimpleDateFormat; |
||||
|
||||
/** |
||||
* Format pane to edit java.text.Format. |
||||
* |
||||
* @author zhou |
||||
* @since 2012-5-24上午10:57:00 |
||||
*/ |
||||
public class FormatPane extends AbstractBasicStylePane { |
||||
private static final long serialVersionUID = 724330854437726751L; |
||||
|
||||
private static final int LABLE_X = 4; |
||||
private static final int LABLE_Y = 18; |
||||
private static final int LABLE_DELTA_WIDTH = 8; |
||||
private static final int LABLE_HEIGHT = 15; //标签背景的范围
|
||||
private static final int CURRENCY_FLAG_POINT = 6; |
||||
|
||||
private static final Integer[] TYPES = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC, |
||||
FormatContents.DATE, FormatContents.TIME, FormatContents.TEXT}; |
||||
|
||||
private static final Integer[] DATETYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME,}; |
||||
|
||||
private Format format; |
||||
|
||||
private UIComboBox typeComboBox; |
||||
private UIComboBox textField; |
||||
private UILabel sampleLabel; |
||||
private JPanel contentPane; |
||||
private JPanel txtCenterPane; |
||||
private JPanel centerPane; |
||||
private JPanel formatFontPane; |
||||
private FRFontPane frFontPane; |
||||
private boolean isRightFormate; |
||||
private boolean isDate = false; |
||||
private boolean isFormat = false; |
||||
|
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
public FormatPane() { |
||||
this.initComponents(TYPES); |
||||
this.setBorder(UIConstants.CELL_ATTR_NORMALBORDER); |
||||
} |
||||
|
||||
protected void initComponents(Integer[] types) { |
||||
this.setLayout(new BorderLayout(0, 4)); |
||||
iniSampleLable(); |
||||
contentPane = new JPanel(new BorderLayout(0, 4)) { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(super.getPreferredSize().width, 70); |
||||
} |
||||
}; |
||||
typeComboBox = new UIComboBox(types); |
||||
UIComboBoxRenderer render = createComBoxRender(); |
||||
typeComboBox.setRenderer(render); |
||||
typeComboBox.addItemListener(itemListener); |
||||
contentPane.add(sampleLabel, BorderLayout.NORTH); |
||||
centerPane = new JPanel(new CardLayout()); |
||||
centerPane.add(new JPanel(), "hide"); |
||||
centerPane.setPreferredSize(new Dimension(0, 0)); |
||||
centerPane.add(contentPane, "show"); |
||||
formatFontPane = new JPanel(new BorderLayout()); |
||||
formatFontPane.add(centerPane, BorderLayout.NORTH); |
||||
formatFontPane.add(new FRFontPane(), BorderLayout.CENTER); |
||||
txtCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
contentPane.add(txtCenterPane, BorderLayout.CENTER); |
||||
textField = new UIComboBox(FormatField.getInstance().getFormatArray(getFormatContents())); |
||||
textField.addItemListener(textFieldItemListener); |
||||
textField.setEditable(true); |
||||
txtCenterPane.add(textField, BorderLayout.NORTH); |
||||
frFontPane = new FRFontPane(); |
||||
UILabel font = new UILabel(Inter.getLocText("FR-Designer_FRFont"), SwingConstants.LEFT); |
||||
JPanel fontPane = new JPanel(new BorderLayout()); |
||||
fontPane.add(font, BorderLayout.NORTH); |
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Base_Format") + " ", SwingConstants.LEFT), typeComboBox}, |
||||
new Component[]{null, centerPane}, |
||||
new Component[]{fontPane, frFontPane}, |
||||
new Component[]{null, null} |
||||
}; |
||||
double[] rowSize = {p, p, p, p, p}; |
||||
double[] columnSize = {p, f}; |
||||
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 3}, {1, 1}}; |
||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
protected UIComboBoxRenderer createComBoxRender() { |
||||
return new UIComboBoxRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof Integer) { |
||||
label.setText(" " + FormatField.getInstance().getName((Integer) value)); |
||||
} |
||||
return label; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void iniSampleLable() { |
||||
Border innterborder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); |
||||
Font tmpFont = null; |
||||
Border border = BorderFactory.createTitledBorder(innterborder, Inter.getLocText("FR-Base_StyleFormat_Sample"), TitledBorder.LEFT, 0, tmpFont, UIConstants.LINE_COLOR); |
||||
sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { |
||||
|
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
int width = getWidth(); |
||||
Color orignal = g.getColor(); |
||||
g.setColor(getBackground()); |
||||
g.fillRect(LABLE_X, LABLE_Y, width - LABLE_DELTA_WIDTH, LABLE_HEIGHT); |
||||
g.setColor(UIConstants.LINE_COLOR); |
||||
FontMetrics cellFM = g.getFontMetrics(); |
||||
int textWidth = cellFM.stringWidth(getText()); |
||||
GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); |
||||
g.setColor(orignal); |
||||
} |
||||
}; |
||||
sampleLabel.setHorizontalAlignment(UILabel.CENTER); |
||||
sampleLabel.setBorder(border); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
/** |
||||
* 得到合适的大小 |
||||
*/ |
||||
public Dimension getPreferredSize() { |
||||
if (this.typeComboBox.getSelectedIndex() == FormatContents.NULL) { |
||||
return typeComboBox.getPreferredSize(); |
||||
} |
||||
return super.getPreferredSize(); |
||||
} |
||||
|
||||
/** |
||||
* 弹出框标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Designer_Text"); |
||||
} |
||||
|
||||
/** |
||||
* Populate |
||||
*/ |
||||
public void populateBean(Format format) { |
||||
this.format = format; |
||||
|
||||
if (format == null) { |
||||
this.typeComboBox.setSelectedIndex(FormatContents.NULL); |
||||
} else { |
||||
if (format instanceof CoreDecimalFormat) { |
||||
// check all value
|
||||
String pattern = ((CoreDecimalFormat) format).toPattern(); |
||||
boolean isCurrency1 = (pattern.length() > 0 && pattern.charAt(0) == '¤'); |
||||
boolean isCurrency2 = (pattern.length() > 0 && pattern.charAt(0) == '$'); |
||||
boolean isCurrency = isCurrency1 || isCurrency2; |
||||
boolean isCurrency4 = (pattern.length() > CURRENCY_FLAG_POINT && ComparatorUtils.equals(pattern.substring(0, CURRENCY_FLAG_POINT), "#,##0;")); |
||||
if (isCurrency || isCurrency4) { |
||||
setPatternComboBoxAndList(FormatContents.CURRENCY, pattern); |
||||
} else if (pattern.endsWith("%")) { |
||||
setPatternComboBoxAndList(FormatContents.PERCENT, pattern); |
||||
} else if (pattern.indexOf("E") > 0) { |
||||
setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern); |
||||
} else { |
||||
setPatternComboBoxAndList(FormatContents.NUMBER, pattern); |
||||
} |
||||
} else if (format instanceof SimpleDateFormat) { // date and time
|
||||
String pattern = ((SimpleDateFormat) format).toPattern(); |
||||
if (!isTimeType(pattern)) { |
||||
setPatternComboBoxAndList(FormatContents.DATE, pattern); |
||||
} else { |
||||
setPatternComboBoxAndList(FormatContents.TIME, pattern); |
||||
} |
||||
} else if (format instanceof TextFormat) { // Text
|
||||
this.typeComboBox.setSelectedItem(FormatContents.TEXT); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 判断是否是数组有模式 |
||||
* |
||||
* @param stringArray 字符串数组 |
||||
* @param pattern 格式 |
||||
* @return 是否是数组有模式 |
||||
*/ |
||||
public static int isArrayContainPattern(String[] stringArray, String pattern) { |
||||
for (int i = 0; i < stringArray.length; i++) { |
||||
if (ComparatorUtils.equals(stringArray[i], pattern)) { |
||||
return i; |
||||
} |
||||
} |
||||
|
||||
return -1; |
||||
} |
||||
|
||||
private void setPatternComboBoxAndList(int formatStyle, String pattern) { |
||||
this.typeComboBox.setSelectedItem(formatStyle); |
||||
int i = isArrayContainPattern(FormatField.getInstance().getFormatArray(formatStyle), pattern); |
||||
if (i == -1) { |
||||
this.textField.setSelectedIndex(0); |
||||
} else { |
||||
this.textField.setSelectedIndex(i); |
||||
} |
||||
} |
||||
|
||||
private boolean isTimeType(String pattern) { |
||||
return pattern.matches(".*[Hhmsa].*"); |
||||
} |
||||
|
||||
/** |
||||
* update |
||||
*/ |
||||
public Format update() { |
||||
String patternString = String.valueOf(textField.getSelectedItem()); |
||||
if (getFormatContents() == FormatContents.TEXT) { |
||||
return FormatField.getInstance().getFormat(getFormatContents(), patternString); |
||||
} |
||||
if (isRightFormate) { |
||||
if (StringUtils.isNotEmpty(patternString)) { |
||||
return FormatField.getInstance().getFormat(getFormatContents(), patternString); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private int getFormatContents() { |
||||
return (Integer) typeComboBox.getSelectedItem(); |
||||
} |
||||
|
||||
/** |
||||
* Refresh preview label. |
||||
*/ |
||||
private void refreshPreviewLabel() { |
||||
this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); |
||||
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); |
||||
try { |
||||
isRightFormate = true; |
||||
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { |
||||
return; |
||||
} |
||||
this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem()))); |
||||
} catch (Exception e) { |
||||
this.sampleLabel.setForeground(Color.red); |
||||
this.sampleLabel.setText(e.getMessage()); |
||||
isRightFormate = false; |
||||
} |
||||
} |
||||
|
||||
private boolean isTextOrNull() { |
||||
int contents = getFormatContents(); |
||||
return contents == FormatContents.TEXT || contents == FormatContents.NULL; |
||||
} |
||||
|
||||
/** |
||||
* Radio selection listener. |
||||
*/ |
||||
ItemListener itemListener = new ItemListener() { |
||||
|
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
int contents = getFormatContents(); |
||||
String[] items = FormatField.getInstance().getFormatArray(contents); |
||||
CardLayout cardLayout = (CardLayout) centerPane.getLayout(); |
||||
|
||||
if (isTextOrNull()) { |
||||
centerPane.setPreferredSize(new Dimension(0, 0)); |
||||
cardLayout.show(centerPane, "hide"); |
||||
} else { |
||||
textField.removeAllItems(); |
||||
for (int i = 0; i < items.length; i++) { |
||||
textField.addItem(items[i]); |
||||
} |
||||
centerPane.setPreferredSize(new Dimension(270, 70)); |
||||
cardLayout.show(centerPane, "show"); |
||||
} |
||||
isFormat = true; |
||||
} |
||||
|
||||
} |
||||
}; |
||||
|
||||
ItemListener textFieldItemListener = new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
isFormat = true; |
||||
refreshPreviewLabel(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
/** |
||||
* populate |
||||
*/ |
||||
public void populateBean(Style style) { |
||||
this.populateBean(style.getFormat()); |
||||
isFormat = false; |
||||
this.frFontPane.populateBean(style.getFRFont()); |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* update |
||||
*/ |
||||
public Style update(Style style) { |
||||
if (isFormat) { |
||||
isFormat = false; |
||||
return style.deriveFormat(this.update()); |
||||
} else { |
||||
return style.deriveFRFont(this.frFontPane.update(style.getFRFont())); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 默认只显示百分比的编辑下拉. |
||||
*/ |
||||
public void justUsePercentFormat() { |
||||
typeComboBox.setEnabled(false); |
||||
this.typeComboBox.setSelectedItem(FormatContents.PERCENT); |
||||
} |
||||
|
||||
public void setForDataSheet() { |
||||
Integer[] otherTypes = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC,}; |
||||
this.typeComboBox = new UIComboBox(otherTypes); |
||||
UIComboBoxRenderer render = new UIComboBoxRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof Integer) { |
||||
label.setText(" " + FormatField.getInstance().getName((Integer) value)); |
||||
} |
||||
return label; |
||||
} |
||||
}; |
||||
typeComboBox.setRenderer(render); |
||||
typeComboBox.addItemListener(itemListener); |
||||
this.add(typeComboBox, BorderLayout.NORTH); |
||||
} |
||||
|
||||
public void setComboBoxModel(boolean isDate) { |
||||
if (this.isDate != isDate) { |
||||
this.isDate = isDate; |
||||
this.typeComboBox.setSelectedIndex(0); |
||||
if (isDate) { |
||||
for (int i = 0; i < DATETYPES.length; i++) { |
||||
this.typeComboBox.addItem(DATETYPES[i]); |
||||
} |
||||
for (int i = 0; i < TYPES.length; i++) { |
||||
this.typeComboBox.removeItemAt(1); |
||||
} |
||||
} else { |
||||
for (int i = 0; i < TYPES.length; i++) { |
||||
this.typeComboBox.addItem(TYPES[i]); |
||||
} |
||||
for (int i = 0; i < DATETYPES.length; i++) { |
||||
this.typeComboBox.removeItemAt(1); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 177 B |
After Width: | Height: | Size: 165 B |
Loading…
Reference in new issue