diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java index c8c7b54ea..c42f06946 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java @@ -54,7 +54,7 @@ public class OnlineShopUtils { } private static String getWidgetFilterPath() { - return StableUtils.pathJoin(getReuInfoPath(), "filter"); + return StableUtils.pathJoin(getReuInfoPath(), "/all/filter/"); } private static String getGetCompositeSortParaPath() { diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java index f71a504c8..5969cb6c2 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java +++ b/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.DialogActionAdapter; 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.ilable.UILabel; 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.ui.Widget; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.border.Border; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Dimension; @@ -113,57 +112,17 @@ public class ShareGeneratePane extends BasicPane { this.mainPane.add(simplePane, ShareUIUtils.convertStateChange(ItemEvent.DESELECTED)); this.mainPane.add(uploadPane, ShareUIUtils.convertStateChange(ItemEvent.SELECTED)); - simplePane.getNameField().getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void changedUpdate(DocumentEvent e) { - validInput(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - validInput(); - } - + simplePane.addRequiredSettingChangeListener(new ChangeListener() { @Override - public void removeUpdate(DocumentEvent e) { - validInput(); + public void fireChanged(ChangeEvent event) { + checkRequiredSettings(); } }); - simplePane.getDesignerVersionField().getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void changedUpdate(DocumentEvent e) { - validInput(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - validInput(); - } - + uploadPane.addRequiredSettingChangeListener(new ChangeListener() { @Override - public void removeUpdate(DocumentEvent e) { - validInput(); - } - }); - - 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(); + public void fireChanged(ChangeEvent event) { + checkRequiredSettings(); } }); @@ -176,14 +135,9 @@ public class ShareGeneratePane extends BasicPane { return pane; } - private void validInput() { - String name = getSelectMainPane().getNameField().getText().trim(); - boolean isValidName = StringUtils.isNotEmpty(name); - - boolean isValidDesignerVersion = getSelectMainPane().getDesignerVersionField().isValidVersion(); - - boolean isValidInput = isValidName && isValidDesignerVersion; - dialog.setButtonEnabled(isValidInput); + private void checkRequiredSettings() { + boolean isSettingsRequired = getSelectMainPane().checkRequiredSettings(); + dialog.setButtonEnabled(isSettingsRequired); } diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index b19dbd659..5639b5957 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/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.DialogActionAdapter; 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.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -62,6 +64,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.border.MatteBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; @@ -142,6 +146,9 @@ public class ShareMainPane extends JPanel { private List effectItemGroups; private final boolean needContentTip; + // 监听必填项 + private ChangeListener requiredSettingChangeListener; + public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List effectItemGroups, boolean needContentTip) { this.shareCover = shareCover; @@ -410,11 +417,31 @@ public class ShareMainPane extends JPanel { pane.add(parentClassify); pane.add(childClassify); + + UILabel validSymbol = new UILabel(" *"); + pane.add(validSymbol); return pane; } private JPanel createDesignerVersionFiledPane() { 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(); UILabel validSymbol = new UILabel(" *"); symbolTextFiled.add(designerVersionField, BorderLayout.CENTER); @@ -546,6 +573,23 @@ public class ShareMainPane extends JPanel { nameField.setPlaceholder(Toolkit.i18nText("Fine-Design_Share_Name_Placeholder")); nameField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT)); 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(); UILabel validSymbol = new UILabel(" *"); symbolTextFiled.add(nameField, BorderLayout.CENTER); @@ -672,16 +716,29 @@ public class ShareMainPane extends JPanel { return provider; } - public Group getSelectGroup() { - return (Group) localGroup.getSelectedItem(); + public boolean checkRequiredSettings() { + 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() { - return nameField; + private void notifyRequiredSettingChanged(ChangeEvent event) { + if (this.requiredSettingChangeListener != null) { + this.requiredSettingChangeListener.fireChanged(event); + } } - public VersionIntervalField getDesignerVersionField() { - return designerVersionField; + public Group getSelectGroup() { + return (Group) localGroup.getSelectedItem(); } private String classify(Object classify) { @@ -761,14 +818,17 @@ public class ShareMainPane extends JPanel { @Override public void insertString(int offset, String str, AttributeSet attrSet) throws BadLocationException { if (str == null) { - return; + throw new BadLocationException(null, offset); } int count = str.length(); for (int i = 0; i < count; i++) { char c = str.charAt(i); if (allowCharAsString.indexOf(c) < 0) { java.awt.Toolkit.getDefaultToolkit().beep(); - return; + // REPORT-63194 + // 合成文本,如中文等存在输入-删除-替换的机制 JTextComponent#replaceInputMethodText() + // 所以这里不能直接return,而应该抛出异常中断后续字符处理,否则在处理中文等合成文本时会导致原有字符被删除 + throw new BadLocationException(str, offset); } } super.insertString(offset, str, attrSet);