Browse Source

Merge branch 'release/11.0' of ssh://code.fineres.com:7999/~kerry/design_10.0 into release/11.0

bugfix/11.0
kerry 3 years ago
parent
commit
1dc4141cfb
  1. 24
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  2. 4
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java
  3. 68
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java
  4. 76
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java

24
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -46,6 +46,7 @@ import com.fr.parser.BlockIntervalLiteral;
import com.fr.parser.ColumnRowRangeInPage; import com.fr.parser.ColumnRowRangeInPage;
import com.fr.parser.NumberLiteral; import com.fr.parser.NumberLiteral;
import com.fr.parser.SheetIntervalLiteral; import com.fr.parser.SheetIntervalLiteral;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.report.core.namespace.SimpleCellValueNameSpace;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.script.ScriptConstants; import com.fr.script.ScriptConstants;
@ -54,7 +55,6 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.EssentialUtils; import com.fr.stable.EssentialUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.UtilEvalError;
import com.fr.stable.script.CRAddress; import com.fr.stable.script.CRAddress;
import com.fr.stable.script.ColumnRowRange; import com.fr.stable.script.ColumnRowRange;
import com.fr.stable.script.Expression; import com.fr.stable.script.Expression;
@ -122,6 +122,7 @@ import java.util.Set;
* @editor zhou * @editor zhou
* @since 2012-3-29下午1:50:53 * @since 2012-3-29下午1:50:53
*/ */
@EnableMetrics
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public static final int DEFUAL_FOMULA_LENGTH = 103; public static final int DEFUAL_FOMULA_LENGTH = 103;
public static final String ELLIPSIS = "..."; public static final String ELLIPSIS = "...";
@ -139,6 +140,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected static UICheckBox autoCompletionCheck; protected static UICheckBox autoCompletionCheck;
protected static UICheckBox checkBeforeColse; protected static UICheckBox checkBeforeColse;
private JList tipsList; private JList tipsList;
private JPopupMenu popupMenu;
protected DefaultListModel listModel = new DefaultListModel(); protected DefaultListModel listModel = new DefaultListModel();
private int ifHasBeenWriten = 0; private int ifHasBeenWriten = 0;
private DefaultListModel functionTypeListModel = new DefaultListModel(); private DefaultListModel functionTypeListModel = new DefaultListModel();
@ -457,6 +459,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) { if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) {
doubleClickActuator(doublePressContent); doubleClickActuator(doublePressContent);
} }
if (popupMenu != null) {
popupMenu.setVisible(false);
}
} }
} }
} }
@ -616,7 +621,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
private void popTips() { private void popTips() {
JPopupMenu popupMenu = new JPopupMenu(); popupMenu = new JPopupMenu();
JScrollPane tipsScrollPane = new JScrollPane(tipsList); JScrollPane tipsScrollPane = new JScrollPane(tipsList);
popupMenu.add(tipsScrollPane); popupMenu.add(tipsScrollPane);
tipsScrollPane.setPreferredSize(new Dimension(240, 146)); tipsScrollPane.setPreferredSize(new Dimension(240, 146));
@ -792,6 +797,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private final ActionListener calculateActionListener = new ActionListener() { private final ActionListener calculateActionListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String formulaText = formulaTextArea.getText().trim(); String formulaText = formulaTextArea.getText().trim();
@ -819,16 +825,20 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText);
Object calResult;
try { try {
Object value = calculator.evalValue(baseFormula); calResult = calculator.evalValue(baseFormula);
String objectToString = EssentialUtils.objectToString(value); String objectToString = EssentialUtils.objectToString(calResult);
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ?
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString;
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result;
FineLoggerFactory.getLogger().info("value:{}", value); } catch (Exception ce) {
} catch (UtilEvalError utilEvalError) { //模拟计算如果出现错误,则抛出错误
FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError); calResult = ce.getMessage();
FineLoggerFactory.getLogger().error(ce.getMessage(), ce);
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Error") + ":" + calResult;
} }
FineLoggerFactory.getLogger().info("value:{}", calResult);
} else { } else {
messageTips = checkResult.getTips(); messageTips = checkResult.getTips();
} }

4
designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java

