Browse Source

Merge pull request #1561 in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit '748c2b8e91971d9c7bd028a3a47cb281a87e637c':
  fix
  fix
  REPORT-28701 设计器-文件选择器优化,替换为系统原生文件选择弹窗
  REPORT-28701 设计器-文件选择器优化,替换为系统原生文件选择弹窗
persist/11.0
Hades 5 years ago
parent
commit
7aa7347a78
  1. 9
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java
  2. 6
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java
  3. 25
      designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java

9
designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java

@ -91,4 +91,13 @@ public abstract class AbstractFileChooser {
* *
*/ */
public abstract int showSaveDialog(Component parent); public abstract int showSaveDialog(Component parent);
/**
* https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4031440
*
* 设置文件名后缀 起到文件过滤的作用 形如 "*.jpg;*.jpeg"
*
*/
public abstract void setExtensionFilter(String file);
} }

6
designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java

@ -1,5 +1,6 @@
package com.fr.design.gui.ifilechooser; package com.fr.design.gui.ifilechooser;
import com.fr.design.gui.ifilechooser.AbstractFileChooser;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
@ -128,6 +129,11 @@ public class UINativeFileChooser extends AbstractFileChooser {
return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION; return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION;
} }
@Override
public void setExtensionFilter(String file) {
fileDialog.setFile(file);
}
/** /**
* 确认本地文件选择器是否支持选择模式 * 确认本地文件选择器是否支持选择模式
* @param selectionMode 选择模式 * @param selectionMode 选择模式

25
designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java

@ -5,6 +5,7 @@ import com.fr.base.FRContext;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ifilechooser.UINativeFileChooser;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
@ -16,20 +17,9 @@ import com.fr.share.ShareConstants;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.DefaultComboBoxModel;
import javax.swing.Icon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingWorker;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -333,10 +323,13 @@ public class FormWidgetDetailPane extends FormDockView{
new ActionListener() { new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser(); UINativeFileChooser fileChooser = new UINativeFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); FileNameExtensionFilter extensionFilter = new FileNameExtensionFilter(".reu", "reu");
int returnValue = fileChooser.showDialog(new UILabel(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); fileChooser.setFileFilter(extensionFilter);
fileChooser.setExtensionFilter("*.reu");
fileChooser.setDialogTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select"));
int returnValue = fileChooser.showOpenDialog(new UILabel());
if (returnValue == JFileChooser.APPROVE_OPTION) { if (returnValue == JFileChooser.APPROVE_OPTION) {
final File chosenFile = fileChooser.getSelectedFile(); final File chosenFile = fileChooser.getSelectedFile();
installFromDiskZipFile(chosenFile); installFromDiskZipFile(chosenFile);

Loading…
Cancel
Save