diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java new file mode 100644 index 000000000..17ee23b53 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java @@ -0,0 +1,48 @@ +package com.fr.design.actions.community; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.BugNeedMark; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/28 + */ +public class BugNeedAction extends UpdateAction { + public BugNeedAction() { + this.setMenuKeySet(BugAndNeed); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/need.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + LocaleMark localeMark = LocaleCenter.getMark(BugNeedMark.class); + BrowseUtils.browser(localeMark.getValue()); + } + + public static final MenuKeySet BugAndNeed = new MenuKeySet() { + @Override + public char getMnemonic() { + return 0; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_BugAndNeed"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java new file mode 100644 index 000000000..9c8067138 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java @@ -0,0 +1,49 @@ +package com.fr.design.actions.community; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.TechSupportMark; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/28 + */ +public class TechSupportAction extends UpdateAction { + public TechSupportAction() { + this.setMenuKeySet(TechSupport); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/support.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + LocaleMark localeMark = LocaleCenter.getMark(TechSupportMark.class); + String str=localeMark.getValue(); + BrowseUtils.browser(localeMark.getValue()); + } + + public static final MenuKeySet TechSupport = new MenuKeySet() { + @Override + public char getMnemonic() { + return 0; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_TechSupport"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java b/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java new file mode 100644 index 000000000..9e4e655f3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java @@ -0,0 +1,9 @@ +package com.fr.design.event; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public interface StateChangeListener { + public void stateChange(); +} diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index f271f23c0..e331d296e 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -1 +1,244 @@ -package com.fr.design.file; 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.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); templatesList.repaint(); } }); final UICheckBox filenameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); filenameCheckBox.setSelected(true); filenameCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isSelected = filenameCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesChoosePane.add(filenameCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file +package com.fr.design.file; + +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.StateChangeListener; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ilist.UIList; +import com.fr.design.gui.itree.checkboxtree.NullTristateCheckBox; +import com.fr.design.gui.itree.checkboxtree.TristateCheckBox; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ComparatorUtils; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; + +/** + * Author : daisy + * Date: 13-8-9 + * Time: 下午3:41 + */ +public class SaveSomeTemplatePane extends BasicPane { + + private UICheckBox[] templateCheckBoxes = null; + private BasicDialog dialog; + private JPanel templatesChoosePane; + private UIScrollPane scrollPane; + private java.util.List> unSavedTemplate = new ArrayList>(); + private boolean isAllSaved = false; + + //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 + private boolean isJudgeCurrentEditingTemplate = true; + + public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + if (this.dialog == null) { + this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + for (int i = 0; i < templateCheckBoxes.length; i++) { + if (templateCheckBoxes[i].isSelected()) { + saveSelectedTemplate(unSavedTemplate.get(i)); + } + } + isAllSaved = true; + } + + public void doCancel() { + isAllSaved = false; + } + + }); + } + UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); + this.add(tip, BorderLayout.NORTH); + templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); + this.add(scrollPane, BorderLayout.CENTER); + this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; + } + + private void initTemplatesChoosePane() { + templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); + for (int i = 0; i < unSavedTemplate.size(); i++) { + templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); + templateCheckBoxes[i].setSelected(true); + } + + final UIList templatesList = new UIList(templateCheckBoxes); + templatesList.setModel(new UnSeletedTemplateListDataMode()); + templatesList.setCellRenderer(new UnSelectedListCellRender()); + + final TristateCheckBox chooseAllCheckBox = new NullTristateCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); + chooseAllCheckBox.setState(TristateCheckBox.SELECTED); + //取消chooseAllCheckBox的焦点事件监听,因为默认的焦点事件监听中失焦时会改变chooseAllCheckBox的状态 + chooseAllCheckBox.setFocusable(false); + chooseAllCheckBox.addStateChangeListener(new StateChangeListener() { + @Override + public void stateChange() { + if (chooseAllCheckBox.getState() == TristateCheckBox.DO_NOT_CARE) { + return; + } + boolean isSelected = chooseAllCheckBox.isSelected(); + for (int i = 0; i < templatesList.getModel().getSize(); i++) { + UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); + checkBox.setSelected(isSelected); + } + templatesList.repaint(); + } + }); + + templatesList.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + int index = templatesList.getSelectedIndex(); + if (index < 0) { + return; + } + UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); + checkBox.setSelected(!checkBox.isSelected()); + + //根据templateCheckBoxes中的选择情况来更新全选框的状态 + int selectedCount = calculateSelectedNum(); + if (selectedCount == 0) { + chooseAllCheckBox.setState(TristateCheckBox.NOT_SELECTED); + } else if (selectedCount == templateCheckBoxes.length) { + chooseAllCheckBox.setState(TristateCheckBox.SELECTED); + } else { + chooseAllCheckBox.setState(TristateCheckBox.DO_NOT_CARE); + } + templatesList.repaint(); + } + }); + + templatesChoosePane.add(chooseAllCheckBox, BorderLayout.NORTH); + templatesChoosePane.add(templatesList, BorderLayout.CENTER); + + } + + /** + * 获取templateCheckBoxes中状态为选中状态的CheckBox数量 + * */ + private int calculateSelectedNum() { + int count = 0; + for (UICheckBox checkBox : templateCheckBoxes) { + if (checkBox.isSelected()) { + count++; + } + } + return count; + } + + + public boolean showSavePane() { + populate(); + //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 + if (!unSavedTemplate.isEmpty()) { + dialog.setVisible(true); + } else { + isAllSaved = true; + } + return isAllSaved; + } + + public void populate() { + java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + for (int i = 0; i < opendedTemplate.size(); i++) { + if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { + unSavedTemplate.add(opendedTemplate.get(i)); + } + } + templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; + initTemplatesChoosePane(); + } + + private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { + //所有模板都判断是不是保存 + if (isJudgeCurrentEditingTemplate) { + return !template.isALLSaved(); + } + + //当前编辑的模板不判断是否已经保存 + if (ComparatorUtils.equals(template, currentTemplate)) { + return false; + } else { + return !template.isALLSaved(); + } + } + + + private void saveSelectedTemplate(JTemplate specifiedTemplate) { + if (!specifiedTemplate.isSaved()) { + specifiedTemplate.stopEditing(); + specifiedTemplate.saveTemplate(); + } + FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + } + + + public int saveLastOneTemplate() { + JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (!specifiedTemplate.isALLSaved()) { + specifiedTemplate.stopEditing(); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { + specifiedTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + } + return returnVal; + } + return JOptionPane.YES_OPTION; + } + + + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); + } + + + private class UnSelectedListCellRender extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + templateCheckBoxes[index] = (UICheckBox) value; + templateCheckBoxes[index].setBackground(list.getBackground()); + return templateCheckBoxes[index]; + } + + } + + + private class UnSeletedTemplateListDataMode extends AbstractListModel { + + @Override + public int getSize() { + return templateCheckBoxes.length; + } + + @Override + public UICheckBox getElementAt(int index) { + if (index > getSize() - 1 || index < 0) { + return null; + } + return templateCheckBoxes[index]; + } + + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java index 0aad7ee91..5e595643c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -1,11 +1,12 @@ package com.fr.design.gui.ipasswordfield; +import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.constants.UIConstants; -import javax.swing.*; +import javax.swing.JPasswordField; import javax.swing.text.Document; -import java.awt.*; +import java.awt.Graphics; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -21,26 +22,34 @@ public class UIPassWordField extends JPasswordField { public UIPassWordField() { super(); - addRollOverListener(); + init(); } public UIPassWordField(String text) { super(text); - addRollOverListener(); + init(); } public UIPassWordField(int columns) { super(columns); - addRollOverListener(); + init(); } public UIPassWordField(String text, int columns) { super(text, columns); - addRollOverListener(); + init(); } public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); + init(); + } + + /** + * 每个构造方法里都需要做的一些操作 + */ + public void init() { + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } @@ -69,4 +78,4 @@ public class UIPassWordField extends JPasswordField { super.paintBorder(g); } } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java index 98823bee9..10edf9fe0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java @@ -9,11 +9,20 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.Document; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.RenderingHints; + /** * @author Jerry @@ -33,31 +42,33 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(int columns) { super(columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(String text, int columns) { super(text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(String text) { super(text); - InputEventBaseOnOS.addBasicEditInputMap(this); - - initListener(); + init(); } public UITextField(Document doc, String text, int columns) { super(doc, text, columns); + init(); + } + + /** + * 每个构造方法里都需要做的一些操作 + */ + public void init() { InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } @@ -251,4 +262,4 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs this.isBorderPainted = isBorderPainted; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java index a4a59ade2..b821b0731 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java @@ -1,6 +1,7 @@ package com.fr.design.gui.itree.checkboxtree; import com.fr.design.constants.UIConstants; +import com.fr.design.event.StateChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; @@ -75,6 +76,8 @@ public class TristateCheckBox extends UICheckBox { private final TristateDecorator model; + public StateChangeListener stateChangeListener; + public TristateCheckBox(String text, Icon icon, State initial) { super(text, icon); setUI(new TristateCheckBoxUI()); @@ -83,7 +86,7 @@ public class TristateCheckBox extends UICheckBox { @Override public void mousePressed(MouseEvent e) { grabFocus(); - model.setState(getNextState(model.getState())); + setState(getNextState(model.getState())); } }); // Reset the keyboard action map @@ -92,7 +95,7 @@ public class TristateCheckBox extends UICheckBox { @Override public void actionPerformed(ActionEvent e) { grabFocus(); - model.setState(getNextState(model.getState())); + setState(getNextState(model.getState())); } }); map.put("released", null); @@ -125,12 +128,20 @@ public class TristateCheckBox extends UICheckBox { public void addMouseListener(MouseListener l) { } + public void addStateChangeListener(StateChangeListener stateChangeListener) { + this.stateChangeListener=stateChangeListener; + } + /** * Set the new state to either SELECTED, NOT_SELECTED or * DO_NOT_CARE. If state == null, it is treated as DO_NOT_CARE. */ public void setState(State state) { + State old = getState(); model.setState(state); + if (old != state) { + fireBoxStateChanged(); + } } /** @@ -141,6 +152,11 @@ public class TristateCheckBox extends UICheckBox { return model.getState(); } + public void fireBoxStateChanged() { + if (stateChangeListener != null) { + stateChangeListener.stateChange(); + } + } /** * Exactly which Design Pattern is this? Is it an Adapter, diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java new file mode 100644 index 000000000..41822d19c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java @@ -0,0 +1,29 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public class BugNeedMark implements LocaleMark { + private Map map = new HashMap<>(); + private static final String TW_BUG_AND_NEEDS = CloudCenter.getInstance().acquireUrlByKind("bbs.bug.needs.zh_TW"); + + public BugNeedMark() { + map.put(Locale.TAIWAN, TW_BUG_AND_NEEDS); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? TW_BUG_AND_NEEDS : result; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java index c6c1b1f28..e192336d6 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java @@ -10,6 +10,7 @@ import java.util.Set; * 某些国际化环境支持的操作 * 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码 * 后续有新的不同语言下的差异操作 添加新的枚举 + * * @author Hades * @date 2019/6/24 */ @@ -50,6 +51,112 @@ public enum SupportLocaleImpl implements SupportLocale { set.add(Locale.KOREA); return set; } + }, + + /** + * BUG反馈 + */ + BUG { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.US); + set.add(Locale.JAPAN); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * 需求反馈 + */ + NEED { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.US); + set.add(Locale.JAPAN); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * BUG需求反馈 + */ + BUG_AND_NEED { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 视频 + */ + VIDEO { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + return set; + } + }, + + /** + * 技术支持-帮助菜单下 + */ + TECH_SUPPORT_HELP { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + return set; + } + }, + + /** + * 技术支持-社区菜单下 + */ + TECH_SUPPORT_COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 帮助文档-帮助菜单下 + */ + TUTORIAL_HELP { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 帮助文档-社区菜单下 + */ + TUTORIAL_COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + set.add(Locale.KOREA); + set.add(Locale.JAPAN); + return set; + } } + } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java new file mode 100644 index 000000000..6d15764b5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java @@ -0,0 +1,30 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public class TechSupportMark implements LocaleMark { + private Map map = new HashMap<>(); + private static final String EN_TECH_SUPPORT = CloudCenter.getInstance().acquireUrlByKind("bbs.tech.support.en_US"); + private static final String TW_TECH_SUPPORT = CloudCenter.getInstance().acquireUrlByKind("bbs.tech.support.zh_TW"); + + public TechSupportMark() { + map.put(Locale.US, EN_TECH_SUPPORT); + map.put(Locale.TAIWAN, TW_TECH_SUPPORT); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? EN_TECH_SUPPORT : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index bc4b85ced..775b03747 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -11,12 +11,14 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.BBSAction; import com.fr.design.actions.community.BugAction; +import com.fr.design.actions.community.BugNeedAction; import com.fr.design.actions.community.CenterAction; import com.fr.design.actions.community.FacebookFansAction; import com.fr.design.actions.community.NeedAction; import com.fr.design.actions.community.QuestionAction; import com.fr.design.actions.community.SignAction; import com.fr.design.actions.community.TechSolutionAction; +import com.fr.design.actions.community.TechSupportAction; import com.fr.design.actions.community.VideoAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; @@ -529,11 +531,30 @@ public abstract class ToolBarMenuDock { */ public ShortCut[] createHelpShortCuts() { final java.util.List shortCuts = new ArrayList(); - // 英文,把 video 和帮助文档放到 Help 下面 - if (GeneralContext.getLocale().equals(Locale.US)) { - shortCuts.add(new VideoAction()); - shortCuts.add(new TutorialAction()); - } + + Locale locale = GeneralContext.getLocale(); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new VideoAction()); + } + }, SupportLocaleImpl.VIDEO); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TutorialAction()); + } + }, SupportLocaleImpl.TUTORIAL_HELP); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TechSupportAction()); + } + }, SupportLocaleImpl.TECH_SUPPORT_HELP); + //远程不使用更新升级,产品演示 if (WorkContext.getCurrent().isLocal()) { shortCuts.add(new WebDemoAction()); @@ -576,9 +597,41 @@ public abstract class ToolBarMenuDock { shortCuts.add(new TechSolutionAction()); shortCuts.add(SeparatorDef.DEFAULT); - - shortCuts.add(new BugAction()); - shortCuts.add(new NeedAction()); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new BugAction()); + } + }, SupportLocaleImpl.BUG); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new NeedAction()); + } + }, SupportLocaleImpl.NEED); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new BugNeedAction()); + } + }, SupportLocaleImpl.BUG_AND_NEED); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TechSupportAction()); + } + }, SupportLocaleImpl.TECH_SUPPORT_COMMUNITY); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TutorialAction()); + } + }, SupportLocaleImpl.TUTORIAL_COMMUNITY); shortCuts.add(SeparatorDef.DEFAULT); diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/support.png b/designer-base/src/main/resources/com/fr/design/images/bbs/support.png new file mode 100644 index 000000000..a19c313c6 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/bbs/support.png differ diff --git a/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java b/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java index 643ad7890..1df652a84 100644 --- a/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java +++ b/designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java @@ -15,6 +15,7 @@ import com.fr.report.cell.cellattr.highlight.HighlightAction; import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; import javax.swing.*; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -30,6 +31,7 @@ public class HyperlinkPane extends ConditionAttrSingleConditionPane { private static final int DIALOG_WIDTH = 700; private static final int DIALOG_HEIGHT = 400; + private static final Dimension WINDOW_CUSTOM_SIZE = new Dimension(720, 600); private Widget widget; private UIComboBox box; @@ -45,8 +48,7 @@ public class WidgetHighlightPane extends ConditionAttrSingleConditionPane