@ -119,10 +119,12 @@ public class LocalWidgetRepoPane extends BasicPane {
content.add(LabelUtils.createAutoWrapLabel(Toolkit.i18nText("Fine-Design_Share_Upgrade_Tip"), new Color(0x333334)), BorderLayout.CENTER); content.add(LabelUtils.createAutoWrapLabel(Toolkit.i18nText("Fine-Design_Share_Upgrade_Tip"), new Color(0x333334)), BorderLayout.CENTER);
JPanel actionsPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); JPanel actionsPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
actionsPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, -5));
actionsPane.setOpaque(false); actionsPane.setOpaque(false);
actionsPane.setBackground(null); actionsPane.setBackground(null);
UIButton cancelUpgradeButton = new UIButton(Toolkit.i18nText("Fine-Design_Share_Upgrade_Cancel")); UIButton cancelUpgradeButton = new UIButton(Toolkit.i18nText("Fine-Design_Share_Upgrade_Cancel"));
cancelUpgradeButton.setRoundBorder(true);
cancelUpgradeButton.addActionListener(new ActionListener() { cancelUpgradeButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -132,6 +134,8 @@ public class LocalWidgetRepoPane extends BasicPane {
UIButton startUpgradeButton = new UIButton(Toolkit.i18nText("Fine-Design_Share_Upgrade_All")); UIButton startUpgradeButton = new UIButton(Toolkit.i18nText("Fine-Design_Share_Upgrade_All"));
startUpgradeButton.setSelected(true); startUpgradeButton.setSelected(true);
startUpgradeButton.setRoundBorder(true);
startUpgradeButton.setBorderPainted(false);
startUpgradeButton.setForeground(Color.WHITE); startUpgradeButton.setForeground(Color.WHITE);
startUpgradeButton.addActionListener(new ActionListener() { startUpgradeButton.addActionListener(new ActionListener() {
@Override @Override

68
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

@ -5,6 +5,8 @@ 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.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.ChangeEvent;
import com.fr.design.event.ChangeListener;
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.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -33,15 +35,12 @@ import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.form.share.record.ShareWidgetInfoManager; import com.fr.form.share.record.ShareWidgetInfoManager;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Dimension; import java.awt.Dimension;
@ -113,57 +112,17 @@ public class ShareGeneratePane extends BasicPane {
this.mainPane.add(simplePane, ShareUIUtils.convertStateChange(ItemEvent.DESELECTED)); this.mainPane.add(simplePane, ShareUIUtils.convertStateChange(ItemEvent.DESELECTED));
this.mainPane.add(uploadPane, ShareUIUtils.convertStateChange(ItemEvent.SELECTED)); this.mainPane.add(uploadPane, ShareUIUtils.convertStateChange(ItemEvent.SELECTED));
simplePane.getNameField().getDocument().addDocumentListener(new DocumentListener() { simplePane.addRequiredSettingChangeListener(new ChangeListener() {
@Override
public void changedUpdate(DocumentEvent e) {
validInput();
}
@Override
public void insertUpdate(DocumentEvent e) {
validInput();
}
@Override @Override
public void removeUpdate(DocumentEvent e) { public void fireChanged(ChangeEvent event) {
validInput(); checkRequiredSettings();
} }
}); });
simplePane.getDesignerVersionField().getDocument().addDocumentListener(new DocumentListener() { uploadPane.addRequiredSettingChangeListener(new ChangeListener() {
@Override
public void changedUpdate(DocumentEvent e) {
validInput();
}
@Override
public void insertUpdate(DocumentEvent e) {
validInput();
}
@Override @Override
public void removeUpdate(DocumentEvent e) { public void fireChanged(ChangeEvent event) {
validInput(); checkRequiredSettings();
}
});
uploadPane.getNameField().getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
validInput();
}
@Override
public void insertUpdate(DocumentEvent e) {
validInput();
}
@Override
public void removeUpdate(DocumentEvent e) {
validInput();
} }
}); });
@ -176,14 +135,9 @@ public class ShareGeneratePane extends BasicPane {
return pane; return pane;
} }
private void validInput() { private void checkRequiredSettings() {
String name = getSelectMainPane().getNameField().getText().trim(); boolean isSettingsRequired = getSelectMainPane().checkRequiredSettings();
boolean isValidName = StringUtils.isNotEmpty(name); dialog.setButtonEnabled(isSettingsRequired);
boolean isValidDesignerVersion = getSelectMainPane().getDesignerVersionField().isValidVersion();
boolean isValidInput = isValidName && isValidDesignerVersion;
dialog.setButtonEnabled(isValidInput);
} }

76
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java

@ -5,6 +5,8 @@ import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.ChangeEvent;
import com.fr.design.event.ChangeListener;
import com.fr.design.extra.LoginWebBridge; import com.fr.design.extra.LoginWebBridge;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
@ -62,6 +64,8 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.AttributeSet; import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument; import javax.swing.text.PlainDocument;
@ -142,6 +146,9 @@ public class ShareMainPane extends JPanel {
private List<EffectItemGroup> effectItemGroups; private List<EffectItemGroup> effectItemGroups;
private final boolean needContentTip; private final boolean needContentTip;
// 监听必填项
private ChangeListener requiredSettingChangeListener;
public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List<EffectItemGroup> effectItemGroups, boolean needContentTip) { public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List<EffectItemGroup> effectItemGroups, boolean needContentTip) {
this.shareCover = shareCover; this.shareCover = shareCover;
@ -410,11 +417,31 @@ public class ShareMainPane extends JPanel {
pane.add(parentClassify); pane.add(parentClassify);
pane.add(childClassify); pane.add(childClassify);
UILabel validSymbol = new UILabel(" *");
pane.add(validSymbol);
return pane; return pane;
} }
private JPanel createDesignerVersionFiledPane() { private JPanel createDesignerVersionFiledPane() {
designerVersionField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT)); designerVersionField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT));
designerVersionField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
notifyRequiredSettingChanged(new ChangeEvent(designerVersionField));
}
@Override
public void insertUpdate(DocumentEvent e) {
notifyRequiredSettingChanged(new ChangeEvent(designerVersionField));
}
@Override
public void removeUpdate(DocumentEvent e) {
notifyRequiredSettingChanged(new ChangeEvent(designerVersionField));
}
});
JPanel symbolTextFiled = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel symbolTextFiled = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel validSymbol = new UILabel(" *"); UILabel validSymbol = new UILabel(" *");
symbolTextFiled.add(designerVersionField, BorderLayout.CENTER); symbolTextFiled.add(designerVersionField, BorderLayout.CENTER);
@ -546,6 +573,23 @@ public class ShareMainPane extends JPanel {
nameField.setPlaceholder(Toolkit.i18nText("Fine-Design_Share_Name_Placeholder")); nameField.setPlaceholder(Toolkit.i18nText("Fine-Design_Share_Name_Placeholder"));
nameField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT)); nameField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT));
nameField.setDocument(nameLimited); nameField.setDocument(nameLimited);
nameField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent e) {
notifyRequiredSettingChanged(new ChangeEvent(nameField));
}
@Override
public void insertUpdate(DocumentEvent e) {
notifyRequiredSettingChanged(new ChangeEvent(nameField));
}
@Override
public void removeUpdate(DocumentEvent e) {
notifyRequiredSettingChanged(new ChangeEvent(nameField));
}
});
JPanel symbolTextFiled = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel symbolTextFiled = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel validSymbol = new UILabel(" *"); UILabel validSymbol = new UILabel(" *");
symbolTextFiled.add(nameField, BorderLayout.CENTER); symbolTextFiled.add(nameField, BorderLayout.CENTER);
@ -672,16 +716,29 @@ public class ShareMainPane extends JPanel {
return provider; return provider;
} }
public Group getSelectGroup() { public boolean checkRequiredSettings() {
return (Group) localGroup.getSelectedItem(); String name = nameField.getText().trim();
boolean isNameRequired = StringUtils.isNotEmpty(name);
boolean isDesignerVersionRequired = designerVersionField.isValidVersion();
boolean isClassifyRequired = parentClassify.getSelectedItem() != null && childClassify.getSelectedItem() != null;
return isNameRequired && isDesignerVersionRequired && isClassifyRequired;
}
public void addRequiredSettingChangeListener(ChangeListener changeListener) {
this.requiredSettingChangeListener = changeListener;
} }
public UITextField getNameField() { private void notifyRequiredSettingChanged(ChangeEvent event) {
return nameField; if (this.requiredSettingChangeListener != null) {
this.requiredSettingChangeListener.fireChanged(event);
}
} }
public VersionIntervalField getDesignerVersionField() { public Group getSelectGroup() {
return designerVersionField; return (Group) localGroup.getSelectedItem();
} }
private String classify(Object classify) { private String classify(Object classify) {
@ -761,14 +818,17 @@ public class ShareMainPane extends JPanel {
@Override @Override
public void insertString(int offset, String str, AttributeSet attrSet) throws BadLocationException { public void insertString(int offset, String str, AttributeSet attrSet) throws BadLocationException {
if (str == null) { if (str == null) {
return; throw new BadLocationException(null, offset);
} }
int count = str.length(); int count = str.length();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
char c = str.charAt(i); char c = str.charAt(i);
if (allowCharAsString.indexOf(c) < 0) { if (allowCharAsString.indexOf(c) < 0) {
java.awt.Toolkit.getDefaultToolkit().beep(); java.awt.Toolkit.getDefaultToolkit().beep();
return; // REPORT-63194
// 合成文本,如中文等存在输入-删除-替换的机制 JTextComponent#replaceInputMethodText()
// 所以这里不能直接return,而应该抛出异常中断后续字符处理,否则在处理中文等合成文本时会导致原有字符被删除
throw new BadLocationException(str, offset);
} }
} }
super.insertString(offset, str, attrSet); super.insertString(offset, str, attrSet);

Loading…
Cancel
Save