Browse Source

bugfix:单元格元素插入内容下拉菜单后变为选中第一个而不是上次选中项

master
vito 7 years ago
parent
commit
ef12593641
  1. 35
      designer/src/com/fr/quickeditor/CellQuickEditor.java
  2. 5
      designer_base/src/com/fr/design/actions/core/ActionFactory.java

35
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.UpdateAction;
import com.fr.design.actions.core.ActionFactory; 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.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;
@ -11,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.selection.QuickEditor; import com.fr.design.selection.QuickEditor;
@ -20,8 +22,6 @@ import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -119,10 +119,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
cellLabel.setPreferredSize(new Dimension(60, 20)); cellLabel.setPreferredSize(new Dimension(60, 20));
UILabel insertContentLabel = new UILabel(Inter.getLocText("HF-Insert_Content")); UILabel insertContentLabel = new UILabel(Inter.getLocText("HF-Insert_Content"));
insertContentLabel.setPreferredSize(new Dimension(60, 20)); insertContentLabel.setPreferredSize(new Dimension(60, 20));
UIComboBox cellElementEditButton = initCellElementEditComboBox(); UIComboBox cellElementEditComboBox = initCellElementEditComboBox();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()},
new Component[]{insertContentLabel, cellElementEditButton}, new Component[]{insertContentLabel, cellElementEditComboBox},
}; };
JPanel topContent = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); JPanel topContent = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
topContent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); topContent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
@ -136,6 +136,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
* @return UIButton * @return UIButton
*/ */
private UIComboBox initCellElementEditComboBox() { private UIComboBox initCellElementEditComboBox() {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) {
return comboBox = new UIComboBox();
}
final String[] items = getDefaultComboBoxItems(); final String[] items = getDefaultComboBoxItems();
comboBox = new UIComboBox(items); comboBox = new UIComboBox(items);
final Object comboBoxSelected = getComboBoxSelected(); final Object comboBoxSelected = getComboBoxSelected();
@ -144,31 +148,10 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
} else { } else {
comboBox.setSelectedIndex(1); 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) {
}
});
comboBox.addActionListener(new ActionListener() { comboBox.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc);
selectedIndex = comboBox.getSelectedIndex(); selectedIndex = comboBox.getSelectedIndex();
cellInsertActions[selectedIndex].actionPerformed(e); cellInsertActions[selectedIndex].actionPerformed(e);
} }

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

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

Loading…
Cancel
Save