[DEV] nearly fisnish to develop fileChooser

This commit is contained in:
Edouard DUPIN 2022-04-27 00:24:09 +02:00
parent f02987f8bf
commit 2e0a24f1c3
7 changed files with 350 additions and 310 deletions

View File

@ -1,197 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/meta/FileChooser.hpp>
#include <ewol/widget/Sizer.hpp>
#include <ewol/widget/List.hpp>
#include <ewol/widget/Button.hpp>
#include <ewol/widget/CheckBox.hpp>
#include <ewol/widget/ListFileSystem.hpp>
#include <ewol/widget/Entry.hpp>
#include <ewol/widget/Spacer.hpp>
#include <ewol/widget/Image.hpp>
#include <ewol/widget/Composer.hpp>
#include <ewol/widget/Manager.hpp>
//#include <etk/Vector.hpp>
#include <etk/Vector.hpp>
#include <etk/tool.hpp>
#include <etk/path/fileSystem.hpp>
extern "C" {
// file browsing ...
#include <dirent.h>
}
#include <ewol/ewol.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::widget::FileChooser);
ewol::widget::FileChooser::FileChooser() :
signalCancel(this, "cancel", ""),
signalValidate(this, "validate", ""),
propertyPath(this, "path",
etk::path::getHomePath(),
"",
ewol::widget::FileChooser::onChangePropertyPath),
propertyFile(this, "file",
"",
"",
ewol::widget::FileChooser::onChangePropertyFile),
propertyLabelTitle(this, "title",
"_T{FileChooser}",
"",
ewol::widget::FileChooser::onChangePropertyLabelTitle),
propertyLabelValidate(this, "label-validate",
"_T{Validate}",
"",
ewol::widget::FileChooser::onChangePropertyLabelValidate),
propertyLabelCancel(this, "label-cancel",
"_T{Cancel}",
"",
ewol::widget::FileChooser::onChangePropertyLabelCancel) {
addObjectType("ewol::widget::FileChooser");
}
void ewol::widget::FileChooser::init() {
ewol::widget::Composer::init();
// Load file with replacing the "{ID}" with the local ID of the widget ==> obtain unique ID
loadFromFile("DATA:///ewol-gui-file-chooser.xml?lib=ewol", getId());
// Basic replacement of labels
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:title-label", "value", propertyLabelTitle);
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:validate-label", "value", propertyLabelValidate);
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel);
subBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:show-hiden-file", signalValue, sharedFromThis(), ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue);
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-validate", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackListValidate);
subBind(ewol::widget::Button, "[" + etk::toString(getId()) + "]file-shooser:button-cancel", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackButtonCancelPressed);
subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-folder", signalFolderValidate, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFolderSelectChange);
subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileSelect, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFileSelectChange);
subBind(ewol::widget::ListFileSystem, "[" + etk::toString(getId()) + "]file-shooser:list-files", signalFileValidate, sharedFromThis(), ewol::widget::FileChooser::onCallbackListFileValidate);
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalModify, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFileChangeValue);
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-file", signalEnter, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFileChangeValidate);
subBind(ewol::widget::Entry, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalModify, sharedFromThis(), ewol::widget::FileChooser::onCallbackEntryFolderChangeValue);
//composerBind(ewol::widget::CheckBox, "[" + etk::toString(getId()) + "]file-shooser:entry-folder", signalEnter, sharedFromThis(), ewol::widget::FileChooser::);
subBind(ewol::widget::Image, "[" + etk::toString(getId()) + "]file-shooser:img-home", signalPressed, sharedFromThis(), ewol::widget::FileChooser::onCallbackHomePressed);
// set the default Folder properties:
updateCurrentFolder();
propertyCanFocus.set(true);
}
void ewol::widget::FileChooser::onGetFocus() {
// transfert focus on a specific widget...
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-file", "focus", "true");
}
ewol::widget::FileChooser::~FileChooser() {
}
void ewol::widget::FileChooser::onChangePropertyPath() {
propertyPath.getDirect() = *propertyPath + "/";
updateCurrentFolder();
}
void ewol::widget::FileChooser::onChangePropertyFile() {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-file", "value", propertyFile.getFileName());
//updateCurrentFolder();
}
void ewol::widget::FileChooser::onChangePropertyLabelTitle() {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:title-label", "value", propertyLabelTitle);
}
void ewol::widget::FileChooser::onChangePropertyLabelValidate() {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:validate-label", "value", propertyLabelValidate);
}
void ewol::widget::FileChooser::onChangePropertyLabelCancel() {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:cancel-label", "value", propertyLabelCancel);
}
void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue( String _value) {
// == > change the folder name
// TODO : change the folder, if it exit ...
}
void ewol::widget::FileChooser::onCallbackEntryFileChangeValue( String _value) {
// == > change the file name.get(.get(
propertyFile.setDirect(_value);
// update the selected file in the list :
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "select", propertyFile.getString());
}
void ewol::widget::FileChooser::onCallbackButtonCancelPressed() {
// == > Auto remove ...
signalCancel.emit();
autoDestroy();
}
void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue( bool _value) {
if (_value == true) {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "show-hidden", "true");
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "show-hidden", "true");
} else {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "show-hidden", "false");
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "show-hidden", "false");
}
}
void ewol::widget::FileChooser::onCallbackListFolderSelectChange( etk::Path _value) {
// == > this is an internal event ...
Log.debug(" old PATH: '" + *propertyPath + "' ==> '" + _value + "'");
propertyPath.setDirect(_value);
Log.debug("new PATH: '" + *propertyPath + "'");
propertyFile.setDirect("");
updateCurrentFolder();
}
void ewol::widget::FileChooser::onCallbackListFileSelectChange( etk::Path _value) {
propertyFile.set(_value);
/*
String tmpFileCompleatName = this.folder;
tmpFileCompleatName += this.file;
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
*/
}
void ewol::widget::FileChooser::onCallbackListFileValidate( etk::Path _value) {
// select the file == > generate a validate
propertyFile.set(_value);
Log.verbose(" generate a fiel opening : '" + propertyFile + "'");
signalValidate.emit(_value);
autoDestroy();
}
void ewol::widget::FileChooser::onCallbackEntryFileChangeValidate( String _value) {
onCallbackListFileValidate(_value);
}
void ewol::widget::FileChooser::onCallbackListValidate() {
if (propertyFile.get() == "") {
Log.warning(" Validate : '" + *propertyFile + "' ==> error No name ...");
return;
}
Log.debug(" generate a file opening : '" + *propertyFile + "'");
signalValidate.emit(*propertyFile);
autoDestroy();
}
void ewol::widget::FileChooser::onCallbackHomePressed() {
etk::Path tmpUserFolder = etk::path::getHomePath();
Log.debug("new PATH: '" + tmpUserFolder + "'");
propertyPath.setDirect(tmpUserFolder);
propertyFile.setDirect("");
updateCurrentFolder();
}
void ewol::widget::FileChooser::updateCurrentFolder() {
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-files", "path", propertyPath.getString());
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:list-folder", "path", propertyPath.getString());
propertySetOnWidgetNamed("[" + etk::toString(getId()) + "]file-shooser:entry-folder", "value", propertyPath.getString());
markToRedraw();
}

