|
|
@ -5,13 +5,12 @@ import com.fr.base.Style; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.core.ActionFactory; |
|
|
|
import com.fr.design.actions.core.ActionFactory; |
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
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.frpane.AttributeChangeListener; |
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.iscrollbar.UIScrollBar; |
|
|
|
import com.fr.design.gui.iscrollbar.UIScrollBar; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.style.TextFormatPane; |
|
|
|
import com.fr.design.gui.style.TextFormatPaneContainer; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
@ -35,8 +34,8 @@ import javax.swing.JComponent; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JScrollBar; |
|
|
|
import javax.swing.JScrollBar; |
|
|
|
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Container; |
|
|
|
import java.awt.Container; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
@ -46,6 +45,7 @@ import java.awt.event.AdjustmentEvent; |
|
|
|
import java.awt.event.AdjustmentListener; |
|
|
|
import java.awt.event.AdjustmentListener; |
|
|
|
import java.awt.event.MouseWheelEvent; |
|
|
|
import java.awt.event.MouseWheelEvent; |
|
|
|
import java.awt.event.MouseWheelListener; |
|
|
|
import java.awt.event.MouseWheelListener; |
|
|
|
|
|
|
|
import java.text.Format; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
@ -67,12 +67,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
private static final int CONTENT_PANE_WIDTH_GAP = 3; |
|
|
|
private static final int CONTENT_PANE_WIDTH_GAP = 3; |
|
|
|
private static final int MOUSE_WHEEL_SPEED = 5; |
|
|
|
private static final int MOUSE_WHEEL_SPEED = 5; |
|
|
|
private static final int SCROLLBAR_WIDTH = 7; |
|
|
|
private static final int SCROLLBAR_WIDTH = 7; |
|
|
|
|
|
|
|
private UILabel cellLabel; |
|
|
|
/** |
|
|
|
|
|
|
|
* 区分单选多选单元格,生成相应设置面板 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private final String SINGLE_SELECT = "singleSelect"; |
|
|
|
|
|
|
|
private final String MULTIPLE_SELECT = "multipleSelect"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int maxHeight = 280; |
|
|
|
private int maxHeight = 280; |
|
|
|
private static final int TITLE_HEIGHT = 50; |
|
|
|
private static final int TITLE_HEIGHT = 50; |
|
|
@ -82,21 +77,16 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected UITextField columnRowTextField; |
|
|
|
protected UITextField columnRowTextField; |
|
|
|
protected TemplateCellElement cellElement; |
|
|
|
protected TemplateCellElement cellElement; |
|
|
|
private TextFormatPane formatPane; |
|
|
|
private TextFormatPaneContainer formatPane; |
|
|
|
private final JPanel topContentContainer; |
|
|
|
private JPanel topContentContainer; |
|
|
|
private final JComponent centerBodyContainer; |
|
|
|
private JComponent centerBodyContainer; |
|
|
|
|
|
|
|
private UILabel multipleLabelTip; |
|
|
|
|
|
|
|
|
|
|
|
private CardLayout topCardLayout; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 不同单元格元素产生的面板 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private CardLayout centerCardLayout; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 占位label
|
|
|
|
// 占位label
|
|
|
|
protected final UILabel EMPTY_LABEL = new UILabel(); |
|
|
|
protected final UILabel EMPTY_LABEL = new UILabel(); |
|
|
|
|
|
|
|
|
|
|
|
private UIComboBox singleComboBox; |
|
|
|
private UIComboBox comboBox; |
|
|
|
private UIComboBox multipleComboBox; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UpdateAction[] cellInsertActions; |
|
|
|
private UpdateAction[] cellInsertActions; |
|
|
|
private int selectedIndex; |
|
|
|
private int selectedIndex; |
|
|
@ -106,23 +96,38 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
private ActionListener comboBoxActionListener; |
|
|
|
private ActionListener comboBoxActionListener; |
|
|
|
|
|
|
|
|
|
|
|
public CellQuickEditor() { |
|
|
|
public CellQuickEditor() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initComponents(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createPanelBody(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); |
|
|
|
EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); |
|
|
|
|
|
|
|
topContentContainer = initTopContent(); |
|
|
|
|
|
|
|
formatPane = createFormatPane(); |
|
|
|
|
|
|
|
centerBodyContainer = createCenterBody(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multipleLabelTip = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip")); |
|
|
|
|
|
|
|
multipleLabelTip.setEnabled(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createPanelBody() { |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double[] columnSize = {p, f}; |
|
|
|
double[] columnSize = {f}; |
|
|
|
JPanel formatContainerPanel = createFormatPane(); |
|
|
|
|
|
|
|
topContentContainer = initTopContent(); |
|
|
|
|
|
|
|
centerBodyContainer = createAllCenterBody(); |
|
|
|
|
|
|
|
if (isScrollAll()) { |
|
|
|
if (isScrollAll()) { |
|
|
|
double[] scrollAllRowSize = {p, p, p}; |
|
|
|
double[] scrollAllRowSize = {p, p, p, p}; |
|
|
|
prepareScrollBar(); |
|
|
|
prepareScrollBar(); |
|
|
|
topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); |
|
|
|
multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground())); |
|
|
|
formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
|
|
|
|
formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
new Component[]{topContentContainer, null}, |
|
|
|
new Component[]{multipleLabelTip}, |
|
|
|
new Component[]{formatContainerPanel, null}, |
|
|
|
new Component[]{topContentContainer}, |
|
|
|
new Component[]{centerBodyContainer, null} |
|
|
|
new Component[]{formatPane}, |
|
|
|
|
|
|
|
new Component[]{centerBodyContainer} |
|
|
|
}; |
|
|
|
}; |
|
|
|
leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); |
|
|
|
leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); |
|
|
|
this.setLayout(new CellElementBarLayout(leftContentPane) { |
|
|
|
this.setLayout(new CellElementBarLayout(leftContentPane) { |
|
|
@ -151,14 +156,16 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
this.add(scrollBar); |
|
|
|
this.add(scrollBar); |
|
|
|
this.add(leftContentPane); |
|
|
|
this.add(leftContentPane); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
double[] scrollContentRowSize = {p, p, f}; |
|
|
|
double[] scrollContentRowSize = {p, p, p, f}; |
|
|
|
topContentContainer.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); |
|
|
|
multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground())); |
|
|
|
formatContainerPanel.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); |
|
|
|
topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); |
|
|
|
|
|
|
|
formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground())); |
|
|
|
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); |
|
|
|
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
new Component[]{topContentContainer, null}, |
|
|
|
new Component[]{multipleLabelTip}, |
|
|
|
new Component[]{formatContainerPanel, null}, |
|
|
|
new Component[]{topContentContainer}, |
|
|
|
new Component[]{centerBodyContainer, null} |
|
|
|
new Component[]{formatPane}, |
|
|
|
|
|
|
|
new Component[]{centerBodyContainer} |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); |
|
|
|
this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); |
|
|
@ -187,31 +194,6 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public abstract Object getComboBoxSelected(); |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 刷新 |
|
|
|
* 刷新 |
|
|
@ -224,61 +206,90 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
refreshFormatPanel(); |
|
|
|
refreshFormatPanel(); |
|
|
|
|
|
|
|
|
|
|
|
refreshDetails(); |
|
|
|
refreshDetails(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refreshMultipleDetails(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 多选时默认隐藏与插入元素类型相关的所有面板 |
|
|
|
|
|
|
|
* 若其他面板需要扩展多选时可修改的内容, |
|
|
|
|
|
|
|
* 通过重写改方法,实现显示/隐藏部分组件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void refreshMultipleDetails() { |
|
|
|
|
|
|
|
centerBodyContainer.setVisible(tc.isSelectedOneCell()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refreshFormatPanel() { |
|
|
|
private void refreshFormatPanel() { |
|
|
|
|
|
|
|
// 在populate的时候会多次触发AttributeChangeListener事件,
|
|
|
|
|
|
|
|
// 导致不断更新单元格格式,因此populate的时候暂时删除listener
|
|
|
|
|
|
|
|
formatPane.removeAttributeChangeListener(); |
|
|
|
|
|
|
|
|
|
|
|
if (cellElement != null) { |
|
|
|
if (cellElement != null) { |
|
|
|
formatPane.populateBean(cellElement.getStyle()); |
|
|
|
formatPane.populateBean(cellElement.getStyle()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
formatPane.populateBean(Style.DEFAULT_STYLE); |
|
|
|
formatPane.populateBean(Style.DEFAULT_STYLE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formatPane.restoreAttributeChangeListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refreshPanel() { |
|
|
|
private void refreshPanel() { |
|
|
|
|
|
|
|
changeVisiableState(); |
|
|
|
|
|
|
|
|
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); |
|
|
|
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()); |
|
|
|
columnRowTextField.setText(columnRow.toString()); |
|
|
|
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); |
|
|
|
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); |
|
|
|
|
|
|
|
|
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
if (jTemplate != null) { |
|
|
|
if (jTemplate != null) { |
|
|
|
singleComboBox.removeActionListener(comboBoxActionListener); |
|
|
|
comboBox.removeActionListener(comboBoxActionListener); |
|
|
|
singleComboBox.removeAllItems(); |
|
|
|
comboBox.removeAllItems(); |
|
|
|
String[] items = getDefaultComboBoxItems(); |
|
|
|
String[] items = getDefaultComboBoxItems(); |
|
|
|
for (String item : items) { |
|
|
|
for (String item : items) { |
|
|
|
singleComboBox.addItem(item); |
|
|
|
comboBox.addItem(item); |
|
|
|
multipleComboBox.addItem(item); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Object comboBoxSelected = getComboBoxSelected(); |
|
|
|
Object comboBoxSelected = getComboBoxSelected(); |
|
|
|
if (comboBoxSelected != null) { |
|
|
|
if (comboBoxSelected != null) { |
|
|
|
singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
singleComboBox.setSelectedIndex(1); |
|
|
|
comboBox.setSelectedIndex(1); |
|
|
|
multipleComboBox.setSelectedIndex(1); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
currentSelectedIndex = singleComboBox.getSelectedIndex(); |
|
|
|
currentSelectedIndex = comboBox.getSelectedIndex(); |
|
|
|
comboBoxActionListener = new ActionListener() { |
|
|
|
comboBoxActionListener = new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); |
|
|
|
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); |
|
|
|
selectedIndex = singleComboBox.getSelectedIndex(); |
|
|
|
selectedIndex = comboBox.getSelectedIndex(); |
|
|
|
singleComboBox.setPopupVisible(false); |
|
|
|
comboBox.setPopupVisible(false); |
|
|
|
singleComboBox.repaint(); |
|
|
|
comboBox.repaint(); |
|
|
|
// comboBox.getSelectedIndex()可能返回-1
|
|
|
|
// comboBox.getSelectedIndex()可能返回-1
|
|
|
|
if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { |
|
|
|
if (selectedIndex != -1 && selectedIndex < cellInsertActions.length) { |
|
|
|
cellInsertActions[selectedIndex].actionPerformed(e); |
|
|
|
cellInsertActions[selectedIndex].actionPerformed(e); |
|
|
|
} |
|
|
|
} |
|
|
|
singleComboBox.setSelectedIndex(currentSelectedIndex); |
|
|
|
comboBox.setSelectedIndex(currentSelectedIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
singleComboBox.addActionListener(comboBoxActionListener); |
|
|
|
comboBox.addActionListener(comboBoxActionListener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 单选多选时切换部分组件的 隐藏/显示 状态 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void changeVisiableState() { |
|
|
|
|
|
|
|
boolean selectedOneCell = tc.isSelectedOneCell(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
comboBox.setEnabled(selectedOneCell); |
|
|
|
|
|
|
|
if (selectedOneCell) { |
|
|
|
|
|
|
|
columnRowTextField.setPreferredSize(null); |
|
|
|
|
|
|
|
cellLabel.setPreferredSize(null); |
|
|
|
|
|
|
|
multipleLabelTip.setPreferredSize(new Dimension()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
columnRowTextField.setPreferredSize(new Dimension()); |
|
|
|
|
|
|
|
cellLabel.setPreferredSize(new Dimension()); |
|
|
|
|
|
|
|
multipleLabelTip.setPreferredSize(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -289,44 +300,19 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel initTopContent() { |
|
|
|
private JPanel initTopContent() { |
|
|
|
topCardLayout = new CardLayout(); |
|
|
|
|
|
|
|
JPanel topContentPane = new JPanel(topCardLayout); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单选面板
|
|
|
|
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double f = TableLayout.FILL; |
|
|
|
double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; |
|
|
|
double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; |
|
|
|
double[] rowSize = {p, p}; |
|
|
|
double[] rowSize = {p, p}; |
|
|
|
UILabel cellLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); |
|
|
|
cellLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); |
|
|
|
UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); |
|
|
|
UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); |
|
|
|
initCellElementEditComboBox(); |
|
|
|
initCellElementEditComboBox(); |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, |
|
|
|
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, |
|
|
|
new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(singleComboBox)}, |
|
|
|
new Component[]{insertContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)}, |
|
|
|
}; |
|
|
|
|
|
|
|
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); |
|
|
|
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); |
|
|
|
topContentPane.add(MULTIPLE_SELECT, multiplePanel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return topContentPane; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void prepareScrollBar() { |
|
|
|
private void prepareScrollBar() { |
|
|
@ -374,23 +360,19 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
private void initCellElementEditComboBox() { |
|
|
|
private void initCellElementEditComboBox() { |
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
if (jTemplate == null) { |
|
|
|
if (jTemplate == null) { |
|
|
|
singleComboBox = new UIComboBox(); |
|
|
|
comboBox = new UIComboBox(); |
|
|
|
multipleComboBox = new UIComboBox(); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
final String[] items = getDefaultComboBoxItems(); |
|
|
|
final String[] items = getDefaultComboBoxItems(); |
|
|
|
singleComboBox = new UIComboBox(items); |
|
|
|
comboBox = new UIComboBox(items); |
|
|
|
multipleComboBox = new UIComboBox(items); |
|
|
|
|
|
|
|
final Object comboBoxSelected = getComboBoxSelected(); |
|
|
|
final Object comboBoxSelected = getComboBoxSelected(); |
|
|
|
if (comboBoxSelected != null) { |
|
|
|
if (comboBoxSelected != null) { |
|
|
|
singleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
multipleComboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
singleComboBox.setSelectedIndex(1); |
|
|
|
comboBox.setSelectedIndex(1); |
|
|
|
multipleComboBox.setSelectedIndex(1); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
currentSelectedIndex = singleComboBox.getSelectedIndex(); |
|
|
|
currentSelectedIndex = comboBox.getSelectedIndex(); |
|
|
|
singleComboBox.addActionListener(comboBoxActionListener); |
|
|
|
comboBox.addActionListener(comboBoxActionListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String[] getDefaultComboBoxItems() { |
|
|
|
private String[] getDefaultComboBoxItems() { |
|
|
@ -439,61 +421,52 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建格式化面板 |
|
|
|
* 创建格式化面板 |
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private JPanel createFormatPane() { |
|
|
|
private TextFormatPaneContainer createFormatPane() { |
|
|
|
formatPane = new TextFormatPane(); |
|
|
|
TextFormatPaneContainer formatPane = new TextFormatPaneContainer(); |
|
|
|
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 |
|
|
|
AttributeChangeListener attributeChangeListener = new AttributeChangeListener() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
|
|
|
if (formatPane == null) { |
|
|
|
|
|
|
|
return super.getPreferredSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return formatPane.getPreferredSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
container.addAttributeChangeListener(new AttributeChangeListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void attributeChange() { |
|
|
|
public void attributeChange() { |
|
|
|
|
|
|
|
|
|
|
|
isEditing = true; |
|
|
|
SwingUtilities.invokeLater(new Runnable() { |
|
|
|
boolean updateStyle = false; |
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
// 耗时任务放线程中,让其他UI组件更新界面,
|
|
|
|
TemplateElementCase editingElementCase = tc.getEditingElementCase(); |
|
|
|
// 防止多次调用此处每次获取的界面值不同,导致不断更新单元格格式
|
|
|
|
Set<TemplateCellElement> allCellElements = cs.getAllCellElements(editingElementCase); |
|
|
|
isEditing = true; |
|
|
|
for (TemplateCellElement cellElement : allCellElements) { |
|
|
|
boolean updateStyle = false; |
|
|
|
Style elementStyle = cellElement.getStyle(); |
|
|
|
|
|
|
|
Style style = formatPane.update(elementStyle); |
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
if (!Objects.equals(style.getFormat(), elementStyle.getFormat())) { |
|
|
|
TemplateElementCase editingElementCase = tc.getEditingElementCase(); |
|
|
|
// 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态
|
|
|
|
Set<TemplateCellElement> allCellElements = cs.getCellElements(); |
|
|
|
editingElementCase.addCellElement(cellElement); |
|
|
|
Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle(); |
|
|
|
cellElement.setStyle(style); |
|
|
|
Style style = formatPane.update(oldStyle); |
|
|
|
updateStyle = true; |
|
|
|
for (TemplateCellElement cellElement : allCellElements) { |
|
|
|
|
|
|
|
Format elementFormat = cellElement.getStyle().getFormat(); |
|
|
|
|
|
|
|
Format paneFormat = style.getFormat(); |
|
|
|
|
|
|
|
if (!Objects.equals(paneFormat, elementFormat)) { |
|
|
|
|
|
|
|
// 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态
|
|
|
|
|
|
|
|
editingElementCase.addCellElement(cellElement); |
|
|
|
|
|
|
|
cellElement.setStyle(style); |
|
|
|
|
|
|
|
updateStyle = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (updateStyle) { |
|
|
|
|
|
|
|
// 防止频繁触发保存
|
|
|
|
|
|
|
|
fireTargetModified(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isEditing = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (updateStyle) { |
|
|
|
|
|
|
|
// 防止频繁触发保存
|
|
|
|
|
|
|
|
fireTargetModified(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
isEditing = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
return container; |
|
|
|
|
|
|
|
|
|
|
|
formatPane.addAttributeChangeListener(attributeChangeListener); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return formatPane; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|