|
|
|
@ -1,13 +1,17 @@
|
|
|
|
|
package com.fr.quickeditor; |
|
|
|
|
|
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
|
import com.fr.base.Style; |
|
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
|
import com.fr.design.actions.core.ActionFactory; |
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
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.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.iscrollbar.UIScrollBar; |
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
import com.fr.design.gui.style.TextFormatPane; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
@ -23,6 +27,7 @@ import com.fr.design.widget.FRWidgetFactory;
|
|
|
|
|
import com.fr.grid.selection.CellSelection; |
|
|
|
|
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout; |
|
|
|
|
import com.fr.report.cell.TemplateCellElement; |
|
|
|
|
import com.fr.report.elementcase.TemplateElementCase; |
|
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
@ -31,6 +36,7 @@ import javax.swing.JOptionPane;
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JScrollBar; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.CardLayout; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Container; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
@ -41,6 +47,8 @@ import java.awt.event.AdjustmentListener;
|
|
|
|
|
import java.awt.event.MouseWheelEvent; |
|
|
|
|
import java.awt.event.MouseWheelListener; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author zhou, yaoh.wu |
|
|
|
@ -59,6 +67,13 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
private static final int CONTENT_PANE_WIDTH_GAP = 3; |
|
|
|
|
private static final int MOUSE_WHEEL_SPEED = 5; |
|
|
|
|
private static final int SCROLLBAR_WIDTH = 7; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 区分单选多选单元格,生成相应设置面板 |
|
|
|
|
*/ |
|
|
|
|
private final String SINGLE_SELECT = "singleSelect"; |
|
|
|
|
private final String MULTIPLE_SELECT = "multipleSelect"; |
|
|
|
|
|
|
|
|
|
private int maxHeight = 280; |
|
|
|
|
private static final int TITLE_HEIGHT = 50; |
|
|
|
|
|
|
|
|
@ -67,11 +82,22 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
*/ |
|
|
|
|
protected UITextField columnRowTextField; |
|
|
|
|
protected TemplateCellElement cellElement; |
|
|
|
|
private TextFormatPane formatPane; |
|
|
|
|
private final JPanel topContentContainer; |
|
|
|
|
private final JComponent centerBodyContainer; |
|
|
|
|
|
|
|
|
|
private CardLayout topCardLayout; |
|
|
|
|
/** |
|
|
|
|
* 不同单元格元素产生的面板 |
|
|
|
|
*/ |
|
|
|
|
private CardLayout centerCardLayout; |
|
|
|
|
|
|
|
|
|
// 占位label
|
|
|
|
|
protected final UILabel EMPTY_LABEL = new UILabel(); |
|
|
|
|
|
|
|
|
|
private UIComboBox comboBox; |
|
|
|
|
private UIComboBox singleComboBox; |
|
|
|
|
private UIComboBox multipleComboBox; |
|
|
|
|
|
|
|
|
|
private UpdateAction[] cellInsertActions; |
|
|
|
|
private int selectedIndex; |
|
|
|
|
private int currentSelectedIndex; |
|
|
|
@ -84,16 +110,19 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
|
double[] columnSize = {p, f}; |
|
|
|
|
JComponent centerBody = createCenterBody(); |
|
|
|
|
JPanel topContent = initTopContent(); |
|
|
|
|
JPanel formatContainerPanel = createFormatPane(); |
|
|
|
|
topContentContainer = initTopContent(); |
|
|
|
|
centerBodyContainer = createAllCenterBody(); |
|
|
|
|
if (isScrollAll()) { |
|
|
|
|
double[] scrollAllRowSize = {p, p}; |
|
|
|
|
double[] scrollAllRowSize = {p, p, p}; |
|
|
|
|
prepareScrollBar(); |
|
|
|
|
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); |
|
|
|
|
centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
|
topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); |
|
|
|
|
formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
|
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
new Component[]{topContent, null}, |
|
|
|
|
new Component[]{centerBody, null} |
|
|
|
|
new Component[]{topContentContainer, null}, |
|
|
|
|
new Component[]{formatContainerPanel, null}, |
|
|
|
|
new Component[]{centerBodyContainer, null} |
|
|
|
|
}; |
|
|
|
|
leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); |
|
|
|
|
this.setLayout(new CellElementBarLayout(leftContentPane) { |
|
|
|
@ -122,12 +151,14 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
this.add(scrollBar); |
|
|
|
|
this.add(leftContentPane); |
|
|
|
|
} else { |
|
|
|
|
double[] scrollContentRowSize = {p, f}; |
|
|
|
|
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); |
|
|
|
|
centerBody.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); |
|
|
|
|
double[] scrollContentRowSize = {p, p, f}; |
|
|
|
|
topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); |
|
|
|
|
formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); |
|
|
|
|
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); |
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
new Component[]{topContent, null}, |
|
|
|
|
new Component[]{centerBody, null} |
|
|
|
|
new Component[]{topContentContainer, null}, |
|
|
|
|
new Component[]{formatContainerPanel, null}, |
|
|
|
|
new Component[]{centerBodyContainer, null} |
|
|
|
|
}; |
|
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); |
|
|
|
@ -156,48 +187,99 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
*/ |
|
|
|
|
public abstract Object getComboBoxSelected(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化创建单选及多选面板 |
|
|
|
|
* |
|
|
|
|
* @return 创建的面板 |
|
|
|
|
*/ |
|
|
|
|
private JComponent createAllCenterBody() { |
|
|
|
|
centerCardLayout = new CardLayout(); |
|
|
|
|
|
|
|
|
|
JPanel centerPanel = new JPanel(centerCardLayout); |
|
|
|
|
|
|
|
|
|
centerPanel.add(SINGLE_SELECT, createCenterBody()); |
|
|
|
|
centerPanel.add(MULTIPLE_SELECT, createCenterBody4Multiple()); |
|
|
|
|
|
|
|
|
|
return centerPanel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 为多选单元格创建详细面板,默认创建空面板 |
|
|
|
|
* |
|
|
|
|
* @return 空面板 |
|
|
|
|
*/ |
|
|
|
|
public JComponent createCenterBody4Multiple() { |
|
|
|
|
return new JPanel(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 刷新 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
protected void refresh() { |
|
|
|
|
|
|
|
|
|
refreshPanel(); |
|
|
|
|
|
|
|
|
|
refreshFormatPanel(); |
|
|
|
|
|
|
|
|
|
refreshDetails(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void refreshFormatPanel() { |
|
|
|
|
if (cellElement != null) { |
|
|
|
|
formatPane.populateBean(cellElement.getStyle()); |
|
|
|
|
} else { |
|
|
|
|
formatPane.populateBean(Style.DEFAULT_STYLE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void refreshPanel() { |
|
|
|
|
|
|
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
|
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); |
|
|
|
|
String selectType = tc.isSelectedOneCell() ? SINGLE_SELECT : MULTIPLE_SELECT; |
|
|
|
|
|
|
|
|
|
topCardLayout.show(topContentContainer, selectType); |
|
|
|
|
centerCardLayout.show(centerBodyContainer, selectType); |
|
|
|
|
|
|
|
|
|
columnRowTextField.setText(columnRow.toString()); |
|
|
|
|
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); |
|
|
|
|
|
|
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (jTemplate != null) { |
|
|
|
|
comboBox.removeActionListener(comboBoxActionListener); |
|
|
|
|
comboBox.removeAllItems(); |
|
|
|
|
singleComboBox.removeActionListener(comboBoxActionListener); |
|
|
|
|
singleComboBox.removeAllItems(); |
|
|
|
|
String[] items = getDefaultComboBoxItems(); |
|
|
|
|
for (String item : items) { |
|
|
|
|
comboBox.addItem(item); |
|
|
|
|
singleComboBox.addItem(item); |
|
|
|
|
multipleComboBox.addItem(item); |
|
|
|
|
} |
|
|
|
|
Object comboBoxSelected = getComboBoxSelected(); |
|
|
|
|
if (comboBoxSelected != null) { |
|
|
|
|
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
} else { |
|
|
|
|
comboBox.setSelectedIndex(1); |
|
|
|
|
singleComboBox.setSelectedIndex(1); |
|
|
|
|
multipleComboBox.setSelectedIndex(1); |
|
|
|
|
} |
|
|
|
|
currentSelectedIndex = comboBox.getSelectedIndex(); |
|
|
|
|
currentSelectedIndex = singleComboBox.getSelectedIndex(); |
|
|
|
|
comboBoxActionListener = new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); |
|
|
|
|
selectedIndex = comboBox.getSelectedIndex(); |
|
|
|
|
comboBox.setPopupVisible(false); |
|
|
|
|
comboBox.repaint(); |
|
|
|
|
selectedIndex = singleComboBox.getSelectedIndex(); |
|
|
|
|
singleComboBox.setPopupVisible(false); |
|
|
|
|
singleComboBox.repaint(); |
|
|
|
|
// comboBox.getSelectedIndex()可能返回-1
|
|
|
|
|
if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { |
|
|
|
|
cellInsertActions[selectedIndex].actionPerformed(e); |
|
|
|
|
} |
|
|
|
|
comboBox.setSelectedIndex(currentSelectedIndex); |
|
|
|
|
singleComboBox.setSelectedIndex(currentSelectedIndex); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
comboBox.addActionListener(comboBoxActionListener); |
|
|
|
|
singleComboBox.addActionListener(comboBoxActionListener); |
|
|
|
|
} |
|
|
|
|
refreshDetails(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -207,6 +289,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel initTopContent() { |
|
|
|
|
topCardLayout = new CardLayout(); |
|
|
|
|
JPanel topContentPane = new JPanel(topCardLayout); |
|
|
|
|
|
|
|
|
|
// 单选面板
|
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
|
double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; |
|
|
|
@ -216,9 +302,31 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
initCellElementEditComboBox(); |
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
|
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, |
|
|
|
|
new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)}, |
|
|
|
|
new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(singleComboBox)}, |
|
|
|
|
}; |
|
|
|
|
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); |
|
|
|
|
JPanel singlePanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); |
|
|
|
|
topContentPane.add(SINGLE_SELECT, singlePanel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 多选面板
|
|
|
|
|
UILabel multipleTipLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); |
|
|
|
|
multipleTipLabel.setEnabled(false); |
|
|
|
|
multipleTipLabel.setBorder(BorderFactory.createMatteBorder(5, 0, 0, 0, this.getBackground())); |
|
|
|
|
UILabel insertContentLabel1 = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); |
|
|
|
|
Component[][] components1 = new Component[][]{ |
|
|
|
|
new Component[]{insertContentLabel1, UIComponentUtils.wrapWithBorderLayoutPane(multipleComboBox)}, |
|
|
|
|
}; |
|
|
|
|
multipleComboBox.setEnabled(false); |
|
|
|
|
JPanel insertPanel = TableLayoutHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize, HGAP, |
|
|
|
|
VGAP); |
|
|
|
|
Component[][] components2 = new Component[][]{ |
|
|
|
|
new Component[]{multipleTipLabel}, |
|
|
|
|
new Component[]{insertPanel}, |
|
|
|
|
}; |
|
|
|
|
JPanel multiplePanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, new double[]{f}, HGAP, VGAP); |
|
|
|
|
topContentPane.add(MULTIPLE_SELECT, multiplePanel); |
|
|
|
|
|
|
|
|
|
return topContentPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void prepareScrollBar() { |
|
|
|
@ -266,19 +374,23 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
private void initCellElementEditComboBox() { |
|
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (jTemplate == null) { |
|
|
|
|
comboBox = new UIComboBox(); |
|
|
|
|
singleComboBox = new UIComboBox(); |
|
|
|
|
multipleComboBox = new UIComboBox(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
final String[] items = getDefaultComboBoxItems(); |
|
|
|
|
comboBox = new UIComboBox(items); |
|
|
|
|
singleComboBox = new UIComboBox(items); |
|
|
|
|
multipleComboBox = new UIComboBox(items); |
|
|
|
|
final Object comboBoxSelected = getComboBoxSelected(); |
|
|
|
|
if (comboBoxSelected != null) { |
|
|
|
|
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
} else { |
|
|
|
|
comboBox.setSelectedIndex(1); |
|
|
|
|
singleComboBox.setSelectedIndex(1); |
|
|
|
|
multipleComboBox.setSelectedIndex(1); |
|
|
|
|
} |
|
|
|
|
currentSelectedIndex = comboBox.getSelectedIndex(); |
|
|
|
|
comboBox.addActionListener(comboBoxActionListener); |
|
|
|
|
currentSelectedIndex = singleComboBox.getSelectedIndex(); |
|
|
|
|
singleComboBox.addActionListener(comboBoxActionListener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String[] getDefaultComboBoxItems() { |
|
|
|
@ -324,4 +436,64 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
|
|
|
|
|
}); |
|
|
|
|
return columnRowTextField; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建格式化面板 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private JPanel createFormatPane() { |
|
|
|
|
formatPane = new TextFormatPane(); |
|
|
|
|
AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { |
|
|
|
|
@Override |
|
|
|
|
protected JPanel createContentPane() { |
|
|
|
|
return formatPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initContentPane() { |
|
|
|
|
leftContentPane = createContentPane(); |
|
|
|
|
if (leftContentPane != null) { |
|
|
|
|
leftContentPane.setBorder(BorderFactory.createEmptyBorder()); |
|
|
|
|
this.add(leftContentPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
if (formatPane == null) { |
|
|
|
|
return super.getPreferredSize(); |
|
|
|
|
} |
|
|
|
|
return formatPane.getPreferredSize(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
container.addAttributeChangeListener(new AttributeChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void attributeChange() { |
|
|
|
|
|
|
|
|
|
isEditing = true; |
|
|
|
|
boolean updateStyle = false; |
|
|
|
|
|
|
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
|
TemplateElementCase editingElementCase = tc.getEditingElementCase(); |
|
|
|
|
Set<TemplateCellElement> allCellElements = cs.getAllCellElements(editingElementCase); |
|
|
|
|
for (TemplateCellElement cellElement : allCellElements) { |
|
|
|
|
Style elementStyle = cellElement.getStyle(); |
|
|
|
|
Style style = formatPane.update(elementStyle); |
|
|
|
|
if (!Objects.equals(style.getFormat(), elementStyle.getFormat())) { |
|
|
|
|
// 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态
|
|
|
|
|
editingElementCase.addCellElement(cellElement); |
|
|
|
|
cellElement.setStyle(style); |
|
|
|
|
updateStyle = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (updateStyle) { |
|
|
|
|
// 防止频繁触发保存
|
|
|
|
|
fireTargetModified(); |
|
|
|
|
} |
|
|
|
|
isEditing = false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return container; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|