View File

@ -1,106 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <ewol/debug.hpp>
#include <ewol/widget/Composer.hpp>
#include <esignal/Signal.hpp>
namespace ewol {
namespace widget {
class FileChooser;
using FileChooser = ememory::Ptr<ewol::widget::FileChooser>;
using FileChooserWeak = ememory::WeakPtr<ewol::widget::FileChooser>;
/**
* File Chooser is a simple selector of file for opening, saving, and what you want ...
*
* As all other pop-up methode ( wost case we can have) the creating is simple , but event back is not all the time simple:
*
* Fist global static declaration and inclusion:
* [code style=c++]
* #include <ewol/widget/meta/FileChooser.hpp>
* [/code]
*
* The first step is to create the file chooser pop-up : (never in the ructor!!!)
* [code style=c++]
* ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create();
* if (tmpWidget == null) {
* APPL_ERROR("Can not open File chooser !!! ");
* return -1;
* }
* // register on the Validate event:
* tmpWidget.signalValidate.connect(sharedFromThis(), ****::onCallbackOpenFile);
* // no need of this event watching ...
* tmpWidget.signalCancel.connect(sharedFromThis(), ****::onCallbackClosePopUp);
* // set the title:
* tmpWidget.propertyLabelTitle.set("Open files ...");
* // Set the validate Label:
* tmpWidget.propertyLabelValidate.set("Open");
* // simply set a folder (by default this is the home folder)
* //tmpWidget.propertyPath.set("/home/me");
* // add the widget as windows pop-up ...
* ewol::widget::Windows tmpWindows = getWindows();
* if (tmpWindows == null) {
* APPL_ERROR("Can not get the current windows !!! ");
* return -1;
* }
* tmpWindows.popUpWidgetPush(tmpWidget);
* [/code]
*
* Now we just need to wait the the open event message.
*
* [code style=c++]
* void ****::onCallbackOpenFile( String _value) {
* APPL_INFO("Request open file : '" + _value + "'");
* }
* void ****::onCallbackClosePopUp() {
* APPL_INFO("The File chooser has been closed");
* }
* [/code]
* This is the best example of a Meta-widget.
*/
class FileChooser : public ewol::widget::Composer {
public: // signals
esignal::Signal<> signalCancel; //!< abort the display of the pop-up or press cancel button
esignal::Signal<etk::Path> signalValidate; //!< select file(s)
public: // properties
eproperty::Value<etk::Path> propertyPath; //!< Current path to explore
eproperty::Value<etk::Path> propertyFile; //!< Selected file
eproperty::Value<String> propertyLabelTitle; //!< Label of the pop-up (can use translation)
eproperty::Value<String> propertyLabelValidate; //!< Label of validate button of the pop-up (can use translation)
eproperty::Value<String> propertyLabelCancel; //!< Label of cancel/close button of the pop-up (can use translation)
protected:
FileChooser();
void init() ;
public:
DECLARE_WIDGET_FACTORY(FileChooser, "FileChooser");
~FileChooser();
private:
void updateCurrentFolder();
public:
void onGetFocus() ;
private:
// callback functions:
void onCallbackEntryFolderChangeValue( String _value);
void onCallbackEntryFileChangeValue( String _value);
void onCallbackEntryFileChangeValidate( String _value);
void onCallbackButtonCancelPressed();
void onCallbackHidenFileChangeChangeValue( bool _value);
void onCallbackListFolderSelectChange( etk::Path _value);
void onCallbackListFileSelectChange( etk::Path _value);
void onCallbackListFileValidate( etk::Path _value);
void onCallbackListValidate();
void onCallbackHomePressed();
protected:
void onChangePropertyPath();
void onChangePropertyFile();
void onChangePropertyLabelTitle();
void onChangePropertyLabelValidate();
void onChangePropertyLabelCancel();
};
};
};

