diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java index f03b726260..68446abc97 100644 --- a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.data.index.Index; import com.fr.stable.StringUtils; import javax.swing.*; @@ -19,7 +20,7 @@ import java.util.List; */ public class MobileRadioGroupPane extends BasicBeanPane{ - private List radioButtons = new ArrayList(); + private List radioButtons = new ArrayList(); public MobileRadioGroupPane(String title) { initComponents(title); @@ -30,26 +31,33 @@ public class MobileRadioGroupPane extends BasicBeanPane{ double[] rowSize = {p}; double[] columnSize = {p, p, p, p, p, p}; - UIRadioButton defaultRadio = new UIRadioButton(MobileFitAttrState.DEFAULT.description()); + IndexRadioButton defaultRadio = new IndexRadioButton(MobileFitAttrState.DEFAULT.description(), MobileFitAttrState.DEFAULT); defaultRadio.setSelected(true); - UIRadioButton horizonRadio = new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()); - UIRadioButton verticalRadio = new UIRadioButton(MobileFitAttrState.VERTICAL.description()); - UIRadioButton bidirectionalRadio = new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()); - UIRadioButton notFitRadio = new UIRadioButton(MobileFitAttrState.NONE.description()); + IndexRadioButton horizonRadio = new IndexRadioButton(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL); + IndexRadioButton verticalRadio = new IndexRadioButton(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL); + IndexRadioButton bidirectionalRadio = new IndexRadioButton(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL); + IndexRadioButton notFitRadio = new IndexRadioButton(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE); addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); Component[][] components = new Component[][]{ - new Component[]{new UILabel(title), defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio} + new Component[] { + new UILabel(title), + defaultRadio, + horizonRadio, + verticalRadio, + bidirectionalRadio, + notFitRadio + } }; JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); this.add(fitOpsPane); } - private void addToButtonGroup(UIRadioButton... radios) { + private void addToButtonGroup(IndexRadioButton... radios) { ButtonGroup buttonGroup = new ButtonGroup(); - for (UIRadioButton radio : radios) { + for (IndexRadioButton radio : radios) { radioButtons.add(radio); buttonGroup.add(radio); } @@ -59,7 +67,7 @@ public class MobileRadioGroupPane extends BasicBeanPane{ * 设置按钮状态 */ public void setEnabled(boolean enabled) { - for (UIRadioButton radioButton : radioButtons) { + for (IndexRadioButton radioButton : radioButtons) { radioButton.setEnabled(enabled); } } @@ -72,7 +80,7 @@ public class MobileRadioGroupPane extends BasicBeanPane{ public int getSelectRadioIndex() { for (int i = 0, len = radioButtons.size(); i < len; i++) { if (radioButtons.get(i).isSelected()) { - return i; + return radioButtons.get(i).getRadioButtonIndex(); } } @@ -87,15 +95,18 @@ public class MobileRadioGroupPane extends BasicBeanPane{ return; } - UIRadioButton button = radioButtons.get(index); - button.setSelected(true); + for (IndexRadioButton radioButton : this.radioButtons) { + if (radioButton.getRadioButtonIndex() == index) { + radioButton.setSelected(true); + } + } } /** * 给所有的按钮加上监听 */ public void addActionListener(ActionListener actionListener) { - for (UIRadioButton radioButton : radioButtons) { + for (IndexRadioButton radioButton : radioButtons) { radioButton.addActionListener(actionListener); } } @@ -116,3 +127,24 @@ public class MobileRadioGroupPane extends BasicBeanPane{ return StringUtils.EMPTY; } } + +/** + * created by fanglei on 2017/1/16 + * 不再用radioButtonGroup的数组下标作为index,而是给每个按钮传入MobileFitAttrState的枚举值 + */ +class IndexRadioButton extends UIRadioButton { + private int index; + + IndexRadioButton(String text, MobileFitAttrState mobileFitAttrState) { + super(text); + this.index = mobileFitAttrState.getState(); + } + + public int getRadioButtonIndex() { + return this.index; + } + + public void setRadioButtonIndex(int index) { + this.index = index; + } +} diff --git a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 553e6814c0..75b3219ebd 100644 --- a/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -7,6 +7,7 @@ import com.fr.base.ParameterHelper; import com.fr.data.core.db.TableProcedure; import com.fr.data.impl.DBTableData; import com.fr.data.impl.NameDatabaseConnection; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; @@ -17,6 +18,7 @@ import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.fun.DBTableDataMenuHandler; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.ParameterTableModel; @@ -34,7 +36,6 @@ import com.fr.general.Inter; import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import javax.swing.*; @@ -53,11 +54,13 @@ public class DBTableDataPane extends AbstractTableDataPane { private ConnectionTableProcedurePane connectionTableProcedurePane; private UITableEditorPane editorPane; + private DBTableDataMenuHandler dbTableDataMenuHandler; private SQLEditPane sqlTextPane; private UICheckBox isShareCheckBox; private MaxMemRowCountPanel maxPanel; private String pageQuery = null; - private String customCountQuery = null; + private DBTableData dbTableData; + public DBTableDataPane() { @@ -149,11 +152,9 @@ public class DBTableDataPane extends AbstractTableDataPane { } private void refresh() { - String[] paramTexts = new String[3]; + String[] paramTexts = new String[2]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; - paramTexts[2] = customCountQuery; - List existParameterList = editorPane.update(); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); @@ -166,8 +167,11 @@ public class DBTableDataPane extends AbstractTableDataPane { toolBarDef.addShortCut(new PreviewAction()); toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(new EditPageQueryAction()); - toolBarDef.addShortCut(SeparatorDef.DEFAULT); - toolBarDef.addShortCut(new EditCustomCountQueryAction()); + dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); + if (dbTableDataMenuHandler != null) { + toolBarDef.addShortCut(SeparatorDef.DEFAULT); + toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction()); + } isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData")); maxPanel = new MaxMemRowCountPanel(); maxPanel.setBorder(null); @@ -179,11 +183,9 @@ public class DBTableDataPane extends AbstractTableDataPane { } private void checkParameter() { - String[] paramTexts = new String[3]; + String[] paramTexts = new String[2]; paramTexts[0] = sqlTextPane.getText(); paramTexts[1] = pageQuery; - paramTexts[2] = customCountQuery; - Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); if (parameters.length < 1 && editorPane.update().size() < 1) { @@ -210,6 +212,10 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override public void populateBean(DBTableData dbtabledata) { + this.dbTableData = dbtabledata; + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.populate(dbtabledata); + } ParameterProvider[] parameters = null; Calculator c = Calculator.createCalculator(); @@ -227,8 +233,6 @@ public class DBTableDataPane extends AbstractTableDataPane { isShare = dbtabledata.isShare(); maxMemeryRow = dbtabledata.getMaxMemRowCount(); this.pageQuery = dbtabledata.getPageQuerySql(); - this.customCountQuery = dbtabledata.getCustomCountQuery(); - this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); this.sqlTextPane.setText(query); this.sqlTextPane.requestFocus(); @@ -253,7 +257,6 @@ public class DBTableDataPane extends AbstractTableDataPane { List parameterList = editorPane.update(); Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); - DBTableData dbTableData = new DBTableData(); dbTableData.setDatabase(new NameDatabaseConnection(dbName)); // p:必须先设置Parameters数组,因为setQuery里面会自动设置的 @@ -264,8 +267,9 @@ public class DBTableDataPane extends AbstractTableDataPane { dbTableData.setShare(isShareCheckBox.isSelected()); dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setPageQuerySql(this.pageQuery); - dbTableData.setCustomCountQuery(this.customCountQuery); - + if (dbTableDataMenuHandler != null) { + dbTableDataMenuHandler.update(); + } return dbTableData; } @@ -318,28 +322,6 @@ public class DBTableDataPane extends AbstractTableDataPane { } } - private class EditCustomCountQueryAction extends UpdateAction { - public EditCustomCountQueryAction() { - this.setName(Inter.getLocText("FR-Designer-LayerPageReport_CustomCountQuery")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png")); - } - - @Override - public void actionPerformed(ActionEvent e) { - final QueryPane editPane = new QueryPane(Inter.getLocText("FR-Designer-LayerPageReport_Define_CustomCountQuery")); - editPane.populate(customCountQuery); - BasicDialog dialog = editPane.showWindow(DesignerContext.getDesignerFrame()); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - customCountQuery = editPane.update(); - checkParameter(); - } - }); - dialog.setVisible(true); - - } - } - private class QueryPane extends BasicPane { private SQLEditPane pageQueryPane; private String title; diff --git a/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java b/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java new file mode 100644 index 0000000000..f06b63b712 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java @@ -0,0 +1,22 @@ +package com.fr.design.fun; + +import com.fr.data.impl.DBTableData; +import com.fr.design.actions.UpdateAction; +import com.fr.stable.fun.mark.Immutable; + +/** + * Created by xiaxiang on 2017/1/15. + */ +public interface DBTableDataMenuHandler extends Immutable { + String MARK_STRING = "DBTableDataMenuHandler"; + + int CURRENT_LEVEL = 1; + + UpdateAction createQueryAction(); + + void populate(DBTableData dbTableData); + + DBTableData update(); + + +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java b/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java new file mode 100644 index 0000000000..dd11712505 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java @@ -0,0 +1,34 @@ +package com.fr.design.fun.impl; + +import com.fr.data.impl.DBTableData; +import com.fr.design.actions.UpdateAction; +import com.fr.design.fun.DBTableDataMenuHandler; +import com.fr.stable.fun.mark.API; + +/** + * Created by xiaxiang on 2017/1/15. + */ +@API(level = DBTableDataMenuHandler.CURRENT_LEVEL) +public abstract class AbstractDBTableDataMenuHandler implements DBTableDataMenuHandler { + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + public int layerIndex() { + return DEFAULT_LAYER_INDEX; + } + + public UpdateAction createQueryAction() { + return null; + } + + @Override + public DBTableData update() { + return null; + } + + @Override + public void populate(DBTableData dbTableData) { + + } +} diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java index 552589b71a..8926befde4 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java @@ -9,12 +9,14 @@ public class MobileFitAlignmentItems implements ItemProvider { private static Item[] VALUE_ITEMS; static { - MobileFitAttrState[] allStates = MobileFitAttrState.values(); - int len = allStates.length; - VALUE_ITEMS = new Item[len]; - for (int i = 0; i < len ; i++) { - VALUE_ITEMS[i] = new Item(allStates[i].description(), allStates[i]); - } +// 此处不能循环根据MobileFitAttrState的枚举顺序创建items,否则不自适应选项就会跑到双向自适应选项前面。 + VALUE_ITEMS = new Item[]{ + new Item(MobileFitAttrState.DEFAULT.description(), MobileFitAttrState.DEFAULT), + new Item(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL), + new Item(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL), + new Item(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL), + new Item(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE) + }; } @Override