Browse Source

Merge pull request #1116 in BA/design from ~VITO/design:release/9.0 to release/9.0

* commit '800fb273b11bb8cd27f6221ea89458fc2b1ee27c':
  bugfix:单元格元素插入内容,对话框取消之后回到原内容
  bugfix:单元格元素插入内容下拉菜单后变为选中第一个而不是上次选中项
master
superman 7 years ago
parent
commit
cd82c1d8f9
  1. 39
      designer/src/com/fr/quickeditor/CellQuickEditor.java
  2. 15
      designer_base/src/com/fr/design/actions/core/ActionFactory.java

39
designer/src/com/fr/quickeditor/CellQuickEditor.java

@ -2,6 +2,7 @@ package com.fr.quickeditor;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
@ -11,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.menu.ShortCut;
import com.fr.design.selection.QuickEditor;
@ -20,8 +22,6 @@ import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.ColumnRow;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
@ -51,6 +51,8 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
/*占位label*/
protected static UILabel emptyLabel = new UILabel();
private int currentSelectedIndex;
static {
emptyLabel.setPreferredSize(new Dimension(60, 20));
}
@ -119,10 +121,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
cellLabel.setPreferredSize(new Dimension(60, 20));
UILabel insertContentLabel = new UILabel(Inter.getLocText("HF-Insert_Content"));
insertContentLabel.setPreferredSize(new Dimension(60, 20));
UIComboBox cellElementEditButton = initCellElementEditComboBox();
UIComboBox cellElementEditComboBox = initCellElementEditComboBox();
Component[][] components = new Component[][]{
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()},
new Component[]{insertContentLabel, cellElementEditButton},
new Component[]{insertContentLabel, cellElementEditComboBox},
};
JPanel topContent = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
topContent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
@ -136,6 +138,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
* @return UIButton
*/
private UIComboBox initCellElementEditComboBox() {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) {
return comboBox = new UIComboBox();
}
final String[] items = getDefaultComboBoxItems();
comboBox = new UIComboBox(items);
final Object comboBoxSelected = getComboBoxSelected();
@ -144,33 +150,14 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
} else {
comboBox.setSelectedIndex(1);
}
comboBox.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
if (cellInsertActions == null) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
}
// 这边重新获取是因为要根据JTemplate做一个过滤
ArrayList<String> arrayList = new ArrayList<String>();
for (UpdateAction action : cellInsertActions) {
arrayList.add(action.getMenuKeySet().getMenuKeySetName());
}
comboBox.setModel(new DefaultComboBoxModel<>(arrayList.toArray(new String[arrayList.size()])));
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
currentSelectedIndex = comboBox.getSelectedIndex();
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
selectedIndex = comboBox.getSelectedIndex();
cellInsertActions[selectedIndex].actionPerformed(e);
comboBox.setSelectedIndex(currentSelectedIndex);
}
});
return comboBox;

15
designer_base/src/com/fr/design/actions/core/ActionFactory.java

@ -73,6 +73,7 @@ public class ActionFactory {
/**
* 注册图表的 地图资源
*
* @param action 地图资源action
*/
public static void registerChartMapEditorAction(UpdateAction action) {
@ -229,16 +230,18 @@ public class ActionFactory {
public static MenuKeySet[] createCellInsertActionName() {
List<MenuKeySet> actionNames = new ArrayList<>();
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
for (Class<?> clazz : actionClasses) {
if (clazz == null) {
continue;
}
try {
Constructor<? extends UpdateAction> c = (Constructor<? extends UpdateAction>) clazz.getConstructor();
actionNames.add(c.newInstance().getMenuKeySet());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
if (jTemplate.acceptToolbarItem(clazz)) {
try {
Constructor<? extends UpdateAction> c = (Constructor<? extends UpdateAction>) clazz.getConstructor();
actionNames.add(c.newInstance().getMenuKeySet());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}
return actionNames.toArray(new MenuKeySet[actionNames.size()]);

Loading…
Cancel
Save