View File

@ -11,15 +11,13 @@ public class MainWindows extends BasicWindows {
public MainWindows() {
setPropertyTitle("Simple Button test");
//final Widget data = Composer.composerGenerateString("<Composer><Label>hello, how are you</Label></Composer>");
//final Widget data = Composer.composerGenerateString("<Composer><Button><Label gravity=\"center\">hello, how are you</Label></Button></Composer>");
final Widget data = Composer.composerGenerateString("<FileChooser/>");
/*
final Widget data = Composer.composerGenerateString("<Button toggle='true' fill='true,false,false' expand='true'>" + "<Label>hello, how are you</Label>"
+ "<Label>You <br/>Click - Me <b>!?<!--kjlkjlkjlkj-->d</b></Label>" + "</Button>");
*/
final Widget data = Composer.composerGenerateFile(new Uri("DATA", "ewol-gui-file-chooser.xml", "ewol"));
//final Widget data = Composer.composerGenerateFile(new Uri("DATA", "ewol-gui-file-chooser.xml", "ewol"));
this.setTestWidget(data);
/*
final Button simpleButton = Button
.createLabelButton("1 - My <font color=\"red\">button <i>internal</i></font> <br/>2 - <b>label</b><br/>3 - an other text ...<br/>4 - and an other line to be sure ...");

View File

@ -32,7 +32,7 @@ public class EwolObject {
private static Integer valUID = 0; //!< Static used for the unique ID definition
/**
* get the curent the system inteface.
* get the current the system interface.
* @return current reference on the instance.
*/
protected static EwolContext getContext() {
@ -60,8 +60,6 @@ public class EwolObject {
private boolean isResource = false; //!< enable this when you want to declare this element is auto-remove
//@EwolPropertyDescription("Object name, might be a unique reference in all the program")
//@JacksonXmlProperty(isAttribute = true, localName = "name")
protected String name = ""; //!< name of the element ...
protected WeakReference<EwolObject> parent = null; //!< Reference on the current parent.

View File

@ -3,6 +3,7 @@ package org.atriasoft.ewol.widget;
import java.util.HashMap;
import java.util.Map;
import org.atriasoft.ewol.widget.meta.FileChooser;
import org.atriasoft.exml.annotation.XmlFactory.InterfaceXmlFactoryAccess;
public class WidgetXmlFactory implements InterfaceXmlFactoryAccess {
@ -18,6 +19,7 @@ public class WidgetXmlFactory implements InterfaceXmlFactoryAccess {
listWidgetAvaillable.put("CheckBox", CheckBox.class);
listWidgetAvaillable.put("ListFileSystem", ListFileSystem.class);
listWidgetAvaillable.put("PopUp", PopUp.class);
listWidgetAvaillable.put("FileChooser", FileChooser.class);
}
@Override

View File

@ -0,0 +1,345 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.ewol.widget.meta;
import java.io.File;
import org.atriasoft.esignal.Signal;
import org.atriasoft.esignal.SignalEmpty;
import org.atriasoft.etk.Uri;
import org.atriasoft.ewol.annotation.EwolDescription;
import org.atriasoft.ewol.annotation.EwolSignal;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.widget.Button;
import org.atriasoft.ewol.widget.CheckBox;
import org.atriasoft.ewol.widget.Composer;
import org.atriasoft.ewol.widget.Entry;
import org.atriasoft.ewol.widget.ImageDisplay;
import org.atriasoft.ewol.widget.Label;
import org.atriasoft.ewol.widget.ListFileSystem;
import org.atriasoft.exml.annotation.XmlAttribute;
import org.atriasoft.exml.annotation.XmlManaged;
import org.atriasoft.exml.annotation.XmlName;
/**
* File Chooser is a simple selector of file for opening, saving, and what you want ...
*
* As all other pop-up methode ( wost case we can have) the creating is simple , but event back is not all the time simple:
*
* Fist global static declaration and inclusion:
* [code style=c++]
* package org.atriasoft.ewol.widget.meta.FileChooser;
* [/code]
*
* The first step is to create the file chooser pop-up : (never in the ructor!!!)
* [code style=c++]
* ewol::widget::FileChooser tmpWidget = ewol::widget::FileChooser::create();
* if (tmpWidget == null) {
* APPL_ERROR("Can not open File chooser !!! ");
* return -1;
* }
* // register on the Validate event:
* tmpWidget.signalValidate.connect(sharedFromThis(), ****::onCallbackOpenFile);
* // no need of this event watching ...
* tmpWidget.signalCancel.connect(sharedFromThis(), ****::onCallbackClosePopUp);
* // set the title:
* tmpWidget.propertyLabelTitle.set("Open files ...");
* // Set the validate Label:
* tmpWidget.propertyLabelValidate.set("Open");
* // simply set a folder (by default this is the home folder)
* //tmpWidget.propertyPath.set("/home/me");
* // add the widget as windows pop-up ...
* ewol::widget::Windows tmpWindows = getWindows();
* if (tmpWindows == null) {
* APPL_ERROR("Can not get the current windows !!! ");
* return -1;
* }
* tmpWindows.popUpWidgetPush(tmpWidget);
* [/code]
*
* Now we just need to wait the the open event message.
*
* [code style=c++]
* void ****::onCallbackOpenFile( String _value) {
* APPL_INFO("Request open file : '" + _value + "'");
* }
* void ****::onCallbackClosePopUp() {
* APPL_INFO("The File chooser has been closed");
* }
* [/code]
* This is the best example of a Meta-widget.
*/
public class FileChooser extends Composer {
static void onCallbackButtonCancelPressed(final FileChooser self, final Boolean value) {
if (!value) {
return;
}
// == > Auto remove ...
self.signalCancel.emit();
self.autoDestroy();
}
protected static void onCallbackEntryFileChangeValidate(final FileChooser self, final String value) {
onCallbackListFileValidate(self, value);
}
protected static void onCallbackEntryFileChangeValue(final FileChooser self, final String value) {
// == > change the file name.get(.get(
self.propertyFile = value;
// update the selected file in the list :
if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-shooser:list-files") instanceof final ListFileSystem tmp) {
tmp.setPropertyFile(new File(self.propertyFile));
}
}
protected static void onCallbackEntryFolderChangeValue(final FileChooser self, final String value) {
// == > change the folder name
// TODO : change the folder, if it exit ...
}
protected static void onCallbackHidenFileChangeChangeValue(final FileChooser self, final Boolean value) {
if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-shooser:list-files") instanceof final ListFileSystem tmp) {
tmp.setPropertyShowHidden(value);
}
if (self.getSubObjectNamed("[" + Long.toString(self.getId()) + "]file-shooser:list-folder") instanceof final ListFileSystem tmp) {
tmp.setPropertyShowHidden(value);
}
}
protected static void onCallbackHomePressed(final FileChooser self) {
final String tmpUserFolder = System.getProperty("user.home");
Log.debug("new PATH: '" + tmpUserFolder + "'");
self.propertyPath = tmpUserFolder;
self.propertyFile = "";
self.updateCurrentFolder();
}
protected static void onCallbackListFileSelectChange(final FileChooser self, final String value) {
self.setPropertyFile(value);
/*
String tmpFileCompleatName = this.folder;
tmpFileCompleatName += this.file;
// TODO : generateEventId(_msg.getMessage(), tmpFileCompleatName);
*/
}
protected static void onCallbackListFileValidate(final FileChooser self, final String value) {
// select the file == > generate a validate
self.setPropertyFile(value);
Log.verbose(" generate a fiel opening : '" + self.propertyFile + "'");
self.signalValidate.emit(value);
self.autoDestroy();
}
protected static void onCallbackListFolderSelectChange(final FileChooser self, final String value) {
// == > this is an internal event ...
Log.debug(" old PATH: '" + self.propertyPath + "' ==> '" + value + "'");
self.propertyPath = value;
Log.debug("new PATH: '" + self.propertyPath + "'");
self.propertyFile = "";
self.updateCurrentFolder();
}
protected static void onCallbackListValidate(final FileChooser self, final Boolean value) {
if (!value) {
return;
}
if (self.propertyFile.isEmpty()) {
Log.warning(" Validate : '" + self.propertyFile + "' ==> error No name ...");
return;
}
Log.debug(" generate a file opening : '" + self.propertyFile + "'");
self.signalValidate.emit(self.propertyFile);
self.autoDestroy();
}
@EwolSignal(name = "cancel")
@EwolDescription(value = "Cancel button is pressed")
public SignalEmpty signalCancel; //!< abort the display of the pop-up or press cancel button
@EwolSignal(name = "validate")
@EwolDescription(value = "Validate button is pressed")
public Signal<String> signalValidate; //!< select file(s)
// properties
public String propertyPath = System.getProperty("user.home"); //!< Current path to explore
public String propertyFile = ""; //!< Selected file
public String propertyLabelTitle = "_T{FileChooser}"; //!< Label of the pop-up (can use translation)
public String propertyLabelValidate = "_T{Validate}"; //!< Label of validate button of the pop-up (can use translation)
public String propertyLabelCancel = "_T{Cancel}"; //!< Label of cancel/close button of the pop-up (can use translation)
public FileChooser() {
// Load file with replacing the "{ID}" with the local ID of the widget ==> obtain unique ID
loadFromFile(new Uri("DATA", "ewol-gui-file-chooser.xml", "ewol"));
// Basic replacement of labels
onChangePropertyLabelTitle();
onChangePropertyLabelValidate();
onChangePropertyLabelCancel();
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:show-hiden-file") instanceof final CheckBox tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackHidenFileChangeChangeValue);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:button-validate") instanceof final Button tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackListValidate);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:button-cancel") instanceof final Button tmp) {
tmp.signalValue.connectAuto(this, FileChooser::onCallbackButtonCancelPressed);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:list-folder") instanceof final ListFileSystem tmp) {
tmp.signalFolderValidate.connectAuto(this, FileChooser::onCallbackListFolderSelectChange);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:list-files") instanceof final ListFileSystem tmp) {
tmp.signalFileSelect.connectAuto(this, FileChooser::onCallbackListFileSelectChange);
tmp.signalFileValidate.connectAuto(this, FileChooser::onCallbackListFileValidate);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-file") instanceof final Entry tmp) {
tmp.signalModify.connectAuto(this, FileChooser::onCallbackEntryFileChangeValue);
tmp.signalEnter.connectAuto(this, FileChooser::onCallbackEntryFileChangeValidate);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-folder") instanceof final Entry tmp) {
tmp.signalModify.connectAuto(this, FileChooser::onCallbackEntryFolderChangeValue);
}
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:img-home") instanceof final ImageDisplay tmp) {
tmp.signalPressed.connectAuto(this, FileChooser::onCallbackHomePressed);
}
// set the default Folder properties:
updateCurrentFolder();
setPropertyCanFocus(true);
}
public String getPropertyFile() {
return this.propertyFile;
}
public String getPropertyLabelCancel() {
return this.propertyLabelCancel;
}
// callback functions:
public String getPropertyLabelTitle() {
return this.propertyLabelTitle;
}
public String getPropertyLabelValidate() {
return this.propertyLabelValidate;
}
public String getPropertyPath() {
return this.propertyPath;
}
protected void onChangePropertyFile() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-file") instanceof final ListFileSystem tmp) {
tmp.setPropertyFile(new File(this.propertyFile));
}
}
protected void onChangePropertyLabelCancel() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:cancel-label") instanceof final Label tmp) {
tmp.setPropertyValue(this.propertyLabelCancel);
}
}
protected void onChangePropertyLabelTitle() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:title-label") instanceof final Label tmp) {
tmp.setPropertyValue(this.propertyLabelTitle);
}
}
protected void onChangePropertyLabelValidate() {
if (this.getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:validate-label") instanceof final Label tmp) {
tmp.setPropertyValue(this.propertyLabelValidate);
}
}
protected void onChangePropertyPath() {
this.propertyPath = this.propertyPath + "/";
updateCurrentFolder();
}
@Override
public void onGetFocus() {
// transfert focus on a specific widget...
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-folder") instanceof final Entry tmp) {
tmp.keepFocus();
}
}
@XmlManaged
@XmlAttribute
@XmlName(value = "file")
public void setPropertyFile(final String propertyFile) {
if (this.propertyFile.equals(propertyFile)) {
return;
}
this.propertyFile = propertyFile;
onChangePropertyFile();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "label-cancel")
@EwolDescription(value = "Label for cancel button")
public void setPropertyLabelCancel(final String propertyLabelCancel) {
if (this.propertyLabelCancel.equals(propertyLabelCancel)) {
return;
}
this.propertyLabelCancel = propertyLabelCancel;
onChangePropertyLabelCancel();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "title")
@EwolDescription(value = "Titile of the Pop-up")
public void setPropertyLabelTitle(final String propertyLabelTitle) {
if (this.propertyLabelTitle.equals(propertyLabelTitle)) {
return;
}
this.propertyLabelTitle = propertyLabelTitle;
onChangePropertyLabelTitle();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "label-validate")
@EwolDescription(value = "Label for validate button")
public void setPropertyLabelValidate(final String propertyLabelValidate) {
if (this.propertyLabelValidate.equals(propertyLabelValidate)) {
return;
}
this.propertyLabelValidate = propertyLabelValidate;
onChangePropertyLabelValidate();
}
@XmlManaged
@XmlAttribute
@XmlName(value = "path")
@EwolDescription(value = "Path of the File chooser")
public void setPropertyPath(final String propertyPath) {
if (this.propertyPath.equals(propertyPath)) {
return;
}
this.propertyPath = propertyPath;
onChangePropertyPath();
}
private void updateCurrentFolder() {
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:list-files") instanceof final ListFileSystem tmp) {
tmp.setPropertyPath(this.propertyPath);
}
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:list-folder") instanceof final ListFileSystem tmp) {
tmp.setPropertyPath(this.propertyPath);
}
if (getSubObjectNamed("[" + Long.toString(getId()) + "]file-shooser:entry-folder") instanceof final Entry tmp) {
tmp.setPropertyValue(this.propertyPath);
}
markToRedraw();
}
}