Browse Source

Merging in latest from upstream (BA/design:refs/heads/dev)

* commit '9548523e0a36e9280307560e350a24e812cc1da7':
  不再独自创建带index的选项按钮,而是继承自UIRadioButton
  rt
  rt
  rt
  RadioButton的构造函数的第二个参数修改为MobileFitAttrState
  表单的双向自适应和不自适应顺序忘记改了
  rt
  修改了双向自适应和不自适应按钮的顺序
  rt
master
daniel 8 years ago
parent
commit
efbe2e4b79
  1. 60
      designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java
  2. 56
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  3. 22
      designer_base/src/com/fr/design/fun/DBTableDataMenuHandler.java
  4. 34
      designer_base/src/com/fr/design/fun/impl/AbstractDBTableDataMenuHandler.java
  5. 14
      designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java

60
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.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.data.index.Index;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -19,7 +20,7 @@ import java.util.List;
*/ */
public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>(); private List<IndexRadioButton> radioButtons = new ArrayList<IndexRadioButton>();
public MobileRadioGroupPane(String title) { public MobileRadioGroupPane(String title) {
initComponents(title); initComponents(title);
@ -30,26 +31,33 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{
double[] rowSize = {p}; double[] rowSize = {p};
double[] columnSize = {p, p, p, p, p, 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); defaultRadio.setSelected(true);
UIRadioButton horizonRadio = new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()); IndexRadioButton horizonRadio = new IndexRadioButton(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL);
UIRadioButton verticalRadio = new UIRadioButton(MobileFitAttrState.VERTICAL.description()); IndexRadioButton verticalRadio = new IndexRadioButton(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL);
UIRadioButton bidirectionalRadio = new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()); IndexRadioButton bidirectionalRadio = new IndexRadioButton(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL);
UIRadioButton notFitRadio = new UIRadioButton(MobileFitAttrState.NONE.description()); IndexRadioButton notFitRadio = new IndexRadioButton(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE);
addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio);
Component[][] components = new Component[][]{ 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); JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10));
this.add(fitOpsPane); this.add(fitOpsPane);
} }
private void addToButtonGroup(UIRadioButton... radios) { private void addToButtonGroup(IndexRadioButton... radios) {
ButtonGroup buttonGroup = new ButtonGroup(); ButtonGroup buttonGroup = new ButtonGroup();
for (UIRadioButton radio : radios) { for (IndexRadioButton radio : radios) {
radioButtons.add(radio); radioButtons.add(radio);
buttonGroup.add(radio); buttonGroup.add(radio);
} }
@ -59,7 +67,7 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{
* 设置按钮状态 * 设置按钮状态
*/ */
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
for (UIRadioButton radioButton : radioButtons) { for (IndexRadioButton radioButton : radioButtons) {
radioButton.setEnabled(enabled); radioButton.setEnabled(enabled);
} }
} }
@ -72,7 +80,7 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{
public int getSelectRadioIndex() { public int getSelectRadioIndex() {
for (int i = 0, len = radioButtons.size(); i < len; i++) { for (int i = 0, len = radioButtons.size(); i < len; i++) {
if (radioButtons.get(i).isSelected()) { if (radioButtons.get(i).isSelected()) {
return i; return radioButtons.get(i).getRadioButtonIndex();
} }
} }
@ -87,15 +95,18 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{
return; return;
} }
UIRadioButton button = radioButtons.get(index); for (IndexRadioButton radioButton : this.radioButtons) {
button.setSelected(true); if (radioButton.getRadioButtonIndex() == index) {
radioButton.setSelected(true);
}
}
} }
/** /**
* 给所有的按钮加上监听 * 给所有的按钮加上监听
*/ */
public void addActionListener(ActionListener actionListener) { public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) { for (IndexRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener); radioButton.addActionListener(actionListener);
} }
} }
@ -116,3 +127,24 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{
return StringUtils.EMPTY; 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;
}
}

