This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit d33e068c314e4c8180e7f5b28273ff7d00fe8c84 Author: Tony CHEMIT <dev@tchemit.fr> Date: Sun Jan 1 18:28:20 2017 +0100 Improve file widgets (See #4119) --- .../org/nuiton/jaxx/widgets/file/FileEditor.jaxx | 33 +++------------ .../jaxx/widgets/file/FileEditorHandler.java | 47 +++++++++++++--------- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditor.jaxx b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditor.jaxx index 1de590b..a6d37ea 100644 --- a/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditor.jaxx +++ b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditor.jaxx @@ -29,8 +29,6 @@ java.io.File </import> - <FileEditorHandler id='handler' constructorParams='this'/> - <Boolean id='acceptAllFileFilterUsed' javaBean='Boolean.TRUE'/> <Boolean id='directoryEnabled' javaBean='Boolean.TRUE'/> @@ -61,12 +59,6 @@ public void setSelectedFilePath(String startPath) { setSelectedFile(startPath == null ? null : new File(startPath)); } -/**public void setSelectedFile(String startPath) { - this.selectedFile = null; - setStartPath(startPath); - fireActionEvent(); -}*/ - public File getSelectedFile() { if (selectedFile == null) { if (StringUtils.isNotEmpty(startPath)) { @@ -82,30 +74,15 @@ public void setDialogOwner(JDialog dialogOwner) { ]]></script> - <JToolBar id='toolbar' - floatable='false' - borderPainted='false' - visible='{isShowReset()}' + <JToolBar id='toolbar' floatable='false' borderPainted='false' visible='{isShowReset()}' constraints='BorderLayout.WEST'> - <JButton id='resetButton' - actionIcon='fileeditor-reset' - toolTipText='fileeditor.action.reset.tip' - focusable='false' - focusPainted='false' - enabled='{isEnabled()}' - onActionPerformed='setSelectedFile(null)'/> + <JButton id='resetButton' actionIcon='fileeditor-reset' toolTipText='fileeditor.action.reset.tip' focusable='false' + focusPainted='false' enabled='{isEnabled()}' onActionPerformed='setSelectedFile(null)'/> </JToolBar> - - <JTextField id='pathField' - constraints='BorderLayout.CENTER' - enabled='{isEnabled()}' - text='{getStartPath()}' + <JTextField id='pathField' constraints='BorderLayout.CENTER' enabled='{isEnabled()}' text='{getStartPath()}' onKeyReleased='setSelectedFilePath(pathField.getText())'/> - <JButton id='boutonXslLocation' - constraints='BorderLayout.EAST' - enabled='{isEnabled()}' - actionIcon='open' + <JButton id='boutonXslLocation' constraints='BorderLayout.EAST' enabled='{isEnabled()}' actionIcon='open' onActionPerformed='handler.openLocation()'/> </BaseActionPanel> diff --git a/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java index 5410324..1afac6e 100644 --- a/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java +++ b/jaxx-widgets-file/src/main/java/org/nuiton/jaxx/widgets/file/FileEditorHandler.java @@ -23,6 +23,7 @@ package org.nuiton.jaxx.widgets.file; import com.google.common.io.Files; import org.apache.commons.lang3.StringUtils; +import org.nuiton.jaxx.runtime.spi.UIHandler; import javax.swing.JDialog; import javax.swing.JFileChooser; @@ -30,13 +31,13 @@ import javax.swing.filechooser.FileFilter; import java.io.File; /** @author Sylvain Lletellier */ -public class FileEditorHandler { +public class FileEditorHandler implements UIHandler<FileEditor> { public static final String SEPARATOR_REGEX = "\\s*,\\s*"; public static File lastSelectedPath; - protected final FileEditor view; + protected FileEditor ui; /** * To set the dialog (see https://forge.nuiton.org/issues/2578). @@ -45,18 +46,11 @@ public class FileEditorHandler { */ protected JDialog dialogOwner; - public FileEditorHandler(FileEditor view) { - this.view = view; - if (lastSelectedPath == null) { - lastSelectedPath = new File(System.getProperty("user.home")); - } - } - public void openLocation() { // use last selected file - File startFile = view.getSelectedFile(); - String startPath = view.getStartPath(); + File startFile = ui.getSelectedFile(); + String startPath = ui.getStartPath(); if (startFile == null && StringUtils.isNotEmpty(startPath)) { // else filed start path @@ -68,21 +62,21 @@ public class FileEditorHandler { } JFileChooser fc = new JFileChooser(startFile); - fc.setDialogTitle(view.getTitle()); - fc.setAcceptAllFileFilterUsed(view.getAcceptAllFileFilterUsed()); + fc.setDialogTitle(ui.getTitle()); + fc.setAcceptAllFileFilterUsed(ui.getAcceptAllFileFilterUsed()); // TODO sletellier 14/06/2012 : activate multi selection // boolean multiSelectionEnabled = view.isMultiSelectionEnabled(); // fc.setMultiSelectionEnabled(multiSelectionEnabled); // used to enable directory selection - boolean directoryEnabled = view.isDirectoryEnabled(); + boolean directoryEnabled = ui.isDirectoryEnabled(); if (directoryEnabled) { fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } // used to enable file selection - boolean fileEnabled = view.isFileEnabled(); + boolean fileEnabled = ui.isFileEnabled(); if (fileEnabled) { if (directoryEnabled) { @@ -92,12 +86,12 @@ public class FileEditorHandler { } else { fc.setFileSelectionMode(JFileChooser.FILES_ONLY); } - String extsAsString = view.getExts(); + String extsAsString = ui.getExts(); if (extsAsString != null) { // extentions can be separted by comma String[] exts = extsAsString.split(SEPARATOR_REGEX); - String extsDescription = view.getExtsDescription(); + String extsDescription = ui.getExtsDescription(); String[] descs = new String[0]; if (extsDescription != null) { @@ -128,7 +122,7 @@ public class FileEditorHandler { if (hackDialog) { dialogOwner.setAlwaysOnTop(false); } - int returnVal = fc.showOpenDialog(view); + int returnVal = fc.showOpenDialog(ui); if (hackDialog) { dialogOwner.setAlwaysOnTop(true); } @@ -146,8 +140,8 @@ public class FileEditorHandler { } public void setSelectedFile(File file) { - view.setSelectedFile(file); - view.setStartPath(file.getPath()); + ui.setSelectedFile(file); + ui.setStartPath(file.getPath()); File dir = file; if (dir.exists()) { if (!dir.isDirectory()) { @@ -161,6 +155,19 @@ public class FileEditorHandler { this.dialogOwner = dialogOwner; } + @Override + public void beforeInit(FileEditor ui) { + this.ui = ui; + if (lastSelectedPath == null) { + lastSelectedPath = new File(System.getProperty("user.home")); + } + } + + @Override + public void afterInit(FileEditor ui) { + + } + public static class ExtentionFileFiler extends FileFilter { protected final String ext; protected final String desciption; -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.