diff --git a/designer/src/com/fr/design/actions/ElementCaseAction.java b/designer/src/com/fr/design/actions/ElementCaseAction.java index be9ff9f9a..bfc0c8b4e 100644 --- a/designer/src/com/fr/design/actions/ElementCaseAction.java +++ b/designer/src/com/fr/design/actions/ElementCaseAction.java @@ -10,24 +10,10 @@ import com.fr.grid.selection.Selection; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; -public abstract class ElementCaseAction extends TemplateComponentAction { +public abstract class ElementCaseAction extends SelectionListenerAction { protected ElementCaseAction(ElementCasePane t) { super(t); - t.addSelectionChangeListener(new SelectionListener() { - - @Override - public void selectionChanged(SelectionEvent e) { - update(); - if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { - Selection selection = getEditingComponent().getSelection(); - if (selection instanceof CellSelection) { - CellSelection cellselection = (CellSelection) selection; - //样式处理 - getEditingComponent().setCellNeedTOFormat(cellselection); - } - } - } - }); + t.addSelectionChangeListener(createSelectionListener()); } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/SelectionListenerAction.java b/designer/src/com/fr/design/actions/SelectionListenerAction.java new file mode 100644 index 000000000..48cd2d4f9 --- /dev/null +++ b/designer/src/com/fr/design/actions/SelectionListenerAction.java @@ -0,0 +1,36 @@ +package com.fr.design.actions; + +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.selection.SelectionEvent; +import com.fr.design.selection.SelectionListener; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.Selection; + +/** + * Created by daniel on 2016/10/10. + */ +public abstract class SelectionListenerAction extends TemplateComponentAction { + + protected SelectionListenerAction(ElementCasePane elementCasePane) { + super(elementCasePane); + } + + protected SelectionListener createSelectionListener () { + return new SelectionListener() { + + @Override + public void selectionChanged(SelectionEvent e) { + update(); + if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { + Selection selection = getEditingComponent().getSelection(); + if (selection instanceof CellSelection) { + CellSelection cellselection = (CellSelection) selection; + //样式处理 + getEditingComponent().setCellNeedTOFormat(cellselection); + } + } + } + }; + } +} diff --git a/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java b/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java index 98fde3f75..27adef643 100644 --- a/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java +++ b/designer/src/com/fr/design/actions/cell/GlobalStyleMenuDef.java @@ -8,6 +8,7 @@ import com.fr.base.BaseUtils; import com.fr.base.ConfigManager; import com.fr.base.NameStyle; import com.fr.design.actions.ElementCaseAction; +import com.fr.design.actions.SelectionListenerAction; import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.UpdateAction; import com.fr.design.gui.imenu.UIMenu; @@ -151,7 +152,7 @@ public class GlobalStyleMenuDef extends MenuDef { - public static class GlobalStyleSelection extends TemplateComponentAction { + public static class GlobalStyleSelection extends SelectionListenerAction { private NameStyle nameStyle; @@ -196,22 +197,5 @@ public class GlobalStyleMenuDef extends MenuDef { return useMenuItem; } - private SelectionListener createSelectionListener (){ - return new SelectionListener (){ - - @Override - public void selectionChanged(SelectionEvent e) { - update(); - if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { - Selection selection = getEditingComponent().getSelection(); - if (selection instanceof CellSelection) { - CellSelection cellselection = (CellSelection) selection; - //样式处理 - getEditingComponent().setCellNeedTOFormat(cellselection); - } - } - } - }; - } } } \ No newline at end of file