56
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.core.db.TableProcedure;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants; 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.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fun.DBTableDataMenuHandler;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
@ -34,7 +36,6 @@ import com.fr.general.Inter;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -53,11 +54,13 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
private ConnectionTableProcedurePane connectionTableProcedurePane; private ConnectionTableProcedurePane connectionTableProcedurePane;
private UITableEditorPane<ParameterProvider> editorPane; private UITableEditorPane<ParameterProvider> editorPane;
private DBTableDataMenuHandler dbTableDataMenuHandler;
private SQLEditPane sqlTextPane; private SQLEditPane sqlTextPane;
private UICheckBox isShareCheckBox; private UICheckBox isShareCheckBox;
private MaxMemRowCountPanel maxPanel; private MaxMemRowCountPanel maxPanel;
private String pageQuery = null; private String pageQuery = null;
private String customCountQuery = null; private DBTableData dbTableData;
public DBTableDataPane() { public DBTableDataPane() {
@ -149,11 +152,9 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
private void refresh() { private void refresh() {
String[] paramTexts = new String[3]; String[] paramTexts = new String[2];
paramTexts[0] = sqlTextPane.getText(); paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery; paramTexts[1] = pageQuery;
paramTexts[2] = customCountQuery;
List<ParameterProvider> existParameterList = editorPane.update(); List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]);
@ -166,8 +167,11 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
toolBarDef.addShortCut(new PreviewAction()); toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditPageQueryAction()); toolBarDef.addShortCut(new EditPageQueryAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT); dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING);
toolBarDef.addShortCut(new EditCustomCountQueryAction()); if (dbTableDataMenuHandler != null) {
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction());
}
isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData")); isShareCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Is_Share_DBTableData"));
maxPanel = new MaxMemRowCountPanel(); maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null); maxPanel.setBorder(null);
@ -179,11 +183,9 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
private void checkParameter() { private void checkParameter() {
String[] paramTexts = new String[3]; String[] paramTexts = new String[2];
paramTexts[0] = sqlTextPane.getText(); paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery; paramTexts[1] = pageQuery;
paramTexts[2] = customCountQuery;
Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false); Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
if (parameters.length < 1 && editorPane.update().size() < 1) { if (parameters.length < 1 && editorPane.update().size() < 1) {
@ -210,6 +212,10 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
@Override @Override
public void populateBean(DBTableData dbtabledata) { public void populateBean(DBTableData dbtabledata) {
this.dbTableData = dbtabledata;
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.populate(dbtabledata);
}
ParameterProvider[] parameters = null; ParameterProvider[] parameters = null;
Calculator c = Calculator.createCalculator(); Calculator c = Calculator.createCalculator();
@ -227,8 +233,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
isShare = dbtabledata.isShare(); isShare = dbtabledata.isShare();
maxMemeryRow = dbtabledata.getMaxMemRowCount(); maxMemeryRow = dbtabledata.getMaxMemRowCount();
this.pageQuery = dbtabledata.getPageQuerySql(); this.pageQuery = dbtabledata.getPageQuerySql();
this.customCountQuery = dbtabledata.getCustomCountQuery();
this.connectionTableProcedurePane.setSelectedDatabaseConnection(db); this.connectionTableProcedurePane.setSelectedDatabaseConnection(db);
this.sqlTextPane.setText(query); this.sqlTextPane.setText(query);
this.sqlTextPane.requestFocus(); this.sqlTextPane.requestFocus();
@ -253,7 +257,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
List<ParameterProvider> parameterList = editorPane.update(); List<ParameterProvider> parameterList = editorPane.update();
Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]);
DBTableData dbTableData = new DBTableData();
dbTableData.setDatabase(new NameDatabaseConnection(dbName)); dbTableData.setDatabase(new NameDatabaseConnection(dbName));
// p:必须先设置Parameters数组,因为setQuery里面会自动设置的 // p:必须先设置Parameters数组,因为setQuery里面会自动设置的
@ -264,8 +267,9 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
dbTableData.setShare(isShareCheckBox.isSelected()); dbTableData.setShare(isShareCheckBox.isSelected());
dbTableData.setMaxMemRowCount(maxPanel.getValue()); dbTableData.setMaxMemRowCount(maxPanel.getValue());
dbTableData.setPageQuerySql(this.pageQuery); dbTableData.setPageQuerySql(this.pageQuery);
dbTableData.setCustomCountQuery(this.customCountQuery); if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.update();
}
return dbTableData; return dbTableData;
} }
@ -318,28 +322,6 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
} }
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 class QueryPane extends BasicPane {
private SQLEditPane pageQueryPane; private SQLEditPane pageQueryPane;
private String title; private String title;

22
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();
}

34
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) {
}
}

14
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; private static Item[] VALUE_ITEMS;
static { static {
MobileFitAttrState[] allStates = MobileFitAttrState.values(); // 此处不能循环根据MobileFitAttrState的枚举顺序创建items,否则不自适应选项就会跑到双向自适应选项前面。
int len = allStates.length; VALUE_ITEMS = new Item[]{
VALUE_ITEMS = new Item[len]; new Item(MobileFitAttrState.DEFAULT.description(), MobileFitAttrState.DEFAULT),
for (int i = 0; i < len ; i++) { new Item(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL),
VALUE_ITEMS[i] = new Item(allStates[i].description(), allStates[i]); new Item(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL),
} new Item(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL),
new Item(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE)
};
} }
@Override @Override

Loading…
Cancel
Save