diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/ui_data/src | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/ui_data/src')
188 files changed, 23668 insertions, 0 deletions
diff --git a/modules/ui_data/src/c/.deps/.dirstamp b/modules/ui_data/src/c/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/c/.deps/.dirstamp diff --git a/modules/ui_data/src/c/.deps/libsciui_data_algo_la-PutScilabVariable.Plo b/modules/ui_data/src/c/.deps/libsciui_data_algo_la-PutScilabVariable.Plo new file mode 100755 index 000000000..45e7d4a65 --- /dev/null +++ b/modules/ui_data/src/c/.deps/libsciui_data_algo_la-PutScilabVariable.Plo @@ -0,0 +1,289 @@ +src/c/libsciui_data_algo_la-PutScilabVariable.lo: \ + src/c/PutScilabVariable.c /usr/include/stdc-predef.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h includes/ui_data.h \ + ../../modules/api_scilab/includes/api_scilab.h \ + ../../modules/core/includes/stack-c.h \ + ../../modules/core/includes/core_math.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h /usr/include/math.h \ + /usr/include/x86_64-linux-gnu/bits/math-vector.h \ + /usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \ + /usr/include/x86_64-linux-gnu/bits/huge_val.h \ + /usr/include/x86_64-linux-gnu/bits/huge_valf.h \ + /usr/include/x86_64-linux-gnu/bits/huge_vall.h \ + /usr/include/x86_64-linux-gnu/bits/inf.h \ + /usr/include/x86_64-linux-gnu/bits/nan.h \ + /usr/include/x86_64-linux-gnu/bits/mathdef.h \ + /usr/include/x86_64-linux-gnu/bits/mathcalls.h \ + /usr/include/x86_64-linux-gnu/bits/mathinline.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + ../../modules/core/includes/stack-def.h \ + ../../modules/core/includes/machine.h \ + ../../modules/core/includes/stackTypeVariable.h \ + ../../modules/core/includes/BOOL.h \ + ../../modules/core/includes/doublecomplex.h \ + ../../modules/core/includes/stack1.h \ + ../../modules/core/includes/scisparse.h \ + ../../modules/core/includes/stack2.h \ + ../../modules/core/includes/stack3.h \ + ../../modules/core/includes/stack-optional.h \ + ../../modules/core/includes/sci_types.h \ + ../../modules/api_scilab/includes/api_common.h \ + ../../modules/api_scilab/includes/api_scilab.h \ + ../../modules/api_scilab/includes/api_double.h \ + ../../modules/core/includes/doublecomplex.h \ + ../../modules/api_scilab/includes/api_string.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h \ + ../../modules/api_scilab/includes/api_int.h \ + ../../modules/api_scilab/includes/api_poly.h \ + ../../modules/api_scilab/includes/api_sparse.h \ + ../../modules/api_scilab/includes/api_boolean.h \ + ../../modules/api_scilab/includes/api_boolean_sparse.h \ + ../../modules/api_scilab/includes/api_pointer.h \ + ../../modules/api_scilab/includes/api_list.h \ + ../../modules/api_scilab/includes/api_error.h \ + ../../modules/api_scilab/includes/api_handle.h \ + ../../modules/api_scilab/includes/api_optional.h \ + ../../modules/core/includes/stack-optional.h \ + ../../modules/api_scilab/includes/api_hypermat.h \ + ../../modules/core/includes/core_math.h \ + ../../modules/core/includes/sci_types.h \ + ../../modules/output_stream/includes/Scierror.h \ + ../../modules/output_stream/includes/do_error_number.h \ + ../../modules/core/includes/machine.h + +/usr/include/stdc-predef.h: + +/usr/include/string.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +includes/ui_data.h: + +../../modules/api_scilab/includes/api_scilab.h: + +../../modules/core/includes/stack-c.h: + +../../modules/core/includes/core_math.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/math.h: + +/usr/include/x86_64-linux-gnu/bits/math-vector.h: + +/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h: + +/usr/include/x86_64-linux-gnu/bits/huge_val.h: + +/usr/include/x86_64-linux-gnu/bits/huge_valf.h: + +/usr/include/x86_64-linux-gnu/bits/huge_vall.h: + +/usr/include/x86_64-linux-gnu/bits/inf.h: + +/usr/include/x86_64-linux-gnu/bits/nan.h: + +/usr/include/x86_64-linux-gnu/bits/mathdef.h: + +/usr/include/x86_64-linux-gnu/bits/mathcalls.h: + +/usr/include/x86_64-linux-gnu/bits/mathinline.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +../../modules/core/includes/stack-def.h: + +../../modules/core/includes/machine.h: + +../../modules/core/includes/stackTypeVariable.h: + +../../modules/core/includes/BOOL.h: + +../../modules/core/includes/doublecomplex.h: + +../../modules/core/includes/stack1.h: + +../../modules/core/includes/scisparse.h: + +../../modules/core/includes/stack2.h: + +../../modules/core/includes/stack3.h: + +../../modules/core/includes/stack-optional.h: + +../../modules/core/includes/sci_types.h: + +../../modules/api_scilab/includes/api_common.h: + +../../modules/api_scilab/includes/api_scilab.h: + +../../modules/api_scilab/includes/api_double.h: + +../../modules/core/includes/doublecomplex.h: + +../../modules/api_scilab/includes/api_string.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +../../modules/api_scilab/includes/api_int.h: + +../../modules/api_scilab/includes/api_poly.h: + +../../modules/api_scilab/includes/api_sparse.h: + +../../modules/api_scilab/includes/api_boolean.h: + +../../modules/api_scilab/includes/api_boolean_sparse.h: + +../../modules/api_scilab/includes/api_pointer.h: + +../../modules/api_scilab/includes/api_list.h: + +../../modules/api_scilab/includes/api_error.h: + +../../modules/api_scilab/includes/api_handle.h: + +../../modules/api_scilab/includes/api_optional.h: + +../../modules/core/includes/stack-optional.h: + +../../modules/api_scilab/includes/api_hypermat.h: + +../../modules/core/includes/core_math.h: + +../../modules/core/includes/sci_types.h: + +../../modules/output_stream/includes/Scierror.h: + +../../modules/output_stream/includes/do_error_number.h: + +../../modules/core/includes/machine.h: diff --git a/modules/ui_data/src/c/.dirstamp b/modules/ui_data/src/c/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/c/.dirstamp diff --git a/modules/ui_data/src/c/.libs/libsciui_data_algo_la-PutScilabVariable.o b/modules/ui_data/src/c/.libs/libsciui_data_algo_la-PutScilabVariable.o Binary files differnew file mode 100755 index 000000000..626229aab --- /dev/null +++ b/modules/ui_data/src/c/.libs/libsciui_data_algo_la-PutScilabVariable.o diff --git a/modules/ui_data/src/c/DllmainUi_data.c b/modules/ui_data/src/c/DllmainUi_data.c new file mode 100755 index 000000000..271042a6f --- /dev/null +++ b/modules/ui_data/src/c/DllmainUi_data.c @@ -0,0 +1,33 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include <windows.h> +/*--------------------------------------------------------------------------*/ +#pragma comment(lib,"../../../../bin/libintl.lib") +/*--------------------------------------------------------------------------*/ +int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + break; + case DLL_PROCESS_DETACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + } + return 1; +} +/*--------------------------------------------------------------------------*/ + diff --git a/modules/ui_data/src/c/PutScilabVariable.c b/modules/ui_data/src/c/PutScilabVariable.c new file mode 100755 index 000000000..78bcd05ae --- /dev/null +++ b/modules/ui_data/src/c/PutScilabVariable.c @@ -0,0 +1,54 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include <string.h> +#include <stdio.h> +#include "ui_data.h" +#include "api_scilab.h" +#include "Scierror.h" +#ifdef _MSC_VER +#include "strdup_windows.h" +#endif + + +void putScilabVariable(char * name, char ** lines, int rows, int cols) +{ + SciErr sciErr; + + if (rows != 0 && cols != 0) + { + sciErr = createNamedMatrixOfString(pvApiCtx, name, rows, cols, lines); + } + else + { + sciErr = createNamedMatrixOfDouble(pvApiCtx, name, 0, 0, NULL); + } + + if (sciErr.iErr) + { + printError(&sciErr, 0); + } +} + +char * getUnnamedVariable(void) +{ + char buffer[128]; + int i = 0; + + do + { + sprintf(buffer, "%s%i", "unnamed", i++); + } + while (isNamedVarExist(pvApiCtx, buffer)); + + return strdup(buffer); +} diff --git a/modules/ui_data/src/c/core_Import.def b/modules/ui_data/src/c/core_Import.def new file mode 100755 index 000000000..d1bbdc569 --- /dev/null +++ b/modules/ui_data/src/c/core_Import.def @@ -0,0 +1,19 @@ +LIBRARY core.dll + + +EXPORTS +; +callFunctionFromGateway +getScilabMode +com_ +getGlobalSizefromId +getGlobalNamefromId +getLocalSizefromId +getLocalNamefromId +getgvariablesinfo_ +getvariablesinfo_ +freeArrayOfString +gettype_ +vstk_ +MyHeapAlloc +MyHeapFree diff --git a/modules/ui_data/src/c/libsciui_data_algo_la-PutScilabVariable.lo b/modules/ui_data/src/c/libsciui_data_algo_la-PutScilabVariable.lo new file mode 100755 index 000000000..81a5f3400 --- /dev/null +++ b/modules/ui_data/src/c/libsciui_data_algo_la-PutScilabVariable.lo @@ -0,0 +1,12 @@ +# src/c/libsciui_data_algo_la-PutScilabVariable.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-PutScilabVariable.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/c/ui_data.rc b/modules/ui_data/src/c/ui_data.rc new file mode 100755 index 000000000..8031d08a9 --- /dev/null +++ b/modules/ui_data/src/c/ui_data.rc @@ -0,0 +1,96 @@ +// Microsoft Visual C++ generated resource script. +// + + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +//#include "afxres.h" +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,5,2,0 + PRODUCTVERSION 5,5,2,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "FileDescription", "ui_data module" + VALUE "FileVersion", "5, 5, 2, 0" + VALUE "InternalName", "ui_data module" + VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "OriginalFilename", "ui_data.dll" + VALUE "ProductName", "ui_data module" + VALUE "ProductVersion", "5, 5, 2, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/modules/ui_data/src/c/ui_data.vcxproj b/modules/ui_data/src/c/ui_data.vcxproj new file mode 100755 index 000000000..8152a2b59 --- /dev/null +++ b/modules/ui_data/src/c/ui_data.vcxproj @@ -0,0 +1,277 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{142D643B-A9EC-49DB-9D48-A925A20F63B1}</ProjectGuid> + <RootNamespace>ui_data</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">sci$(ProjectName)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">sci$(ProjectName)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">sci$(ProjectName)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">sci$(ProjectName)</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>.;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes;../../../windows_tools/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>..\..\..\..\bin\scilocalization.lib;core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <ImportLibrary>$(SolutionDir)bin\sci$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>.;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes;../../../windows_tools/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL + +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <ImportLibrary>$(SolutionDir)bin\sci$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <WholeProgramOptimization>false</WholeProgramOptimization> + <AdditionalIncludeDirectories>.;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes;../../../windows_tools/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>..\..\..\..\bin\scilocalization.lib;core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ImportLibrary>$(SolutionDir)bin\sci$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <WholeProgramOptimization>false</WholeProgramOptimization> + <AdditionalIncludeDirectories>.;../jni;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../../libs/intl;../../includes;../../../api_scilab/includes;../../../core/includes;../../../localization/includes;../../../jvm/includes;../../../output_stream/includes;../cpp;../../../functions/includes;../../../fileio/includes;../../../windows_tools/includes;../../../commons/src/jni;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL + +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ImportLibrary>$(SolutionDir)bin\sci$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\sci_gateway\cpp\sci_closeEditvar.cpp" /> + <ClCompile Include="..\..\sci_gateway\cpp\sci_filebrowser.cpp" /> + <ClCompile Include="..\..\sci_gateway\cpp\sci_updatebrowsevar.cpp" /> + <ClCompile Include="..\cpp\FileBrowserChDir.cpp" /> + <ClCompile Include="..\cpp\BrowseVarManager.cpp" /> + <ClCompile Include="..\jni\BrowseVar.cpp" /> + <ClCompile Include="..\jni\FileBrowser.cpp" /> + <ClCompile Include="..\jni\ui_data_wrap.c" /> + <ClCompile Include="DllmainUi_data.c" /> + <ClCompile Include="..\jni\EditVar.cpp" /> + <ClCompile Include="..\..\sci_gateway\c\gw_ui_data.c" /> + <ClCompile Include="..\..\sci_gateway\cpp\sci_browsevar.cpp" /> + <ClCompile Include="..\..\sci_gateway\cpp\sci_editvar.cpp" /> + <ClCompile Include="PutScilabVariable.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\includes\FileBrowserChDir.h" /> + <ClInclude Include="..\..\includes\ui_data.h" /> + <ClInclude Include="..\..\includes\BrowseVarManager.h" /> + <ClInclude Include="..\jni\BrowseVar.hxx" /> + <ClInclude Include="..\..\includes\dynlib_ui_data.h" /> + <ClInclude Include="..\jni\EditVar.hxx" /> + <ClInclude Include="..\jni\FileBrowser.hxx" /> + <ClInclude Include="..\..\includes\gw_ui_data.h" /> + </ItemGroup> + <ItemGroup> + <None Include="..\..\locales\ui_data.pot" /> + <None Include="core_import.def" /> + <None Include="..\..\Makefile.am" /> + <None Include="..\..\ui_data.iss" /> + <None Include="..\..\sci_gateway\ui_data_gateway.xml" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\..\Visual-Studio-settings\rename-vc-files\rename-vc-files.vcxproj"> + <Project>{dd8a0506-8d31-4cf8-856a-c10ece9c13a4}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\action_binding\src\c\action_binding.vcxproj"> + <Project>{8a654cc5-22c1-4972-a8cf-1b89f78b5383}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\api_scilab\api_scilab.vcxproj"> + <Project>{43c5bab1-1dca-4743-a183-77e0d42fe7d0}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\fileio\fileio.vcxproj"> + <Project>{4fc72d4a-80ee-4b1a-8724-0201c1a35621}</Project> + </ProjectReference> + <ProjectReference Include="..\..\..\commons\src\c\commons.vcxproj"> + <Project>{eca09a1e-6d12-4a47-92e1-a671c181df77}</Project> + </ProjectReference> + <ProjectReference Include="..\..\..\jvm\libjvm.vcxproj"> + <Project>{8ba2dda8-bd04-4d4d-8ee6-6caa955f7470}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\localization\src\localization.vcxproj"> + <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj"> + <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\windows_tools\src\c\scilab_windows\scilab_windows.vcxproj"> + <Project>{8028f371-6a94-4a26-8804-6e7f05f1d1aa}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="ui_data.rc" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/ui_data/src/c/ui_data.vcxproj.filters b/modules/ui_data/src/c/ui_data.vcxproj.filters new file mode 100755 index 000000000..56f4b4f9a --- /dev/null +++ b/modules/ui_data/src/c/ui_data.vcxproj.filters @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{9044ad4b-68bd-43dd-9dd8-80429a66292d}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{f5de4a0f-2155-4a2d-8b32-56b00fde2c39}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + <Filter Include="localization"> + <UniqueIdentifier>{085bd88d-d97e-43ea-9d50-f6e8ee023026}</UniqueIdentifier> + </Filter> + <Filter Include="Libraries Dependencies"> + <UniqueIdentifier>{dde6e8e6-4ef8-4bb0-a3f9-e36ed52420f2}</UniqueIdentifier> + </Filter> + <Filter Include="Libraries Dependencies\Imports"> + <UniqueIdentifier>{3572c96e-9d91-4578-874e-df4648c0242d}</UniqueIdentifier> + </Filter> + <Filter Include="swig"> + <UniqueIdentifier>{e80c00e9-808d-4fe1-ae70-8b758e25110f}</UniqueIdentifier> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{b5e2adde-d2fd-4625-9c9b-654817244158}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\jni\BrowseVar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="DllmainUi_data.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\EditVar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\sci_gateway\c\gw_ui_data.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\sci_gateway\cpp\sci_browsevar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\sci_gateway\cpp\sci_editvar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\FileBrowser.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\cpp\FileBrowserChDir.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\sci_gateway\cpp\sci_filebrowser.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="PutScilabVariable.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\ui_data_wrap.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\sci_gateway\cpp\sci_updatebrowsevar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\..\sci_gateway\cpp\sci_closeEditvar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\cpp\BrowseVarManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\jni\BrowseVar.hxx"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\includes\dynlib_ui_data.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\jni\EditVar.hxx"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\includes\gw_ui_data.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\includes\FileBrowserChDir.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\jni\FileBrowser.hxx"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\includes\ui_data.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\includes\BrowseVarManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <None Include="core_import.def"> + <Filter>Libraries Dependencies\Imports</Filter> + </None> + <None Include="..\..\Makefile.am" /> + <None Include="..\..\ui_data.iss" /> + <None Include="..\..\sci_gateway\ui_data_gateway.xml" /> + <None Include="..\..\locales\ui_data.pot"> + <Filter>localization</Filter> + </None> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="ui_data.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/ui_data/src/cpp/.deps/.dirstamp b/modules/ui_data/src/cpp/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/cpp/.deps/.dirstamp diff --git a/modules/ui_data/src/cpp/.deps/libsciui_data_algo_la-BrowseVarManager.Plo b/modules/ui_data/src/cpp/.deps/libsciui_data_algo_la-BrowseVarManager.Plo new file mode 100755 index 000000000..6d7d61f80 --- /dev/null +++ b/modules/ui_data/src/cpp/.deps/libsciui_data_algo_la-BrowseVarManager.Plo @@ -0,0 +1,556 @@ +src/cpp/libsciui_data_algo_la-BrowseVarManager.lo: \ + src/cpp/BrowseVarManager.cpp /usr/include/stdc-predef.h \ + /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc src/jni/BrowseVar.hxx \ + /usr/include/string.h /usr/include/x86_64-linux-gnu/bits/string3.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + ../../modules/commons/src/jni/GiwsException.hxx \ + /usr/include/c++/5/sstream /usr/include/c++/5/bits/sstream.tcc \ + /usr/include/c++/5/iterator /usr/include/c++/5/bits/stream_iterator.h \ + /usr/include/c++/5/set /usr/include/c++/5/bits/stl_tree.h \ + /usr/include/c++/5/bits/stl_set.h /usr/include/c++/5/bits/stl_multiset.h \ + includes/BrowseVarManager.h includes/dynlib_ui_data.h \ + ../../modules/localization/includes/localization.h \ + ../../modules/core/includes/machine.h /usr/include/libintl.h \ + ../../modules/core/includes/MALLOC.h \ + ../../modules/core/includes/sci_mem_alloc.h \ + ../../modules/core/includes/BOOL.h \ + ../../modules/core/includes/stackinfo.h \ + ../../modules/core/includes/machine.h ../../modules/core/includes/BOOL.h \ + ../../modules/api_scilab/includes/api_scilab.h \ + ../../modules/core/includes/stack-c.h \ + ../../modules/core/includes/core_math.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \ + /usr/include/x86_64-linux-gnu/bits/xopen_lim.h /usr/include/math.h \ + /usr/include/x86_64-linux-gnu/bits/math-vector.h \ + /usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \ + /usr/include/x86_64-linux-gnu/bits/huge_val.h \ + /usr/include/x86_64-linux-gnu/bits/huge_valf.h \ + /usr/include/x86_64-linux-gnu/bits/huge_vall.h \ + /usr/include/x86_64-linux-gnu/bits/inf.h \ + /usr/include/x86_64-linux-gnu/bits/nan.h \ + /usr/include/x86_64-linux-gnu/bits/mathdef.h \ + /usr/include/x86_64-linux-gnu/bits/mathcalls.h \ + /usr/include/x86_64-linux-gnu/bits/mathinline.h /usr/include/values.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/float.h \ + ../../modules/core/includes/stack-def.h \ + ../../modules/core/includes/stackTypeVariable.h \ + ../../modules/core/includes/doublecomplex.h \ + ../../modules/core/includes/stack1.h \ + ../../modules/core/includes/scisparse.h \ + ../../modules/core/includes/stack2.h \ + ../../modules/core/includes/stack3.h \ + ../../modules/core/includes/stack-optional.h \ + ../../modules/core/includes/sci_types.h \ + ../../modules/api_scilab/includes/api_common.h \ + ../../modules/api_scilab/includes/api_scilab.h \ + ../../modules/api_scilab/includes/api_double.h \ + ../../modules/core/includes/doublecomplex.h \ + ../../modules/api_scilab/includes/api_string.h \ + ../../modules/api_scilab/includes/api_int.h \ + ../../modules/api_scilab/includes/api_poly.h \ + ../../modules/api_scilab/includes/api_sparse.h \ + ../../modules/api_scilab/includes/api_boolean.h \ + ../../modules/api_scilab/includes/api_boolean_sparse.h \ + ../../modules/api_scilab/includes/api_pointer.h \ + ../../modules/api_scilab/includes/api_list.h \ + ../../modules/api_scilab/includes/api_error.h \ + ../../modules/api_scilab/includes/api_handle.h \ + ../../modules/api_scilab/includes/api_optional.h \ + ../../modules/core/includes/stack-optional.h \ + ../../modules/api_scilab/includes/api_hypermat.h \ + ../../modules/core/includes/core_math.h \ + ../../modules/core/includes/sci_types.h \ + ../../modules/jvm/includes/getScilabJavaVM.h \ + ../../modules/output_stream/includes/Scierror.h \ + ../../modules/output_stream/includes/do_error_number.h \ + ../../modules/core/includes/freeArrayOfString.h + +/usr/include/stdc-predef.h: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +src/jni/BrowseVar.hxx: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +../../modules/commons/src/jni/GiwsException.hxx: + +/usr/include/c++/5/sstream: + +/usr/include/c++/5/bits/sstream.tcc: + +/usr/include/c++/5/iterator: + +/usr/include/c++/5/bits/stream_iterator.h: + +/usr/include/c++/5/set: + +/usr/include/c++/5/bits/stl_tree.h: + +/usr/include/c++/5/bits/stl_set.h: + +/usr/include/c++/5/bits/stl_multiset.h: + +includes/BrowseVarManager.h: + +includes/dynlib_ui_data.h: + +../../modules/localization/includes/localization.h: + +../../modules/core/includes/machine.h: + +/usr/include/libintl.h: + +../../modules/core/includes/MALLOC.h: + +../../modules/core/includes/sci_mem_alloc.h: + +../../modules/core/includes/BOOL.h: + +../../modules/core/includes/stackinfo.h: + +../../modules/core/includes/machine.h: + +../../modules/core/includes/BOOL.h: + +../../modules/api_scilab/includes/api_scilab.h: + +../../modules/core/includes/stack-c.h: + +../../modules/core/includes/core_math.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/x86_64-linux-gnu/bits/xopen_lim.h: + +/usr/include/math.h: + +/usr/include/x86_64-linux-gnu/bits/math-vector.h: + +/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h: + +/usr/include/x86_64-linux-gnu/bits/huge_val.h: + +/usr/include/x86_64-linux-gnu/bits/huge_valf.h: + +/usr/include/x86_64-linux-gnu/bits/huge_vall.h: + +/usr/include/x86_64-linux-gnu/bits/inf.h: + +/usr/include/x86_64-linux-gnu/bits/nan.h: + +/usr/include/x86_64-linux-gnu/bits/mathdef.h: + +/usr/include/x86_64-linux-gnu/bits/mathcalls.h: + +/usr/include/x86_64-linux-gnu/bits/mathinline.h: + +/usr/include/values.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/float.h: + +../../modules/core/includes/stack-def.h: + +../../modules/core/includes/stackTypeVariable.h: + +../../modules/core/includes/doublecomplex.h: + +../../modules/core/includes/stack1.h: + +../../modules/core/includes/scisparse.h: + +../../modules/core/includes/stack2.h: + +../../modules/core/includes/stack3.h: + +../../modules/core/includes/stack-optional.h: + +../../modules/core/includes/sci_types.h: + +../../modules/api_scilab/includes/api_common.h: + +../../modules/api_scilab/includes/api_scilab.h: + +../../modules/api_scilab/includes/api_double.h: + +../../modules/core/includes/doublecomplex.h: + +../../modules/api_scilab/includes/api_string.h: + +../../modules/api_scilab/includes/api_int.h: + +../../modules/api_scilab/includes/api_poly.h: + +../../modules/api_scilab/includes/api_sparse.h: + +../../modules/api_scilab/includes/api_boolean.h: + +../../modules/api_scilab/includes/api_boolean_sparse.h: + +../../modules/api_scilab/includes/api_pointer.h: + +../../modules/api_scilab/includes/api_list.h: + +../../modules/api_scilab/includes/api_error.h: + +../../modules/api_scilab/includes/api_handle.h: + +../../modules/api_scilab/includes/api_optional.h: + +../../modules/core/includes/stack-optional.h: + +../../modules/api_scilab/includes/api_hypermat.h: + +../../modules/core/includes/core_math.h: + +../../modules/core/includes/sci_types.h: + +../../modules/jvm/includes/getScilabJavaVM.h: + +../../modules/output_stream/includes/Scierror.h: + +../../modules/output_stream/includes/do_error_number.h: + +../../modules/core/includes/freeArrayOfString.h: diff --git a/modules/ui_data/src/cpp/.deps/libsciui_data_algo_la-FileBrowserChDir.Plo b/modules/ui_data/src/cpp/.deps/libsciui_data_algo_la-FileBrowserChDir.Plo new file mode 100755 index 000000000..13d9e5d92 --- /dev/null +++ b/modules/ui_data/src/cpp/.deps/libsciui_data_algo_la-FileBrowserChDir.Plo @@ -0,0 +1,349 @@ +src/cpp/libsciui_data_algo_la-FileBrowserChDir.lo: \ + src/cpp/FileBrowserChDir.cpp /usr/include/stdc-predef.h \ + src/jni/FileBrowser.hxx /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + ../../modules/commons/src/jni/GiwsException.hxx \ + includes/FileBrowserChDir.h includes/dynlib_ui_data.h \ + ../../modules/jvm/includes/getScilabJavaVM.h + +/usr/include/stdc-predef.h: + +src/jni/FileBrowser.hxx: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +../../modules/commons/src/jni/GiwsException.hxx: + +includes/FileBrowserChDir.h: + +includes/dynlib_ui_data.h: + +../../modules/jvm/includes/getScilabJavaVM.h: diff --git a/modules/ui_data/src/cpp/.dirstamp b/modules/ui_data/src/cpp/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/cpp/.dirstamp diff --git a/modules/ui_data/src/cpp/.libs/libsciui_data_algo_la-BrowseVarManager.o b/modules/ui_data/src/cpp/.libs/libsciui_data_algo_la-BrowseVarManager.o Binary files differnew file mode 100755 index 000000000..a1ccd98b4 --- /dev/null +++ b/modules/ui_data/src/cpp/.libs/libsciui_data_algo_la-BrowseVarManager.o diff --git a/modules/ui_data/src/cpp/.libs/libsciui_data_algo_la-FileBrowserChDir.o b/modules/ui_data/src/cpp/.libs/libsciui_data_algo_la-FileBrowserChDir.o Binary files differnew file mode 100755 index 000000000..1d7603621 --- /dev/null +++ b/modules/ui_data/src/cpp/.libs/libsciui_data_algo_la-FileBrowserChDir.o diff --git a/modules/ui_data/src/cpp/BrowseVarManager.cpp b/modules/ui_data/src/cpp/BrowseVarManager.cpp new file mode 100755 index 000000000..9879bfd3f --- /dev/null +++ b/modules/ui_data/src/cpp/BrowseVarManager.cpp @@ -0,0 +1,442 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan CORNET + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include <iostream> +#include "BrowseVar.hxx" + +#include <sstream> +#include <string> +#include <iterator> +using std::string; + +#include <set> + +extern "C" +{ +#include <string.h> +#include "BrowseVarManager.h" +#include "localization.h" +#include "MALLOC.h" +#include "BOOL.h" +#include "stackinfo.h" +#include "api_scilab.h" +#include "getScilabJavaVM.h" +#include "Scierror.h" +#include "freeArrayOfString.h" +#include "sci_types.h" +#ifdef _MSC_VER +#include "strdup_windows.h" +#endif +} +using namespace org_scilab_modules_ui_data; + +static std::set < string > createScilabDefaultVariablesSet(); +static char * getListName(char * variableName); +static std::string formatMatrix(int nbRows, int nbCols, BOOL isComplex, double *pdblReal, double *pdblImg); +static char * valueToDisplay(char * variableName, int variableType, int nbRows, int nbCols); +void OpenBrowseVar() +{ + BrowseVar::openVariableBrowser(getScilabJavaVM()); + SetBrowseVarData(); +} + +void UpdateBrowseVar() +{ + if (BrowseVar::isVariableBrowserOpened(getScilabJavaVM())) + { + SetBrowseVarData(); + } +} + +void SetBrowseVarData() +{ + SciErr err; + int iGlobalVariablesUsed = 0; + int iGlobalVariablesTotal = 0; + int iLocalVariablesUsed = 0; + int iLocalVariablesTotal = 0; + int i = 0; + + // First get how many global / local variable we have. + C2F(getvariablesinfo) (&iLocalVariablesTotal, &iLocalVariablesUsed); + C2F(getgvariablesinfo) (&iGlobalVariablesTotal, &iGlobalVariablesUsed); + + char **pstAllVariableNames = (char **)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(char *)); + char **pstAllVariableVisibility = (char **)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(char *)); + char **pstAllVariableListTypes = (char **)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(char *)); + int *piAllVariableBytes = (int *)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(int)); + char **pstAllVariableSizes = (char **)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(char *)); + int *piAllVariableTypes = (int *)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(int)); + int *piAllVariableIntegerTypes = (int *)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(int)); + bool *piAllVariableFromUser = (bool *) MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(bool)); + /* Necessary for the plots in the var browser */ + int *piAllVariableNbRows = (int *)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(int)); + int *piAllVariableNbCols = (int *)MALLOC((iLocalVariablesUsed + iGlobalVariablesUsed) * sizeof(int)); + + int nbRows, nbCols; + char *sizeStr = NULL; + + std::set < string > scilabDefaultVariablesSet = createScilabDefaultVariablesSet(); + + // for each local variable get information + for (; i < iLocalVariablesUsed; ++i) + { + // name + pstAllVariableNames[i] = getLocalNamefromId(i + 1); + // type + err = getNamedVarType(pvApiCtx, pstAllVariableNames[i], &piAllVariableTypes[i]); + if (!err.iErr) + { + piAllVariableBytes[i] = getLocalSizefromId(i); + err = getNamedVarDimension(pvApiCtx, pstAllVariableNames[i], &nbRows, &nbCols); + } + + if (err.iErr || nbRows * nbCols == 0) + { +#define N_A "N/A" + pstAllVariableSizes[i] = (char *)MALLOC((sizeof(N_A) + 1) * sizeof(char)); + strcpy(pstAllVariableSizes[i], N_A); + } + else + { + pstAllVariableSizes[i] = valueToDisplay(pstAllVariableNames[i], piAllVariableTypes[i], nbRows, nbCols); + piAllVariableNbRows[i] = nbRows; + piAllVariableNbCols[i] = nbCols; + } + + + if (piAllVariableTypes[i] == sci_ints) + { + // Integer case + int iPrec = 0; + err = getNamedMatrixOfIntegerPrecision(pvApiCtx, pstAllVariableNames[i], &iPrec); + switch (iPrec) + { + case SCI_INT8: + piAllVariableIntegerTypes[i] = 8; + break; + case SCI_INT16: + piAllVariableIntegerTypes[i] = 16; + break; + case SCI_INT32: + piAllVariableIntegerTypes[i] = 32; + break; +#ifdef __SCILAB_INT64__ + case SCI_INT64: + piAllVariableIntegerTypes[i] = 64; + break; +#endif + default: + piAllVariableIntegerTypes[i] = 0; // Should never occurs + break; + } + } + else + { + piAllVariableIntegerTypes[i] = -1; + } + + if (piAllVariableTypes[i] == sci_tlist || piAllVariableTypes[i] == sci_mlist) + { + pstAllVariableListTypes[i] = getListName(pstAllVariableNames[i]); + } + else + { + pstAllVariableListTypes[i] = strdup(""); + } + + + // global / local ?? + pstAllVariableVisibility[i] = strdup("local"); + + if (scilabDefaultVariablesSet.find(string(pstAllVariableNames[i])) == scilabDefaultVariablesSet.end() && piAllVariableTypes[i] != sci_lib) + { + piAllVariableFromUser[i] = TRUE; + } + else + { + piAllVariableFromUser[i] = FALSE; + } + } + + // for each global variable get information + for (int j = 0; j < iGlobalVariablesUsed; ++j, ++i) + { + // name + pstAllVariableNames[i] = getGlobalNamefromId(j); + // Bytes used - 8 is the number of bytes in a word + piAllVariableBytes[i] = getGlobalSizefromId(j) * 8; + // type + // Calling "API Scilab": not yet implemented for global variable + //getNamedVarType(pvApiCtx, pstAllVariableNames[i], &piAllVariableTypes[i]); + // Using old stack operations... + int pos = C2F(vstk).isiz + 2 + j; + + piAllVariableTypes[i] = C2F(gettype) (&pos); + + // Sizes of the variable + getNamedVarDimension(pvApiCtx, pstAllVariableNames[i], &nbRows, &nbCols); + pstAllVariableSizes[i] = valueToDisplay(pstAllVariableNames[i], piAllVariableTypes[i], nbRows, nbCols); + piAllVariableNbRows[i] = nbRows; + piAllVariableNbCols[i] = nbCols; + + + // global / local ?? + pstAllVariableVisibility[i] = strdup("global"); + + + if (piAllVariableTypes[i] == sci_tlist || piAllVariableTypes[i] == sci_mlist) + { + pstAllVariableListTypes[i] = getListName(pstAllVariableNames[i]); + } + else + { + pstAllVariableListTypes[i] = strdup(""); + } + + + if (scilabDefaultVariablesSet.find(string(pstAllVariableNames[i])) == scilabDefaultVariablesSet.end() + && piAllVariableTypes[i] != sci_c_function && piAllVariableTypes[i] != sci_lib) + { + piAllVariableFromUser[i] = TRUE; + } + else + { + piAllVariableFromUser[i] = FALSE; + } + } + + // Launch Java Variable Browser through JNI + BrowseVar::setVariableBrowserData(getScilabJavaVM(), + pstAllVariableNames, iLocalVariablesUsed + iGlobalVariablesUsed, + piAllVariableBytes, iLocalVariablesUsed + iGlobalVariablesUsed, + piAllVariableTypes, iLocalVariablesUsed + iGlobalVariablesUsed, + piAllVariableIntegerTypes, iLocalVariablesUsed + iGlobalVariablesUsed, + pstAllVariableListTypes, iLocalVariablesUsed + iGlobalVariablesUsed, + pstAllVariableSizes, iLocalVariablesUsed + iGlobalVariablesUsed, + piAllVariableNbRows, iLocalVariablesUsed + iGlobalVariablesUsed, + piAllVariableNbCols, iLocalVariablesUsed + iGlobalVariablesUsed, + pstAllVariableVisibility, iLocalVariablesUsed + iGlobalVariablesUsed, + piAllVariableFromUser, iLocalVariablesUsed + iGlobalVariablesUsed); + + freeArrayOfString(pstAllVariableNames, iLocalVariablesUsed + iGlobalVariablesUsed); + freeArrayOfString(pstAllVariableVisibility, iLocalVariablesUsed + iGlobalVariablesUsed); + freeArrayOfString(pstAllVariableSizes, iLocalVariablesUsed + iGlobalVariablesUsed); + freeArrayOfString(pstAllVariableListTypes, iLocalVariablesUsed + iGlobalVariablesUsed); + + if (piAllVariableFromUser) + { + FREE(piAllVariableFromUser); + piAllVariableFromUser = NULL; + } + + if (piAllVariableBytes) + { + FREE(piAllVariableBytes); + piAllVariableBytes = NULL; + } + + if (piAllVariableTypes) + { + FREE(piAllVariableTypes); + piAllVariableTypes = NULL; + } + + if (piAllVariableIntegerTypes) + { + FREE(piAllVariableIntegerTypes); + piAllVariableIntegerTypes = NULL; + } + + if (piAllVariableNbRows) + { + FREE(piAllVariableNbRows); + piAllVariableNbRows = NULL; + } + + if (piAllVariableNbCols) + { + FREE(piAllVariableNbCols); + piAllVariableNbCols = NULL; + } +} + +/*--------------------------------------------------------------------------*/ +static std::set < string > createScilabDefaultVariablesSet() +{ + string arr[] = { "home", + "PWD", + "%tk", + "%pvm", + "MSDOS", + "%F", + "%T", + "%f", + "%t", + "%e", + "%pi", + "%modalWarning", + "%nan", + "%inf", + "SCI", + "WSCI", + "SCIHOME", + "TMPDIR", + "%gui", + "%fftw", + "%helps", + "%eps", + "%io", + "%i", + "demolist", + "%z", + "%s", + "$", + "%toolboxes", + "%toolboxes_dir", + "TICTOC", + "%helps_modules", + "%_atoms_cache", + "evoid", // Constant for external object + "jvoid", // Constant for external object Java (jims) + "jnull", // Constant for external object Java (jims) + "enull" // Constant for external object + }; + int i = 0; + +#define NBELEMENT 37 + std::set < string > ScilabDefaultVariables; + + for (i = 0; i < NBELEMENT; i++) + { + ScilabDefaultVariables.insert(arr[i]); + } + + return ScilabDefaultVariables; +} + +static char * getListName(char * variableName) +{ + SciErr sciErr; + int *piAddr = NULL; + int* piAddr1 = NULL; + int iRows = 0; + int iCols = 0; + char **pstType; + char *tmpChar; + sciErr = getVarAddressFromName(pvApiCtx, variableName, &piAddr); + if (sciErr.iErr) + { + return strdup(""); + } + + sciErr = getListItemAddress(pvApiCtx, piAddr, 1, &piAddr1); + if (sciErr.iErr) + { + return strdup(""); + } + + if (getAllocatedMatrixOfString(pvApiCtx, piAddr1, &iRows, &iCols, &pstType)) + { + + return strdup(""); + } + tmpChar = strdup(pstType[0]); + freeAllocatedMatrixOfString(iRows, iCols, pstType); + return tmpChar; +} + +static char * valueToDisplay(char * variableName, int variableType, int nbRows, int nbCols) +{ + SciErr err; + + + // 4 is the dimension max to which display the content + if (nbRows * nbCols <= 4 && variableType == sci_matrix) + { + // Small double value, display it + double* pdblReal = (double *)malloc(((nbRows) * (nbCols)) * sizeof(double)); + double* pdblImg = (double *)malloc(((nbRows) * (nbCols)) * sizeof(double)); + BOOL isComplex = FALSE; + + if (isNamedVarComplex(pvApiCtx, variableName)) + { + err = readNamedComplexMatrixOfDouble(pvApiCtx, variableName, &nbRows, &nbCols, pdblReal, pdblImg); + isComplex = TRUE; + } + else + { + err = readNamedMatrixOfDouble(pvApiCtx, variableName, &nbRows, &nbCols, pdblReal); + } + + + return strdup(formatMatrix(nbRows, nbCols, isComplex, pdblReal, pdblImg).c_str()); + } + else + { + char *sizeStr = NULL; + // 11 =strlen("2147483647")+1 (1 for security) + sizeStr = (char *)MALLOC((11 + 11 + 1 + 1) * sizeof(char)); + sprintf(sizeStr, "%dx%d", nbRows, nbCols); + return sizeStr; + } +} + +std::string formatMatrix(int nbRows, int nbCols, BOOL isComplex, double *pdblReal, double *pdblImg) +{ + int i, j ; +#define PRECISION_DISPLAY 3 + if (nbRows * nbCols == 1) + { + std::ostringstream os; + os.precision(PRECISION_DISPLAY); + os << pdblReal[0]; // Convert the double to string + if (isComplex) + { + os << " + " << pdblImg[0] << "i"; + } + return os.str(); + } + + std::string formated = "["; + for (j = 0 ; j < nbRows ; j++) + { + for (i = 0 ; i < nbCols ; i++) + { + /* Display the formated matrix ... the way the user + * expect */ + std::ostringstream os; + os.precision(PRECISION_DISPLAY); + os << pdblReal[i * nbRows + j]; // Convert the double to string + formated += os.str(); + if (isComplex) + { + std::ostringstream osComplex; + osComplex.precision(PRECISION_DISPLAY); + osComplex << pdblImg[i * nbRows + j]; + formated += " + " + osComplex.str() + "i"; + } + + + if (i + 1 != nbCols) // Not the last element of the matrix + { + formated += ", "; + } + } + if (j + 1 != nbRows) // Not the last line of the matrix + { + formated += "; "; + } + } + return formated + "]"; +} diff --git a/modules/ui_data/src/cpp/FileBrowserChDir.cpp b/modules/ui_data/src/cpp/FileBrowserChDir.cpp new file mode 100755 index 000000000..373fc3346 --- /dev/null +++ b/modules/ui_data/src/cpp/FileBrowserChDir.cpp @@ -0,0 +1,29 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include "FileBrowser.hxx" + +extern "C" +{ +#include "FileBrowserChDir.h" +#include "getScilabJavaVM.h" +} +using namespace org_scilab_modules_ui_data; + +/*--------------------------------------------------------------------------*/ +void FileBrowserChDir(char * baseDir) +{ + if (getScilabJavaVM()) + { + FileBrowser::setBaseDir(getScilabJavaVM(), baseDir); + } +} diff --git a/modules/ui_data/src/cpp/libsciui_data_algo_la-BrowseVarManager.lo b/modules/ui_data/src/cpp/libsciui_data_algo_la-BrowseVarManager.lo new file mode 100755 index 000000000..eb516dac6 --- /dev/null +++ b/modules/ui_data/src/cpp/libsciui_data_algo_la-BrowseVarManager.lo @@ -0,0 +1,12 @@ +# src/cpp/libsciui_data_algo_la-BrowseVarManager.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-BrowseVarManager.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/cpp/libsciui_data_algo_la-FileBrowserChDir.lo b/modules/ui_data/src/cpp/libsciui_data_algo_la-FileBrowserChDir.lo new file mode 100755 index 000000000..0f31e723d --- /dev/null +++ b/modules/ui_data/src/cpp/libsciui_data_algo_la-FileBrowserChDir.lo @@ -0,0 +1,12 @@ +# src/cpp/libsciui_data_algo_la-FileBrowserChDir.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-FileBrowserChDir.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/BrowseVar.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/BrowseVar.java new file mode 100755 index 000000000..ce569e437 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/BrowseVar.java @@ -0,0 +1,186 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * Copyright (C) 2010 - DIGITEO - Sylvestre KOUMAR + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.localization.Messages; +import org.scilab.modules.types.ScilabTypeEnum; +import org.scilab.modules.types.ScilabTypeEnumDescription; +import org.scilab.modules.ui_data.variablebrowser.ScilabVariableBrowser; + +/** + * + * Static class to open/close Scilab Variable browser + * + */ +public class BrowseVar { + + public static final int ICON_COLUMN_INDEX = 0; + public static final int NAME_COLUMN_INDEX = 1; + public static final int SIZE_COLUMN_INDEX = 2; + public static final int TYPE_DESC_COLUMN_INDEX = 3; + public static final int VISIBILITY_COLUMN_INDEX = 4; + public static final int BYTES_COLUMN_INDEX = 5; + public static final int FROM_SCILAB_COLUMN_INDEX = 6; + public static final int TYPE_COLUMN_INDEX = 7; + public static final int NB_ROWS_INDEX = 8; + public static final int NB_COLS_INDEX = 9; + + public static final String[] COLUMNNAMES = new String[] {"", /* Icon */ + Messages.gettext("Name"), + Messages.gettext("Value"), + Messages.gettext("Type"), + Messages.gettext("Visibility"), + Messages.gettext("Bytes"), + Messages.gettext("User"), + Messages.gettext("Type int value"), + "", /* nbrows */ + "" /* nbcols */ + }; + + public static final int[] COLUMNSALIGNMENT = new int[] { -1, JLabel.LEFT, JLabel.RIGHT, JLabel.RIGHT, JLabel.RIGHT, JLabel.RIGHT, JLabel.RIGHT, JLabel.RIGHT}; + + private static final ImageIcon NO_ICON = new ImageIcon(FindIconHelper.findIcon("noicon")); + private static final ImageIcon DOUBLE_ICON = new ImageIcon(FindIconHelper.findIcon("double")); + private static final ImageIcon POLYNOMIAL_ICON = new ImageIcon(FindIconHelper.findIcon("polynomial")); + private static final ImageIcon BOOLEAN_ICON = new ImageIcon(FindIconHelper.findIcon("boolean")); + private static final ImageIcon SPARSE_ICON = new ImageIcon(FindIconHelper.findIcon("sparse")); + private static final ImageIcon INT_ICON = new ImageIcon(FindIconHelper.findIcon("int")); + private static final ImageIcon HANDLE_ICON = new ImageIcon(FindIconHelper.findIcon("handle")); + private static final ImageIcon STRING_ICON = new ImageIcon(FindIconHelper.findIcon("string")); + private static final ImageIcon FUNCTION_ICON = new ImageIcon(FindIconHelper.findIcon("function")); + private static final ImageIcon LIST_ICON = new ImageIcon(FindIconHelper.findIcon("list")); + private static final ImageIcon TLIST_ICON = new ImageIcon(FindIconHelper.findIcon("tlist")); + private static final ImageIcon MLIST_ICON = new ImageIcon(FindIconHelper.findIcon("mlist")); + private static final ImageIcon USER_ICON = new ImageIcon(FindIconHelper.findIcon("user")); + private static final ImageIcon FPTR_ICON = new ImageIcon(FindIconHelper.findIcon("fptr")); + + /** + * Default private constructor for utility class + */ + private BrowseVar() { } + + /** + * Get ImageIcon instance from Scilab type (as int) + * @param type : scilab type as integer + * @return instance of type Icon + */ + private static ImageIcon getIconFromType(int type) { + switch (type) { + case 1: + return DOUBLE_ICON; + case 2: + return POLYNOMIAL_ICON; + case 4: + return BOOLEAN_ICON; + case 5: + case 6: + case 7: + return SPARSE_ICON; + case 8: + return INT_ICON; + case 9: + return HANDLE_ICON; + case 10: + return STRING_ICON; + case 11: + case 13: + return FUNCTION_ICON; + /*case 14: + return LIBRARY_ICON;*/ + case 15: + return LIST_ICON; + case 16: + return TLIST_ICON; + case 17: + return MLIST_ICON; + case 128: + return USER_ICON; + case 130: + return FPTR_ICON; + default: + return NO_ICON; + } + } + + /** + * Open Variable Browser + */ + public static void openVariableBrowser() { + ScilabVariableBrowser.openVariableBrowser(); + } + + /** + * Set the Variable Browser data given by Scilab + * @param dataNames : scilab variable name + * @param dataBytes : scilab variable size in bytes + * @param dataTypes : scilab variable type (as integer) + * @param dataIntegerTypes : Type of int (-1 if not int) + * @param dataSizes : scilab variable size under the form "XxX" + * @param dataVisibility : local or global variable + * @param dataFromUser : Scilab data or user data + */ + public static void setVariableBrowserData(String[] dataNames, int[] dataBytes, int[] dataTypes, int[] dataIntegerTypes, String[] variableListTypes, String[] dataSizes, int[] dataNbRows, int[] dataNbCols, String[] dataVisibility, boolean[] dataFromUser) { + Object[][] data = new Object[dataNames.length][COLUMNNAMES.length]; + for (int i = 0; i < dataNames.length; ++i) { + data[i][ICON_COLUMN_INDEX] = getIconFromType(dataTypes[i]); + data[i][NAME_COLUMN_INDEX] = dataNames[i]; + data[i][SIZE_COLUMN_INDEX] = dataSizes[i]; + data[i][TYPE_DESC_COLUMN_INDEX] = ScilabTypeEnumDescription.getTypeDescriptionFromId(dataTypes[i]); + + if (dataTypes[i] == ScilabTypeEnum.sci_ints.swigValue() && dataIntegerTypes[i] != 0) { + // It is an integer. We want to detail the precision of the int + data[i][TYPE_DESC_COLUMN_INDEX] = data[i][TYPE_DESC_COLUMN_INDEX] + " " + dataIntegerTypes[i]; + } + + if ((dataTypes[i] == ScilabTypeEnum.sci_tlist.swigValue() || dataTypes[i] == ScilabTypeEnum.sci_mlist.swigValue()) && !variableListTypes[i].equals("")) { + // Improve the display of the list + String varType = ScilabTypeEnumDescription.getListTypeDescription(variableListTypes[i]); + + // It is a tlist and we want to display the user datatype + data[i][TYPE_DESC_COLUMN_INDEX] = varType + " (" + data[i][TYPE_DESC_COLUMN_INDEX] + ")"; + } + data[i][VISIBILITY_COLUMN_INDEX] = dataVisibility[i]; + data[i][BYTES_COLUMN_INDEX] = dataBytes[i]; + data[i][FROM_SCILAB_COLUMN_INDEX] = dataFromUser[i]; /* Tag if it is a variable from the user or from Scilab (%pi, %eps, etc) */ + data[i][TYPE_COLUMN_INDEX] = dataTypes[i]; + data[i][NB_ROWS_INDEX] = dataNbRows[i]; + data[i][NB_COLS_INDEX] = dataNbCols[i]; + } + ScilabVariableBrowser.setVariableBrowserData(data); + } + + /** + * Update Variable Browser + */ + public static void updateVariableBrowserData() { + ScilabVariableBrowser.updateVariableBrowser(); + } + + /** + * @return true if an instance of BrowseVar already exists. + */ + public static boolean isVariableBrowserOpened() { + return ScilabVariableBrowser.isBrowseVarOpened(); + } + + /** + * Close Variable Browser + */ + public static void closeVariableBrowser() { + ScilabVariableBrowser.closeVariableBrowser(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/EditVar.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/EditVar.java new file mode 100755 index 000000000..f6a3133be --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/EditVar.java @@ -0,0 +1,490 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data; + +import org.scilab.modules.ui_data.variableeditor.ScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.VariableEditor; + +/** + * Static class to open/close Scilab Variable Editor + * @author Allan SIMON + * @author Calixte DENIZET + */ +public final class EditVar { + + /** + * Integer type + */ + public static final String INTEGER = "Integer"; + + /** + * Double type + */ + public static final String DOUBLE = "Double"; + + /** + * Boolean sparse type + */ + public static final String BOOLEANSPARSE = "Boolean Sparse"; + + /** + * Sparse type + */ + public static final String SPARSE = "Sparse"; + + /** + * Complex sparse type + */ + public static final String COMPLEXSPARSE = "Complex Sparse"; + + /** + * Complex type + */ + public static final String COMPLEX = "Complex"; + + /** + * String type + */ + public static final String STRING = "String"; + + /** + * Boolean type + */ + public static final String BOOLEAN = "Boolean"; + + /** + * Default private constructor for utility class + */ + private EditVar() { } + + /** + * Open Variable editor + */ + public static void openVariableEditor() { } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorDouble(double[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Double[][] dataDouble = new Double[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataDouble[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(DOUBLE, dataDouble, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorBooleanSparse(int[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Boolean[][] dataBool = new Boolean[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataBool[i][j] = data[i][j] == 1; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(BOOLEANSPARSE, dataBool, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorSparse(double[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Double[][] dataDouble = new Double[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataDouble[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(SPARSE, dataDouble, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorComplexSparse(double[][] realData, double[][] complexData, String variableName) { + int c = realData.length == 0 ? 0 : realData[0].length; + Double[][][] dataDoubleComplex = new Double[realData.length][c][2]; + for (int i = 0; i < realData.length; i++) { + for (int j = 0; j < c; j++) { + dataDoubleComplex[i][j][0] = realData[i][j]; + dataDoubleComplex[i][j][1] = complexData[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(COMPLEXSPARSE, dataDoubleComplex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorInteger8(byte[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Byte[][] dataInteger = new Byte[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(INTEGER, dataInteger, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorUInteger8(short[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Short[][] dataInteger = new Short[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(INTEGER, dataInteger, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorInteger16(short[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Short[][] dataInteger = new Short[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(INTEGER, dataInteger, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorUInteger16(int[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Integer[][] dataInteger = new Integer[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(INTEGER, dataInteger, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorInteger32(int[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Integer[][] dataInteger = new Integer[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(INTEGER, dataInteger, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorUInteger32(long[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Long[][] dataInteger = new Long[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(INTEGER, dataInteger, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorString(String[][] data, String variableName) { + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(STRING, data, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param realData : real part of scilab double matrix + * @param complexData : complex part of scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorComplex(double[][] realData, double[][] complexData, String variableName) { + int c = realData.length == 0 ? 0 : realData[0].length; + Double[][][] dataDoubleComplex = new Double[realData.length][c][2]; + for (int i = 0; i < realData.length; i++) { + for (int j = 0; j < c; j++) { + dataDoubleComplex[i][j][0] = realData[i][j]; + dataDoubleComplex[i][j][1] = complexData[i][j]; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(COMPLEX, dataDoubleComplex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void openVariableEditorBoolean(int[][] data, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Boolean[][] dataBool = new Boolean[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataBool[i][j] = data[i][j] == 1; + } + } + VariableEditor editvar = ScilabVariableEditor.getVariableEditor(BOOLEAN, dataBool, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorDouble(double[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Double[][] dataDouble = new Double[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataDouble[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(DOUBLE, dataDouble, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorBooleanSparse(int[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Boolean[][] dataBool = new Boolean[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataBool[i][j] = data[i][j] == 1; + } + } + ScilabVariableEditor.refreshVariableEditor(BOOLEANSPARSE, dataBool, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorSparse(double[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Double[][] dataDouble = new Double[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataDouble[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(SPARSE, dataDouble, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param realData : real part of scilab double matrix + * @param complexData : complex part of scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorComplexSparse(double[][] realData, double[][] complexData, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = realData.length == 0 ? 0 : realData[0].length; + Double[][][] dataDoubleComplex = new Double[realData.length][c][2]; + for (int i = 0; i < realData.length; i++) { + for (int j = 0; j < c; j++) { + dataDoubleComplex[i][j][0] = realData[i][j]; + dataDoubleComplex[i][j][1] = complexData[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(COMPLEXSPARSE, dataDoubleComplex, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorInteger8(byte[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Byte[][] dataInteger = new Byte[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(INTEGER, dataInteger, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorUInteger8(short[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Short[][] dataInteger = new Short[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(INTEGER, dataInteger, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorInteger16(short[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Short[][] dataInteger = new Short[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(INTEGER, dataInteger, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorUInteger16(int[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Integer[][] dataInteger = new Integer[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(INTEGER, dataInteger, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorInteger32(int[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Integer[][] dataInteger = new Integer[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(INTEGER, dataInteger, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorUInteger32(long[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Long[][] dataInteger = new Long[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataInteger[i][j] = data[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(INTEGER, dataInteger, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorString(String[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + ScilabVariableEditor.refreshVariableEditor(STRING, data, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param realData : real part of scilab double matrix + * @param complexData : complex part of scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorComplex(double[][] realData, double[][] complexData, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = realData.length == 0 ? 0 : realData[0].length; + Double[][][] dataDoubleComplex = new Double[realData.length][c][2]; + for (int i = 0; i < realData.length; i++) { + for (int j = 0; j < c; j++) { + dataDoubleComplex[i][j][0] = realData[i][j]; + dataDoubleComplex[i][j][1] = complexData[i][j]; + } + } + ScilabVariableEditor.refreshVariableEditor(COMPLEX, dataDoubleComplex, rowsIndex, colsIndex, variableName); + } + + /** + * Open variable Editor with information given by Scilab + * @param data : scilab double matrix + * @param variableName : name of the variable being edited. + */ + public static void refreshVariableEditorBoolean(int[][] data, double[] rowsIndex, double[] colsIndex, String variableName) { + int c = data.length == 0 ? 0 : data[0].length; + Boolean[][] dataBool = new Boolean[data.length][c]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < c; j++) { + dataBool[i][j] = data[i][j] == 1; + } + } + ScilabVariableEditor.refreshVariableEditor(BOOLEAN, dataBool, rowsIndex, colsIndex, variableName); + } + + /** + * Close Variable Editor + */ + public static void closeVariableEditor() { + ScilabVariableEditor.closeEditVar(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/FileBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/FileBrowser.java new file mode 100755 index 000000000..406d0ca50 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/FileBrowser.java @@ -0,0 +1,37 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data; + +import org.scilab.modules.ui_data.filebrowser.ScilabFileBrowser; + +/** + * Main class used in the GIWS interface + * @author Calixte DENIZET + */ +public final class FileBrowser { + + /** + * Open the file browser + */ + public static void openFileBrowser() { + ScilabFileBrowser.getFileBrowser(); + } + + /** + * Set the base directory + * @param baseDir the base directory + */ + public static void setBaseDir(String baseDir) { + ScilabFileBrowser.setBaseDir(baseDir); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/UI_data.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/UI_data.java new file mode 100755 index 000000000..1b8317d10 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/UI_data.java @@ -0,0 +1,48 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.scilab.modules.ui_data; + + +/** + * ui_data management + * @author Vincent COUVERT + * @author Allan CORNET + * @copyright INRIA + */ +public class UI_data { + + /** + * Constructor + */ + protected UI_data() { + throw new UnsupportedOperationException(); + } + + /** + * Put a scilab variable as an array of strings in C envrionment + * @param lines array of string + * @param rows the number of rows + * @param cols the number of cols + */ + public static void putScilabVariable(String name, String[] lines, int rows, int cols) { + UI_dataJNI.putScilabVariable(name, lines, rows, cols); + } + + + /** + * Put a scilab variable as an array of strings in C envrionment + * @param lines array of string + * @param rows the number of rows + * @param cols the number of cols + */ + public static String getUnnamedVariable() { + return UI_dataJNI.getUnnamedVariable(); + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/UI_dataJNI.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/UI_dataJNI.java new file mode 100755 index 000000000..a6bfe780a --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/UI_dataJNI.java @@ -0,0 +1,45 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.scilab.modules.ui_data; + + +/* It is generated code. Disable checkstyle */ +//CHECKSTYLE:OFF +/** + * All Scilab history management used in Java console + * @author Vincent COUVERT + * @author Allan CORNET + * @copyright INRIA + */ +class UI_dataJNI { + + /** + * Constructor + */ + protected UI_dataJNI() { + throw new UnsupportedOperationException(); + } + + static { + try { + System.loadLibrary("sciui_data"); + } catch (SecurityException e) { + System.err.println("A security manager exists and does not allow the loading of the specified dynamic library."); + System.err.println(e.getLocalizedMessage()); + e.printStackTrace(System.err); + } catch (UnsatisfiedLinkError e) { + System.err.println("The native library sciui_data does not exist or cannot be found."); + System.err.println(e.getLocalizedMessage()); + e.printStackTrace(System.err); + } + } + + public final static native void putScilabVariable(String jarg1, String[] jarg2, int jarg3, int jarg4); + public final static native String getUnnamedVariable(); +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/BooleanFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/BooleanFilteringAction.java new file mode 100755 index 000000000..886d1b5c6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/BooleanFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class BooleanFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.BOOLEAN; + + /** + * Constructor + * + */ + public BooleanFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new BooleanFilteringAction()); + return menu; + } + +} + diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/CompiledFunctionFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/CompiledFunctionFilteringAction.java new file mode 100755 index 000000000..233bda440 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/CompiledFunctionFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class CompiledFunctionFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.COMPILED_FUNC; + + + /** + * Constructor + * + */ + public CompiledFunctionFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new CompiledFunctionFilteringAction()); + return menu; + } + +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/DefaultAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/DefaultAction.java new file mode 100755 index 000000000..846e54673 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/DefaultAction.java @@ -0,0 +1,186 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.actions; + + +import java.awt.event.ActionEvent; + +import javax.swing.Action; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.KeyStroke; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.graphic_objects.graphicObject.CallBack; +import org.scilab.modules.gui.bridge.checkboxmenuitem.SwingScilabCheckBoxMenuItem; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.gui.checkboxmenuitem.ScilabCheckBoxMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; + +/** + * Default action for a BrowseVar + */ +public abstract class DefaultAction extends CommonCallBack { + + /** + * Default constructor. + * + *The {@link AbstractAction} object is configured using the reflection API. + * So you have to be sure that the following fields are declared as static + * final fields of each subclasses. + * <ul> + * <li>String NAME : The name of the action</li> + * <li>String SMALL_ICON : The associated icon name (located on + * $SCI/modules/gui/images/icons)</li> + * <li>int MNEMONIC_KEY : The key associated with the action (see + * {@link KeyEvent})</li> + * <li>int ACCELERATOR_KEY : The key mask to apply to the mnemonic</li> + * </ul> + * + * @param scilabVariableBrowser + * corresponding scilabVariableBrowser + */ + public DefaultAction() { + super("", CallBack.UNTYPED); + + installProperties(); + } + + /** + * Install the static actions properties on the instance + */ + private void installProperties() { + String name = ""; + ImageIcon icon = null; + int mnemonic = 0; + int accelerator = 0; + try { + name = (String) getClass().getField("NAME").get(null); + + /* + * Getting icon from the registered icon path + */ + final String iconName = (String) getClass().getField("SMALL_ICON").get(null); + if (iconName != null && !iconName.isEmpty()) { + icon = new ImageIcon(FindIconHelper.findIcon(iconName)); + } + + mnemonic = getClass().getField("MNEMONIC_KEY").getInt(null); + accelerator = getClass().getField("ACCELERATOR_KEY").getInt(null); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + + assert !"".equals(name); + putValue(Action.NAME, name); + putValue(Action.SHORT_DESCRIPTION, name); + putValue(Action.LONG_DESCRIPTION, name); + if (icon != null) { + putValue(Action.SMALL_ICON, icon); + } + + /* + * Set up the accelerator instead of the mnemonic as the menu is the + * preferred way on keyboard control. We are using Action.MNEMONIC_KEY + * as keyboard key and Action.ACCELERATOR_KEY as a mask. + * + * Install it only when there is a real shortcut (with a mnemonic). + */ + if (mnemonic != 0) { + putValue(Action.MNEMONIC_KEY, mnemonic); + putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(mnemonic, + accelerator)); + } + } + + /** + * Create a menu item + * + * @param callBack + * the associated callBack + * @return the menu item + */ + protected static MenuItem createMenu(CommonCallBack callBack) { + MenuItem item = ScilabMenuItem.createMenuItem(); + + SwingScilabMenuItem swingItem = (SwingScilabMenuItem) item + .getAsSimpleMenuItem(); + swingItem.setAction(callBack); + + return item; + } + + /** + * Create a button + * + * @param callback + * the associated callback + * @return the push button + */ + protected static JButton createButton(CommonCallBack callback) { + JButton button = new JButton(); + button.setAction(callback); + + // Not compatible with java 1.5 + // Hide the name text + // button.setHideActionText(true); + button.setText(""); + + return button; + } + + /** + * Create a checkbox item + * + * @param callback + * the associated callback + * @return the checkbox item + */ + protected static CheckBoxMenuItem createCheckBoxMenu(CommonCallBack callback) { + CheckBoxMenuItem item = ScilabCheckBoxMenuItem.createCheckBoxMenuItem(); + + SwingScilabCheckBoxMenuItem swingItem = (SwingScilabCheckBoxMenuItem) item + .getAsSimpleCheckBoxMenuItem(); + swingItem.setAction(callback); + + return item; + } + + + /** + * Action + * @param e parameters + * @see org.scilab.modules.gui.events.callback.CallBack#actionPerformed(java.awt.event.ActionEvent) + */ + @Override + public abstract void actionPerformed(ActionEvent e); + + /** + * Not used + * @see org.scilab.modules.gui.events.callback.CallBack#callBack() + */ + @Override + public void callBack() { + assert "Must never be called as we bypass Callback.java".equals(""); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/DoubleFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/DoubleFilteringAction.java new file mode 100755 index 000000000..2dca1a807 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/DoubleFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class DoubleFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.DOUBLE; + + + /** + * Constructor + * + */ + public DoubleFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new DoubleFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/FilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/FilteringAction.java new file mode 100755 index 000000000..51121f10e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/FilteringAction.java @@ -0,0 +1,38 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import java.awt.event.ActionEvent; + +import org.scilab.modules.ui_data.variablebrowser.ScilabVariableBrowser; + +public abstract class FilteringAction extends DefaultAction { + + /** Icon name of the action */ + public static final String SMALL_ICON = ""; + /** Mnemonic key of the action */ + public static final int MNEMONIC_KEY = 0; + /** Accelerator key for the action */ + public static final int ACCELERATOR_KEY = 0; + + + /** + * @param e parameter + * @see org.scilab.modules.graph.actions.base.DefaultAction#actionPerformed(java.awt.event.ActionEvent) + */ + @Override + public void actionPerformed(ActionEvent e) { + ScilabVariableBrowser.getVariableBrowser().updateRowFiltering(); + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/FunctionLibFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/FunctionLibFilteringAction.java new file mode 100755 index 000000000..d5cfe1172 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/FunctionLibFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class FunctionLibFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.FUNCTIONLIB; + + + /** + * Constructor + * + */ + public FunctionLibFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new FunctionLibFilteringAction()); + return menu; + } + +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/GraphicHandlesFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/GraphicHandlesFilteringAction.java new file mode 100755 index 000000000..79fffe15e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/GraphicHandlesFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class GraphicHandlesFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.GRAPHIC_HANDLES; + + + /** + * Constructor + * + */ + public GraphicHandlesFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new GraphicHandlesFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/HelpAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/HelpAction.java new file mode 100755 index 000000000..8e44dcdc5 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/HelpAction.java @@ -0,0 +1,84 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement; +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; + +/** + * Launch Scilab help class + * @author Vincent COUVERT + */ +@SuppressWarnings(value = { "serial" }) +public final class HelpAction extends CommonCallBack { + + private static ImageIcon icon = new ImageIcon(FindIconHelper.findIcon("help-browser")); + + /** + * Constructor + * @param name the name of the action + */ + public HelpAction(String name) { + super(name); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + try { + ScilabInterpreterManagement.asynchronousScilabExec(null, "help"); + } catch (InterpreterException e) { + System.err.println(e); + } + } + + /** + * Create a button for a tool bar + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new HelpAction(title)); + button.setToolTipText(title); + button.setIcon(icon); + + return button; + } + + /** + * Create the menu for the menubar + * @param label the menu label + * @return the menu + */ + public static MenuItem createMenuItem(String label) { + MenuItem menuItem = ScilabMenuItem.createMenuItem(); + menuItem.setText(label); + SwingScilabMenuItem swingItem = (SwingScilabMenuItem) menuItem.getAsSimpleMenuItem(); + swingItem.setCallback(new HelpAction(label)); + swingItem.setIcon(icon); + return menuItem; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ImplicitPolynomialFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ImplicitPolynomialFilteringAction.java new file mode 100755 index 000000000..f108eedf6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ImplicitPolynomialFilteringAction.java @@ -0,0 +1,46 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Manage MATLAB SPARSE display + * @author Vincent COUVERT + * + */ +public class ImplicitPolynomialFilteringAction extends FilteringAction { + + /** Name of the action */ + public static final String NAME = UiDataMessages.IMPLICIT_POLYNOMIAL; + + private static final long serialVersionUID = -7371889324166887650L; + + /** + * Constructor + */ + public ImplicitPolynomialFilteringAction() { + super(); + } + + /** + * Create checkbox menu for the graph menu bar + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu(new ImplicitPolynomialFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/IntegerFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/IntegerFilteringAction.java new file mode 100755 index 000000000..f5cb520c4 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/IntegerFilteringAction.java @@ -0,0 +1,42 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class IntegerFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.INTEGER; + + + /** + * Constructor + * + */ + public IntegerFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new IntegerFilteringAction()); + return menu; + } + +} + diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/IntrinsicFunctionFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/IntrinsicFunctionFilteringAction.java new file mode 100755 index 000000000..3d1942c61 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/IntrinsicFunctionFilteringAction.java @@ -0,0 +1,46 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Manage INTRINSIC FUNCTIONS display + * @author Vincent COUVERT + * + */ +public class IntrinsicFunctionFilteringAction extends FilteringAction { + + /** Name of the action */ + public static final String NAME = UiDataMessages.INTRINSIC_FUNCTION; + + private static final long serialVersionUID = -7371889324166887650L; + + /** + * Constructor + */ + public IntrinsicFunctionFilteringAction() { + super(); + } + + /** + * Create checkbox menu for the graph menu bar + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu(new IntrinsicFunctionFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ListFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ListFilteringAction.java new file mode 100755 index 000000000..8a3059752 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ListFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class ListFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.LIST; + + + /** + * Constructor + * + */ + public ListFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new ListFilteringAction()); + return menu; + } + +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/MListFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/MListFilteringAction.java new file mode 100755 index 000000000..925494210 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/MListFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class MListFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.MLIST; + + + /** + * Constructor + * + */ + public MListFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new MListFilteringAction()); + return menu; + } + +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/MatlabSparseFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/MatlabSparseFilteringAction.java new file mode 100755 index 000000000..f8de45702 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/MatlabSparseFilteringAction.java @@ -0,0 +1,46 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Manage MATLAB SPARSE display + * @author Vincent COUVERT + * + */ +public class MatlabSparseFilteringAction extends FilteringAction { + + /** Name of the action */ + public static final String NAME = UiDataMessages.MATLAB_SPARSE; + + private static final long serialVersionUID = -7371889324166887650L; + + /** + * Constructor + */ + public MatlabSparseFilteringAction() { + super(); + } + + /** + * Create checkbox menu for the graph menu bar + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu(new MatlabSparseFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/PointerFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/PointerFilteringAction.java new file mode 100755 index 000000000..8d03abf4c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/PointerFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class PointerFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.POINTER; + + + /** + * Constructor + * + */ + public PointerFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new PointerFilteringAction()); + return menu; + } + +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/PolynomialFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/PolynomialFilteringAction.java new file mode 100755 index 000000000..b38aae27c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/PolynomialFilteringAction.java @@ -0,0 +1,40 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class PolynomialFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.POLYNOMIAL; + + + /** + * Constructor + * + */ + public PolynomialFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new PolynomialFilteringAction()); + return menu; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ScilabVarFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ScilabVarFilteringAction.java new file mode 100755 index 000000000..d67e6ab31 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ScilabVarFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class ScilabVarFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.SCILABVAR; + + /** + * Constructor + * + */ + public ScilabVarFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new ScilabVarFilteringAction()); + return menu; + } + +} + diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ScilabVarFilteringButtonAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ScilabVarFilteringButtonAction.java new file mode 100755 index 000000000..79730789a --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/ScilabVarFilteringButtonAction.java @@ -0,0 +1,63 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variablebrowser.ScilabVariableBrowser; + +@SuppressWarnings(value = { "serial" }) +public class ScilabVarFilteringButtonAction extends CommonCallBack { + /** Name of the action */ + public static final String NAME = UiDataMessages.SCILABVAR; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public ScilabVarFilteringButtonAction(String name) { + super(name); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + ScilabVariableBrowser.getVariableBrowser().updateRowFiltering(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new ScilabVarFilteringButtonAction(title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("edit-clear")); + button.setIcon(imageIcon); + + return button; + } +} + diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/SparseBoolFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/SparseBoolFilteringAction.java new file mode 100755 index 000000000..f5b182d38 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/SparseBoolFilteringAction.java @@ -0,0 +1,46 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Manage BOOLEAN SPARSE variables display + * @author Allan SIMON + */ +public class SparseBoolFilteringAction extends FilteringAction { + + /** Name of the action */ + public static final String NAME = UiDataMessages.SPARSE_BOOLEAN; + + private static final long serialVersionUID = 438747338817314109L; + + /** + * Constructor + * + */ + public SparseBoolFilteringAction() { + super(); + } + + /** + * Create checkbox menu for the graph menu bar + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu(new SparseBoolFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/SparseFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/SparseFilteringAction.java new file mode 100755 index 000000000..788a22739 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/SparseFilteringAction.java @@ -0,0 +1,44 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Manages SPARSE variable display + * @author Allan SIMON + */ +public class SparseFilteringAction extends FilteringAction { + + /** Name of the action */ + public static final String NAME = UiDataMessages.SPARSE; + + private static final long serialVersionUID = 2739127354867960374L; + + /** + * Constructor + * + */ + public SparseFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu(new SparseFilteringAction()); + return menu; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/StringFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/StringFilteringAction.java new file mode 100755 index 000000000..f4ca3492b --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/StringFilteringAction.java @@ -0,0 +1,40 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class StringFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.STRING; + + + /** + * Constructor + * + */ + public StringFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new StringFilteringAction()); + return menu; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/TListFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/TListFilteringAction.java new file mode 100755 index 000000000..2e9cf6c11 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/TListFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class TListFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.TLIST; + + + /** + * Constructor + * + */ + public TListFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new TListFilteringAction()); + return menu; + } + +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/UncompiledFunctionFilteringAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/UncompiledFunctionFilteringAction.java new file mode 100755 index 000000000..4b61ed092 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/actions/UncompiledFunctionFilteringAction.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.actions; + +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +@SuppressWarnings(value = { "serial" }) +public class UncompiledFunctionFilteringAction extends FilteringAction { + /** Name of the action */ + public static final String NAME = UiDataMessages.UNCOMPILED_FUNC; + + + /** + * Constructor + * + */ + public UncompiledFunctionFilteringAction() { + super(); + } + /** + * Create checkbox menu for the graph menu bar + * + * @return the menu + */ + public static CheckBoxMenuItem createCheckBoxMenu() { + CheckBoxMenuItem menu = createCheckBoxMenu( new UncompiledFunctionFilteringAction()); + return menu; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/ScilabTable.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/ScilabTable.java new file mode 100755 index 000000000..6a36b8de7 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/ScilabTable.java @@ -0,0 +1,30 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.datatable; + +import javax.swing.table.TableModel; +/** + * + * Encapsulate Swing Table model for reusability. + * + * @param <Type> in order to have strongly/lazy typed JTable + */ +public interface ScilabTable<Type> extends TableModel { + + /** + * Set data in the Model + * @param data : the data + */ + void setData(Type[][] data); + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/SwingEditvarTableModel.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/SwingEditvarTableModel.java new file mode 100755 index 000000000..852b72fb6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/SwingEditvarTableModel.java @@ -0,0 +1,886 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.datatable; + +import java.awt.Cursor; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement; +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.EditVar; +import org.scilab.modules.ui_data.UI_data; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.celleditor.ScilabGenericCellEditor; +import org.scilab.modules.ui_data.variableeditor.undo.CellsUndoManager; +import org.scilab.modules.ui_data.variableeditor.undo.CellsUndoableEdit; + +/** + * Swing implementation of table model. + * @author Allan SIMON + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class SwingEditvarTableModel extends DefaultTableModel { + + private static final long serialVersionUID = -4255704246347716837L; + private static final String GUILL = "\""; + private static final String EQUAL = "="; + private static final String COMMA = ","; + private static final String SEMI = ";"; + + private int scilabMatrixRowCount; + private int scilabMatrixColCount; + private int currentRow = -1; + private int currentCol = -1; + private String type; + private String varName; + private ScilabGenericCellEditor cellEditor; + private SwingScilabVariableEditor editor; + private CellsUndoManager undoManager; + + private Vector copyVector; + + /** + * Default construction setting table data. + * @param editor the editor + * @param varName the variable name + * @param type the variable type + * @param data : the data to store. + * @param cellEditor the cellEditor + */ + public SwingEditvarTableModel(SwingScilabVariableEditor editor, String varName, String type, Object[][] data, ScilabGenericCellEditor cellEditor, int rows, int cols) { + this.editor = editor; + this.varName = varName; + scilabMatrixRowCount = data.length; + scilabMatrixColCount = 0; + if (scilabMatrixRowCount != 0) { // Not an empty matrix + scilabMatrixColCount = data[0].length; + } + this.type = type; + this.setDataVector(data, rows, cols); + this.cellEditor = cellEditor; + this.undoManager = new CellsUndoManager(editor); + } + + /** + * Change the data + * @param type the data type + * @param data the datas + * @param cellEditor the cell editor + * @param rows the number of rows + * @param cols the number of columns + */ + public void changeData(String type, Object[][] data, ScilabGenericCellEditor cellEditor, int rows, int cols) { + this.type = type; + this.cellEditor = cellEditor; + scilabMatrixRowCount = data.length; + scilabMatrixColCount = 0; + if (scilabMatrixRowCount != 0) { // Not an empty matrix + scilabMatrixColCount = data[0].length; + } + setDataVector(data, rows, cols); + } + + /** + * Change all the data + * @param v the data vector + * @param row the number of rows + * @param row the number of columns + */ + public void changeData(Vector v, int row, int col) { + dataVector = v; + scilabMatrixRowCount = row; + scilabMatrixColCount = col; + updateFullMatrix(null, 0, 0); + } + + /** + * {@inheritDoc} + */ + public void setDataVector(Object[][] data, int rows, int cols) { + int colsData = 0; + if (data.length != 0) { // Not an empty matrix + colsData = data[0].length; + } + + int c = Math.max(cols, colsData); + + Vector identifiers = new Vector(c); + for (int i = 0; i < c; ++i) { + identifiers.addElement(i + 1); + } + super.setDataVector(convertData(data, rows, cols), identifiers); + } + + /** + * Convert datas as arrays in a Vector object + * @param data the datas + * @param rows the number of rows + * @param columns the number of columns + * @return the corresponding Vector + */ + protected Vector convertData(Object[][] data, int rows, int cols) { + int r = Math.max(data.length, rows); + int c = 0; + if (data.length != 0) { + c = Math.max(data[0].length, cols); + } + Vector rv = new Vector(r); + for (int i = 0; i < data.length; i++) { + Vector cv = new Vector(c); + for (int j = 0; j < data[i].length; j++) { + cv.addElement(data[i][j]); + } + for (int j = 0; j < cols - data[i].length; j++) { + cv.addElement(null); + } + rv.addElement(cv); + } + for (int i = 0; i < rows - data.length; i++) { + Vector cv = new Vector(c); + for (int j = 0; j < c; j++) { + cv.addElement(null); + } + rv.addElement(cv); + } + + return rv; + } + + /** + * Enlarge the model + * @param rows the number of rows + * @param columns the number of columns + * @return true if the model has been enlarged + */ + public boolean enlarge(int rows, int cols) { + boolean isEnlarged = false; + + if (cols > getColumnCount()) { + addColumns(cols - getColumnCount()); + isEnlarged = true; + } + if (rows > getRowCount()) { + int r = rows - getRowCount(); + for (int i = 0; i < r; i++) { + Vector v = new Vector(getColumnCount()); + for (int j = 0; j < getColumnCount(); j++) { + v.addElement(null); + } + dataVector.addElement(v); + } + isEnlarged = true; + } + + return isEnlarged; + } + + /** + * Clone the datas + * @return the cloned datas + */ + public Vector cloneDatas() { + Vector v = new Vector(dataVector.size()); + for (int i = 0; i < dataVector.size(); i++) { + Vector vv = (Vector) dataVector.get(i); + if (vv != null) { + v.addElement(vv.clone()); + } else { + v.addElement(null); + } + } + return v; + } + + /** + * Add columns to the model + * @param number the number of columns to add + */ + public void addColumns(int number) { + columnIdentifiers.setSize(getColumnCount() + number); + for (int i = 0; i < getRowCount(); i++) { + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + } + + /** + * Add rows + * @param number the number of rows to add + */ + public void addRows(int number) { + enlarge(getRowCount() + number, getColumnCount()); + } + + /** + * @return the CellEditor used in this tableModel + */ + public ScilabGenericCellEditor getCellEditor() { + return cellEditor; + } + + /** + * @return the undoManager used in this tableModel + */ + public CellsUndoManager getUndoManager() { + return undoManager; + } + + /** + * @param manager the undoManager to set in this tableModel + */ + public void setUndoManager(CellsUndoManager manager) { + this.undoManager = manager; + } + + /** + * @return the type of this tableModel + */ + public String getType() { + return type; + } + + /** + * @return the type of this tableModel + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the Scilab matrix rows number + */ + public int getScilabMatrixRowCount() { + return scilabMatrixRowCount; + } + + /** + * @return the Scilab matrix columns number + */ + public int getScilabMatrixColCount() { + return scilabMatrixColCount; + } + + /** + * @param row the row + * @param col the col + * @param useDefault if true, null is replaced by the default value + * @return the scilab expression corresponding to the value + */ + public String getScilabValueAt(int row, int col, boolean useDefault) { + String str = cellEditor.getDataAsScilabString(getValueAt(row, col)); + if (!useDefault && getValueAt(row, col) == null) { + return null; + } + + if (str.length() == 0) { + str = getDefaultStringValue(); + } + + if (type.equals(EditVar.STRING)) { + str = GUILL + getDataAsScilabString(str) + GUILL; + } + + return str; + } + + /** + * @param row the row + * @param col the col + * @return the scilab expression corresponding to the value + */ + public String getScilabValueAt(int row, int col) { + return getScilabValueAt(row, col, true); + } + + /** + * @param row the row + * @param col the col + */ + public void emptyValueAt(int row, int col) { + super.setValueAt(null, row, col); + } + + /** + * @param mustUpdate if true, update in Scilab (useful with paste action) + * @param value the value + * @param row the row + * @param col the col + */ + public void setValueAtAndUpdate(boolean mustUpdate, boolean addUndoableEdit, Object value, int row, int col) { + Object oldValue = addUndoableEdit ? getValueAt(row, col) : null; + int oldScilabMatrixRowCount = scilabMatrixRowCount; + int oldScilabMatrixColCount = scilabMatrixColCount; + + copyVector = null; + boolean defaultAdded = setValue(value, row, col); + + if (defaultAdded) { + fireTableChanged(new TableModelEvent(this)); + } else { + fireTableCellUpdated(row, col); + } + + if (mustUpdate) { + if (defaultAdded) { + updateFullMatrix(copyVector, oldScilabMatrixRowCount, oldScilabMatrixColCount); + } else { + updateMatrix(oldValue, row, col); + } + } + } + + /** + * Set a value at the given row and column + * @param value the value to set + * @param row the row + * @param col the column + * @return true if the matrix has been enlarged (typically when the value to set is outside the actual matrix, zeros are added) + */ + public boolean setValue(Object value, int row, int col) { + if (value == null || (value instanceof String && ((String) value).length() == 0)) { + return false; + } + + Object defaultValue = getDefaultValue(); + boolean defaultAdded = false; + + if (row >= scilabMatrixRowCount) { + for (int i = scilabMatrixRowCount; i <= row; i++) { + Vector rowVector = (Vector) dataVector.elementAt(i); + for (int j = 0; j <= Math.max(col, scilabMatrixColCount - 1); j++) { + rowVector.setElementAt(defaultValue, j); + if (copyVector == null) { + copyVector = (Vector) dataVector.clone(); + } + if (!defaultAdded) { + defaultAdded = true; + } + } + } + } + + if (col >= scilabMatrixColCount) { + for (int i = 0; i <= Math.max(row, scilabMatrixRowCount - 1); i++) { + Vector rowVector = (Vector) dataVector.elementAt(i); + for (int j = scilabMatrixColCount; j <= col; j++) { + rowVector.setElementAt(defaultValue, j); + if (copyVector == null) { + copyVector = (Vector) dataVector.clone(); + } + if (!defaultAdded) { + defaultAdded = true; + } + } + } + } + + ((Vector) dataVector.elementAt(row)).setElementAt(value, col); + + if (col >= scilabMatrixColCount || row >= scilabMatrixRowCount) { + if (col >= scilabMatrixColCount) { + scilabMatrixColCount = col + 1; + } + if (row >= scilabMatrixRowCount) { + scilabMatrixRowCount = row + 1; + } + } + + return defaultAdded; + } + + /** + * Set values at the given row and column + * @param data the datas + * @param row the row index + * @param col the column index + * @return true if the matrix has been enlarged + */ + public boolean setValues(Vector data, int row, int col) { + int countCols = 0; + for (int i = 0; i < data.size(); i++) { + countCols = Math.max(countCols, ((Vector) data.get(i)).size()); + } + boolean isModified = enlarge(row + data.size(), col + countCols); + + for (int i = 0; i < data.size(); i++) { + for (int j = 0; j < ((Vector) data.get(i)).size(); j++) { + isModified = setValue(((Vector) data.get(i)).get(j), row + i, col + j) || isModified; + } + } + + return isModified; + } + + /** + * {@inheritDoc} + */ + public void setValueAt(Object value, int row, int col) { + setValueAtAndUpdate(true, true, value, row, col); + currentRow = row; + currentCol = col; + } + + /** + * @return the current row + */ + public int getCurrentRow() { + return currentRow; + } + + /** + * @return the current col + */ + public int getCurrentCol() { + return currentCol; + } + + /** + * @param row the row + * @param colB the first column + * @param colE the last column + */ + public void removeRow(int row, int colB, int colE) { + if (row == scilabMatrixRowCount - 1 && colB == 0 && colE >= scilabMatrixColCount - 1) { + scilabMatrixRowCount--; + Vector v = (Vector) dataVector.get(row); + for (int i = 0; i < scilabMatrixColCount; i++) { + v.setElementAt(null, i); + } + } + } + + /** + * @param table where to remove the col + * @param col the col + * @param rowB the first row + * @param rowE the last row + */ + public void removeCol(int col, int rowB, int rowE) { + if (col == scilabMatrixColCount - 1 && rowB == 0 && rowE >= scilabMatrixRowCount - 1) { + scilabMatrixColCount--; + for (int i = 0; i < scilabMatrixRowCount; i++) { + ((Vector) dataVector.get(i)).setElementAt(null, col); + } + } + } + + /** + * @param cols the column indexes to remove, the array is supposed to be ordered + */ + public void removeColumns(int[] cols) { + Vector copy = null; + int oldRowCount = scilabMatrixRowCount; + int oldColCount = scilabMatrixColCount; + int c = 0; + for (Integer col : cols) { + if (col - c < scilabMatrixColCount) { + if (copy == null) { + copy = cloneDatas(); + } + if (col - c == scilabMatrixColCount - 1) { + for (int i = 0; i < scilabMatrixRowCount; i++) { + ((Vector) dataVector.get(i)).setElementAt(null, col - c); + } + } else { + for (int i = 0; i < scilabMatrixRowCount; i++) { + ((Vector) dataVector.get(i)).removeElementAt(col - c); + } + } + scilabMatrixColCount--; + c++; + } + } + if (copy != null) { + fireTableStructureChanged(); + updateFullMatrix(copy, oldRowCount, oldColCount); + } + } + + /** + * @param rows the row indexes to remove, the array is supposed to be ordered + */ + public void removeRows(int[] rows) { + Vector copy = null; + int oldRowCount = scilabMatrixRowCount; + int oldColCount = scilabMatrixColCount; + int r = 0; + for (Integer row : rows) { + if (row - r < scilabMatrixRowCount) { + if (copy == null) { + copy = cloneDatas(); + } + if (row - r == scilabMatrixRowCount - 1) { + Vector rv = (Vector) dataVector.get(row - r); + for (int i = 0; i < scilabMatrixColCount; i++) { + rv.setElementAt(null, i); + } + } else { + dataVector.removeElementAt(row - r); + } + scilabMatrixRowCount--; + fireTableRowsDeleted(row - r, row - r); + r++; + } + } + if (copy != null) { + updateFullMatrix(copy, oldRowCount, oldColCount); + } + } + + /** + * @param col the column index to insert + */ + public void insertColumn(int col) { + if (col < scilabMatrixColCount - 1) { + Vector copy = cloneDatas(); + int oldRowCount = scilabMatrixRowCount; + int oldColCount = scilabMatrixColCount; + Object o = getDefaultValue(); + for (int i = 0; i < scilabMatrixRowCount; i++) { + ((Vector) dataVector.get(i)).insertElementAt(o, col); + } + scilabMatrixColCount++; + updateFullMatrix(copy, oldRowCount, oldColCount); + } + } + + /** + * @param row the row index to insert + */ + public void insertRow(int row) { + if (row < scilabMatrixRowCount - 1) { + Vector copy = cloneDatas(); + int oldRowCount = scilabMatrixRowCount; + int oldColCount = scilabMatrixColCount; + Object o = getDefaultValue(); + Vector v = new Vector(getColumnCount()); + for (int i = 0; i < scilabMatrixColCount; i++) { + v.addElement(o); + } + for (int i = scilabMatrixColCount; i < getColumnCount(); i++) { + v.addElement(null); + } + dataVector.insertElementAt(v, row); + scilabMatrixRowCount++; + updateFullMatrix(copy, oldRowCount, oldColCount); + } + } + + /** + * Update all the matrix on the Scilab's side. + */ + public void updateFullMatrix(Object oldValue, int oldRow, int oldCol) { + String[] mat = getSubMatrix(0, scilabMatrixRowCount - 1, 0, scilabMatrixColCount - 1); + UI_data.putScilabVariable("L?8625083632641564278", mat, scilabMatrixRowCount, scilabMatrixColCount); + String command; + if (type.equals(EditVar.SPARSE) || type.equals(EditVar.COMPLEXSPARSE) || type.equals(EditVar.BOOLEANSPARSE)) { + command = buildScilabRequest(varName + "=sparse(evstr(L?8625083632641564278))", "editvar(\"" + varName + "\"),clear(\"L?8625083632641564278\")"); + } else { + command = buildScilabRequest(varName + "=evstr(L?8625083632641564278)", "editvar(\"" + varName + "\"),clear(\"L?8625083632641564278\")"); + } + execCommand(command, oldValue, oldRow, oldCol); + } + + /** + * Get a submatrix + * @param rowB first row index + * @param rowE last row index + * @param colB first col index + * @param colE last col index + * @return the corresponding submatrix + */ + private String[] getSubMatrix(int rowB, int rowE, int colB, int colE) { + int row = rowE - rowB + 1; + int col = colE - colB + 1; + String[] mat = new String[row * col]; + for (int i = 0; i < row; i++) { + for (int j = 0; j < col; j++) { + mat[j * row + i] = getScilabValueAt(i + rowB, j + colB); + } + } + + return mat; + } + + /** + * Get a Scilab submatrix + * @param varName the variable name + * @param rowB first row index + * @param rowE last row index + * @param colB first col index + * @param colE last col index + */ + public String getScilabSubMatrix(int[] rows, int[] cols, int[] rowSize, int[] colSize) { + if (rows.length == 0 || cols.length == 0) { + return null; + } + + int rowC = getScilabMatrixRowCount() - 1; + int colC = getScilabMatrixColCount() - 1; + String rowsLim = getLimits(rows, rowC, rowSize); + if (rowsLim == null) { + return null; + } + + String colsLim = getLimits(cols, colC, colSize); + if (colsLim == null) { + return null; + } + + if (rowSize[0] == rowC + 1 && colSize[0] == colC + 1) { + return getVarName(); + } else { + return getVarName() + "(" + rowsLim + "," + colsLim + ")"; + } + } + + public String getScilabSubMatrix(int[] rows, int[] cols) { + int[] csize = new int[1]; + int[] rsize = new int[1]; + + return getScilabSubMatrix(rows, cols, csize, rsize); + } + + /** + * Build the Scilab indexes to extract the corresponding matrix. + * For example, if index={1,2,3,5,6,10} then the string "1:3,5:6,10" will be returned. + * @param index the indexes + * @param max the maximum value that an index can have + * @param size an array of length 1 which will contain the total size (e.g. with the previous example size[0] will be 6) + * @return the corresponding Scilab string + */ + private static String getLimits(int[] index, int max, int[] size) { + if (index.length == 0 || index[0] > max) { + return null; + } + + Vector<Integer> lim = new Vector<Integer>(2 * index.length); + int i = 1; + + lim.addElement(index[0]); + for (; i < index.length && index[i] <= max; i++) { + if (index[i] != index[i - 1] + 1) { + lim.addElement(index[i - 1]); + lim.addElement(index[i]); + } + } + + if (i == index.length) { + lim.addElement(index[index.length - 1]); + } else { + lim.addElement(max); + } + + if (lim.size() == 2) { + size[0] = lim.get(1) - lim.get(0) + 1; + if (lim.get(0) == 0 && lim.get(1) == max) { + return ":"; + } else { + if (lim.get(0) == lim.get(1)) { + return Integer.toString(lim.get(0) + 1); + } else { + return (lim.get(0) + 1) + ":" + (lim.get(1) + 1); + } + } + } + + StringBuilder buf = new StringBuilder("["); + size[0] = 0; + for (i = 0; i < lim.size(); i += 2) { + size[0] += lim.get(i + 1) - lim.get(i) + 1; + buf.append(lim.get(i) + 1); + if (lim.get(i) != lim.get(i + 1)) { + buf.append(":"); + buf.append(lim.get(i + 1) + 1); + } + if (i == lim.size() - 2) { + buf.append("]"); + } else { + buf.append(","); + } + } + + return buf.toString(); + } + + /** + * Refresh the current matrix + */ + public void refreshMatrix() { + execCommand("editvar(\"" + varName + "\");"); + } + + /** + * @return the var name in this model + */ + public String getVarName() { + return varName; + } + + /** + * @return the default value according to this type + */ + private Object getDefaultValue() { + Object ret = null; + if (type.equals(EditVar.DOUBLE)) { + ret = new Double(0.0); + } else if (type.equals(EditVar.STRING)) { + ret = ""; + } else if (type.equals(EditVar.INTEGER)) { + ret = new Integer(0); + } else if (type.equals(EditVar.COMPLEX)) { + ret = new Double[] {0.0, 0.0}; + } else if (type.equals(EditVar.BOOLEAN)) { + ret = Boolean.FALSE; + } else if (type.equals(EditVar.SPARSE) || type.equals(EditVar.COMPLEXSPARSE) || type.equals(EditVar.BOOLEANSPARSE)) { + ret = ""; + } + + return ret; + } + + /** + * @return the default representation according to the type + */ + private String getDefaultStringValue() { + if (type.equals(EditVar.DOUBLE) || type.equals(EditVar.COMPLEX) || type.equals(EditVar.INTEGER) || type.equals(EditVar.SPARSE) || type.equals(EditVar.COMPLEXSPARSE)) { + return "0"; + } + + if (type.equals(EditVar.STRING)) { + return ""; + } + + if (type.equals(EditVar.BOOLEAN) || type.equals(EditVar.BOOLEANSPARSE)) { + return "%f"; + } + + return null; + } + + /** + * @param oldValue the value to update on the Scilab's side + * @param row the row coord + * @param col the col coord + */ + public void updateMatrix(Object oldValue, int row, int col) { + String val = getScilabValueAt(row, col); + String coords = ""; + if (scilabMatrixRowCount != 1 || scilabMatrixColCount != 1) { + coords = "(" + (row + 1) + COMMA + (col + 1) + ")"; + } + String expr = varName + coords + EQUAL + getDataAsScilabString(val); + String update = "editvar(\"" + varName + "\"," + varName + "(" + (row + 1) + "," + (col + 1) + ")," + (row + 1) + "," + (col + 1) + ");"; + String command = buildScilabRequest(expr, update); + execCommand(command, oldValue, row, col); + } + + /** + * Execute a command + * @param com the command + */ + public void execCommand(String com) { + execCommand(com, null, 0 , 0); + } + + /** + * @param com the command to execute. + */ + private void execCommand(final String com, final Object oldValue, final int row, final int col) { + try { + CommonCallBack callback = new CommonCallBack("") { + public void callBack() { + editor.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + if (oldValue != null) { + Object newValue; + if (oldValue instanceof Vector) { + newValue = (Vector) dataVector.clone(); + } else { + newValue = getValueAt(row, col); + } + if (!oldValue.equals(newValue)) { + undoManager.addEdit(new CellsUndoableEdit(SwingEditvarTableModel.this, newValue, oldValue, row, col)); + } + } + } + }; + editor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ScilabInterpreterManagement.asynchronousScilabExec(callback, com); + } catch (InterpreterException e1) { + System.err.println(e1); + } + } + + /** + * @param expr the expr to put in the request. + * @return the request + */ + public static String buildScilabRequest(String expr, String update) { + StringBuilder command = new StringBuilder(); + command.append("L$8625083632641564277=warning(\"query\");warning(\"off\");"); + command.append("if execstr(\""); + command.append(expr); + command.append("\",\"errcatch\") <> 0 then messagebox(\"Could not edit variable: \" + lasterror() + \"\""); + command.append(",\"Variable editor\",\"error\",\"modal\");"); + command.append("end;"); + command.append("warning(L$8625083632641564277);clear(\"L$8625083632641564277\");"); + command.append(update); + command.append(";"); + command.append("updatebrowsevar()"); + return command.toString(); + } + + /** + * @return the Scilab matrix for this JTable + */ + private String getMatrix() { + StringBuilder str = new StringBuilder("["); + for (int i = 0; i < scilabMatrixRowCount; i++) { + for (int j = 0; j < scilabMatrixColCount; j++) { + str.append(getScilabValueAt(i, j)); + if (j < scilabMatrixColCount - 1) { + str.append(COMMA); + } else if (i < scilabMatrixRowCount - 1) { + str.append(SEMI); + } + } + } + str.append("]"); + + return str.toString(); + } + + /** + * Refresh the model + */ + public void refresh() { + try { + ScilabInterpreterManagement.asynchronousScilabExec(null, "editvar(\"" + varName + "\")"); + } catch (InterpreterException e1) { + System.err.println(e1); + } + } + + /** + * @param str the string where replace " and ' + * @return the well-formed string + */ + public static String getDataAsScilabString(String str) { + return str.replace(GUILL, "\"\"").replace("'", "''"); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/SwingTableModel.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/SwingTableModel.java new file mode 100755 index 000000000..dd5f8bdee --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/datatable/SwingTableModel.java @@ -0,0 +1,122 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.datatable; + +import javax.swing.ImageIcon; +import javax.swing.table.DefaultTableModel; + +/** + * Swing implementation of table model. + * @param <Type> Type of data to be stored by the model + */ +public class SwingTableModel<Type> extends DefaultTableModel implements ScilabTable<Type> { + + private static final long serialVersionUID = -4255704246347716837L; + + private String[] columnNames; + private Type[][] data; + + /** + * Default construction setting columns title. + * @param columnsNames : the columns title. + */ + public SwingTableModel(String[] columnsNames) { + this.columnNames = columnsNames; + } + + public SwingTableModel(Type[][] data) { + this.data = data; + } + + /** + * {@inheritDoc} + */ + public int getColumnCount() { + if (columnNames != null) { + return columnNames.length; + } else { + return data[0].length; + } + } + + /** + * {@inheritDoc} + */ + public int getRowCount() { + if (data == null) { + return 0; + } + return data.length; + } + + /** + * {@inheritDoc} + */ + public Type getValueAt(int row, int col) { + if (data == null) { + return null; + } + return data[row][col]; + } + + /** + * {@inheritDoc} + */ + public void setData(Type[][] data) { + this.data = data; + } + + /** + * {@inheritDoc} + */ + public String getColumnName(int col) { + if (columnNames != null) { + return columnNames[col]; + } else { + return String.valueOf(col); + } + } + + /** + * {@inheritDoc} + */ + public void setColumnNames(String[] columnNames) { + this.columnNames = columnNames; + } + + /** + * {@inheritDoc} + */ + public Class getColumnClass(int c) { + // Need to force return of ImageIcon when needed + // to have real images displayed + // and no PATH comming from "toString" method. + if (c == 0) { + return ImageIcon.class; + } + + if (c == 2 || c == 3) { + return Integer.class; + } + + if (getValueAt(0, c) != null) { + return getValueAt(0, c).getClass(); + } + return Object.class; + } + + @Override + public boolean isCellEditable(int row, int column) { + return false; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/AbstractScilabTreeTableModel.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/AbstractScilabTreeTableModel.java new file mode 100755 index 000000000..2080e471e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/AbstractScilabTreeTableModel.java @@ -0,0 +1,177 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import javax.swing.tree.TreePath; +import javax.swing.event.EventListenerList; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; + +/** + * The tree table model abstract implementation + * @author Calixte DENIZET + */ +public abstract class AbstractScilabTreeTableModel implements ScilabTreeTableModel { + + protected Object root; + protected Object parent; + protected EventListenerList listenerList = new EventListenerList(); + + /** + * Default constructor + * @param root the root element + */ + public AbstractScilabTreeTableModel(Object root) { + this.root = root; + } + + /** + * Default constructor + */ + public AbstractScilabTreeTableModel() { } + + /** + * Set the root element + * @param root the root + */ + public void setRoot(Object root) { + this.root = root; + } + + /** + * {@inheritdoc} + */ + public Object getRoot() { + return root; + } + + /** + * {@inheritdoc} + */ + public boolean isLeaf(Object node) { + return ((FileNode) node).isLeaf(); + } + + /** + * {@inheritdoc} + */ + public void valueForPathChanged(TreePath path, Object newValue) { } + + /** + * {@inheritdoc} + */ + public int getIndexOfChild(Object parent, Object child) { + if (parent == root && this.parent != null) { + return ((FileNode) child).getPosition() + 1; + } else { + return ((FileNode) child).getPosition(); + } + } + + /** + * {@inheritdoc} + */ + public void addTreeModelListener(TreeModelListener l) { + listenerList.add(TreeModelListener.class, l); + } + + /** + * {@inheritdoc} + */ + public void removeTreeModelListener(TreeModelListener l) { + listenerList.remove(TreeModelListener.class, l); + } + + /** + * {@inheritdoc} + */ + protected void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children) { + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == TreeModelListener.class) { + if (e == null) { + e = new TreeModelEvent(source, path, childIndices, children); + } + ((TreeModelListener) listeners[i + 1]).treeNodesChanged(e); + } + } + } + + /** + * {@inheritdoc} + */ + protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children) { + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == TreeModelListener.class) { + if (e == null) { + e = new TreeModelEvent(source, path, childIndices, children); + } + ((TreeModelListener) listeners[i + 1]).treeNodesInserted(e); + } + } + } + + /** + * {@inheritdoc} + */ + protected void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children) { + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == TreeModelListener.class) { + if (e == null) { + e = new TreeModelEvent(source, path, childIndices, children); + } + ((TreeModelListener) listeners[i + 1]).treeNodesRemoved(e); + } + } + } + + /** + * {@inheritdoc} + */ + protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children) { + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == TreeModelListener.class) { + if (e == null) { + e = new TreeModelEvent(source, path, childIndices, children); + } + ((TreeModelListener) listeners[i + 1]).treeStructureChanged(e); + } + } + } + + /** + * {@inheritdoc} + */ + public Class getColumnClass(int column) { + return Object.class; + } + + /** + * {@inheritdoc} + */ + public boolean isCellEditable(Object node, int column) { + return false; + } + + /** + * {@inheritdoc} + */ + public void setValueAt(Object aValue, Object node, int column) { } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileBrowserRowSorter.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileBrowserRowSorter.java new file mode 100755 index 000000000..0a8a06574 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileBrowserRowSorter.java @@ -0,0 +1,166 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.Cursor; +import java.util.Enumeration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.SwingUtilities; +import javax.swing.table.TableModel; +import javax.swing.tree.TreePath; + +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; + +/** + * A RowSorter to sort the files in the view + * @author Calixte DENIZET + */ +public class FileBrowserRowSorter extends RowSorter<TableModel> { + + private JTree tree; + private JTable table; + private List<RowSorter.SortKey> sortKeys; + + /** + * Default constructor + * @param tree the associated JTree + * @param table the associated JTable + */ + public FileBrowserRowSorter(JTree tree, JTable table) { + this.tree = tree; + this.table = table; + } + + /** + * {@inheritDoc} + */ + public void allRowsChanged() { } + + /** + * {@inheritDoc} + */ + public int convertRowIndexToModel(int index) { + return index; + } + + /** + * {@inheritDoc} + */ + public int convertRowIndexToView(int index) { + return index; + } + + /** + * {@inheritDoc} + */ + public TableModel getModel() { + return table.getModel(); + } + + /** + * {@inheritDoc} + */ + public int getModelRowCount() { + return tree.getRowCount(); + } + + /** + * {@inheritDoc} + */ + public List<RowSorter.SortKey> getSortKeys() { + if (sortKeys == null) { + List<RowSorter.SortKey> list = new ArrayList<RowSorter.SortKey>(); + list.add(new RowSorter.SortKey(0, SortOrder.ASCENDING)); + setSortKeys(list); + } + + return sortKeys; + } + + public int getViewRowCount() { + return getModelRowCount(); + } + + /** + * {@inheritDoc} + */ + public void modelStructureChanged() { } + + /** + * {@inheritDoc} + */ + public void rowsDeleted(int firstRow, int endRow) { } + + /** + * {@inheritDoc} + */ + public void rowsInserted(int firstRow, int endRow) { } + + /** + * {@inheritDoc} + */ + public void rowsUpdated(int firstRow, int endRow) { } + + /** + * {@inheritDoc} + */ + public void rowsUpdated(int firstRow, int endRow, int column) { } + + /** + * {@inheritDoc} + */ + public void setSortKeys(List <? extends RowSorter.SortKey > keys) { + this.sortKeys = Collections.unmodifiableList(new ArrayList<SortKey>(keys)); + fireSortOrderChanged(); + } + + /** + * {@inheritDoc} + */ + public void toggleSortOrder(int column) { + SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, table).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + ScilabFileBrowserModel model = (ScilabFileBrowserModel) tree.getModel(); + FileNode root = (FileNode) model.getRoot(); + Enumeration<TreePath> en = tree.getExpandedDescendants(new TreePath(root)); + root.toggleSortOrder(table.getColumnName(column)); + + root.orderFiles(); + for (int i = 0; i < tree.getRowCount(); i++) { + FileNode fn = (FileNode) tree.getPathForRow(i).getLastPathComponent(); + fn.orderFiles(); + } + + model.fireTreeStructureChanged(model, new TreePath(root).getPath(), null, null); + if (en != null) { + while (en.hasMoreElements()) { + tree.expandPath(en.nextElement()); + } + } + + SortOrder order = root.getOrder(); + List<RowSorter.SortKey> list = new ArrayList<RowSorter.SortKey>(); + list.add(new RowSorter.SortKey(column, order)); + setSortKeys(list); + + table.repaint(); + + SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, table).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } +}
\ No newline at end of file diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileComparators.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileComparators.java new file mode 100755 index 000000000..b1f39a034 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileComparators.java @@ -0,0 +1,146 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.util.Comparator; + +import org.scilab.modules.commons.OS; + +/** + * Several file comparators + * @author Calixte DENIZET + */ +public final class FileComparators { + + private static final boolean isWindows = (OS.get() == OS.WINDOWS); + + public static final Comparator<FileNode> ASCENDING_ALPHA = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + if (f1.isFile == f2.isFile) { + int diff; + if (isWindows) { + diff = f1.name.compareToIgnoreCase(f2.name); + if (diff == 0) { + diff = f1.name.compareTo(f2.name); + } + } else { + diff = f1.name.compareTo(f2.name); + } + return diff; + } else if (f1.isFile) { + return 1; + } + return -1; + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> DESCENDING_ALPHA = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + return -ASCENDING_ALPHA.compare(f1, f2); + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> ASCENDING_DATE = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + long diff = f1.lastModified - f2.lastModified; + if (diff == 0) { + return ASCENDING_ALPHA.compare(f1, f2); + } else { + return diff > 0 ? 1 : -1; + } + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> DESCENDING_DATE = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + return -ASCENDING_DATE.compare(f1, f2); + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> ASCENDING_SIZE = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + long diff = f1.length - f2.length; + if (diff == 0) { + return ASCENDING_ALPHA.compare(f1, f2); + } else { + return diff > 0 ? 1 : -1; + } + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> DESCENDING_SIZE = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + return -ASCENDING_SIZE.compare(f1, f2); + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> ASCENDING_TYPE = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + int diff; + if (isWindows) { + diff = f1.extension.compareToIgnoreCase(f2.extension); + if (diff == 0) { + diff = f1.extension.compareTo(f2.extension); + } + } else { + diff = f1.extension.compareTo(f2.extension); + } + + if (diff == 0) { + return ASCENDING_ALPHA.compare(f1, f2); + } + + return diff; + } + + public boolean equals(Object obj) { + return false; + } + }; + + public static final Comparator<FileNode> DESCENDING_TYPE = new Comparator<FileNode>() { + public int compare(FileNode f1, FileNode f2) { + return -ASCENDING_TYPE.compare(f1, f2); + } + + public boolean equals(Object obj) { + return false; + } + }; + + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileNode.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileNode.java new file mode 100755 index 000000000..6079ed85f --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileNode.java @@ -0,0 +1,341 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.io.File; +import java.util.Comparator; +import java.util.TreeSet; +import java.util.regex.Pattern; + +import javax.swing.Icon; +import javax.swing.SortOrder; + +import org.scilab.modules.commons.CommonFileUtils; +import org.scilab.modules.commons.ScilabConstants; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Handle a File as a node in the JTree + * @author Calixte DENIZET + */ +public class FileNode { + + public static final int NAMEORDER = 1; + public static final int SIZEORDER = 2; + public static final int DATEORDER = 3; + public static final int TYPEORDER = 4; + + private static final File userHomeDir = new File(ScilabConstants.USERHOME); + private static final File SCIDIR = new File(System.getenv("SCI")); + + private static Comparator<FileNode> comparator = FileComparators.ASCENDING_ALPHA; + + protected File file; + protected Icon icon; + protected FileNode[] children; + protected long lastModified; + protected boolean isFile; + protected boolean canRead; + protected boolean canWrite; + protected boolean isEmpty; + protected boolean userHome; + protected boolean sci; + protected long length; + protected String name; + protected String extension; + private int order = 1; + private Pattern pat; + private int position; + + /** + * Default constructor + * @param file the file in this node + */ + public FileNode(File file, int position) { + this(file, file.getName(), file.canRead(), file.isFile()); + this.position = position; + } + + public FileNode(File file, String name, boolean canRead, boolean isFile) { + this.file = file; + this.name = name; + this.isFile = isFile; + this.canRead = canRead; + this.canWrite = file.canWrite(); + this.lastModified = file.lastModified(); + this.userHome = file.equals(userHomeDir); + if (isFile) { + this.length = file.length(); + } + this.extension = FileUtils.getFileExtension(file); + this.sci = file.equals(SCIDIR); + this.isEmpty = isFile || CommonFileUtils.isEmptyDirectory(file.getAbsolutePath()) == 1; + } + + public int getPosition() { + return position; + } + + /** + * @param pat the pattern to filter the files + */ + public void setFilter(Pattern pat) { + this.pat = pat; + resetChildren(); + } + + /** + * @param order the order to use to sort the file. If order is positive, then ascending order is used. + */ + public void setOrder(int order) { + this.order = order; + switch (order) { + case NAMEORDER: + comparator = FileComparators.ASCENDING_ALPHA; + break; + case -NAMEORDER: + comparator = FileComparators.DESCENDING_ALPHA; + break; + case TYPEORDER: + comparator = FileComparators.ASCENDING_TYPE; + break; + case -TYPEORDER: + comparator = FileComparators.DESCENDING_TYPE; + break; + case DATEORDER: + comparator = FileComparators.ASCENDING_DATE; + break; + case -DATEORDER: + comparator = FileComparators.DESCENDING_DATE; + break; + case SIZEORDER: + comparator = FileComparators.ASCENDING_SIZE; + break; + case -SIZEORDER: + comparator = FileComparators.DESCENDING_SIZE; + break; + } + } + + /** + * @param order the order to use to sort the file. + * @param ascending if true, the ascending order is used + */ + public void setOrder(int order, boolean ascending) { + int sign = ascending ? +1 : -1; + setOrder(sign * order); + } + + /** + * @return the used order + */ + public SortOrder getOrder() { + return order > 0 ? SortOrder.ASCENDING : SortOrder.DESCENDING; + } + + /** + * Sort a column according to the natural order for its. + * @param nameColumn the column name + */ + public void toggleSortOrder(String nameColumn) { + if (nameColumn.equals(UiDataMessages.NAME_COLUMN)) { + if (Math.abs(order) == NAMEORDER) { + setOrder(-order); + } else { + setOrder(NAMEORDER); + } + } else if (nameColumn.equals(UiDataMessages.TYPE_COLUMN)) { + if (Math.abs(order) == TYPEORDER) { + setOrder(-order); + } else { + setOrder(TYPEORDER); + } + } else if (nameColumn.equals(UiDataMessages.SIZE_COLUMN)) { + if (Math.abs(order) == SIZEORDER) { + setOrder(-order); + } else { + setOrder(SIZEORDER); + } + } else if (nameColumn.equals(UiDataMessages.LASTMODIF_COLUMN)) { + if (Math.abs(order) == DATEORDER) { + setOrder(-order); + } else { + setOrder(DATEORDER); + } + } + } + + /** + * Sort the files + * @param order the order to use + * @param files the files to order + * @return the ordered FileNodes + */ + protected void orderFiles() { + if (children != null) { + TreeSet<FileNode> set = new TreeSet<FileNode>(comparator); + for (FileNode fn : children) { + set.add(fn); + } + + children = set.toArray(children); + for (int i = 0; i < children.length; i++) { + children[i].position = i; + } + } + } + + /** + * Returns the string to be used to display this leaf in the JTree. + */ + public String toString() { + String name = file.getName(); + if (name.isEmpty()) { + name = file.toString(); + } + return name; + } + + /** + * @return the file associated with this node + */ + public File getFile() { + return file; + } + + /** + * @return true if this represents the user-home directory + */ + public boolean isUserHome() { + return userHome; + } + + /** + * @return true if this represents the SCI directory + */ + public boolean isSCI() { + return sci; + } + + /** + * @return the last modified time for this file + */ + public long getLastModified() { + return lastModified; + } + + /** + * @return the icon associated with this file + */ + public Icon getIcon() { + if (icon == null) { + icon = FileUtils.getIconForFile(file); + } + + return icon; + } + + /** + * @return true if the file is not a directory or if it is an empty one + */ + public boolean isLeaf() { + return isEmpty; + } + + /** + * @return the number of files in the directory representated by this file + */ + public int getChildrenCount() { + if (children == null && !isEmpty) { + synchronized (file) { + if (children == null) { + children = listFiles(); + } + } + } + + if (children != null) { + return children.length; + } + + return 0; + } + + /** + * @return the children FileNode of this FileNode + */ + protected Object[] getChildren() { + if (children == null && !isEmpty) { + children = listFiles(); + } + + return children; + } + + public FileNode[] listFiles() { + String[] filesName = file.list(); + if (filesName != null) { + TreeSet<FileNode> nodes = new TreeSet<FileNode>(comparator); + for (String fileName : filesName) { + File f = new File(file, fileName); + if (pat != null && !pat.matcher(fileName).matches()) { + continue; + } + if (f.isHidden()) { + continue; + } + boolean canRead = f.canRead(); + if (!canRead) { + continue; + } + boolean isFile = f.isFile(); + if (!isFile && !f.isDirectory()) { + continue; + } + nodes.add(new FileNode(f, fileName, canRead, isFile)); + } + + FileNode[] fnodes = new FileNode[nodes.size()]; + fnodes = nodes.toArray(fnodes); + + for (int i = 0; i < fnodes.length; i++) { + fnodes[i].position = i; + } + + return fnodes; + } + + return null; + } + + /** + * Reset children only + */ + public void resetChildren() { + children = null; + } + + /** + * {@inheritDoc} + */ + public boolean equals(Object o) { + return (o instanceof FileNode) && ((FileNode) o).file.equals(file); + } + + /** + * {@inheritDoc} + */ + public int hashCode() { + return file.hashCode(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileUtils.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileUtils.java new file mode 100755 index 000000000..fc1ca0b81 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/FileUtils.java @@ -0,0 +1,201 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.Icon; +import javax.swing.ImageIcon; + +import org.scilab.modules.commons.gui.FindIconHelper; + +/** + * Few file tools + * + * @author Calixte DENIZET + */ +public final class FileUtils { + + private static final Icon SCILABICON = new ImageIcon(FindIconHelper.findIcon("scilab")); + private static final Icon PDFICON = new ImageIcon(FindIconHelper.findIcon("application-pdf")); + private static final Icon BINARYICON = new ImageIcon(FindIconHelper.findIcon("binary")); + private static final Icon IMAGEICON = new ImageIcon(FindIconHelper.findIcon("image-x-generic")); + private static final Icon TEXTICON = new ImageIcon(FindIconHelper.findIcon("text-x-generic")); + private static final Icon HTMLICON = new ImageIcon(FindIconHelper.findIcon("text-html")); + private static final Icon XMLICON = new ImageIcon(FindIconHelper.findIcon("text-xml")); + private static final Icon CSVICON = new ImageIcon(FindIconHelper.findIcon("text-csv")); + private static final Icon DIRICON = new ImageIcon(FindIconHelper.findIcon("folder")); + private static final Icon OPENDIRICON = new ImageIcon(FindIconHelper.findIcon("folder-open")); + private static final Icon READONLYICON = new ImageIcon(FindIconHelper.findIcon("emblem-readonly")); + private static final Icon CLOSEDUSERHOMEICON = new ImageIcon(FindIconHelper.findIcon("user-home")); + private static final Icon OPENUSERHOMEICON = new ImageIcon(FindIconHelper.findIcon("user-home-open")); + private static final Icon UPICON = new ImageIcon(FindIconHelper.findIcon("dynamic-blue-up")); + private static final Icon SCIICON = new ImageIcon(FindIconHelper.findIcon("scilab-folder")); + private static final Icon OPENSCIICON = new ImageIcon(FindIconHelper.findIcon("scilab-folder-open")); + private static final Icon MATICON = new ImageIcon(FindIconHelper.findIcon("application-mat")); + + private static final int CHARTOREAD = 128; + + private static final Map<String, Icon> extToIcon = new HashMap<String, Icon>(); + + static { + extToIcon.put("sce", SCILABICON); + extToIcon.put("sci", SCILABICON); + extToIcon.put("scg", SCILABICON); + extToIcon.put("cos", SCILABICON); + extToIcon.put("cosf", SCILABICON); + extToIcon.put("xcos", SCILABICON); + extToIcon.put("zcos", SCILABICON); + extToIcon.put("bin", SCILABICON); + extToIcon.put("sod", SCILABICON); + extToIcon.put("dem", SCILABICON); + extToIcon.put("graph", SCILABICON); + extToIcon.put("sav", SCILABICON); + extToIcon.put("tst", SCILABICON); + extToIcon.put("pdf", PDFICON); + extToIcon.put("png", IMAGEICON); + extToIcon.put("gif", IMAGEICON); + extToIcon.put("jpg", IMAGEICON); + extToIcon.put("jpeg", IMAGEICON); + extToIcon.put("html", HTMLICON); + extToIcon.put("htm", HTMLICON); + extToIcon.put("xml", XMLICON); + extToIcon.put("csv", CSVICON); + extToIcon.put("mat", MATICON); + } + + /** + * @param f + * the file + * @return the extension of f + */ + public static String getFileExtension(File f) { + if (f.isFile()) { + String name = f.getName(); + int pos = name.lastIndexOf("."); + if (pos != -1) { + return name.substring(pos + 1, name.length()); + } + } + + return ""; + } + + /** + * @param file + * the file to test + * @return true if it is a binary file + */ + public static boolean isBinaryFile(File f) { + if (f.isFile() && f.canRead()) { + try { + BufferedReader reader = new BufferedReader(new FileReader(f)); + char[] buffer = new char[CHARTOREAD]; + int len = reader.read(buffer, 0, CHARTOREAD); + reader.close(); + int i = 0; + if (len != -1) { + for (; i < len && buffer[i] != '\0'; i++) { + ; + } + } + + return len != -1 && i != len; + } catch (IOException e) { + e.printStackTrace(); + } + } + return false; + } + + /** + * @return the up icon + */ + public static Icon getUpDirIcon() { + return UPICON; + } + + /** + * @return the SCI icon + */ + public static Icon getSCIIcon() { + return SCIICON; + } + + /** + * @return the open SCI icon + */ + public static Icon getOpenSCIIcon() { + return OPENSCIICON; + } + + /** + * @return the open dir icon + */ + public static Icon getOpenDirIcon() { + return OPENDIRICON; + } + + /** + * @return the closed dir icon + */ + public static Icon getClosedDirIcon() { + return DIRICON; + } + + /** + * @return the closed user-home dir icon + */ + public static Icon getClosedUserHomeIcon() { + return CLOSEDUSERHOMEICON; + } + + /** + * @return the open user-home dir icon + */ + public static Icon getOpenUserHomeIcon() { + return OPENUSERHOMEICON; + } + + /** + * @param f + * the file + * @return an icon according to its extension + */ + public static Icon getIconForFile(File f) { + if (f.isDirectory()) { + return DIRICON; + } + + if (f.canRead() && !f.canWrite()) { + return READONLYICON; + } + + String ext = getFileExtension(f).toLowerCase(); + Icon icon = extToIcon.get(ext); + if (icon != null) { + return icon; + } + + if (f.isFile() && isBinaryFile(f)) { + return BINARYICON; + } + + return TEXTICON; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowser.java new file mode 100755 index 000000000..8c1be4884 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowser.java @@ -0,0 +1,125 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import javax.swing.SwingUtilities; + +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; +import org.scilab.modules.gui.tabfactory.ScilabTabFactory; +import org.scilab.modules.gui.textbox.ScilabTextBox; +import org.scilab.modules.gui.textbox.TextBox; +import org.scilab.modules.gui.utils.WindowsConfigurationManager; +import org.scilab.modules.gui.window.ScilabWindow; +import org.scilab.modules.ui_data.tabfactory.FileBrowserTab; +import org.scilab.modules.ui_data.tabfactory.FileBrowserTabFactory; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * The file browser + * @author Calixte DENIZET + */ +public final class ScilabFileBrowser { + + private static SwingScilabFileBrowser instance; + + static { + ScilabTabFactory.getInstance().addTabFactory(FileBrowserTabFactory.getInstance()); + } + + /** + * Constructor + */ + private ScilabFileBrowser() { + TextBox infobar = ScilabTextBox.createTextBox(); + instance = new SwingScilabFileBrowser(); + instance.addInfoBar(infobar); + instance.setTitle(UiDataMessages.FILE_BROWSER); + } + + /** + * Create a file browser (as tab) instance + * @return the instance + */ + public static SwingScilabFileBrowser createFileBrowserTab() { + if (instance == null) { + new ScilabFileBrowser(); + } + + return instance; + } + + /** + * @return true if an instance of BrowseVar already exists. + */ + public static boolean isFileBrowserOpened() { + return instance != null; + } + + /** + * Set the base directory + * @param dir the base directory + */ + public static void setBaseDir(String dir) { + if (instance != null) { + instance.setBaseDir(dir); + } + } + + /** + * Get the variable browser singleton with specified columns title. + * @return the File Browser + */ + public static SwingScilabFileBrowser getFileBrowser() { + if (instance == null) { + boolean success = WindowsConfigurationManager.restoreUUID(SwingScilabFileBrowser.FILEBROWSERUUID); + if (!success) { + FileBrowserTab.getFileBrowserInstance(); + SwingScilabWindow window = SwingScilabWindow.createWindow(true); + window.addTab(instance); + window.setLocation(0, 0); + window.setSize(500, 500); + window.setVisible(true); + } + } else { + SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, instance); + window.setVisible(true); + window.toFront(); + } + + return instance; + } + + /** + * Close File Browser + */ + public static void closeFileBrowser() { + if (instance != null) { + instance.close(); + instance = null; + } + } + + /** + * Close File Browser + */ + public void close() { + instance = null; + } + + /** + * {@inheritDoc} + */ + public void setVisible(boolean status) { + instance.setVisible(status); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserComponent.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserComponent.java new file mode 100755 index 000000000..e8bb55c32 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserComponent.java @@ -0,0 +1,87 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.BorderLayout; +import java.awt.Color; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; +import javax.swing.border.EmptyBorder; + +/** + * A JPanel containing the different elements composing the File Browser + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabFileBrowserComponent extends JPanel { + + private static final int GAP = 3; + + private SwingScilabFileBrowser filebrowser; + private SwingScilabTreeTable stt; + + /** + * Default constructor + */ + public ScilabFileBrowserComponent() { + super(new BorderLayout()); + setBorder(new EmptyBorder(GAP, GAP, GAP, GAP)); + ScilabFileSelectorComboBox combobox = new ScilabFileSelectorComboBox(); + stt = new SwingScilabTreeTable(new ScilabFileBrowserModel(), combobox); + Color bg = Color.WHITE; + stt.setBackground(bg); + + add(new ScilabFileSelectorPanel(stt), BorderLayout.PAGE_START); + add(new ScilabFileSelectorFilter(stt), BorderLayout.PAGE_END); + + JScrollPane jsp = new JScrollPane(stt); + jsp.getViewport().setBackground(bg); + add(jsp, BorderLayout.CENTER); + } + + /** + * Set the base directory + * @param baseDir the base directory + */ + public void setBaseDir(final String baseDir) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + stt.setBaseDir(baseDir); + } + }); + } + + /** + * @return the file browser (as Tab) instance + */ + public SwingScilabFileBrowser getFileBrowser() { + return filebrowser; + } + + /** + * @return the next button in the history + */ + public JButton getNextButton() { + return stt.getNextButton(); + } + + /** + * @return the previous button in the history + */ + public JButton getPreviousButton() { + return stt.getPreviousButton(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserHistory.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserHistory.java new file mode 100755 index 000000000..302d269ae --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserHistory.java @@ -0,0 +1,241 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; + +import org.scilab.modules.action_binding.InterpreterManagement; +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * The File Browser history + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabFileBrowserHistory { + + private static final String PREVIOUSICON = FindIconHelper.findIcon("go-previous"); + private static final String NEXTICON = FindIconHelper.findIcon("go-next"); + + private final SwingScilabTreeTable stt; + private final List<String> history = new ArrayList<String>(); + private int position = -1; + private final JButton previous; + private final JButton next; + private final JPopupMenu popup; + private Timer timer; + + /** + * Default constructor + * @param stt the treetable associated with this history + */ + public ScilabFileBrowserHistory(SwingScilabTreeTable stt) { + this.stt = stt; + this.popup = new JPopupMenu(); + this.popup.setBorderPainted(true); + + previous = new JButton(); + previous.setIcon(new ImageIcon(PREVIOUSICON)); + ScilabLAF.setDefaultProperties(previous); + + previous.setToolTipText(UiDataMessages.PREVIOUSDIR); + previous.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (timer == null) { + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + if (!popup.isVisible() || popup.getInvoker() != next) { + showPopup(true); + } + } + }, 1000); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (timer != null) { + timer.cancel(); + timer = null; + } + } + + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isRightMouseButton(e) && previous.isEnabled() && (!popup.isVisible() || popup.getInvoker() != previous)) { + showPopup(true); + } else if (SwingUtilities.isLeftMouseButton(e) && !popup.isVisible() && previous.isEnabled()) { + ScilabFileBrowserHistory.this.stt.setBaseDir(history.get(position - 1), false); + chDir(history.get(position - 1)); + setPositionInHistory(position - 1); + } + } + }); + + next = new JButton(); + next.setIcon(new ImageIcon(NEXTICON)); + ScilabLAF.setDefaultProperties(next); + + next.setToolTipText(UiDataMessages.NEXTDIR); + next.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (timer == null) { + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + if (!popup.isVisible() || popup.getInvoker() != next) { + showPopup(false); + } + } + }, 1000); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (timer != null) { + timer.cancel(); + timer = null; + } + } + + @Override + public void mouseClicked(MouseEvent e) { + if (SwingUtilities.isRightMouseButton(e) && next.isEnabled() && (!popup.isVisible() || popup.getInvoker() != next)) { + showPopup(false); + } else if (SwingUtilities.isLeftMouseButton(e) && !popup.isVisible() && next.isEnabled()) { + ScilabFileBrowserHistory.this.stt.setBaseDir(history.get(position + 1), false); + chDir(history.get(position + 1)); + setPositionInHistory(position + 1); + } + } + }); + + updateButton(0); + } + + /** + * Show the popup under the button + * @param prev if true, the popup is show under the previous button + */ + private void showPopup(boolean prev) { + popup.removeAll(); + if (prev) { + for (int i = position - 1; i >= 0; i--) { + JMenuItem item = new JMenuItem(history.get(i)); + final int j = i; + item.addActionListener(new CommonCallBack(null) { + @Override + public void callBack() { + ScilabFileBrowserHistory.this.stt.setBaseDir(history.get(j), false); + chDir(history.get(j)); + setPositionInHistory(j); + } + }); + popup.add(item); + } + } else { + for (int i = position + 1; i < history.size(); i++) { + JMenuItem item = new JMenuItem(history.get(i)); + final int j = i; + item.addActionListener(new CommonCallBack(null) { + @Override + public void callBack() { + ScilabFileBrowserHistory.this.stt.setBaseDir(history.get(j), false); + chDir(history.get(j)); + setPositionInHistory(j); + } + }); + popup.add(item); + } + } + popup.pack(); + + JButton button; + if (prev) { + button = previous; + } else { + button = next; + } + + popup.show(button, 0, button.getBounds(null).height); + } + + private static final void chDir(String path) { + File f = new File(path); + if (f.exists() && f.isDirectory() && f.canRead()) { + InterpreterManagement.requestScilabExec("chdir('" + path + "')"); + } + } + + /** + * Add a path in the history + * @param path the path to add + */ + public void addPathInHistory(String path) { + history.add(path); + setPositionInHistory(position + 1); + } + + /** + * @return the previous button + */ + public JButton getPreviousButton() { + return previous; + } + + /** + * @return the next button + */ + public JButton getNextButton() { + return next; + } + + /** + * Set the current position in the history + * @param pos the new position + */ + private void setPositionInHistory(int pos) { + position = pos; + updateButton(pos); + } + + /** + * Update the buttons state according to the position + * @param pos the position + */ + private void updateButton(int pos) { + previous.setEnabled(history.size() >= 2 && pos != 0); + next.setEnabled(history.size() >= 2 && pos != history.size() - 1); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserModel.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserModel.java new file mode 100755 index 000000000..8ef498456 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileBrowserModel.java @@ -0,0 +1,277 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.io.File; +import java.text.DecimalFormat; +import java.util.Date; +import java.util.regex.Pattern; + +import javax.swing.SwingWorker; + +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * The tree table model abstract implementation + * @author Calixte DENIZET + */ +public class ScilabFileBrowserModel extends AbstractScilabTreeTableModel implements ScilabTreeTableModel { + + private static final String[] names = {UiDataMessages.NAME_COLUMN, + UiDataMessages.SIZE_COLUMN, + UiDataMessages.TYPE_COLUMN, + UiDataMessages.LASTMODIF_COLUMN + }; + + private static final Class[] types = {ScilabTreeTableModel.class, + FileSize.class, + String.class, + Date.class + }; + + private static final FileSize MINUSONE = new FileSize(-1); + + private int order = 1; + private String baseDir = ""; + + /** + * Default constructor + */ + public ScilabFileBrowserModel() { + super(); + } + + /** + * Set the base directory + * @param baseDir the base directory + * @param stt the associated treetable component + */ + public void setBaseDir(final String baseDir, final SwingScilabTreeTable stt) { + this.baseDir = baseDir; + SwingWorker worker = new SwingWorker<Void, Void>() { + protected Void doInBackground() throws Exception { + File f = new File(baseDir); + setRoot(new FileNode(f, -1)); + File parentFile = f.getParentFile(); + if (parentFile != null) { + parent = new ParentNode(parentFile); + } else { + parent = null; + } + + return null; + } + + protected void done() { + stt.reload(ScilabFileBrowserModel.this); + } + }; + worker.execute(); + } + + public void setRoot(Object root) { + super.setRoot(root); + + // Force the root to load its children in the SwingWorker thread rather than in EDT + ((FileNode) root).getChildrenCount(); + } + + /** + * @return the base directory of this model + */ + public String getBaseDir() { + return baseDir; + } + + /** + * Set the filter pattern + * @pat the pattern + */ + public void setFilter(Pattern pat) { + ((FileNode) root).setFilter(pat); + } + + /** + * @param node the node + * @return the file associated with the node + */ + protected File getFile(Object node) { + FileNode fileNode = (FileNode) node; + return fileNode.getFile(); + } + + /** + * @param node the node + * @return the children of this node + */ + protected Object[] getChildren(Object node) { + FileNode fileNode = (FileNode) node; + return fileNode.getChildren(); + } + + /** + * @param node the node + * @return the number of children of this node + */ + public int getChildCount(Object node) { + int count = ((FileNode) node).getChildrenCount(); + if (parent == null || node != getRoot()) { + return count; + } + return count + 1; + } + + /** + * @param node the node + * @param i the child number + * @return the child at position i + */ + public Object getChild(Object node, int i) { + Object ret; + if (node == getRoot()) { + if (parent == null) { + ret = getChildren(node)[i]; + } else { + if (i == 0) { + ret = parent; + } else { + ret = getChildren(node)[i - 1]; + } + } + } else { + ret = getChildren(node)[i]; + } + + return ret; + } + + /** + * @param node the node + * @return true is this node is a leaf + */ + public boolean isLeaf(Object node) { + return node != getRoot() && ((FileNode) node).isLeaf(); + } + + /** + * {@inheritDoc} + */ + public int getColumnCount() { + // TODO : remove the comment and let the choice to the user to remove or not the columns + return 1;//names.length; + } + + /** + * {@inheritDoc} + */ + public String getColumnName(int column) { + return names[column]; + } + + /** + * {@inheritDoc} + */ + public Class getColumnClass(int column) { + return types[column]; + } + + /** + * {@inheritDoc} + */ + public Object getValueAt(Object node, int column) { + File file = getFile(node); + try { + switch (column) { + case 0: + return file.getName(); + case 1: + return file.isFile() ? new FileSize((int) file.length()) : MINUSONE; + case 2: + if (file.isFile()) { + String ext = FileUtils.getFileExtension(file); + if (ext.isEmpty()) { + return UiDataMessages.FILE; + } else { + return String.format(UiDataMessages.FILETYPE, FileUtils.getFileExtension(file)); + } + } else { + return UiDataMessages.DIRECTORY; + } + case 3: + return new Date(file.lastModified()); + } + } catch (SecurityException se) { } + + return null; + } + + /** + * Inner class to represent the parent node of a file node + */ + public class ParentNode extends FileNode { + + /** + * {@inheritDoc} + */ + public ParentNode(File f) { + super(f, -1); + } + + /** + * {@inheritDoc} + */ + public boolean isLeaf() { + return true; + } + + /** + * {@inheritDoc} + */ + public String toString() { + return ".."; + } + } + + /** + * Inner class to represent the size of file + */ + public static class FileSize { + + int size; + + FileSize(int size) { + this.size = size; + } + + public String toString() { + if (size < 0) { + return ""; + } + + if (size >= 0 && size < 1000) { + return size + " B"; + } + + DecimalFormat df = new DecimalFormat("#.#"); + if (size >= 1000 && size < 1000000) { + return df.format(((float) size) / 1000f).toString() + " KB"; + } + + if (size >= 1000000 && size < 1000000000) { + return df.format(((float) size) / 1000000f).toString() + " MB"; + } + + return df.format(((float) size) / 1000000000f).toString() + " GB"; + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorComboBox.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorComboBox.java new file mode 100755 index 000000000..9faee313c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorComboBox.java @@ -0,0 +1,559 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.AWTEvent; +import java.awt.Color; +import java.awt.KeyboardFocusManager; +import java.awt.Toolkit; +import java.awt.event.AWTEventListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.TreeSet; + +import javax.swing.JComboBox; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultEditorKit; +import javax.swing.text.JTextComponent; + +import org.scilab.modules.commons.OS; +import org.scilab.modules.commons.ScilabConstants; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabFileSelectorComboBox extends JComboBox implements DocumentListener { + + private static final FileFilter DIRFILTER = new FileFilter() { + public boolean accept(File f) { + return f.isDirectory(); + } + }; + + private static boolean isWindows = (OS.get() == OS.WINDOWS); + + private int lastSize = -1; + private String oldName = ""; + private TreeSet<String> currentSet; + private JTextComponent textComponent; + private boolean disableUpdateCombo; + private boolean disableShowPopup; + private boolean isValidate; + private CommonCallBack validation; + private SwingScilabTreeTable stt; + private Color defaultFg; + + /** + * Default constructor + * @param baseDir the base directory to open + * @param validation the callback to execute when the user valids the directory + */ + public ScilabFileSelectorComboBox() { + super(); + setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); + textComponent = (JTextComponent) getEditor().getEditorComponent(); + textComponent.getDocument().addDocumentListener(this); + defaultFg = textComponent.getForeground(); + + getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent e) { + int code = e.getKeyCode(); + if (code != KeyEvent.VK_ESCAPE && code != KeyEvent.VK_ENTER) { + showPopup(); + } else if (code == KeyEvent.VK_ENTER) { + if (!isValidate) { + updateComboBoxLater(); + if (!currentSet.isEmpty()) { + showPopup(); + } + } else { + isValidate = false; + } + } + } + + public void keyPressed(KeyEvent e) { + int code = e.getKeyCode(); + if (code == KeyEvent.VK_DOWN || code == KeyEvent.VK_KP_DOWN || code == KeyEvent.VK_PAGE_DOWN + || code == KeyEvent.VK_UP || code == KeyEvent.VK_KP_UP || code == KeyEvent.VK_PAGE_UP + || code == KeyEvent.VK_END || code == KeyEvent.VK_BEGIN) { + disableUpdateCombo = true; + } else { + disableUpdateCombo = false; + } + } + }); + + /* Workaround to override the default behaviour of TAB key */ + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + KeyEvent ke = (KeyEvent) e; + if (ke.getKeyCode() == KeyEvent.VK_TAB && ke.getID() == KeyEvent.KEY_RELEASED && ke.getSource() == textComponent) { + updateComboBoxLater(); + String cp = getCommonPart(); + getEditor().setItem(cp); + showPopup(); + ke.consume(); + } + } + }, AWTEvent.KEY_EVENT_MASK); + + setEditable(true); + + textComponent.setComponentPopupMenu(createPopup()); + } + + /** + * Set the treetable linked with this combobox + */ + public void setTreeTable(SwingScilabTreeTable stt) { + this.stt = stt; + } + + /** + * Set the action as CallBack + * @param validation the action to use when a path is validated + */ + public void setAction(CommonCallBack validation) { + this.validation = validation; + textComponent.addKeyListener(new KeyAdapter() { + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + isValidate = true; + ScilabFileSelectorComboBox.this.validation.callBack(); + hidePopup(); + e.consume(); + } + } + }); + } + + /** + * Set the base directory and validate + * @param path the path to set + */ + public void setBaseDirAndValidate(String path) { + disableUpdateCombo = true; + textComponent.getDocument().removeDocumentListener(this); + getEditor().setItem(path); + validation.callBack(); + disableUpdateCombo = false; + } + + /** + * @return the base directory + */ + public void setBaseDir(String baseDir) { + if (!baseDir.endsWith(File.separator)) { + baseDir += File.separator; + } + disableShowPopup = true; + textComponent.setText(baseDir); + disableShowPopup = false; + } + + /** + * @return the base directory + */ + public String getBaseDir() { + return getTruePath(getText()); + } + + /** + * {@inheritDoc} + */ + public void changedUpdate(DocumentEvent e) { } + + /** + * {@inheritDoc} + */ + public void insertUpdate(DocumentEvent e) { + testPathValidity(); + } + + /** + * {@inheritDoc} + */ + public void removeUpdate(DocumentEvent e) { + testPathValidity(); + } + + /** + * Test the path validity. If the path is invalid the color in the combo's textfield is set to RED + */ + private void testPathValidity() { + File f = new File(getText()); + if (f.exists() && f.isDirectory() && f.canRead()) { + textComponent.setForeground(defaultFg); + updateComboBox(); + } else { + textComponent.setForeground(Color.RED); + } + } + + /** + * @return the text in the textfield + */ + private String getText() { + int len = textComponent.getDocument().getLength(); + try { + return textComponent.getDocument().getText(0, len); + } catch (BadLocationException e) { + return ""; + } + } + + /** + * Get the path where the jokers such as ~, SCI or TMPDIR are replaced by their values + * @param path the path + * @return the true path + */ + private static final String getTruePath(String path) { + if (path != null) { + if (path.startsWith("SCI\\") || path.startsWith("SCI/") || path.startsWith("SCI")) { + return path.replaceFirst("SCI", ScilabConstants.SCI.getAbsolutePath()); + } + if (path.startsWith("~\\") || path.startsWith("~/") || path.startsWith("~")) { + return path.replaceFirst("~", ScilabConstants.USERHOME); + } + if (path.startsWith("TMPDIR\\") || path.startsWith("TMPDIR/") || path.startsWith("TMPDIR")) { + return path.replaceFirst("TMPDIR", ScilabConstants.TMPDIR.getAbsolutePath()); + } + } + + boolean failed = true; + for (int i = 0; i < 5 && failed; i++) { + try { + path = new File(path).getCanonicalPath(); + failed = false; + } catch (IOException e) { + try { + Thread.sleep(10); + } catch (InterruptedException ee) { } + } + } + + return path; + } + + + /** + * Get the path where the jokers such as ~, SCI or TMPDIR are replaced by their values + * @param path the path + * @param joker the joker + * @return the true path + */ + private static final String getTruePath(String path, String joker) { + if (path != null && joker != null) { + if (joker.equals("SCI")) { + return path.replaceFirst("SCI", ScilabConstants.SCI.getAbsolutePath()); + } + if (joker.equals("~")) { + return path.replaceFirst("~", ScilabConstants.USERHOME); + } + if (joker.equals("TMPDIR")) { + return path.replaceFirst("TMPDIR", ScilabConstants.TMPDIR.getAbsolutePath()); + } + } + + return path; + } + + /** + * Get the joker, if one exists, in the path. Jokers can be ~, SCI or TMPDIR + * @param path the path to analyze + * @return the joker + */ + private static final String getJoker(String path) { + if (path != null) { + if (path.startsWith("SCI\\") || path.startsWith("SCI/")) { + return "SCI"; + } + if (path.startsWith("~\\") || path.startsWith("~/")) { + return "~"; + } + if (path.startsWith("TMPDIR\\") || path.startsWith("TMPDIR/")) { + return "TMPDIR"; + } + } + + return null; + } + + /** + * Get a path where the value of SCI is replaced by the string "SCI" (or ~, TMPDIR) + * @param path the path + * @param joker the joker + * @return the fake path + */ + private static final String getFakePath(String path, String joker) { + if (path != null && joker != null) { + if (joker.equals("SCI")) { + return path.replaceFirst(ScilabConstants.SCI.getAbsolutePath(), "SCI"); + } + if (joker.equals("~")) { + return path.replaceFirst(ScilabConstants.USERHOME, "~"); + } + if (joker.equals("TMPDIR")) { + return path.replaceFirst(ScilabConstants.TMPDIR.getAbsolutePath(), "TMPDIR"); + } + } + + return path; + } + + /** + * Get the directory where to list the file + * @param name the directory name + * @return the directory + */ + private static final File getFileDirectory(String name) { + File file = new File(name); + + if (name.endsWith(File.separator) && file.isDirectory()) { + return file; + } + + File parent = file.getParentFile(); + if (parent != null && parent.isDirectory()) { + return parent; + } + + return null; + } + + /** + * Get the common part of the strings present in currentSet (in fine, the combobox content list) + * @return the common part + */ + private String getCommonPart() { + if (currentSet != null && !currentSet.isEmpty()) { + if (currentSet.size() == 1) { + return currentSet.first(); + } + + String parent = new File(currentSet.first()).getParent(); + int lenParent = 0; + if (parent != null) { + lenParent = parent.length(); + } + + int min = Integer.MAX_VALUE; + char[][] strs = new char[currentSet.size()][]; + int i = 0; + + for (String s : currentSet) { + strs[i] = s.substring(lenParent).toCharArray(); + if (strs[i].length < min) { + min = strs[i].length; + } + i++; + } + + /* Now we get the common part */ + int j = strs.length; + for (i = 0; i < min && j == strs.length; i++) { + if (isWindows) { + char c = Character.toLowerCase(strs[0][i]); + j = 1; + for (; j < strs.length && Character.toLowerCase(strs[j][i]) == c; j++) { + ; + } + } else { + char c = strs[0][i]; + j = 1; + for (; j < strs.length && strs[j][i] == c; j++) { + ; + } + } + } + + String common = new String(strs[0], 0, i - 1); + if (isWindows) { + int k = i - 1; + for (j = 1; j < strs.length && k == i - 1; j++) { + for (k = 0; k < i - 1 && strs[j][k] == strs[0][k]; k++) { + ; + } + } + + if (j != strs.length) { + common = common.toLowerCase(); + } + } + + if (lenParent != 0) { + return parent + common; + } + return common; + } + + return getText(); + } + + /** + * Update the combobox. Since this function is called from the DocumentListener and methods in JComboBox change the JTextComponent content + * (so the listener would try to write under a writeLock()... see DocumentListener javadoc), the update is called outside the main thread. + */ + private void updateComboBox() { + final boolean b = disableShowPopup; + textComponent.getDocument().removeDocumentListener(this); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (!disableUpdateCombo) { + updateComboBoxLater(b); + } + textComponent.getDocument().addDocumentListener(ScilabFileSelectorComboBox.this); + } + }); + } + + /** + * Update the comboBox with the possible completion of the name + * entered in the comboBox. + */ + private void updateComboBoxLater() { + updateComboBoxLater(false); + } + + /** + * Update the comboBox with the possible completion of the name + * entered in the comboBox. + */ + private void updateComboBoxLater(final boolean hidepopup) { + String trueName = getText(); + if (trueName != null && !trueName.equals(oldName)) { + String joker = getJoker(trueName); + String name = getTruePath(trueName, joker); + oldName = trueName; + + TreeSet<String> set = null; + File[] files; + + if (name.isEmpty()) { + files = File.listRoots(); + } else { + File parent = getFileDirectory(name); + + if (parent != null) { + files = parent.listFiles(DIRFILTER); + } else { + files = File.listRoots(); + } + } + + if (isWindows) { + set = new TreeSet<String>(new Comparator<String>() { + public int compare(String s1, String s2) { + int diff = s1.compareToIgnoreCase(s2); + if (diff == 0) { + diff = s1.compareTo(s2); + } + return diff; + } + + public boolean equals(Object obj) { + return false; + } + }); + } else { + set = new TreeSet<String>(); + } + for (File f : files) { + String extra = File.separator; + if (f.getParent() == null) { + extra = ""; + } + set.add(getFakePath(f.getAbsolutePath(), joker) + extra); + } + + if (set != null) { + String bound = ""; + int len = trueName.length(); + if (len != 0) { + if (len == 1) { + bound = new String(new char[] {(char) (trueName.charAt(0) + 1)}); + } else { + bound = trueName.substring(0, len - 1); + bound += (char) (trueName.charAt(len - 1) + 1); + } + currentSet = (TreeSet) set.subSet(trueName, true, bound, false); + } else { + currentSet = set; + } + + if (currentSet != null && currentSet.size() != lastSize) { + hidePopup(); + removeAllItems(); + for (String f : currentSet) { + addItem(f); + } + lastSize = currentSet.size(); + } + } + + setSelectedIndex(-1); + getEditor().setItem(trueName); + textComponent.setSelectionStart(textComponent.getSelectionEnd()); + + if (isShowing()) { + setPopupVisible(!hidepopup); + } + } + } + + /** + * @return the popup used in the combo's textfield + */ + private JPopupMenu createPopup() { + JPopupMenu popup = new JPopupMenu(); + + JMenuItem item = new JMenuItem(UiDataMessages.CUT); + item.addActionListener(new DefaultEditorKit.CutAction()); + popup.add(item); + + item = new JMenuItem(UiDataMessages.COPY); + item.addActionListener(new DefaultEditorKit.CopyAction()); + popup.add(item); + + item = new JMenuItem(UiDataMessages.PASTE); + item.addActionListener(new DefaultEditorKit.PasteAction()); + popup.add(item); + + item = new JMenuItem(UiDataMessages.CLEAR); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + textComponent.setText(""); + } + }); + popup.add(item); + + return popup; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorFilter.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorFilter.java new file mode 100755 index 000000000..55114045e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorFilter.java @@ -0,0 +1,295 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.Color; +import java.awt.ContainerOrderFocusTraversalPolicy; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.util.regex.Pattern; + +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import javax.swing.border.EmptyBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.DefaultEditorKit; + +import org.scilab.modules.commons.OS; +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * A panel with file filter and the combo to set the cwd. + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabFileSelectorFilter extends JPanel { + + private static boolean isWindows = (OS.get() == OS.WINDOWS); + private static final int GAP = 3; + private static final Icon VALIDATE = new ImageIcon(FindIconHelper.findIcon("filter")); + + private MyJTextField textfield; + private final SwingScilabTreeTable stt; + private JCheckBox caseSensitive; + private JCheckBox regexp; + private JButton validate; + + /** + * Default constructor + * @param stt the SwingScilabTree containing the cwd + * @param comboPath the combobox where to set the path + */ + public ScilabFileSelectorFilter(SwingScilabTreeTable stt) { + super(); + this.stt = stt; + initPanel(); + } + + /** + * Init the panel + */ + private void initPanel() { + setBorder(new EmptyBorder(0, 0, GAP, 0)); + setLayout(new GridBagLayout()); + textfield = new MyJTextField(); + setFocusCycleRoot(true); + setFocusTraversalPolicy(new ContainerOrderFocusTraversalPolicy()); + + validate = new JButton(new CommonCallBack(null) { + @Override + public void callBack() { + stt.setFilter(getPattern()); + } + }); + validate.setIcon(VALIDATE); + validate.setToolTipText(UiDataMessages.RUNFILTER); + + caseSensitive = new JCheckBox(UiDataMessages.CASESENSITIVE, !isWindows); + regexp = new JCheckBox(UiDataMessages.REGEXP, false); + + GridBagConstraints gbc = new GridBagConstraints(); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.gridheight = 1; + gbc.weightx = 1; + gbc.fill = GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.LINE_START; + add(textfield, gbc); + + gbc.gridx = 2; + gbc.gridwidth = gbc.gridheight = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.VERTICAL; + gbc.anchor = GridBagConstraints.LINE_START; + add(validate, gbc); + + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = gbc.gridheight = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.LINE_START; + add(caseSensitive, gbc); + + gbc.gridx = 1; + gbc.gridwidth = gbc.gridheight = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.LINE_START; + add(regexp, gbc); + } + + /** + * Test the pattern and change the color of the text in textfield if the pattern is invalid + */ + private void testPattern() { + if (regexp.isSelected()) { + if (getPattern() == null) { + textfield.setForeground(Color.RED); + } else { + textfield.setForeground(textfield.defaultFg); + } + } + } + + /** + * Get the pattern according to the textfield content + * @return the pattern + */ + private Pattern getPattern() { + String text = textfield.getText(); + if (text != null && !text.isEmpty()) { + if (!regexp.isSelected()) { + text = text.replaceAll("\\*", "\\\\E.*\\\\Q").replaceAll("\\?", "\\\\E.?\\\\Q"); + text = "\\Q" + text + "\\E"; + } + if (!caseSensitive.isSelected()) { + text = "(?i)" + text; + } + + if (regexp.isSelected()) { + text = "(?m)" + text; + } + + try { + return Pattern.compile(text); + } catch (Exception e) { } + } + + return null; + } + + /** + * Inner class to have the possibility to add a default text in the textfield but in this case the textfield is empty ! + * It is a workaround for a GTK bug which avoids me to paint directly in the field. + */ + private class MyJTextField extends JTextField implements DocumentListener, FocusListener { + + boolean isEmpty = true; + Color defaultFg; + + /** + * {@inheritDoc} + */ + MyJTextField() { + super(); + defaultFg = getForeground(); + setEditable(true); + setComponentPopupMenu(createPopup()); + addFocusListener(this); + getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER"); + getActionMap().put("ENTER", new CommonCallBack(null) { + @Override + public void callBack() { + stt.setFilter(getPattern()); + } + }); + toggleContents(); + } + + /** + * Toggle the contents + */ + private void toggleContents() { + if (isEmpty) { + setForeground(Color.LIGHT_GRAY); + setText(UiDataMessages.FILEFILTER); + } + } + + /** + * {@inheritDoc} + */ + @Override + public String getText() { + if (isEmpty) { + return ""; + } + + return super.getText(); + } + + /** + * {@inheritDoc} + */ + @Override + public void focusGained(FocusEvent e) { + getDocument().addDocumentListener(this); + if (isEmpty) { + setForeground(defaultFg); + setText(""); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void focusLost(FocusEvent e) { + getDocument().removeDocumentListener(this); + isEmpty = super.getText().isEmpty(); + toggleContents(); + } + + /** + * {@inheritDoc} + */ + @Override + public void insertUpdate(DocumentEvent e) { + isEmpty = super.getText().isEmpty(); + testPattern(); + } + + /** + * {@inheritDoc} + */ + @Override + public void removeUpdate(DocumentEvent e) { + isEmpty = super.getText().isEmpty(); + testPattern(); + } + + /** + * {@inheritDoc} + */ + @Override + public void changedUpdate(DocumentEvent e) { } + + /** + * @return the popup menu used in this textfield + */ + private JPopupMenu createPopup() { + JPopupMenu popup = new JPopupMenu(); + + JMenuItem item = new JMenuItem(UiDataMessages.CUT); + item.addActionListener(new DefaultEditorKit.CutAction()); + popup.add(item); + + item = new JMenuItem(UiDataMessages.COPY); + item.addActionListener(new DefaultEditorKit.CopyAction()); + popup.add(item); + + item = new JMenuItem(UiDataMessages.PASTE); + item.addActionListener(new DefaultEditorKit.PasteAction()); + popup.add(item); + + item = new JMenuItem(UiDataMessages.CLEAR); + item.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + MyJTextField.this.setText(""); + } + }); + popup.add(item); + + return popup; + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorPanel.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorPanel.java new file mode 100755 index 000000000..8d63cb21c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabFileSelectorPanel.java @@ -0,0 +1,75 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import org.scilab.modules.ui_data.filebrowser.actions.ChangeCWDAction; + +/** + * The JPanel containing the combobox used to set the path and the two buttons + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabFileSelectorPanel extends JPanel { + + private SwingScilabTreeTable table; + + /** + * Default constructor + * @param table the table linked with the combobox + */ + public ScilabFileSelectorPanel(SwingScilabTreeTable table) { + super(); + this.table = table; + init(); + } + + /** + * Init the panel contents + */ + private void init() { + setLayout(new GridBagLayout()); + JButton changeDirButton = ((ChangeCWDAction) table.getActionMap().get("cwd")).createButton(); + JButton upDirButton = ((ChangeCWDAction) table.getActionMap().get("cwd")).createParentDirButton(); + + GridBagConstraints gbc = new GridBagConstraints(); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.VERTICAL; + gbc.anchor = GridBagConstraints.LINE_START; + add(changeDirButton, gbc); + + gbc.gridx = 1; + gbc.gridwidth = gbc.gridheight = 1; + gbc.weightx = 1; + gbc.fill = GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.LINE_START; + add(table.getComboBox(), gbc); + + gbc.gridx = 2; + gbc.gridwidth = gbc.gridheight = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.VERTICAL; + gbc.anchor = GridBagConstraints.LINE_START; + add(upDirButton, gbc); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableCellRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableCellRenderer.java new file mode 100755 index 000000000..b4a1326c9 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableCellRenderer.java @@ -0,0 +1,196 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.SwingUtilities; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.event.TreeWillExpandListener; +import javax.swing.table.TableCellRenderer; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeSelectionModel; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; +import org.scilab.modules.gui.events.callback.CommonCallBack; + +/** + * The table renderer to render the tree in the first column of the JTable + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabTreeTableCellRenderer extends JTree implements TableCellRenderer { + + private SwingScilabTreeTable table; + protected int visibleRow; + + /** + * {@inheritdoc} + */ + public ScilabTreeTableCellRenderer(SwingScilabTreeTable table, TreeModel model) { + super(model); + this.table = table; + DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() { + + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + FileNode fn = (FileNode) value; + if (leaf) { + if (fn instanceof ScilabFileBrowserModel.ParentNode) { + this.setLeafIcon(FileUtils.getUpDirIcon()); + } else { + this.setLeafIcon(fn.getIcon()); + } + } else if (fn.isUserHome()) { + this.setClosedIcon(FileUtils.getClosedUserHomeIcon()); + this.setOpenIcon(FileUtils.getOpenUserHomeIcon()); + } else if (fn.isSCI()) { + this.setClosedIcon(FileUtils.getSCIIcon()); + this.setOpenIcon(FileUtils.getOpenSCIIcon()); + } else { + this.setClosedIcon(FileUtils.getClosedDirIcon()); + this.setOpenIcon(FileUtils.getOpenDirIcon()); + } + super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + + return this; + } + }; + + /* Force the JTable and JTree to share their row selection models. + And let the table to handle the selection rather than the tree; */ + setSelectionModel(new DefaultTreeSelectionModel() { + { + ScilabTreeTableCellRenderer.this.table.setSelectionModel(listSelectionModel); + } + + public void setSelectionPaths(TreePath[] pPaths) { } + + public void addSelectionPaths(TreePath[] paths) { } + + public void removeSelectionPaths(TreePath[] paths) { } + }); + + setCellRenderer(renderer); + setRootVisible(true); + setRowHeight(table.getRowHeight()); + setLargeModel(true); + setEditable(true); + setToggleClickCount(0); + + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + int selRow = getRowForLocation(e.getX(), e.getY()); + TreePath selPath = getPathForLocation(e.getX(), e.getY()); + if (selRow != -1) { + switch (e.getClickCount()) { + case 1 : + /*int sel = SwingScilabTreeTable.this.getSelectedRow(); + System.out.println(sel+":::"+selRow+":::"+isEditable()); + if (sel == selRow) { + System.out.println(getCellEditor().getTreeCellEditorComponent(ScilabTreeTableCellRenderer.this, getCellEditor().getCellEditorValue(), true, false, true, selRow)); + } + e.consume();*/ + break; + case 2: + ((CommonCallBack) ScilabTreeTableCellRenderer.this.table.getActionMap().get("validate")).callBack(); + e.consume(); + } + } + } + + public void mouseReleased(MouseEvent e) { } + }); + + addTreeWillExpandListener(new TreeWillExpandListener() { + public void treeWillCollapse(TreeExpansionEvent event) { } + + public void treeWillExpand(TreeExpansionEvent event) { + Container win = SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, ScilabTreeTableCellRenderer.this.table); + if (win != null) { + win.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + } + }); + addTreeExpansionListener(new TreeExpansionListener() { + public void treeCollapsed(TreeExpansionEvent event) { } + + public void treeExpanded(TreeExpansionEvent event) { + Container win = SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, ScilabTreeTableCellRenderer.this.table); + if (win != null) { + win.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } + }); + } + + /** + * {@inheritDoc} + */ + protected TreeModelListener createTreeModelListener() { + return new TreeModelListener() { + public void treeNodesChanged(TreeModelEvent e) { } + + public void treeNodesInserted(TreeModelEvent e) { } + + public void treeStructureChanged(TreeModelEvent e) { } + + public void treeNodesRemoved(TreeModelEvent e) { } + }; + } + + /** + * {@inheritdoc} + */ + public void setBounds(int x, int y, int w, int h) { + super.setBounds(x, 0, w, table.getHeight()); + } + + /** + * {@inheritdoc} + */ + public void paint(Graphics g) { + g.translate(0, -visibleRow * getRowHeight()); + try { + ui.update(g, this); + } catch (NullPointerException e) { + // Occurs sometimes... + g.translate(0, visibleRow * getRowHeight()); + paint(g); + } + } + + /** + * {@inheritdoc} + */ + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (isSelected) { + setBackground(table.getSelectionBackground()); + } else { + setBackground(table.getBackground()); + } + visibleRow = row; + + return this; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableModel.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableModel.java new file mode 100755 index 000000000..2c5a301d0 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableModel.java @@ -0,0 +1,60 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import javax.swing.tree.TreeModel; + +/** + * The tree table model interface + * @author Calixte DENIZET + */ +public interface ScilabTreeTableModel extends TreeModel { + + /** + * @return the number of available columns. + */ + public int getColumnCount(); + + /** + * @param column the column number + * @return the name for column number + */ + public String getColumnName(int column); + + /** + * @param column the column number + * @return the type for column number + */ + public Class getColumnClass(int column); + + /** + * @param node the node + * @param column the column number + * @return the value to be displayed for node at column number + */ + public Object getValueAt(Object node, int column); + + /** + * @param node the node + * @param column the column number + * @return true if the cell is editable + */ + public boolean isCellEditable(Object node, int column); + + /** + * @param value the value to set + * @param node the node + * @param column the column number + */ + public void setValueAt(Object value, Object node, int column); +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableModelAdapter.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableModelAdapter.java new file mode 100755 index 000000000..71a63ecec --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/ScilabTreeTableModelAdapter.java @@ -0,0 +1,105 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import javax.swing.table.AbstractTableModel; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; + +/** + * The tree table model abstract implementation + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabTreeTableModelAdapter extends AbstractTableModel { + + private JTree tree; + private ScilabTreeTableModel treeTableModel; + + /** + * Default constructor + * @param treeTableModel the table model + * @param tree the tree + */ + public ScilabTreeTableModelAdapter(ScilabTreeTableModel treeTableModel, JTree tree) { + this.tree = tree; + this.treeTableModel = treeTableModel; + tree.addTreeExpansionListener(new TreeExpansionListener() { + public void treeExpanded(TreeExpansionEvent event) { + fireTableDataChanged(); + } + public void treeCollapsed(TreeExpansionEvent event) { + fireTableDataChanged(); + } + }); + } + + /** + * {@inheritdoc} + */ + public int getColumnCount() { + return treeTableModel.getColumnCount(); + } + + /** + * {@inheritdoc} + */ + public String getColumnName(int column) { + return treeTableModel.getColumnName(column); + } + + /** + * {@inheritdoc} + */ + public Class getColumnClass(int column) { + return treeTableModel.getColumnClass(column); + } + + /** + * {@inheritdoc} + */ + public int getRowCount() { + return tree.getRowCount(); + } + + /** + * {@inheritdoc} + */ + protected Object nodeForRow(int row) { + TreePath treePath = tree.getPathForRow(row); + return treePath.getLastPathComponent(); + } + + /** + * {@inheritdoc} + */ + public Object getValueAt(int row, int column) { + return treeTableModel.getValueAt(nodeForRow(row), column); + } + + /** + * {@inheritdoc} + */ + public boolean isCellEditable(int row, int column) { + return treeTableModel.isCellEditable(nodeForRow(row), column); + } + + /** + * {@inheritdoc} + */ + public void setValueAt(Object value, int row, int column) { + treeTableModel.setValueAt(value, nodeForRow(row), column); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/SwingScilabFileBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/SwingScilabFileBrowser.java new file mode 100755 index 000000000..bbc9f7060 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/SwingScilabFileBrowser.java @@ -0,0 +1,134 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.bridge.toolbar.SwingScilabToolBar; +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; +import org.scilab.modules.gui.menu.Menu; +import org.scilab.modules.gui.menu.ScilabMenu; +import org.scilab.modules.gui.menubar.MenuBar; +import org.scilab.modules.gui.menubar.ScilabMenuBar; +import org.scilab.modules.gui.tab.SimpleTab; +import org.scilab.modules.gui.textbox.TextBox; +import org.scilab.modules.gui.toolbar.ScilabToolBar; +import org.scilab.modules.gui.toolbar.ToolBar; +import org.scilab.modules.gui.utils.WindowsConfigurationManager; +import org.scilab.modules.ui_data.actions.HelpAction; +import org.scilab.modules.ui_data.filebrowser.actions.CloseAction; +import org.scilab.modules.ui_data.filebrowser.actions.GoToHomeAction; +import org.scilab.modules.ui_data.filebrowser.actions.GoToSCIAction; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Swing implementation of Scilab Variable browser + * uses JTable + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SwingScilabFileBrowser extends SwingScilabDockablePanel { + + public static final String FILEBROWSERUUID = "3b649047-6a71-4998-bd8e-00d367a4793d"; + + private ScilabFileBrowserComponent filebrowser; + + /** + * Create a JTable with data Model. + */ + public SwingScilabFileBrowser() { + super(UiDataMessages.FILE_BROWSER, FILEBROWSERUUID); + setAssociatedXMLIDForHelp("filebrowser"); + addMenuBar(createMenuBar()); + filebrowser = new ScilabFileBrowserComponent(); + + ToolBar toolBar = ScilabToolBar.createToolBar(); + SwingScilabToolBar stb = (SwingScilabToolBar) toolBar.getAsSimpleToolBar(); + stb.add(filebrowser.getPreviousButton()); + stb.add(filebrowser.getNextButton()); + stb.addSeparator(); + stb.add(GoToHomeAction.createButton()); + stb.add(GoToSCIAction.createButton()); + stb.addSeparator(); + stb.add(HelpAction.createButton(UiDataMessages.HELP)); + + addToolBar(toolBar); + setContentPane(filebrowser); + WindowsConfigurationManager.restorationFinished(this); + } + + /** + * Set the base directory + * @param baseDir the base directory + */ + public void setBaseDir(String baseDir) { + filebrowser.setBaseDir(baseDir); + } + + /** + * {@inheritDoc} + */ + public SimpleTab getAsSimpleTab() { + return this; + } + + /** + * {@inheritDoc} + */ + public SwingScilabWindow getParentWindow() { + return SwingScilabWindow.allScilabWindows.get(getParentWindowId()); + } + + /** + * {@inheritDoc} + */ + public void addInfoBar(TextBox infoBarToAdd) { + setInfoBar(infoBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void addMenuBar(MenuBar menuBarToAdd) { + setMenuBar(menuBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void addToolBar(ToolBar toolBarToAdd) { + setToolBar(toolBarToAdd); + } + + /** + * Create History Browser MenuBar + * @return the menu bar + */ + private static MenuBar createMenuBar() { + MenuBar menuBar = ScilabMenuBar.createMenuBar(); + Menu fileMenu = ScilabMenu.createMenu(); + fileMenu.setText(UiDataMessages.FILE); + fileMenu.setMnemonic('F'); + + fileMenu.add(CloseAction.createMenu()); + + menuBar.add(fileMenu); + + Menu helpMenu = ScilabMenu.createMenu(); + helpMenu.setText("?"); + helpMenu.setMnemonic('?'); + helpMenu.add(HelpAction.createMenuItem(UiDataMessages.HELP)); + menuBar.add(helpMenu); + + return menuBar; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/SwingScilabTreeTable.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/SwingScilabTreeTable.java new file mode 100755 index 000000000..bd7bc15da --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/SwingScilabTreeTable.java @@ -0,0 +1,460 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.lang.reflect.Method; +import java.text.DateFormat; +import java.util.Date; +import java.util.regex.Pattern; + +import javax.swing.ActionMap; +import javax.swing.ImageIcon; +import javax.swing.InputMap; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.border.AbstractBorder; +import javax.swing.border.Border; +import javax.swing.plaf.basic.BasicTreeUI; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.tree.TreePath; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.filebrowser.actions.ChangeCWDAction; +import org.scilab.modules.ui_data.filebrowser.actions.EditFileWithDefaultAppAction; +import org.scilab.modules.ui_data.filebrowser.actions.ExecuteFileInConsoleAction; +import org.scilab.modules.ui_data.filebrowser.actions.ExecuteFileInXcosAction; +import org.scilab.modules.ui_data.filebrowser.actions.ExecuteMatFileAction; +import org.scilab.modules.ui_data.filebrowser.actions.LoadFileAsGraphAction; +import org.scilab.modules.ui_data.filebrowser.actions.LoadFileInScilabAction; +import org.scilab.modules.ui_data.filebrowser.actions.OpenFileInSciNotesAction; +import org.scilab.modules.ui_data.filebrowser.actions.OpenFileWithDefaultAppAction; +import org.scilab.modules.ui_data.filebrowser.actions.ValidateAction; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * The tree table model abstract implementation + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class SwingScilabTreeTable extends JTable { + + private static final Insets INSETS = new Insets(0, 2, 0, 0); + private static final DateFormat DATEFORMAT = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM); + + private static final Border BORDER = new AbstractBorder() { + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + g.setColor(Color.LIGHT_GRAY); + g.drawLine(x, y, x, y + height); + } + + public Insets getBorderInsets(Component c) { + return INSETS; + } + + public Insets getBorderInsets(Component c, Insets insets) { + return INSETS; + } + }; + + private Method isLocationInExpandControl; + + protected ScilabTreeTableCellRenderer tree; + protected ScilabFileSelectorComboBox combobox; + protected ScilabFileBrowserHistory history; + + /** + * Default Constructor + * @param treeTableModel the tree table model + * @param combobox the combox used to set the path + */ + public SwingScilabTreeTable(ScilabTreeTableModel treeTableModel, ScilabFileSelectorComboBox combobox) { + super(); + this.combobox = combobox; + combobox.setTreeTable(this); + history = new ScilabFileBrowserHistory(this); + tree = new ScilabTreeTableCellRenderer(this, treeTableModel); + super.setModel(new ScilabTreeTableModelAdapter(treeTableModel, tree)); + + // Install the tree editor renderer and editor. + setDefaultRenderer(ScilabTreeTableModel.class, tree); + setDefaultRenderer(Date.class, new DefaultTableCellRenderer() { + { + setHorizontalTextPosition(DefaultTableCellRenderer.LEFT); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focus, int row, int col) { + JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, selected, focus, row, col); + label.setText(DATEFORMAT.format((Date) value)); + if (col == 1) { + label.setBorder(BORDER); + } + return label; + } + }); + setDefaultRenderer(ScilabFileBrowserModel.FileSize.class, new DefaultTableCellRenderer() { + { + setHorizontalTextPosition(DefaultTableCellRenderer.LEFT); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focus, int row, int col) { + Component c = super.getTableCellRendererComponent(table, value, selected, focus, row, col); + if (col == 1) { + JLabel jl = (JLabel) c; + jl.setBorder(BORDER); + } + return c; + } + }); + setDefaultRenderer(String.class, new DefaultTableCellRenderer() { + { + setHorizontalTextPosition(DefaultTableCellRenderer.LEFT); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focus, int row, int col) { + Component c = super.getTableCellRendererComponent(table, value, selected, focus, row, col); + if (col == 1) { + JLabel jl = (JLabel) c; + jl.setBorder(BORDER); + } + return c; + } + }); + + setShowGrid(false); + setFillsViewportHeight(true); + setIntercellSpacing(new Dimension(0, 0)); + setRowSorter(new FileBrowserRowSorter(tree, this)); + setAutoResizeMode(AUTO_RESIZE_NEXT_COLUMN); + + try { + isLocationInExpandControl = BasicTreeUI.class.getDeclaredMethod("isLocationInExpandControl", new Class[] {TreePath.class, int.class, int.class}); + isLocationInExpandControl.setAccessible(true); + } catch (NoSuchMethodException e) { } + + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + Point p = e.getPoint(); + int col = columnAtPoint(p); + if (getColumnClass(col) == ScilabTreeTableModel.class && SwingUtilities.isLeftMouseButton(e)) { + MouseEvent me = e; + if (isLocationInExpandControl != null) { + try { + int row = rowAtPoint(p); + TreePath path = tree.getPathForRow(row); + boolean isOnExpander = ((Boolean) isLocationInExpandControl.invoke(tree.getUI(), path, e.getX(), e.getY())).booleanValue(); + Rectangle r = tree.getRowBounds(row); + if (!isOnExpander && !r.contains(p)) { + me = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), r.x, r.y, e.getClickCount(), e.isPopupTrigger()); + } + } catch (Exception ex) { } + } + tree.dispatchEvent(me); + } + } + }); + + addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + char c = e.getKeyChar(); + if (Character.isLetter(c)) { + int step = 1; + if (Character.isUpperCase(c)) { + step = -1; + } + c = Character.toLowerCase(c); + int[] rows = getSelectedRows(); + int count = getRowCount(); + int start = 0; + if (rows != null && rows.length != 0) { + start = modulo(rows[0] + step, count); + } + for (int i = start; i != start - step; i = modulo(i + step, count)) { + char first = ((FileNode) tree.getPathForRow(i).getLastPathComponent()).toString().charAt(0); + first = Character.toLowerCase(first); + if (first == c) { + scrollRectToVisible(tree.getRowBounds(i)); + setRowSelectionInterval(i, i); + break; + } + } + } + } + }); + + + initActions(); + setComponentPopupMenu(createPopup()); + } + + /** + * @return the Next button used in history + */ + public JButton getNextButton() { + return history.getNextButton(); + } + + /** + * @return the Previous button used in history + */ + public JButton getPreviousButton() { + return history.getPreviousButton(); + } + + /** + * @return the combobox used to set the path + */ + public ScilabFileSelectorComboBox getComboBox() { + return combobox; + } + + /** + * Get the selected rows as file path + * @return the paths + */ + public String[] getSelectedPaths() { + int[] rows = getSelectedRows(); + String[] paths = new String[rows.length]; + for (int i = 0; i < rows.length; i++) { + TreePath path = tree.getPathForRow(rows[i]); + FileNode fn = (FileNode) path.getLastPathComponent(); + paths[i] = fn.getFile().getAbsolutePath(); + } + + return paths; + } + + /** + * Get the selected rows as file + * @return the paths + */ + public File[] getSelectedFiles() { + int[] rows = getSelectedRows(); + File[] files = new File[rows.length]; + for (int i = 0; i < rows.length; i++) { + TreePath path = tree.getPathForRow(rows[i]); + FileNode fn = (FileNode) path.getLastPathComponent(); + files[i] = fn.getFile(); + } + + return files; + } + + /** + * {@inheritDoc} + */ + public int getRowHeight(int row) { + return getRowHeight(); + } + + /** + * {@inheritDoc} + */ + public boolean isOpaque() { + return false; + } + + /** + * Set the base directory + * @param baseDir the base directory + */ + public void setBaseDir(String baseDir) { + setBaseDir(baseDir, true); + } + + /** + * Set the base directory + * @param baseDir the base directory + * @param addInHistory if true the dir is add in the history + */ + public void setBaseDir(String baseDir, boolean addInHistory) { + ScilabFileBrowserModel model = (ScilabFileBrowserModel) tree.getModel(); + combobox.setBaseDir(baseDir); + if (model != null) { + File f = new File(baseDir); + if (!baseDir.equals(model.getBaseDir()) && f.exists() && f.isDirectory() && f.canRead()) { + tree.setModel(null); + if (addInHistory) { + history.addPathInHistory(baseDir); + } + model.setBaseDir(baseDir, this); + } + } + } + + /** + * Set the file filter to use in table + * @param pat the pattern to use + */ + public void setFilter(Pattern pat) { + ScilabFileBrowserModel model = (ScilabFileBrowserModel) tree.getModel(); + TreePath rootPath = new TreePath(model.getRoot()); + tree.setModel(null); + model.setFilter(pat); + reload(model); + } + + /** + * Reload the table + */ + public void reload(ScilabFileBrowserModel model) { + tree.setModel(model); + tree.setRowHeight(getRowHeight()); + tree.setLargeModel(true); + TreePath path = new TreePath(model.getRoot()); + tree.collapsePath(path); + ((JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this)).getVerticalScrollBar().setValue(0); + tree.expandPath(path); + if (getRowCount() >= 1) { + repaint(tree.getRowBounds(0)); + } + editingRow = 0; + } + + /* Workaround for BasicTableUI anomaly. Make sure the UI never tries to + * paint the editor. The UI currently uses different techniques to + * paint the renderers and editors and overriding setBounds() below + * is not the right thing to do for an editor. Returning -1 for the + * editing row in this case, ensures the editor is never painted. + */ + public int getEditingRow() { + if (getColumnClass(editingColumn) == ScilabTreeTableModel.class) { + return -1; + } else { + return editingRow; + } + } + + /** + * Init the actions + */ + private void initActions() { + final ActionMap actions = getActionMap(); + actions.put("scinotes", new OpenFileInSciNotesAction(this)); + actions.put("xcos", new ExecuteFileInXcosAction(this)); + actions.put("mat", new ExecuteMatFileAction(this)); + actions.put("console", new ExecuteFileInConsoleAction(this)); + actions.put("load", new LoadFileInScilabAction(this)); + actions.put("graph", new LoadFileAsGraphAction(this)); + actions.put("cwd", new ChangeCWDAction(this)); + if (EditFileWithDefaultAppAction.isSupported()) { + actions.put("edit", new EditFileWithDefaultAppAction(this)); + } + if (OpenFileWithDefaultAppAction.isSupported()) { + actions.put("open", new OpenFileWithDefaultAppAction(this)); + } + actions.put("validate", new ValidateAction(this)); + actions.put("validateorexpand", new CommonCallBack(null) { + public void callBack() { + int[] rows = getSelectedRows(); + if (rows != null && rows.length != 0) { + TreePath path = tree.getPathForRow(rows[0]); + FileNode fn = (FileNode) path.getLastPathComponent(); + if (fn.isLeaf()) { + ((CommonCallBack) actions.get("validate")).callBack(); + } else { + if (tree.isExpanded(path)) { + tree.collapsePath(path); + } else { + tree.expandPath(path); + } + setRowSelectionInterval(rows[0], rows[0]); + } + } + } + }); + + combobox.setAction((CommonCallBack) actions.get("cwd")); + InputMap map = getInputMap(); + map.put(KeyStroke.getKeyStroke("ENTER"), "validateorexpand"); + } + + /** + * Create the popup menu + */ + private JPopupMenu createPopup() { + ActionMap actions = getActionMap(); + JPopupMenu popup = new JPopupMenu(); + JMenuItem item = new JMenuItem(UiDataMessages.OPENINSCINOTES); + item.addActionListener(actions.get("scinotes")); + item.setIcon(new ImageIcon(FindIconHelper.findIcon("accessories-text-editor"))); + popup.add(item); + + item = new JMenuItem(UiDataMessages.EXECINCONSOLE); + item.addActionListener(actions.get("console")); + item.setIcon(new ImageIcon(FindIconHelper.findIcon("media-playback-start"))); + popup.add(item); + + item = new JMenuItem(UiDataMessages.OPENINXCOS); + item.addActionListener(actions.get("xcos")); + item.setIcon(new ImageIcon(FindIconHelper.findIcon("utilities-system-monitor"))); + popup.add(item); + + item = new JMenuItem(UiDataMessages.LOADINSCILAB); + item.addActionListener(actions.get("load")); + item.setIcon(new ImageIcon(FindIconHelper.findIcon("scilab"))); + popup.add(item); + + if (actions.get("edit") != null || actions.get("open") != null) { + popup.addSeparator(); + } + + if (actions.get("edit") != null) { + item = new JMenuItem(UiDataMessages.EDITWITHDEFAULT); + item.addActionListener(actions.get("edit")); + popup.add(item); + } + + if (actions.get("open") != null) { + item = new JMenuItem(UiDataMessages.OPENWITHDEFAULT); + item.addActionListener(actions.get("open")); + popup.add(item); + } + + popup.pack(); + + return popup; + } + + /** + * A modulo for negative numbers + * @param n an int + * @param p an other int + * @return n modulo p + */ + private static final int modulo(int n, int p) { + if (n >= 0) { + return n % p; + } + return p - (-n % p); + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ChangeCWDAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ChangeCWDAction.java new file mode 100755 index 000000000..904f98181 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ChangeCWDAction.java @@ -0,0 +1,112 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.io.File; + +import javax.swing.JButton; + +import org.scilab.modules.action_binding.InterpreterManagement; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.bridge.filechooser.SwingScilabFileChooser; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.FileBrowser; +import org.scilab.modules.ui_data.filebrowser.FileUtils; +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Change cwd action + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ChangeCWDAction extends CommonCallBack { + + private SwingScilabTreeTable table; + + /** + * Default constructor + * @param table the associated table + */ + public ChangeCWDAction(SwingScilabTreeTable table) { + super(null); + this.table = table; + } + + /** + * {@inheritDoc} + */ + public void callBack() { + changeDir(table.getComboBox().getBaseDir()); + } + + /** + * @return the button used to set the cwd in using a JFileChooser + */ + public JButton createButton() { + JButton button = new JButton(); + button.setToolTipText(UiDataMessages.SELECTDIR); + button.addActionListener(new CommonCallBack(null) { + public void callBack() { + SwingScilabFileChooser filechooser = new SwingScilabFileChooser(); + filechooser.setCurrentDirectory(new File(table.getComboBox().getBaseDir())); + filechooser.setTitle(UiDataMessages.SELECTADIR); + filechooser.setMultipleSelection(false); + filechooser.setDirectorySelectionOnly(); + filechooser.displayAndWait(); + String[] paths = filechooser.getSelection(); + if (paths != null && paths.length != 0) { + changeDir(paths[0]); + } + } + }); + button.setIcon(FileUtils.getClosedDirIcon()); + ScilabLAF.setDefaultProperties(button); + + return button; + } + + /** + * @return the button used to jump to the parent directory + */ + public JButton createParentDirButton() { + JButton button = new JButton(); + button.setToolTipText(UiDataMessages.PARENTDIR); + button.addActionListener(new CommonCallBack(null) { + public void callBack() { + File f = new File(table.getComboBox().getBaseDir()); + if (f.exists()) { + File parent = f.getParentFile(); + if (parent != null && parent.exists() && parent.canRead()) { + changeDir(parent.getAbsolutePath()); + } + } + } + }); + button.setIcon(FileUtils.getUpDirIcon()); + + return button; + } + + /** + * Change the dir + * @param path the new path + */ + private void changeDir(String path) { + File f = new File(path); + if (f.exists() && f.isDirectory() && f.canRead()) { + InterpreterManagement.requestScilabExec("chdir('" + path + "')"); + FileBrowser.setBaseDir(path); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/CloseAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/CloseAction.java new file mode 100755 index 000000000..c72afe6a9 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/CloseAction.java @@ -0,0 +1,62 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import javax.swing.KeyStroke; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.gui.utils.ClosingOperationsManager; +import org.scilab.modules.ui_data.filebrowser.ScilabFileBrowser; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Close action + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class CloseAction extends CommonCallBack { + + private static final KeyStroke KEY = ScilabKeyStroke.getKeyStroke("OSSCKEY W"); + + /** + * Default constructor + */ + public CloseAction() { + super(null); + } + + /** + * @return a menuitem associated with this action + */ + public static MenuItem createMenu() { + MenuItem item = ScilabMenuItem.createMenuItem(); + SwingScilabMenuItem swingItem = (SwingScilabMenuItem) item.getAsSimpleMenuItem(); + swingItem.setAction(new CloseAction()); + swingItem.setText(UiDataMessages.CLOSE); + swingItem.setAccelerator(KEY); + + return item; + } + + /** + * {@inheritDoc} + */ + public void callBack() { + ClosingOperationsManager.startClosingOperation((SwingScilabDockablePanel) ScilabFileBrowser.getFileBrowser()); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/EditFileWithDefaultAppAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/EditFileWithDefaultAppAction.java new file mode 100755 index 000000000..3da15d5b5 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/EditFileWithDefaultAppAction.java @@ -0,0 +1,73 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.awt.Desktop; +import java.io.File; + +import javax.swing.SwingUtilities; + +import org.scilab.modules.commons.OS; +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.messagebox.ScilabModalDialog; +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Action to edit a file with the default associated application + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class EditFileWithDefaultAppAction extends CommonCallBack { + + private static final boolean isWindows = (OS.get() == OS.WINDOWS); + + private SwingScilabTreeTable table; + + /** + * Default constructor + * @param table the table associated with this action + */ + public EditFileWithDefaultAppAction(SwingScilabTreeTable table) { + super(null); + this.table = table; + } + + /** + * @return true if this action is available with the OS + */ + public static boolean isSupported() { + return Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.EDIT); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + Desktop dt = Desktop.getDesktop(); + File[] files = table.getSelectedFiles(); + for (File file : files) { + try { + if (isWindows) { + String cmd = "rundll32 url.dll,FileProtocolHandler " + file.getCanonicalPath(); + Runtime.getRuntime().exec(cmd); + } else { + dt.edit(file); + } + } catch (Exception e) { + ScilabModalDialog.show((SwingScilabDockablePanel) SwingUtilities.getAncestorOfClass(SwingScilabDockablePanel.class, table), String.format(UiDataMessages.CANNOTREAD, file.getName())); + } + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteCommandAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteCommandAction.java new file mode 100755 index 000000000..0326bfb77 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteCommandAction.java @@ -0,0 +1,65 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.io.File; + +import javax.swing.SwingUtilities; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.console.ScilabConsole; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.messagebox.ScilabModalDialog; +import org.scilab.modules.localization.Messages; +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to execute a command + * @author Calixte DENIZET + */ + +@SuppressWarnings(value = { "serial" }) +public class ExecuteCommandAction extends CommonCallBack { + + private SwingScilabTreeTable table; + private String cmd; + + /** + * Default constructor + * @param table the table associated with this action + * @param the command with a %s which will be replaced by the file name + */ + public ExecuteCommandAction(SwingScilabTreeTable table, String cmd) { + super(null); + this.table = table; + this.cmd = cmd; + } + + /** + * {@inheritDoc} + */ + public void callBack() { + String[] paths = table.getSelectedPaths(); + for (String path : paths) { + File f = new File(path); + if (f.exists() && f.canRead() && f.isFile()) { + try { + String com = String.format(cmd, path); + ScilabConsole.getConsole().getAsSimpleConsole().sendCommandsToScilab(com, true /* display */, true /* store in history */); + } catch (NoClassDefFoundError e) { + ScilabModalDialog.show((SwingScilabDockablePanel) SwingUtilities.getAncestorOfClass(SwingScilabDockablePanel.class, table), Messages.gettext("Feature not available in this mode...")); + } + } + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteFileInConsoleAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteFileInConsoleAction.java new file mode 100755 index 000000000..3ed493993 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteFileInConsoleAction.java @@ -0,0 +1,32 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to execute the file in the console + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ExecuteFileInConsoleAction extends ExecuteCommandAction { + + private static final String EXEC = "exec('%s',-1)"; + + /** + * {@inheritDoc} + */ + public ExecuteFileInConsoleAction(SwingScilabTreeTable table) { + super(table, EXEC); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteFileInXcosAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteFileInXcosAction.java new file mode 100755 index 000000000..5aa5e7232 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteFileInXcosAction.java @@ -0,0 +1,32 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to execute the file in Xcos + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ExecuteFileInXcosAction extends ExecuteCommandAction { + + private static final String XCOS = "xcos('%s')"; + + /** + * {@inheritDoc} + */ + public ExecuteFileInXcosAction(SwingScilabTreeTable table) { + super(table, XCOS); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteMatFileAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteMatFileAction.java new file mode 100755 index 000000000..11c7b0089 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ExecuteMatFileAction.java @@ -0,0 +1,32 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to load the mat file + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ExecuteMatFileAction extends ExecuteCommandAction { + + private static final String MAT = "loadmatfile('%s')"; + + /** + * {@inheritDoc} + */ + public ExecuteMatFileAction(SwingScilabTreeTable table) { + super(table, MAT); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/GoToHomeAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/GoToHomeAction.java new file mode 100755 index 000000000..844ace0c6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/GoToHomeAction.java @@ -0,0 +1,64 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.io.File; + +import javax.swing.JButton; + +import org.scilab.modules.action_binding.InterpreterManagement; +import org.scilab.modules.commons.ScilabConstants; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.FileBrowser; +import org.scilab.modules.ui_data.filebrowser.FileUtils; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Action to go to user-home + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class GoToHomeAction extends CommonCallBack { + + /** + * {@inheritDoc} + */ + public GoToHomeAction() { + super(null); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + File f = new File(ScilabConstants.USERHOME); + if (f.exists() && f.isDirectory() && f.canRead()) { + InterpreterManagement.requestScilabExec("chdir('" + f.getAbsolutePath() + "')"); + FileBrowser.setBaseDir(f.getAbsolutePath()); + } + } + + /** + * @return the corresponding button + */ + public static JButton createButton() { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new GoToHomeAction()); + button.setToolTipText(UiDataMessages.USERHOME); + button.setIcon(FileUtils.getClosedUserHomeIcon()); + + return button; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/GoToSCIAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/GoToSCIAction.java new file mode 100755 index 000000000..bb78d4e0a --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/GoToSCIAction.java @@ -0,0 +1,63 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.io.File; + +import javax.swing.JButton; + +import org.scilab.modules.action_binding.InterpreterManagement; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.FileBrowser; +import org.scilab.modules.ui_data.filebrowser.FileUtils; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Action to go to SCI + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class GoToSCIAction extends CommonCallBack { + + /** + * {@inheritDoc} + */ + public GoToSCIAction() { + super(null); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + File f = new File(System.getenv("SCI")); + if (f.exists() && f.isDirectory() && f.canRead()) { + InterpreterManagement.requestScilabExec("chdir('" + f.getAbsolutePath() + "')"); + FileBrowser.setBaseDir(f.getAbsolutePath()); + } + } + + /** + * @return the corresponding button + */ + public static JButton createButton() { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new GoToSCIAction()); + button.setToolTipText(UiDataMessages.SCIFOLDER); + button.setIcon(FileUtils.getSCIIcon()); + + return button; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/LoadFileAsGraphAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/LoadFileAsGraphAction.java new file mode 100755 index 000000000..737b9c1a6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/LoadFileAsGraphAction.java @@ -0,0 +1,32 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to load the file as a graph + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class LoadFileAsGraphAction extends ExecuteCommandAction { + + private static final String LOADGRAPH = "load_graph('%s')"; + + /** + * {@inheritDoc} + */ + public LoadFileAsGraphAction(SwingScilabTreeTable table) { + super(table, LOADGRAPH); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/LoadFileInScilabAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/LoadFileInScilabAction.java new file mode 100755 index 000000000..bacd808a6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/LoadFileInScilabAction.java @@ -0,0 +1,32 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to load the file in Scilab + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class LoadFileInScilabAction extends ExecuteCommandAction { + + private static final String LOAD = "load('%s')"; + + /** + * {@inheritDoc} + */ + public LoadFileInScilabAction(SwingScilabTreeTable table) { + super(table, LOAD); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/OpenFileInSciNotesAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/OpenFileInSciNotesAction.java new file mode 100755 index 000000000..1223dea03 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/OpenFileInSciNotesAction.java @@ -0,0 +1,80 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.io.File; +import java.lang.reflect.Method; + +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to open the file in SciNotes + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class OpenFileInSciNotesAction extends CommonCallBack { + + private SwingScilabTreeTable table; + + /** + * Default constructor + * @param table the table associated with this action + */ + public OpenFileInSciNotesAction(SwingScilabTreeTable table) { + super(null); + this.table = table; + } + + /** + * {@inheritDoc} + */ + public void callBack() { + Class scinotesClass = null; + Method scinotes = null; + try { + scinotesClass = Class.forName("org.scilab.modules.scinotes.SciNotes"); + scinotes = scinotesClass.getMethod("scinotes", new Class[] {String.class}); + } catch (ClassNotFoundException e) { + System.err.println("Could not find SciNotes class"); + e.printStackTrace(); + } catch (SecurityException e) { + System.err.println("Security error: Could not access to SciNotes class"); + e.printStackTrace(); + } catch (NoSuchMethodException e) { + System.err.println("Could not access to scinotesWithText method from object SciNotes"); + e.printStackTrace(); + } + if (scinotesClass != null && scinotes != null) { + final Method scin = scinotes; + String[] paths = table.getSelectedPaths(); + for (final String path : paths) { + File f = new File(path); + if (f.exists() && f.canRead() && f.isFile()) { + Thread t = new Thread(new Runnable() { + public void run() { + try { + scin.invoke(null, new Object[] {path}); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + try { + t.start(); + } catch (Exception e) { } + } + } + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/OpenFileWithDefaultAppAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/OpenFileWithDefaultAppAction.java new file mode 100755 index 000000000..faa5f6090 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/OpenFileWithDefaultAppAction.java @@ -0,0 +1,65 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.awt.Desktop; +import java.io.File; + +import javax.swing.SwingUtilities; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.messagebox.ScilabModalDialog; +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * Action to open a file with the default associated application + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class OpenFileWithDefaultAppAction extends CommonCallBack { + + private SwingScilabTreeTable table; + + /** + * Default constructor + * @param table the table associated with this action + */ + public OpenFileWithDefaultAppAction(SwingScilabTreeTable table) { + super(null); + this.table = table; + } + + /** + * @return true if this action is available with the OS + */ + public static boolean isSupported() { + return Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + Desktop dt = Desktop.getDesktop(); + File[] files = table.getSelectedFiles(); + for (File file : files) { + try { + dt.open(file); + } catch (Exception e) { + ScilabModalDialog.show((SwingScilabDockablePanel) SwingUtilities.getAncestorOfClass(SwingScilabDockablePanel.class, table), String.format(UiDataMessages.CANNOTOPEN, file.getName())); + } + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ValidateAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ValidateAction.java new file mode 100755 index 000000000..f9114b191 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/filebrowser/actions/ValidateAction.java @@ -0,0 +1,79 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.filebrowser.actions; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.Action; +import javax.swing.ActionMap; + +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.filebrowser.FileUtils; +import org.scilab.modules.ui_data.filebrowser.SwingScilabTreeTable; + +/** + * Action to validate a file + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ValidateAction extends CommonCallBack { + + private SwingScilabTreeTable table; + private Map<String, Action> ext = new HashMap<String, Action>(); + + /** + * Default constructor + * @param table the table associated with this action + */ + public ValidateAction(SwingScilabTreeTable table) { + super(null); + this.table = table; + ActionMap actions = table.getActionMap(); + ext.put("", actions.get("open")); + ext.put("sce", actions.get("scinotes")); + ext.put("sci", actions.get("scinotes")); + ext.put("tst", actions.get("scinotes")); + ext.put("dem", actions.get("scinotes")); + ext.put("zcos", actions.get("xcos")); + ext.put("xcos", actions.get("xcos")); + ext.put("cos", actions.get("xcos")); + ext.put("cosf", actions.get("xcos")); + ext.put("bin", actions.get("load")); + ext.put("scg", actions.get("load")); + ext.put("sav", actions.get("load")); + ext.put("sod", actions.get("load")); + ext.put("graph", actions.get("graph")); + ext.put("mat", actions.get("mat")); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + File[] files = table.getSelectedFiles(); + if (files[0].isDirectory() && files[0].canRead()) { + table.getComboBox().setBaseDirAndValidate(files[0].getAbsolutePath()); + return; + } + + String extension = FileUtils.getFileExtension(files[0]).toLowerCase(); + CommonCallBack c = (CommonCallBack) ext.get(extension); + if (c != null) { + c.callBack(); + } else { + ((CommonCallBack) ext.get("")).callBack(); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/HeaderRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/HeaderRenderer.java new file mode 100755 index 000000000..163165ea3 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/HeaderRenderer.java @@ -0,0 +1,126 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.rowheader; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Insets; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.UIManager; +import javax.swing.border.AbstractBorder; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +/** + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class HeaderRenderer extends JLabel implements TableCellRenderer { + + private static final Insets INSETS = new Insets(1, 1, 1, 0); + + private int index; + private JTable table; + private boolean rowModel; + + private Font selectedFont; + private Font unselectedFont; + private Color selectedFgColor; + private Color unselectedFgColor; + private Color selectedBgColor; + private Color unselectedBgColor; + + /** + * Constructor + */ + public HeaderRenderer(JTable table, boolean rowModel) { + this.table = table; + this.rowModel = rowModel; + JTableHeader header = table.getTableHeader(); + this.selectedFont = header.getFont().deriveFont(Font.BOLD); + this.unselectedFont = header.getFont(); + this.selectedFgColor = UIManager.getColor("textHighlightText"); + this.unselectedFgColor = header.getForeground(); + this.unselectedBgColor = header.getBackground().darker(); + + Color c = table.getSelectionBackground(); + float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); + this.selectedBgColor = Color.getHSBColor(hsb[0], hsb[1] * 2f, hsb[2]); + + setOpaque(true); + setBorder(BorderFactory.createEmptyBorder()); + setHorizontalAlignment(CENTER); + setForeground(unselectedFgColor); + setBackground(unselectedBgColor); + setFont(unselectedFont); + if (!rowModel) { + setBorder(new AbstractBorder() { + public Insets getBorderInsets(Component c) { + return INSETS; + } + + public Insets getBorderInsets(Component c, Insets insets) { + return INSETS; + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + g.setColor(HeaderRenderer.this.table.getGridColor().darker()); + g.drawLine(x, y, x + width, y); + g.drawLine(x, y, x, y + height); + } + }); + } + } + + public void paintComponent(Graphics g) { + ListSelectionModel lsm; + if (rowModel) { + lsm = table.getSelectionModel(); + } else { + lsm = table.getColumnModel().getSelectionModel(); + } + + if (lsm.isSelectedIndex(index)) { + setForeground(selectedFgColor); + setBackground(selectedBgColor); + setFont(selectedFont); + } else { + setForeground(unselectedFgColor); + setBackground(unselectedBgColor); + setFont(unselectedFont); + } + + super.paintComponent(g); + } + + /** + * {@inheritDoc} + */ + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (rowModel) { + this.index = row; + } else { + this.index = column; + } + + setText(Integer.toString(index + 1)); + + return this; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeader.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeader.java new file mode 100755 index 000000000..57a68fa7a --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeader.java @@ -0,0 +1,210 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.rowheader; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Toolkit; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; + +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.border.AbstractBorder; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; + +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.TableVariableEditor; +import org.scilab.modules.ui_data.variableeditor.actions.InsertRowAction; +import org.scilab.modules.ui_data.variableeditor.actions.RemoveRowAction; + +/** + * Class for the RowHeader + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class RowHeader extends JPanel implements TableModelListener { + + private static final Insets INSETS = new Insets(1, 0, 0, 0); + + private JTable rowTable; + private JTable table; + private DefaultTableModel model; + private int clickedRow; + + /** + * Constructor + * @param table the table + */ + public RowHeader(final JTable table) { + super(new BorderLayout()); + this.table = table; + table.getModel().addTableModelListener(this); + model = new DefaultTableModel(0, 1) { + public boolean isCellEditable(int iRowIndex, int iColumnIndex) { + return false; + } + }; + rowTable = new JTable(model); + setBorder(new AbstractBorder() { + public Insets getBorderInsets(Component c) { + return INSETS; + } + + public Insets getBorderInsets(Component c, Insets insets) { + return INSETS; + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + g.setColor(table.getGridColor().darker()); + g.drawLine(x, y, x + width, y); + } + }); + rowTable.setDoubleBuffered(true); + rowTable.setDragEnabled(false); + rowTable.setGridColor(table.getGridColor().darker()); + rowTable.setShowVerticalLines(true); + rowTable.setModel(model); + rowTable.setRowHeight(table.getRowHeight()); + rowTable.setRowMargin(table.getRowMargin()); + rowTable.setIntercellSpacing(table.getIntercellSpacing()); + rowTable.setDefaultEditor(Object.class, null); + rowTable.setCellEditor(null); + rowTable.setDefaultRenderer(Object.class, new HeaderRenderer(table, true)); + rowTable.setComponentPopupMenu(createPopupMenu()); + rowTable.doLayout(); + add(rowTable); + doLayout(); + rowTable.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e)) { + int row = rowTable.rowAtPoint(e.getPoint()); + ListSelectionModel rsm = table.getSelectionModel(); + int colC = ((SwingEditvarTableModel) ((TableVariableEditor) table).getModel()).getScilabMatrixColCount(); + if (colC == 0) { + colC = 1; + } + + if (e.isShiftDown()) { + rsm.setSelectionInterval(row, clickedRow); + table.setColumnSelectionInterval(0, colC - 1); + } else { + if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { + if (table.isRowSelected(row)) { + rsm.removeSelectionInterval(row, row); + } else { + rsm.addSelectionInterval(row, row); + table.setColumnSelectionInterval(0, colC - 1); + } + } else { + rsm.setSelectionInterval(row, row); + table.setColumnSelectionInterval(0, colC - 1); + } + clickedRow = row; + } + table.requestFocus(); + } + } + }); + + rowTable.addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent e) { + if (SwingUtilities.isLeftMouseButton(e)) { + Point p = e.getPoint(); + int row; + if (p.y >= rowTable.getCellRect(rowTable.getRowCount() - 1, 0, false).y) { + row = rowTable.getRowCount() - 1; + } else { + row = rowTable.rowAtPoint(p); + } + + ListSelectionModel rsm = table.getSelectionModel(); + int lead = rsm.getLeadSelectionIndex(); + if (lead != row) { + if (row == rowTable.getRowCount() - 1) { + ((TableVariableEditor) table).addTenRows(); + } + table.scrollRectToVisible(table.getCellRect(row, 0, false)); + if (e.isShiftDown()) { + rsm.setSelectionInterval(clickedRow, row); + } else { + if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { + if (rsm.isSelectedIndex(row)) { + rsm.removeSelectionInterval(lead, row); + rsm.addSelectionInterval(clickedRow, row); + } else { + rsm.addSelectionInterval(clickedRow, row); + } + } else { + rsm.setSelectionInterval(clickedRow, row); + } + } + + int colC = ((SwingEditvarTableModel) ((TableVariableEditor) table).getModel()).getScilabMatrixColCount(); + if (colC == 0) { + colC = 1; + } + table.setColumnSelectionInterval(0, colC - 1); + + table.requestFocus(); + } + } + } + }); + } + + /** + * @return a popup menu for the table + */ + public JPopupMenu createPopupMenu() { + JPopupMenu popup = new JPopupMenu() { + public void show(Component invoker, int x, int y) { + ((TableVariableEditor) table).setPopupRow(rowTable.rowAtPoint(new Point(x, y))); + super.show(invoker, x, y); + } + }; + popup.setBorderPainted(true); + popup.add(InsertRowAction.createMenuItem(table, UiDataMessages.INSERTR)); + popup.add(RemoveRowAction.createMenuItem(table, UiDataMessages.REMOVER)); + + return popup; + } + + /** + * {@inheritDoc} + */ + public void tableChanged(TableModelEvent e) { + DefaultTableModel dtm = (DefaultTableModel) e.getSource(); + int N = dtm.getRowCount() - model.getRowCount(); + for (int i = 0; i < N; i++) { + model.addRow(new Object[1]); + } + } + + /** + * @return the JTable used as row header + */ + public JTable getTable() { + return rowTable; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeaderCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeaderCellEditor.java new file mode 100755 index 000000000..f879d7fbd --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeaderCellEditor.java @@ -0,0 +1,70 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.rowheader; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; + +import javax.swing.AbstractCellEditor; +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellEditor; + +/** + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class RowHeaderCellEditor extends AbstractCellEditor implements TableCellEditor { + + private JLabel label; + private int row; + + /** + * Constructor + * @param table the table where to put the rowHeader + */ + public RowHeaderCellEditor(final JTable table) { + label = new JLabel(); + JTableHeader header = table.getTableHeader(); + label.setOpaque(true); + label.setBorder(BorderFactory.createEmptyBorder()); + label.setHorizontalAlignment(JLabel.CENTER); + label.setForeground(UIManager.getColor("textHighlightText")); + label.setFont(header.getFont().deriveFont(Font.BOLD)); + + Color selected = UIManager.getColor("Table.selectionBackground"); + float[] hsb = Color.RGBtoHSB(selected.getRed(), selected.getGreen(), selected.getBlue(), null); + label.setBackground(Color.getHSBColor(hsb[0], 1, hsb[2])); + } + + /** + * {@inheritDoc} + */ + public Object getCellEditorValue() { + return row; + } + + /** + * {@inheritDoc} + */ + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { + this.row = row; + label.setText(Integer.toString(row + 1)); + + return label; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeaderRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeaderRenderer.java new file mode 100755 index 000000000..9a20481b6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/rowheader/RowHeaderRenderer.java @@ -0,0 +1,93 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.rowheader; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Graphics; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.UIManager; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +/** + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class RowHeaderRenderer extends JLabel implements TableCellRenderer { + + private int index; + private JTable table; + private boolean rowModel; + + /** + * Constructor + */ + public RowHeaderRenderer(JTable table, boolean rowModel) { + this.table = table; + this.rowModel = rowModel; + JTableHeader header = table.getTableHeader(); + setOpaque(true); + setBorder(BorderFactory.createEmptyBorder()); + setHorizontalAlignment(CENTER); + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + if (!rowModel) { + setBorder(BorderFactory.createLineBorder(table.getGridColor().darker(), 1)); + } + } + + public void paintComponent(Graphics g) { + JTableHeader header = table.getTableHeader(); + ListSelectionModel lsm; + if (rowModel) { + lsm = table.getSelectionModel(); + } else { + lsm = table.getColumnModel().getSelectionModel(); + } + + if (lsm.isSelectedIndex(index)) { + Color c = UIManager.getColor("Table.selectionBackground"); + float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); + setBackground(Color.getHSBColor(hsb[0], 1, hsb[2])); + setFont(header.getFont().deriveFont(Font.BOLD)); + setForeground(UIManager.getColor("textHighlightText")); + } else { + setForeground(header.getForeground()); + setBackground(header.getBackground()); + setFont(header.getFont()); + } + super.paintComponent(g); + } + + /** + * {@inheritDoc} + */ + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (rowModel) { + this.index = row; + } else { + this.index = column; + } + + setText(Integer.toString(index + 1)); + + return this; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/FileBrowserTab.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/FileBrowserTab.java new file mode 100755 index 000000000..fb0d64971 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/FileBrowserTab.java @@ -0,0 +1,68 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2011 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.tabfactory; + +import java.util.List; +import java.util.ListIterator; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.tabfactory.ScilabTabFactory; +import org.scilab.modules.gui.utils.ClosingOperationsManager; +import org.scilab.modules.ui_data.filebrowser.ScilabFileBrowser; + +/** + * Class to create File Browser instances + * + * @author Calixte DENIZET + */ +public class FileBrowserTab { + + /** + * @param uuid + * the uuid to restore + * @return a new SciNotes instance + */ + public static SwingScilabDockablePanel getFileBrowserInstance() { + final SwingScilabDockablePanel filebrowser = ScilabFileBrowser + .createFileBrowserTab(); + ScilabTabFactory.getInstance().addToCache(filebrowser); + + ClosingOperationsManager.registerClosingOperation(filebrowser, + new ClosingOperationsManager.ClosingOperation() { + + @Override + public int canClose() { + return 1; + } + + @Override + public void destroy() { + ScilabFileBrowser.closeFileBrowser(); + } + + @Override + public String askForClosing(final List<SwingScilabDockablePanel> list) { + return null; + } + + @Override + public void updateDependencies(List<SwingScilabDockablePanel> list, + ListIterator<SwingScilabDockablePanel> it) { + } + }); + + ClosingOperationsManager.addDependencyWithRoot(filebrowser); + + return filebrowser; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/FileBrowserTabFactory.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/FileBrowserTabFactory.java new file mode 100755 index 000000000..68be737f4 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/FileBrowserTabFactory.java @@ -0,0 +1,85 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2011 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.tabfactory; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.tabfactory.AbstractScilabTabFactory; +import org.scilab.modules.ui_data.filebrowser.SwingScilabFileBrowser; + +/** + * The main Tab factory. + * A component which needs to restore a Tab with a given uuid must register its factory. + * + * @author Calixte DENIZET + */ +public class FileBrowserTabFactory extends AbstractScilabTabFactory { + + public static final String APPLICATION = "FileBrowser"; + public static final String PACKAGE = ""; + public static final String CLASS = "org.scilab.modules.ui_data.tabfactory.FileBrowserTabFactory"; + + private static FileBrowserTabFactory instance; + + /** + * Default constructor + */ + public FileBrowserTabFactory() { + if (instance == null) { + instance = this; + } + } + + /** + * {@inheritDoc} + */ + public SwingScilabDockablePanel getTab(String uuid) { + return FileBrowserTab.getFileBrowserInstance(); + } + + /** + * {@inheritDoc} + */ + public String getPackage() { + return PACKAGE; + } + + /** + * {@inheritDoc} + */ + public String getClassName() { + return CLASS; + } + + /** + * {@inheritDoc} + */ + public String getApplication() { + return APPLICATION; + } + + /** + * {@inheritDoc} + */ + public boolean isAValidUUID(String uuid) { + return SwingScilabFileBrowser.FILEBROWSERUUID.equals(uuid); + } + + /** + * @return an instance of this factory + */ + public static FileBrowserTabFactory getInstance() { + new FileBrowserTabFactory(); + + return instance; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/VariableBrowserTab.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/VariableBrowserTab.java new file mode 100755 index 000000000..684e4e1f5 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/VariableBrowserTab.java @@ -0,0 +1,68 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.tabfactory; + +import java.util.List; +import java.util.ListIterator; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.tabfactory.ScilabTabFactory; +import org.scilab.modules.gui.utils.ClosingOperationsManager; +import org.scilab.modules.ui_data.variablebrowser.ScilabVariableBrowser; + +/** + * Class to create SciNotes instances + * + * @author Calixte DENIZET + */ +public class VariableBrowserTab { + + /** + * @param uuid + * the uuid to restore + * @return a new SciNotes instance + */ + public static SwingScilabDockablePanel getVariableBrowserInstance() { + final SwingScilabDockablePanel varbrowser = ScilabVariableBrowser + .createVarBrowserTab(); + ScilabTabFactory.getInstance().addToCache(varbrowser); + + ClosingOperationsManager.registerClosingOperation(varbrowser, + new ClosingOperationsManager.ClosingOperation() { + + @Override + public int canClose() { + return 1; + } + + @Override + public void destroy() { + ScilabVariableBrowser.closeVariableBrowser(); + } + + @Override + public String askForClosing(final List<SwingScilabDockablePanel> list) { + return null; + } + + @Override + public void updateDependencies(List<SwingScilabDockablePanel> list, + ListIterator<SwingScilabDockablePanel> it) { + } + }); + + ClosingOperationsManager.addDependencyWithRoot(varbrowser); + + return varbrowser; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/VariableBrowserTabFactory.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/VariableBrowserTabFactory.java new file mode 100755 index 000000000..411eeca62 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/tabfactory/VariableBrowserTabFactory.java @@ -0,0 +1,85 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.tabfactory; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.tabfactory.AbstractScilabTabFactory; +import org.scilab.modules.ui_data.variablebrowser.SwingScilabVariableBrowser; + +/** + * The main Tab factory. + * A component which needs to restore a Tab with a given uuid must register its factory. + * + * @author Calixte DENIZET + */ +public class VariableBrowserTabFactory extends AbstractScilabTabFactory { + + public static final String APPLICATION = "VariableBrowser"; + public static final String PACKAGE = ""; + public static final String CLASS = "org.scilab.modules.ui_data.tabfactory.VariableBrowserTabFactory"; + + private static VariableBrowserTabFactory instance; + + /** + * Default constructor + */ + public VariableBrowserTabFactory() { + if (instance == null) { + instance = this; + } + } + + /** + * {@inheritDoc} + */ + public SwingScilabDockablePanel getTab(String uuid) { + return VariableBrowserTab.getVariableBrowserInstance(); + } + + /** + * {@inheritDoc} + */ + public String getPackage() { + return PACKAGE; + } + + /** + * {@inheritDoc} + */ + public String getClassName() { + return CLASS; + } + + /** + * {@inheritDoc} + */ + public String getApplication() { + return APPLICATION; + } + + /** + * {@inheritDoc} + */ + public boolean isAValidUUID(String uuid) { + return SwingScilabVariableBrowser.VARBROWSERUUID.equals(uuid); + } + + /** + * @return an instance of this factory + */ + public static VariableBrowserTabFactory getInstance() { + new VariableBrowserTabFactory(); + + return instance; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/utils/UiDataMessages.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/utils/UiDataMessages.java new file mode 100755 index 000000000..c00d01421 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/utils/UiDataMessages.java @@ -0,0 +1,154 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.utils; + +import java.awt.event.MouseEvent; +import javax.swing.SwingUtilities; + +import org.scilab.modules.localization.Messages; + +/** + * All localized messages/menus labels used in Editvar and Browsevar + */ +// CSOFF: JavadocVariable +// CSOFF: LineLength +// CSOFF: MultipleStringLiterals + +public final class UiDataMessages { + + /* File menu */ + public static final String FILE = Messages.gettext("File"); + public static final String CLOSE = Messages.gettext("Close"); + public static final String DELETE = Messages.gettext("Delete"); + public static final String MODIFY = Messages.gettext("Modify"); + public static final String FILTER = Messages.gettext("Filter"); + + public static final String SCILABVAR = Messages.gettext("Hide Scilab variables"); + + public static final String DOUBLE = Messages.gettext("Double"); + public static final String POLYNOMIAL = Messages.gettext("Polynomial"); + public static final String BOOLEAN = Messages.gettext("Boolean"); + public static final String SPARSE = Messages.gettext("Sparse"); + public static final String SPARSE_BOOLEAN = Messages.gettext("Sparse boolean"); + public static final String INTEGER = Messages.gettext("Integer"); + public static final String GRAPHIC_HANDLES = Messages.gettext("Graphic handles"); + public static final String STRING = Messages.gettext("String"); + public static final String UNCOMPILED_FUNC = Messages.gettext("Un-compiled function"); + public static final String COMPILED_FUNC = Messages.gettext("Compiled function"); + public static final String FUNCTIONLIB = Messages.gettext("Function library"); + public static final String LIST = Messages.gettext("List"); + public static final String TLIST = Messages.gettext("Tlist"); + public static final String MLIST = Messages.gettext("Mlist"); + public static final String POINTER = Messages.gettext("Pointer"); + public static final String INTRINSIC_FUNCTION = Messages.gettext("Intrinsic function"); + public static final String MATLAB_SPARSE = Messages.gettext("Matlab sparse"); + public static final String IMPLICIT_POLYNOMIAL = Messages.gettext("Implicit polynomial"); + + public static final String VARIABLE_EDITOR = Messages.gettext("Variable Editor"); + public static final String VARIABLE_BROWSER = Messages.gettext("Variable Browser"); + + public static final String GLOBAL_NOT_EDITABLE = Messages.gettext("Global variables can not be edited."); + + public static final String EDITION = Messages.gettext("Edition"); + public static final String REFRESH = Messages.gettext("Refresh the variable "); + public static final String HELP = Messages.gettext("Scilab Help"); + public static final String COPY = Messages.gettext("Copy"); + public static final String PASTE = Messages.gettext("Paste"); + public static final String CUT = Messages.gettext("Cut"); + public static final String CLEAR = Messages.gettext("Clear"); + public static final String UNDO = Messages.gettext("Undo"); + public static final String REDO = Messages.gettext("Redo"); + public static final String FIT = Messages.gettext("Size columns to fit"); + public static final String COPYASSCILABCOM = Messages.gettext("Copy as Scilab command"); + public static final String COPYASSCILABMAT = Messages.gettext("Copy as Scilab matrix"); + public static final String COPYASSCILABMATWITHCR = Messages.gettext("Copy as Scilab matrix with CR"); + + public static final String SHORT = Messages.gettext("Short format"); + public static final String SHORTE = Messages.gettext("ShortE format"); + public static final String LONG = Messages.gettext("Long format"); + public static final String LONGE = Messages.gettext("LongE format"); + + public static final String CREATE = Messages.gettext("Create variable from selection"); + + public static final String INSERTR = Messages.gettext("Insert a row"); + public static final String REMOVER = Messages.gettext("Remove rows"); + public static final String INSERTC = Messages.gettext("Insert a column"); + public static final String REMOVEC = Messages.gettext("Remove columns"); + + public static final String PLOTSELECTION = Messages.gettext("Plot the selection"); + public static final String PLOTALL = Messages.gettext("Plot the matrix"); + + public static final String CANCEL = Messages.gettext("Cancel"); + public static final String OK = Messages.gettext("Ok"); + public static final String CREATEVAR = Messages.gettext("Create variable from selection"); + public static final String VARNAME = Messages.gettext("Variable name"); + public static final String CREATENEWVAR = Messages.gettext("Create new variable"); + public static final String DUPLICATE = Messages.gettext("Duplicate the variable"); + public static final String EXPORTCSV = Messages.gettext("Export to CSV"); + public static final String EXPORTSELECTIONCSV = Messages.gettext("Export the selection to CSV"); + public static final String NUMROWS = Messages.gettext("Rows number"); + public static final String NUMCOLS = Messages.gettext("Columns number"); + public static final String FILLWITH = Messages.gettext("Fill with"); + + public static final String FILE_BROWSER = Messages.gettext("File Browser"); + public static final String NAME_COLUMN = Messages.gettext("Name"); + public static final String SIZE_COLUMN = Messages.gettext("Size"); + public static final String TYPE_COLUMN = Messages.gettext("Type"); + public static final String LASTMODIF_COLUMN = Messages.gettext("Last modified"); + public static final String DIRECTORY = Messages.gettext("Directory"); + public static final String FILETYPE = Messages.gettext("%s File"); + public static final String FILEFILTER = Messages.gettext("File/directory filter"); + public static final String CWD = Messages.gettext("Enter your working folder"); + public static final String CASESENSITIVE = Messages.gettext("Case sensitive"); + public static final String REGEXP = Messages.gettext("Regular expression"); + public static final String SELECTADIR = Messages.gettext("Select a directory"); + public static final String USERHOME = Messages.gettext("Home"); + public static final String SCIFOLDER = Messages.gettext("Scilab"); + + public static final String CANNOTREAD = Messages.gettext("Cannot edit the file %s"); + public static final String CANNOTOPEN = Messages.gettext("Cannot open the file %s"); + + public static final String OPENINSCINOTES = Messages.gettext("Open with SciNotes"); + public static final String EXECINCONSOLE = Messages.gettext("Execute in Scilab"); + public static final String OPENINXCOS = Messages.gettext("Open with Xcos"); + public static final String LOADINSCILAB = Messages.gettext("Load in Scilab"); + public static final String EDITWITHDEFAULT = Messages.gettext("Edit with default application"); + public static final String OPENWITHDEFAULT = Messages.gettext("Open with default application"); + + public static final String PREVIOUSDIR = Messages.gettext("Previous directory"); + public static final String NEXTDIR = Messages.gettext("Next directory"); + public static final String PARENTDIR = Messages.gettext("Parent directory"); + public static final String SELECTDIR = Messages.gettext("Select a directory"); + public static final String RUNFILTER = Messages.gettext("Run filter"); + + /** This class is a static singleton, thus it must not be instantiated */ + private UiDataMessages() { } + + + + // CSON: JavadocVariable + // CSON: LineLength + // CSON: MultipleStringLiterals + + /** + * This function checks for the popup menu activation under MacOS with Java version 1.5 + * Related to Scilab bug #5190 + * @param e Click event + * @return true if Java 1.5 and MacOS and mouse clic and ctrl activated + */ + public static boolean isMacOsPopupTrigger(MouseEvent e) { + return (SwingUtilities.isLeftMouseButton(e) + && e.isControlDown() + && (System.getProperty("os.name").toLowerCase().indexOf("mac") != -1) && (System.getProperty("java.specification.version").equals("1.5"))); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/ScilabVariableBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/ScilabVariableBrowser.java new file mode 100755 index 000000000..5409af833 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/ScilabVariableBrowser.java @@ -0,0 +1,160 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.variablebrowser; + +import javax.swing.SwingUtilities; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; +import org.scilab.modules.gui.tabfactory.ScilabTabFactory; +import org.scilab.modules.gui.textbox.ScilabTextBox; +import org.scilab.modules.gui.textbox.TextBox; +import org.scilab.modules.gui.utils.ClosingOperationsManager; +import org.scilab.modules.gui.utils.WindowsConfigurationManager; +import org.scilab.modules.gui.window.ScilabWindow; +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.ui_data.tabfactory.VariableBrowserTab; +import org.scilab.modules.ui_data.tabfactory.VariableBrowserTabFactory; +import org.scilab.modules.ui_data.utils.UiDataMessages; + +/** + * + * Class ScilabVariableBrowser + * Implements a ScilabWindow containing Variable Browser (JTable) + * + */ +public final class ScilabVariableBrowser implements VariableBrowser { + + private static ScilabVariableBrowser instance; + private static SwingScilabVariableBrowser browserTab; + + static { + ScilabTabFactory.getInstance().addTabFactory(VariableBrowserTabFactory.getInstance()); + } + + /** + * Constructor + * @param columnNames the columns title. + */ + private ScilabVariableBrowser() { + TextBox infobar = ScilabTextBox.createTextBox(); + browserTab = new SwingScilabVariableBrowser(BrowseVar.COLUMNNAMES, BrowseVar.COLUMNSALIGNMENT); + browserTab.addInfoBar(infobar); + browserTab.setTitle(UiDataMessages.VARIABLE_BROWSER); + } + + public static SwingScilabVariableBrowser createVarBrowserTab() { + if (instance == null) { + instance = new ScilabVariableBrowser(); + } + + return browserTab; + } + + /** + * @return true if an instance of BrowseVar already exists. + */ + public static boolean isBrowseVarOpened() { + return instance != null; + } + + /** + * Opens Variable Browser + * @return the Variable Browser + */ + public static VariableBrowser openVariableBrowser() { + if (instance == null) { + boolean success = WindowsConfigurationManager.restoreUUID(SwingScilabVariableBrowser.VARBROWSERUUID); + if (!success) { + VariableBrowserTab.getVariableBrowserInstance(); + SwingScilabWindow window = SwingScilabWindow.createWindow(true); + window.addTab(browserTab); + window.setLocation(0, 0); + window.setSize(500, 500); + window.setVisible(true); + window.toFront(); + } + } + return instance; + } + + /** + * Set Variable Browser data + * @param data : data from scilab (type, name, size, ...) + */ + public static void setVariableBrowserData(final Object[][] data) { + if (instance != null) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (instance != null) { + instance.setData(data); + } + } + }); + } + } + + /** + * Update Variable Browser window + */ + public static void updateVariableBrowser() { + if (instance != null) { + SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, browserTab); + window.repaint(); + } + } + + /** + * Close Variable Browser + */ + public static void closeVariableBrowser() { + if (instance != null) { + instance = null; + } + } + + /** + * Get the variable browser singleton + * @return the Variable Browser + */ + public static VariableBrowser getVariableBrowser() { + return instance; + } + + /** + * Close Variable Browser + */ + public void close() { + ClosingOperationsManager.startClosingOperationWithoutSave((SwingScilabDockablePanel) browserTab); + } + + /** + * Set data displayed in JTable + * @param data : data to be displayed in JTable + */ + public void setData(Object[][] data) { + browserTab.setData(data); + } + + + public void updateRowFiltering() { + browserTab.updateRowFiltering(); + } + + /** + * {@inheritDoc} + */ + public void setVisible(boolean status) { + //super.setVisible(status); + browserTab.setVisible(status); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SimpleVariableBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SimpleVariableBrowser.java new file mode 100755 index 000000000..747c69165 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SimpleVariableBrowser.java @@ -0,0 +1,36 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.variablebrowser; + +/** + * Interface for Variable browser. + */ +public interface SimpleVariableBrowser { + + /** + * Set columns title + * @param columnNames : the columns Title + */ + void setColumnNames(String[] columnNames); + + /** + * Set data to be displayed + * @param data : the data displayed in JTable + */ + void setData(Object[][] data); + + /** + * Update the row filtering + */ + void updateRowFiltering(); + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SwingScilabVariableBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SwingScilabVariableBrowser.java new file mode 100755 index 000000000..2617b0449 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/SwingScilabVariableBrowser.java @@ -0,0 +1,681 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * Copyright (C) 2011 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.variablebrowser; + +import static org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.asynchronousScilabExec; + +import java.awt.Color; +import java.awt.MouseInfo; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement; +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.bridge.toolbar.SwingScilabToolBar; +import org.scilab.modules.gui.bridge.contextmenu.SwingScilabContextMenu; +import org.scilab.modules.gui.contextmenu.ContextMenu; +import org.scilab.modules.gui.contextmenu.ScilabContextMenu; +import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem; +import org.scilab.modules.gui.menu.Menu; +import org.scilab.modules.gui.menu.ScilabMenu; +import org.scilab.modules.gui.menubar.MenuBar; +import org.scilab.modules.gui.menubar.ScilabMenuBar; +import org.scilab.modules.gui.messagebox.ScilabModalDialog; +import org.scilab.modules.gui.messagebox.ScilabModalDialog.IconType; +import org.scilab.modules.gui.textbox.TextBox; +import org.scilab.modules.gui.toolbar.ScilabToolBar; +import org.scilab.modules.gui.toolbar.ToolBar; +import org.scilab.modules.gui.utils.WindowsConfigurationManager; +import org.scilab.modules.localization.Messages; +import org.scilab.modules.types.ScilabTypeEnum; +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.ui_data.actions.BooleanFilteringAction; +import org.scilab.modules.ui_data.actions.CompiledFunctionFilteringAction; +import org.scilab.modules.ui_data.actions.DoubleFilteringAction; +import org.scilab.modules.ui_data.actions.FunctionLibFilteringAction; +import org.scilab.modules.ui_data.actions.GraphicHandlesFilteringAction; +import org.scilab.modules.ui_data.actions.HelpAction; +import org.scilab.modules.ui_data.actions.ImplicitPolynomialFilteringAction; +import org.scilab.modules.ui_data.actions.IntegerFilteringAction; +import org.scilab.modules.ui_data.actions.IntrinsicFunctionFilteringAction; +import org.scilab.modules.ui_data.actions.ListFilteringAction; +import org.scilab.modules.ui_data.actions.MListFilteringAction; +import org.scilab.modules.ui_data.actions.MatlabSparseFilteringAction; +import org.scilab.modules.ui_data.actions.PointerFilteringAction; +import org.scilab.modules.ui_data.actions.PolynomialFilteringAction; +import org.scilab.modules.ui_data.actions.ScilabVarFilteringAction; +import org.scilab.modules.ui_data.actions.ScilabVarFilteringButtonAction; +import org.scilab.modules.ui_data.actions.SparseBoolFilteringAction; +import org.scilab.modules.ui_data.actions.SparseFilteringAction; +import org.scilab.modules.ui_data.actions.StringFilteringAction; +import org.scilab.modules.ui_data.actions.TListFilteringAction; +import org.scilab.modules.ui_data.actions.UncompiledFunctionFilteringAction; +import org.scilab.modules.ui_data.datatable.SwingTableModel; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.actions.ExportToCsvAction; +import org.scilab.modules.ui_data.variableeditor.actions.PlotAction; +import org.scilab.modules.ui_data.variablebrowser.actions.CloseAction; +import org.scilab.modules.ui_data.variablebrowser.actions.DeleteAction; +import org.scilab.modules.ui_data.variablebrowser.actions.ModifyAction; +import org.scilab.modules.ui_data.variablebrowser.actions.RefreshAction; +import org.scilab.modules.ui_data.variablebrowser.rowfilter.VariableBrowserRowDataFilter; +import org.scilab.modules.ui_data.variablebrowser.rowfilter.VariableBrowserRowTypeFilter; + +/** + * Swing implementation of Scilab Variable browser + * uses JTable + */ +public final class SwingScilabVariableBrowser extends SwingScilabDockablePanel implements SimpleVariableBrowser { + + public static final String VARBROWSERUUID = "3b649047-6a71-4998-bd8e-00d367a4793c"; + + private static final long serialVersionUID = 2169382559550113917L; + + private SwingTableModel<Object> dataModel; + private JTable table; + + private MenuBar menuBar; + private Menu fileMenu; + private Menu helpMenu; + private Menu filterMenu; + private CheckBoxMenuItem filterDoubleCheckBox; + private CheckBoxMenuItem filterPolynomialCheckBox; + private CheckBoxMenuItem filterScilabVarCheckBox; + private CheckBoxMenuItem filterBooleanCheckBox; + private CheckBoxMenuItem filterSparseCheckBox; + private CheckBoxMenuItem filterSparseBoolCheckBox; + private CheckBoxMenuItem filterIntegerCheckBox; + private CheckBoxMenuItem filterGraphicHandlesCheckBox; + private CheckBoxMenuItem filterStringCheckBox; + private CheckBoxMenuItem filterUncompiledFuncCheckBox; + private CheckBoxMenuItem filtercompiledFuncCheckBox; + private CheckBoxMenuItem filterFunctionLibCheckBox; + private CheckBoxMenuItem filterListCheckBox; + private CheckBoxMenuItem filterTListCheckBox; + private CheckBoxMenuItem filterMListCheckBox; + private CheckBoxMenuItem filterPointerCheckBox; + private CheckBoxMenuItem filterIntrinsicFunctionCheckBox; + private CheckBoxMenuItem filterMatlabSparseCheckBox; + private CheckBoxMenuItem filterImplicitPolynomialCheckBox; + private JButton filteringButton; + + private boolean isSetData = false; + + private TableRowSorter < ? > rowSorter; + + /** + * Create a JTable with data Model. + * @param columnsName : Titles of JTable columns. + */ + public SwingScilabVariableBrowser(String[] columnsName, int[] aligment) { + super(UiDataMessages.VARIABLE_BROWSER, VARBROWSERUUID); + + setAssociatedXMLIDForHelp("browsevar"); + + buildMenuBar(); + addMenuBar(menuBar); + + ToolBar toolBar = ScilabToolBar.createToolBar(); + SwingScilabToolBar stb = (SwingScilabToolBar) toolBar.getAsSimpleToolBar(); + stb.add(RefreshAction.createButton(UiDataMessages.REFRESH)); + stb.addSeparator(); + stb.add(ModifyAction.createButton(this, UiDataMessages.MODIFY)); + stb.add(DeleteAction.createButton(this, UiDataMessages.DELETE)); + stb.addSeparator(); + stb.add(HelpAction.createButton(UiDataMessages.HELP)); + filteringButton = ScilabVarFilteringButtonAction.createButton("Show/hide Scilab variable"); + // toolBar.add(filteringButton); + addToolBar(toolBar); + + dataModel = new SwingTableModel<Object>(columnsName); + + table = new JTable(dataModel) { + //Implement table cell tool tips. + public String getToolTipText(MouseEvent e) { + String tip = null; + TableModel model = ((JTable) e.getSource()).getModel(); + java.awt.Point p = e.getPoint(); + int rowIndex = rowAtPoint(p); + + if (rowIndex >= 0) { + rowIndex = convertRowIndexToModel(rowIndex); + int colIndex = columnAtPoint(p); + if (colIndex == BrowseVar.TYPE_DESC_COLUMN_INDEX) { /* Scilab type */ + try { + tip = Messages.gettext("Scilab type:") + " " + model.getValueAt(rowIndex, BrowseVar.TYPE_COLUMN_INDEX).toString(); + } catch (IllegalArgumentException exception) { + /* If the type is not known/managed, don't crash */ + } + } else { + + if (colIndex == BrowseVar.SIZE_COLUMN_INDEX) { + /* Use the getModel() method because the + * column 5 has been removed from display + * but still exist in the model */ + tip = Messages.gettext("Bytes:") + " " + model.getValueAt(rowIndex, BrowseVar.BYTES_COLUMN_INDEX).toString(); + } + } + } + return tip; + } + }; + + table.setFillsViewportHeight(true); + table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + table.setAutoCreateRowSorter(true); + + /* Size of the icon column */ + table.getColumnModel().getColumn(0).setPreferredWidth(30); + + /* Hide the columns. But keep it in memory for the tooltip */ + TableColumn column = table.getColumnModel().getColumn(BrowseVar.NB_COLS_INDEX); + table.removeColumn(column); + + /* The order to removing does matter since it changes the positions */ + + column = table.getColumnModel().getColumn(BrowseVar.NB_ROWS_INDEX); + table.removeColumn(column); + + column = table.getColumnModel().getColumn(BrowseVar.TYPE_COLUMN_INDEX); + table.removeColumn(column); + + column = table.getColumnModel().getColumn(BrowseVar.FROM_SCILAB_COLUMN_INDEX); + table.removeColumn(column); + + column = table.getColumnModel().getColumn(BrowseVar.BYTES_COLUMN_INDEX); + table.removeColumn(column); + + table.addMouseListener(new BrowseVarMouseListener()); + // Mouse selection mode + table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table.setCellSelectionEnabled(true); + + table.setBackground(Color.WHITE); + if (table.getGridColor().equals(Color.WHITE)) { + table.setGridColor(new Color(128, 128, 128)); + } + table.setShowHorizontalLines(true); + table.setShowVerticalLines(true); + + for (int i = 0; i < aligment.length; i++) { + align(table, columnsName[i], aligment[i]); + } + + // Plug the shortcuts + ExportToCsvAction.registerAction(this, table); + + JScrollPane scrollPane = new JScrollPane(table); + setContentPane(scrollPane); + WindowsConfigurationManager.restorationFinished(this); + } + + /** + * {@inheritDoc} + */ + public void addInfoBar(TextBox infoBarToAdd) { + setInfoBar(infoBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void addMenuBar(MenuBar menuBarToAdd) { + setMenuBar(menuBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void addToolBar(ToolBar toolBarToAdd) { + setToolBar(toolBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void setColumnNames(String[] columnNames) { + dataModel.setColumnNames(columnNames); + } + + /** + * {@inheritDoc} + */ + public void setData(Object[][] data) { + isSetData = true; + dataModel.setData(data); + rowSorter = new TableRowSorter<TableModel>(dataModel); + this.updateRowFiltering(); + } + + private static void align(JTable table, String name, int alignment) { + if (alignment != -1) { + DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); + renderer.setHorizontalAlignment(alignment); + try { + TableColumn col = table.getColumn(name); + if (col != null) { + col.setCellRenderer(renderer); + } + } catch (IllegalArgumentException e) { } + } + } + + /** + * Update the display after filtering + * @see org.scilab.modules.ui_data.variablebrowser.SimpleVariableBrowser#updateRowFiltering() + */ + public void updateRowFiltering() { + if (isSetData == false) { /* If the pull of the data has not been done, do it (please) */ + try { + ScilabInterpreterManagement.synchronousScilabExec("browsevar"); + isSetData = true; + } catch (InterpreterException e) { + System.err.println(e); + } + } + VariableBrowserRowTypeFilter rowTypeFilter = new VariableBrowserRowTypeFilter(getFilteredTypeValues()); + VariableBrowserRowDataFilter rowDataFilter = new VariableBrowserRowDataFilter(getFilteredDataValues()); + + List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(); + RowFilter<Object, Object> compoundRowFilter = null; + filters.add(rowTypeFilter); + filters.add(rowDataFilter); + compoundRowFilter = RowFilter.andFilter(filters); + + rowSorter.setRowFilter(compoundRowFilter); + table.setRowSorter(rowSorter); + } + + /** + * MouseListener inner class + */ + private class BrowseVarMouseListener implements MouseListener { + + /** + * Contructor + */ + public BrowseVarMouseListener() { + + } + + /** + * Mouse CLICKED event handling + * @param e the event + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + */ + public void mouseClicked(MouseEvent e) { + + // Right click management + if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e)) || e.isPopupTrigger()) { + + + int clickedRow = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); + // Does nothing if no variable selected + if (clickedRow != -1) { + // Right click ? We force the selection of the current row + table.setRowSelectionInterval(clickedRow, clickedRow); + table.setEditingRow(clickedRow); + + displayContextMenu(); + } + } + + if (e.getClickCount() >= 2) { + int clickedRow = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); + if (clickedRow != -1) { + String variableName = table.getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString(); + + String variableVisibility = ((JTable) e.getSource()) + .getValueAt(((JTable) e.getSource()).getSelectedRow(), BrowseVar.VISIBILITY_COLUMN_INDEX).toString(); + SwingScilabVariableBrowser.this.startEditVar(variableVisibility, variableName); + } + } + } + + /** + * Mouse ENTERED event handling + * @param e the event + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + */ + public void mouseEntered(MouseEvent e) { + } + + /** + * Mouse EXITED event handling + * @param e the event + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + */ + public void mouseExited(MouseEvent e) { + } + + /** + * Mouse PRESSED event handling + * @param e the event + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + */ + public void mousePressed(MouseEvent e) { + } + + /** + * Mouse RELEASED event handling + * @param e the event + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + */ + public void mouseReleased(MouseEvent e) { + + } + + /** + * Create and display the context menu + */ + private void displayContextMenu() { + ContextMenu menu = ScilabContextMenu.createContextMenu(); + ModifyAction modify = new ModifyAction(SwingScilabVariableBrowser.this); + menu.add(modify.createMenuItem()); + + DeleteAction delete = new DeleteAction(SwingScilabVariableBrowser.this); + menu.add(delete.createMenuItem()); + + menu.add(ExportToCsvAction.createMenuItem(SwingScilabVariableBrowser.this, UiDataMessages.EXPORTCSV)); + + Menu menuPlot = ScilabMenu.createMenu(); + menuPlot.setText(UiDataMessages.PLOTALL); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "plot2d", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "Matplot", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "grayplot", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "Sgrayplot", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "champ", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "histplot", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "mesh", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "surf", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "hist3d", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "contour2d", false)); + menuPlot.add(PlotAction.createMenuItem((SwingScilabDockablePanel)SwingScilabVariableBrowser.this, "pie", false)); + menu.add(menuPlot); + + menu.setVisible(true); + + ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation( + MouseInfo.getPointerInfo().getLocation().x, + MouseInfo.getPointerInfo().getLocation().y); + + } + + + } + + /** + * Creates the menuBar + */ + public void buildMenuBar() { + menuBar = ScilabMenuBar.createMenuBar(); + + fileMenu = ScilabMenu.createMenu(); + fileMenu.setText(UiDataMessages.FILE); + fileMenu.setMnemonic('F'); + fileMenu.add(RefreshAction.createMenuItem(UiDataMessages.REFRESH)); + fileMenu.addSeparator(); + fileMenu.add(CloseAction.createMenu()); + + menuBar.add(fileMenu); + + filterMenu = ScilabMenu.createMenu(); + filterMenu.setText(UiDataMessages.FILTER); + filterMenu.setMnemonic('I'); + + filterScilabVarCheckBox = ScilabVarFilteringAction.createCheckBoxMenu(); + filterScilabVarCheckBox.setChecked(true); + filterMenu.add(filterScilabVarCheckBox); + + filterMenu.addSeparator(); + + filterBooleanCheckBox = BooleanFilteringAction.createCheckBoxMenu(); + filterBooleanCheckBox.setChecked(true); + filterMenu.add(filterBooleanCheckBox); + + filterDoubleCheckBox = DoubleFilteringAction.createCheckBoxMenu(); + filterDoubleCheckBox.setChecked(true); + filterMenu.add(filterDoubleCheckBox); + + filterPolynomialCheckBox = PolynomialFilteringAction.createCheckBoxMenu(); + filterPolynomialCheckBox.setChecked(true); + filterMenu.add(filterPolynomialCheckBox); + + filterFunctionLibCheckBox = FunctionLibFilteringAction.createCheckBoxMenu(); + filterMenu.add(filterFunctionLibCheckBox); + + filterStringCheckBox = StringFilteringAction.createCheckBoxMenu(); + filterStringCheckBox.setChecked(true); + filterMenu.add(filterStringCheckBox); + + filterSparseCheckBox = SparseFilteringAction.createCheckBoxMenu(); + filterSparseCheckBox.setChecked(true); + filterMenu.add(filterSparseCheckBox); + + filterSparseBoolCheckBox = SparseBoolFilteringAction.createCheckBoxMenu(); + filterSparseBoolCheckBox.setChecked(true); + filterMenu.add(filterSparseBoolCheckBox); + + filterIntegerCheckBox = IntegerFilteringAction.createCheckBoxMenu(); + filterIntegerCheckBox.setChecked(true); + filterMenu.add(filterIntegerCheckBox); + + filterGraphicHandlesCheckBox = GraphicHandlesFilteringAction.createCheckBoxMenu(); + filterGraphicHandlesCheckBox.setChecked(true); + filterMenu.add(filterGraphicHandlesCheckBox); + + filterUncompiledFuncCheckBox = UncompiledFunctionFilteringAction.createCheckBoxMenu(); + filterMenu.add(filterUncompiledFuncCheckBox); + + filtercompiledFuncCheckBox = CompiledFunctionFilteringAction.createCheckBoxMenu(); + filterMenu.add(filtercompiledFuncCheckBox); + + filterListCheckBox = ListFilteringAction.createCheckBoxMenu(); + filterListCheckBox.setChecked(true); + filterMenu.add(filterListCheckBox); + + filterTListCheckBox = TListFilteringAction.createCheckBoxMenu(); + filterTListCheckBox.setChecked(true); + filterMenu.add(filterTListCheckBox); + + filterMListCheckBox = MListFilteringAction.createCheckBoxMenu(); + filterMListCheckBox.setChecked(true); + filterMenu.add(filterMListCheckBox); + + filterPointerCheckBox = PointerFilteringAction.createCheckBoxMenu(); + filterPointerCheckBox.setChecked(true); + filterMenu.add(filterPointerCheckBox); + + filterIntrinsicFunctionCheckBox = IntrinsicFunctionFilteringAction.createCheckBoxMenu(); + filterMenu.add(filterIntrinsicFunctionCheckBox); + + filterMatlabSparseCheckBox = MatlabSparseFilteringAction.createCheckBoxMenu(); + filterMenu.add(filterMatlabSparseCheckBox); + + filterImplicitPolynomialCheckBox = ImplicitPolynomialFilteringAction.createCheckBoxMenu(); + filterMenu.add(filterImplicitPolynomialCheckBox); + + menuBar.add(filterMenu); + + helpMenu = ScilabMenu.createMenu(); + helpMenu.setText("?"); + helpMenu.setMnemonic('?'); + helpMenu.add(HelpAction.createMenuItem(UiDataMessages.HELP)); + menuBar.add(helpMenu); + } + + + /** + * Filter management of data (Scilab or user data) + * @return the set of filtered values + */ + public boolean getFilteredDataValues() { + return filterScilabVarCheckBox.isChecked(); + + } + + /** + * Filter management of type + * @return the set of filtered values + */ + public HashSet<ScilabTypeEnum> getFilteredTypeValues() { + HashSet<ScilabTypeEnum> filteredValues = new HashSet<ScilabTypeEnum>(); + // TODO to replace later by something which smells less + if (!filterBooleanCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_boolean); + } + + if (!filterDoubleCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_matrix); + } + + if (!filterFunctionLibCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_lib); + } + + if (!filterStringCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_strings); + } + + if (!filterPolynomialCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_poly); + } + + if (!filterSparseCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_sparse); + } + + if (!filterSparseBoolCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_boolean_sparse); + } + + if (!filterIntegerCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_ints); + } + + if (!filterGraphicHandlesCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_handles); + } + + if (!filterUncompiledFuncCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_u_function); + } + + if (!filtercompiledFuncCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_c_function); + } + + if (!filterListCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_list); + } + + if (!filterTListCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_tlist); + } + + if (!filterMListCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_mlist); + } + + if (!filterPointerCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_pointer); + } + + if (!filterIntrinsicFunctionCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_intrinsic_function); + } + + if (!filterMatlabSparseCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_matlab_sparse); + } + + if (!filterImplicitPolynomialCheckBox.isChecked()) { + filteredValues.add(ScilabTypeEnum.sci_implicit_poly); + } + + return filteredValues; + } + + /** + * Get this browser as a Tab object + * @return the tab + */ + public SwingScilabDockablePanel getBrowserTab() { + return this; + } + + + /** + * Return the variable Browser Table + * @return The variable Browser Table + */ + public JTable getTable() { + return table; + } + + /** + * Start the variable editor + * + * @param variableVisibility the visibility of the variable + * @param variableName The variable name + */ + public void startEditVar(String variableVisibility, String variableName) { + // Global variables are not editable yet + if (variableVisibility.equals("global")) { + ScilabModalDialog.show(getBrowserTab(), + UiDataMessages.GLOBAL_NOT_EDITABLE, + UiDataMessages.VARIABLE_EDITOR, + IconType.ERROR_ICON); + return; + } + + try { + asynchronousScilabExec(null, + "if exists(\"" + variableName + "\") == 1 then " + + " try " + + " editvar(\"" + variableName + "\"); " + + " catch " + + " messagebox(\"Variables of type \"\"\" + typeof (" + + variableName + ") + \"\"\" can not be edited.\"" + + ",\"" + UiDataMessages.VARIABLE_EDITOR + "\", \"error\", \"modal\");" + + " clear ans;" // clear return value of messagebox + + " end " + + "else " + + " messagebox(\"Variable \"\"" + + variableName + "\"\" no more exists.\"" + + ",\"" + UiDataMessages.VARIABLE_EDITOR + "\", \"error\", \"modal\");" + + " clear ans;" // clear return value of messagebox + + " browsevar();" // Reload browsevar to remove cleared variables + + "end"); + } catch (InterpreterException e1) { + System.err.println("An error in the interpreter has been catched: " + e1.getLocalizedMessage()); + } + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/VariableBrowser.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/VariableBrowser.java new file mode 100755 index 000000000..02ec58f2f --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/VariableBrowser.java @@ -0,0 +1,37 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.variablebrowser; + +/** + * Variable browser Interface + * Describes actions exposed to scilab. + * + */ +public interface VariableBrowser { + + /** + * Close Variable Browser. + */ + void close(); + + /** + * Set Data stored in JTable. + * @param data : the data to be displayed. + */ + void setData(Object[][] data); + + /** + * Update row filtering + */ + void updateRowFiltering(); + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/CloseAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/CloseAction.java new file mode 100755 index 000000000..044fcaca4 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/CloseAction.java @@ -0,0 +1,52 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * Copyright (C) 2010 - Allan Simon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variablebrowser.actions; + +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.ui_data.actions.DefaultAction; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variablebrowser.ScilabVariableBrowser; + +@SuppressWarnings(value = { "serial" }) +public class CloseAction extends DefaultAction { + + /** Name of the action */ + public static final String NAME = UiDataMessages.CLOSE; + /** Icon name of the action */ + public static final String SMALL_ICON = ""; + /** Mnemonic key of the action */ + public static final int MNEMONIC_KEY = KeyEvent.VK_W; + /** Accelerator key for the action */ + public static final int ACCELERATOR_KEY = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + + + /** + * Menu for diagram menubar + * @param scilabGraph associated diagram + * @return the menu + */ + public static MenuItem createMenu() { + return createMenu(new CloseAction()); + } + + + @Override + public void actionPerformed(ActionEvent e) { + ScilabVariableBrowser.getVariableBrowser().close(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/DeleteAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/DeleteAction.java new file mode 100755 index 000000000..ace119be6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/DeleteAction.java @@ -0,0 +1,106 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * Copyright (C) 2013 - S/E - Sylvestre Ledru + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variablebrowser.actions; + +import static org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.asynchronousScilabExec; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variablebrowser.SwingScilabVariableBrowser; + +/** + * Manage Delete Actions + * @author Vincent COUVERT + */ +public final class DeleteAction extends CommonCallBack { + + private static final long serialVersionUID = 1L; + + private static ImageIcon icon = new ImageIcon(FindIconHelper.findIcon("edit-delete")); + + private static final char MNEMONIC = 'D'; + + private static final String KEY = "DELETE"; + private static final String SUPPR = "Suppr"; + + private final SwingScilabVariableBrowser variableBrowser; + + /** + * Constructor + */ + public DeleteAction(SwingScilabVariableBrowser variableBrowser) { + super(""); + this.variableBrowser = variableBrowser; + } + + /** + * Create a button for a tool bar + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableBrowser variableBrowser, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new DeleteAction(variableBrowser)); + button.setToolTipText(title); + button.setIcon(icon); + + return button; + } + + /** + * Create the associated menu + * @return the menu + */ + public MenuItem createMenuItem() { + MenuItem menuItem = ScilabMenuItem.createMenuItem(); + menuItem.setText(UiDataMessages.DELETE + " '" + getSelectedVariable() + "'"); + menuItem.setMnemonic(MNEMONIC); + menuItem.setCallback(this); + ((SwingScilabMenuItem) menuItem.getAsSimpleMenuItem()).setIcon(icon); + return menuItem; + } + + /** + * Action! + * @see org.scilab.modules.gui.events.callback.CallBack#callBack() + */ + @Override + public void callBack() { + try { + asynchronousScilabExec(null, "clear('" + getSelectedVariable() + "'); updatebrowsevar()"); + } catch (InterpreterException e1) { + System.err.println("An error in the interpreter has been catched: " + e1.getLocalizedMessage()); + } + } + + private String getSelectedVariable() { + int clickedRow = variableBrowser.getTable().getSelectedRow(); + // Does nothing if no variable selected + if (clickedRow != -1) { + return variableBrowser.getTable().getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString(); + } + return ""; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/ModifyAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/ModifyAction.java new file mode 100755 index 000000000..12188f116 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/ModifyAction.java @@ -0,0 +1,108 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * Copyright (C) 2013 - S/E - Sylvestre Ledru + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variablebrowser.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variablebrowser.SwingScilabVariableBrowser; + +/** + * Manage Modify Actions + * @author Vincent COUVERT + */ +public final class ModifyAction extends CommonCallBack { + + private static final long serialVersionUID = 1L; + + private static ImageIcon icon = new ImageIcon(FindIconHelper.findIcon("rrze_table")); + + private static final char MNEMONIC = 'M'; + + private static final String KEY = "MODIFY"; + // private static final String SUPPR = "Suppr"; + + private final SwingScilabVariableBrowser variableBrowser; + + /** + * Constructor + */ + public ModifyAction(SwingScilabVariableBrowser variableBrowser) { + super(""); + this.variableBrowser = variableBrowser; + } + + /** + * Create a button for a tool bar + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableBrowser variableBrowser, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new ModifyAction(variableBrowser)); + button.setToolTipText(title); + button.setIcon(icon); + + return button; + } + + /** + * Create the associated menu + * @return the menu + */ + public MenuItem createMenuItem() { + MenuItem menuItem = ScilabMenuItem.createMenuItem(); + menuItem.setText(UiDataMessages.MODIFY + " '" + getSelectedVariable() + "'"); + menuItem.setMnemonic(MNEMONIC); + menuItem.setCallback(this); + ((SwingScilabMenuItem) menuItem.getAsSimpleMenuItem()).setIcon(icon); + return menuItem; + } + + /** + * Action! + * @see org.scilab.modules.gui.events.callback.CallBack#callBack() + */ + @Override + public void callBack() { + variableBrowser.startEditVar(getSelectedVariableVisibility(), getSelectedVariable()); + } + + private String getSelectedVariable() { + int clickedRow = variableBrowser.getTable().getSelectedRow(); + // Does nothing if no variable selected + if (clickedRow != -1) { + return variableBrowser.getTable().getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString(); + } + return ""; + } + + private String getSelectedVariableVisibility() { + int clickedRow = variableBrowser.getTable().getSelectedRow(); + // Does nothing if no variable selected + if (clickedRow != -1) { + return variableBrowser.getTable().getValueAt(clickedRow, BrowseVar.VISIBILITY_COLUMN_INDEX).toString(); + } + return ""; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/RefreshAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/RefreshAction.java new file mode 100755 index 000000000..d7722fe3e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/actions/RefreshAction.java @@ -0,0 +1,92 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variablebrowser.actions; + +import java.awt.Toolkit; +import java.awt.event.KeyEvent; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement; +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class RefreshAction extends CommonCallBack { + + /** Mnemonic key of the action */ + public static final int MNEMONIC_KEY = KeyEvent.VK_W; + /** Accelerator key for the action */ + public static final int ACCELERATOR_KEY = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + + private static ImageIcon icon = new ImageIcon(FindIconHelper.findIcon("view-refresh")); + + /** + * Constructor + * @param name the name of the action + */ + public RefreshAction(String name) { + super(name); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + try { + ScilabInterpreterManagement.asynchronousScilabExec(null, "browsevar"); + } catch (InterpreterException e) { + System.err.println(e); + } + } + + /** + * Create a button for a tool bar + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new RefreshAction(title)); + button.setToolTipText(title); + button.setIcon(icon); + + return button; + } + + /** + * Create the menu for the menubar + * @param label the menu label + * @return the menu + */ + public static MenuItem createMenuItem(String label) { + MenuItem menuItem = ScilabMenuItem.createMenuItem(); + menuItem.setText(label); + SwingScilabMenuItem swingItem = (SwingScilabMenuItem) menuItem.getAsSimpleMenuItem(); + swingItem.setCallback(new RefreshAction(label)); + swingItem.setIcon(icon); + return menuItem; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/rowfilter/VariableBrowserRowDataFilter.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/rowfilter/VariableBrowserRowDataFilter.java new file mode 100755 index 000000000..1ae5a2453 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/rowfilter/VariableBrowserRowDataFilter.java @@ -0,0 +1,43 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Sylvestre LEDRU + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variablebrowser.rowfilter; + +import javax.swing.RowFilter; + +import org.scilab.modules.ui_data.BrowseVar; + +public class VariableBrowserRowDataFilter extends RowFilter<Object, Object> { + + // private HashSet<Boolean> filteredValues = new HashSet<Boolean>(); + private Boolean filteredValues; + + public VariableBrowserRowDataFilter() { + super(); + } + + public VariableBrowserRowDataFilter(Boolean filteredValues) { + this.filteredValues = filteredValues; + } + + + @Override + public boolean include(Entry < ? extends Object, ? extends Object > entry) { + boolean currentRowVariableclassNumber = ((Boolean) entry.getValue(BrowseVar.FROM_SCILAB_COLUMN_INDEX)).booleanValue(); + if (filteredValues != currentRowVariableclassNumber && currentRowVariableclassNumber != true) { + return false; + } else { + return true; + } + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/rowfilter/VariableBrowserRowTypeFilter.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/rowfilter/VariableBrowserRowTypeFilter.java new file mode 100755 index 000000000..9063ea193 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variablebrowser/rowfilter/VariableBrowserRowTypeFilter.java @@ -0,0 +1,54 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Vincent COUVERT + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variablebrowser.rowfilter; + +import java.util.HashSet; + +import javax.swing.RowFilter; + +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.types.ScilabTypeEnum; + +public class VariableBrowserRowTypeFilter extends RowFilter<Object, Object> { + + private HashSet<ScilabTypeEnum> filteredValues; + + public VariableBrowserRowTypeFilter() { + super(); + filteredValues = new HashSet<ScilabTypeEnum>(); + } + + public VariableBrowserRowTypeFilter(HashSet<ScilabTypeEnum> filteredValues) { + this.filteredValues = filteredValues; + } + + @Override + public boolean include(Entry < ? extends Object, ? extends Object > entry) { + Integer currentRowVariableTypeNumber = (Integer) entry.getValue(BrowseVar.TYPE_COLUMN_INDEX); + + try { + if (filteredValues.contains(ScilabTypeEnum.swigToEnum(currentRowVariableTypeNumber))) { + return false; + } + } catch (IllegalArgumentException e) { + // This case should never occur + // But there is a bug in Scilab global variables type detection + // So we show these "unknown type" variables by default (See bug #7333) + return true; + } + + return true; + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/ScilabTabbedPane.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/ScilabTabbedPane.java new file mode 100755 index 000000000..c9d1dda0a --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/ScilabTabbedPane.java @@ -0,0 +1,386 @@ +/* + * Scilab (http://www.scilab.org/) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.io.IOException; + +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; + +import org.scilab.modules.gui.events.callback.CommonCallBack; + +/** + * Class for a tabbedpane with close-button + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabTabbedPane extends JTabbedPane implements DragGestureListener, + DragSourceListener, + DropTargetListener, + Transferable { + + private static final ImageIcon CLOSEICON = new ImageIcon(System.getenv("SCI") + "/modules/gui/images/icons/close-tab.png"); + private static final int BUTTONSIZE = 18; + + private static DataFlavor DATAFLAVOR; + private static ScilabTabbedPane currentWhenDragged; + + static { + try { + DATAFLAVOR = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + ";class=" + ScilabTabbedPane.class.getName()); + } catch (ClassNotFoundException e) { } + } + + private SwingScilabVariableEditor editor; + private int draggedIndex; + + /** + * Constructor + * @param editor the editor + */ + public ScilabTabbedPane(SwingScilabVariableEditor editor) { + super(); + this.editor = editor; + DragSource dragsource = DragSource.getDefaultDragSource(); + dragsource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this); + DropTarget droptarget = new DropTarget(this, this); + addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + if (getSelectedIndex() > 0) { + ((JScrollPane) getComponentAt(getSelectedIndex())).getViewport().getView().requestFocus(); + } + } + }); + } + + /** + * {@inheritDoc} + */ + public void insertTab(String title, Icon icon, Component component, String tip, int index) { + super.insertTab(title, icon, component, tip, index); + setTabComponentAt(index, new CloseTabButton(title)); + } + + /** + * {@inheritDoc} + */ + public Component add(String title, Component c) { + Component cc = super.add(title, c); + setTitleAt(getTabCount() - 1, title); + return cc; + } + + /** + * @param index the index of the tab + * @return the title of the tab + */ + public String getScilabTitleAt(int index) { + if (index != -1) { + CloseTabButton tab = (CloseTabButton) getTabComponentAt(index); + if (tab != null) { + return tab.getText(); + } + } + + return ""; + } + + /** + * {@inheritDoc} + */ + public String getTitleAt(int index) { + return ""; + } + + /** + * {@inheritDoc} + */ + public void setTitleAt(int index, String title) { + if (index != -1) { + CloseTabButton tab = (CloseTabButton) getTabComponentAt(index); + if (tab != null) { + tab.setText(title); + } + } + } + + /** + * Implements getTransferData in Transferable + * @param flavor to get + * @return the object to transfer + * @throws UnsupportedFlavorException for an unknown flavor + */ + public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { + if (!flavor.equals(DATAFLAVOR)) { + throw new UnsupportedFlavorException(flavor); + } + + return this; + } + + /** + * Implements getTransferDataFlavors in Transferable + * @return the supported flavors + */ + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] {DATAFLAVOR}; + } + + /** + * Implements isDataFlavorSupported in Transferable + * @param flavor to support + * @return true if the flavor is supported + */ + public boolean isDataFlavorSupported(DataFlavor flavor) { + return flavor.equals(DATAFLAVOR); + } + + /** + * Interface DropTargetListener + * {@inheritDoc} + */ + public void dragEnter(DropTargetDragEvent dtde) { + if (dtde.isDataFlavorSupported(DATAFLAVOR)) { + dtde.acceptDrag(DnDConstants.ACTION_MOVE); + Component c = dtde.getDropTargetContext().getComponent(); + if (c instanceof ScilabTabbedPane) { + currentWhenDragged = (ScilabTabbedPane) c; + } + } else { + dtde.rejectDrag(); + } + } + + /** + * Interface DropTargetListener + * {@inheritDoc} + */ + public void dragOver(DropTargetDragEvent dtde) { + if (dtde.isDataFlavorSupported(DATAFLAVOR)) { + dtde.acceptDrag(DnDConstants.ACTION_MOVE); + } else { + dtde.rejectDrag(); + } + } + + /** + * Interface DropTargetListener + * {@inheritDoc} + */ + public void drop(DropTargetDropEvent dtde) { + if (!dtde.isDataFlavorSupported(DATAFLAVOR) || dtde.getSourceActions() != DnDConstants.ACTION_MOVE) { + dtde.rejectDrop(); + } else { + try { + ScilabTabbedPane tabbedPane = (ScilabTabbedPane) dtde.getTransferable().getTransferData(DATAFLAVOR); + int index = indexAtLocation(dtde.getLocation().x, dtde.getLocation().y); + if (tabbedPane == this && index == tabbedPane.draggedIndex) { + dtde.rejectDrop(); + } else { + Component c = tabbedPane.getComponentAt(tabbedPane.draggedIndex); + String title = tabbedPane.getScilabTitleAt(tabbedPane.draggedIndex); + tabbedPane.remove(c); + if (index == -1) { + index = getTabCount(); + } + + insertTab(title, null, c, null, index); + + setSelectedIndex(index); + dtde.acceptDrop(DnDConstants.ACTION_MOVE); + } + } catch (IOException e) { + dtde.rejectDrop(); + } catch (UnsupportedFlavorException e) { + dtde.rejectDrop(); + } + } + } + + /** + * Interface DropTargetListener + * {@inheritDoc} + */ + public void dropActionChanged(DropTargetDragEvent dtde) { } + + /** + * Interface DropTargetListener + * {@inheritDoc} + */ + public void dragExit(DropTargetEvent dte) { } + + /** + * Interface DragSourceListener + * {@inheritDoc} + */ + public void dragDropEnd(DragSourceDropEvent dsde) { + dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop); + } + + /** + * Interface DragSourceListener + * {@inheritDoc} + */ + public void dragExit(DragSourceEvent dse) { + dse.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop); + } + + /** + * Interface DragSourceListener + * {@inheritDoc} + */ + public void dragOver(DragSourceDragEvent dsde) { + Point pt = new Point(dsde.getX(), dsde.getY()); + JRootPane rootpane = (JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class, currentWhenDragged); + + if (rootpane == null) { + dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop); + } else { + SwingUtilities.convertPointFromScreen(pt, rootpane); + Component c = SwingUtilities.getDeepestComponentAt(rootpane, pt.x, pt.y); + + if (c != null && !(c instanceof JTable) && !(c instanceof ScilabTabbedPane)) { + c = SwingUtilities.getAncestorOfClass(ScilabTabbedPane.class, c); + } + + if (c instanceof ScilabTabbedPane) { + dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop); + } else { + dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop); + } + } + } + + /** + * Interface DragSourceListener + * {@inheritDoc} + */ + public void dragEnter(DragSourceDragEvent dsde) { } + + /** + * Interface DragSourceListener + * {@inheritDoc} + */ + public void dropActionChanged(DragSourceDragEvent dsde) { } + + /** + * Interface DragGestureListener + * {@inheritDoc} + */ + public void dragGestureRecognized(DragGestureEvent dge) { + InputEvent inputEvent = dge.getTriggerEvent(); + if (inputEvent instanceof MouseEvent) { + MouseEvent mouseEvent = (MouseEvent) inputEvent; + int index = indexAtLocation(mouseEvent.getX(), mouseEvent.getY()); + currentWhenDragged = this; + + if (index != -1) { + draggedIndex = index; + dge.startDrag(DragSource.DefaultMoveDrop, this, this); + } + } + } + + /** + * Inner class to have a label and a button + */ + class CloseTabButton extends JPanel { + + private JLabel label; + + /** + * Constructor + * @param title the title of the tab + */ + public CloseTabButton(String title) { + super(new FlowLayout(FlowLayout.LEFT, 0, 0)); + setOpaque(false); + label = new JLabel(title); + add(label); + add(new JLabel(" ")); + add(new CloseButton()); + } + + /** + * @param text the text for the tab + */ + public void setText(String text) { + label.setText(text); + } + + /** + * @return the text of the tab + */ + public String getText() { + return label.getText(); + } + + /** + * Inner class for the close-button + */ + class CloseButton extends JButton { + + /** + * Constructor + */ + CloseButton() { + super(CLOSEICON); + setFocusable(false); + setContentAreaFilled(true); + setOpaque(false); + setRolloverEnabled(true); + setBorderPainted(false); + setPreferredSize(new Dimension(BUTTONSIZE, BUTTONSIZE)); + addActionListener(new CommonCallBack("") { + public void callBack() { + String name = CloseTabButton.this.getText().substring(SwingScilabVariableEditor.PREFIX.length()); + removeTabAt(indexOfTabComponent(CloseTabButton.this)); + ScilabVariableEditor.close(name); + } + }); + } + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/ScilabVariableEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/ScilabVariableEditor.java new file mode 100755 index 000000000..8890dd5aa --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/ScilabVariableEditor.java @@ -0,0 +1,230 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.variableeditor; + +import java.awt.Component; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeListener; + +import org.scilab.modules.action_binding.InterpreterManagement; +import org.scilab.modules.gui.bridge.window.SwingScilabDockingWindow; +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; +import org.scilab.modules.gui.textbox.ScilabTextBox; +import org.scilab.modules.gui.textbox.TextBox; +import org.scilab.modules.localization.Messages; + +/** + * Class ScilabVariableEditor + * Implements a ScilabWindow containing Variable Editor (JTable) + */ +@SuppressWarnings(value = { "serial" }) +public final class ScilabVariableEditor extends SwingScilabDockingWindow implements VariableEditor { + + private static Map<String, Component> map = new HashMap(); + + private static ScilabVariableEditor instance; + + private static SwingScilabVariableEditor editorTab; + private static ScilabTabbedPane tabPane; + + /** + * Constructor + * @param type the variable type + * @param data the JTable data. + * @param variableName the name in Scilab of the variable being edited. + */ + private ScilabVariableEditor(String type, Object[][] data, String variableName) { + super(); + editorTab = new SwingScilabVariableEditor(variableName, type, data); + tabPane = editorTab.getTabPane(); + TextBox infobar = ScilabTextBox.createTextBox(); + editorTab.addInfoBar(infobar); + addTab(editorTab); + map.put(variableName, tabPane.getSelectedComponent()); + } + + /** + * Close Variable Editor + */ + public void close() { + SwingScilabWindow editvarWindow = SwingScilabWindow.allScilabWindows.get(editorTab.getParentWindowId()); + ChangeListener[] cl = tabPane.getChangeListeners(); + for (int i = 0; i < cl.length; i++) { + tabPane.removeChangeListener(cl[i]); + } + instance = null; + map.clear(); + super.close(); + } + + /** + * Close the edition of the variable + */ + public static void closeEditVar() { + if (instance != null) { + instance.close(); + } + } + + /** + * Close the edition of the variable + * @param name the variable + */ + public static void close(String name) { + map.remove(name); + } + + /** + * Set data displayed in JTable + * @param name the variable name + * @param type the variable type + * @param data : data to be displayed in JTable + */ + public void updateData(String name, String type, Object[][] data) { + if (map.containsKey(name)) { + editorTab.updateData(map.get(name), name, type, data); + } else { + editorTab.setData(name, type, data); + map.put(name, tabPane.getSelectedComponent()); + } + } + + /** + * Set data displayed in JTable + * @param name the variable name + * @param type the variable type + * @param data : data to be displayed in JTable + */ + public void updateData(String name, String type, Object[][] data, double[] rowsIndex, double[] colsIndex) { + if (map.containsKey(name)) { + editorTab.updateData(map.get(name), name, type, data, rowsIndex, colsIndex); + } + } + + /** + * Get the variable editor singleton + * @return the Variable Editor + */ + public static ScilabVariableEditor getVariableEditor() { + return instance; + } + + /** + * Get the variable editor singleton with specified data. + * @param type the variable type + * @param data : the data to fill the editor with + * @param variableName : the scilab name of the variable being edited. + * @return the Variable Editor + */ + public static ScilabVariableEditor getVariableEditor(final String type, final Object[][] data, final String variableName) { + if (instance == null) { + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + instance = new ScilabVariableEditor(type, data, variableName); + instance.setVisible(true); + } + }); + } catch (Exception e) { + System.err.println(e); + } + } else { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, editorTab); + window.setVisible(true); + window.toFront(); + final JTable table = editorTab.getCurrentTable(); + int r = -1; + int c = -1; + + if (table != null) { + r = table.getSelectedRow(); + c = table.getSelectedColumn(); + } + boolean b = map.containsKey(variableName); + instance.updateData(variableName, type, data); + if (b && r != -1 && c != -1) { + table.setRowSelectionInterval(r, r); + table.setColumnSelectionInterval(c, c); + } + } + }); + } + + editorTab.setName(Messages.gettext("Variable Editor") + " - " + variableName + " (" + type + ")"); + return instance; + } + + public static void refreshVariableEditor(final String type, final Object[][] data, double[] rowsIndex, double[] colsIndex, final String variableName) { + if (instance != null) { + instance.updateData(variableName, type, data, rowsIndex, colsIndex); + } + } + + /** + * {@inheritDoc} + */ + public String getVariablename() { + String title = tabPane.getScilabTitleAt(tabPane.getSelectedIndex()); + return title.substring(SwingScilabVariableEditor.PREFIX.length()); + } + + /** + * {@inheritDoc} + */ + public void setVariableName(String variableName) { + tabPane.setTitleAt(tabPane.getSelectedIndex(), SwingScilabVariableEditor.PREFIX + variableName); + } + + /** + * {@inheritDoc} + */ + public void setVisible(boolean status) { + super.setVisible(status); + editorTab.setVisible(status); + } + + /** + * This method is called by the OSXAdapter class when the specific Mac + * OS X "About" menu is called. It is the only case where this method + * should be used + */ + public void macosxAbout() { + InterpreterManagement.requestScilabExec("about()"); + } + + /** + * This method is called by the OSXAdapter class when the specific Mac + * OS X "Quit Scilab" menu is called. It is the only case where this method + * should be used + */ + public boolean macosxQuit() { + InterpreterManagement.requestScilabExec("exit()"); + return false; + } + + /** + * This method is called by the OSXAdapter class when the specific Mac + * OS X "Preferences" menu is called. It is the only case where this method + * should be used + */ + public void macosxPreferences() { + InterpreterManagement.requestScilabExec("preferences();"); + } + + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SimpleVariableEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SimpleVariableEditor.java new file mode 100755 index 000000000..ff40d3a9c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SimpleVariableEditor.java @@ -0,0 +1,28 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +package org.scilab.modules.ui_data.variableeditor; + +/** + * Interface for Variable editor. + */ +public interface SimpleVariableEditor { + + /** + * Set data to be displayed + * @param name the variable name + * @param type the variable type + * @param data : the data displayed in JTable + */ + void setData(String name, String type, Object[][] data); +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SwingScilabVariableEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SwingScilabVariableEditor.java new file mode 100755 index 000000000..34d360bb4 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/SwingScilabVariableEditor.java @@ -0,0 +1,452 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor; + +import java.awt.Component; + +import javax.swing.JButton; +import javax.swing.JMenu; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.TableModelEvent; +import javax.swing.table.TableModel; + +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.bridge.toolbar.SwingScilabToolBar; +import org.scilab.modules.gui.bridge.window.SwingScilabWindow; +import org.scilab.modules.gui.menu.Menu; +import org.scilab.modules.gui.menu.ScilabMenu; +import org.scilab.modules.gui.menubar.MenuBar; +import org.scilab.modules.gui.menubar.ScilabMenuBar; +import org.scilab.modules.gui.tab.SimpleTab; +import org.scilab.modules.gui.textbox.TextBox; +import org.scilab.modules.gui.toolbar.ScilabToolBar; +import org.scilab.modules.gui.toolbar.ToolBar; +import org.scilab.modules.gui.utils.WindowsConfigurationManager; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.rowheader.RowHeader; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.actions.CloseAction; +import org.scilab.modules.ui_data.variableeditor.actions.CopyAction; +import org.scilab.modules.ui_data.variableeditor.actions.CopySelectionAsScilabCommandAction; +import org.scilab.modules.ui_data.variableeditor.actions.CopySelectionAsScilabMatrixAction; +import org.scilab.modules.ui_data.variableeditor.actions.CopySelectionAsScilabMatrixWithCRAction; +import org.scilab.modules.ui_data.variableeditor.actions.CreateNewVariableAction; +import org.scilab.modules.ui_data.variableeditor.actions.CreateVariableFromSelectionAction; +import org.scilab.modules.ui_data.variableeditor.actions.CutAction; +import org.scilab.modules.ui_data.variableeditor.actions.DuplicateVariableAction; +import org.scilab.modules.ui_data.variableeditor.actions.ExportToCsvAction; +import org.scilab.modules.ui_data.variableeditor.actions.ExportToCsvFromSelectionAction; +import org.scilab.modules.ui_data.variableeditor.actions.PasteAction; +import org.scilab.modules.ui_data.variableeditor.actions.PlotAction; +import org.scilab.modules.ui_data.variableeditor.actions.RedoAction; +import org.scilab.modules.ui_data.variableeditor.actions.RefreshAction; +import org.scilab.modules.ui_data.variableeditor.actions.SetPrecisionLongAction; +import org.scilab.modules.ui_data.variableeditor.actions.SetPrecisionLongeAction; +import org.scilab.modules.ui_data.variableeditor.actions.SetPrecisionShortAction; +import org.scilab.modules.ui_data.variableeditor.actions.SetPrecisionShorteAction; +import org.scilab.modules.ui_data.variableeditor.actions.SizeColumnsToFitAction; +import org.scilab.modules.ui_data.variableeditor.actions.SupprAction; +import org.scilab.modules.ui_data.variableeditor.actions.UndoAction; +import org.scilab.modules.ui_data.variableeditor.celleditor.CellEditorFactory; +import org.scilab.modules.ui_data.variableeditor.celleditor.ScilabGenericCellEditor; +import org.scilab.modules.ui_data.variableeditor.renderers.RendererFactory; +import org.scilab.modules.ui_data.variableeditor.undo.CellsUndoManager; + +/** + * Swing implementation of Scilab Variable Editor + * uses JTable + * @author Allan SIMON + * @author Calixte DENIZET + */ +public class SwingScilabVariableEditor extends SwingScilabDockablePanel implements SimpleVariableEditor { + + /** + * Prefix used in the tabs titles. + */ + public static final String PREFIX = "Var - "; + + private static final String APOS = "'"; + private static final long serialVersionUID = 1L; + + private final ScilabTabbedPane tabPane; + private final JButton refreshButton; + private final JButton undoButton; + private final JButton redoButton; + + /** + * Create a JTable with data Model. + * @param name the variable name + * @param type the variable type + * @param data : The JTable data. + */ + public SwingScilabVariableEditor(String name, String type, Object[][] data) { + super(UiDataMessages.VARIABLE_EDITOR); + setAssociatedXMLIDForHelp("editvar"); + setWindowIcon("rrze_table"); + refreshButton = RefreshAction.createButton(this, UiDataMessages.REFRESH); + undoButton = UndoAction.createButton(this, UiDataMessages.UNDO); + redoButton = RedoAction.createButton(this, UiDataMessages.REDO); + enableUndoButton(false); + enableRedoButton(false); + tabPane = new ScilabTabbedPane(this); + tabPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + String name = tabPane.getScilabTitleAt(tabPane.getSelectedIndex()); + if (name.length() != 0) { + name = name.substring(PREFIX.length()); + String tooltip = ""; + if (name != null && getCurrentModel() != null) { + tooltip = UiDataMessages.REFRESH + APOS + name + APOS; + String type = ((SwingEditvarTableModel) getCurrentModel()).getType(); + String title = UiDataMessages.VARIABLE_EDITOR + " - " + name + " (" + type + ")"; + setName(title); + SwingScilabWindow window = (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, tabPane); + if (window != null) { + window.setTitle(title); + } + } + CellsUndoManager undoManager = ((SwingEditvarTableModel) getCurrentModel()).getUndoManager(); + enableUndoButton(undoManager.canUndo()); + enableRedoButton(undoManager.canRedo()); + refreshButton.setToolTipText(tooltip); + } + } + }); + setContentPane(tabPane); + setData(name, type, data); + WindowsConfigurationManager.restorationFinished(this); + + addToolBar(createToolBar()); + addMenuBar(createMenuBar()); + } + + /** + * {@inheritDoc} + */ + public void addInfoBar(TextBox infoBarToAdd) { + setInfoBar(infoBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void addMenuBar(MenuBar menuBarToAdd) { + setMenuBar(menuBarToAdd); + } + + /** + * {@inheritDoc} + */ + public void addToolBar(ToolBar toolBarToAdd) { + setToolBar(toolBarToAdd); + } + + /** + * @return the TabbedPane used in this window + */ + public ScilabTabbedPane getTabPane() { + return tabPane; + } + + /** + * @return the current table + */ + public JTable getCurrentTable() { + Component c = tabPane.getSelectedComponent(); + if (c != null) { + return (JTable) ((JScrollPane) c).getViewport().getComponent(0); + } + + return null; + } + + /** + * @return the current table + */ + public TableModel getCurrentModel() { + JTable t = getCurrentTable(); + if (t != null) { + return t.getModel(); + } + + return null; + } + + /** + * Create the toolbar + * @return the built toolbar + */ + public ToolBar createToolBar() { + ToolBar toolBar = ScilabToolBar.createToolBar(); + SwingScilabToolBar stb = (SwingScilabToolBar) toolBar.getAsSimpleToolBar(); + + stb.add(refreshButton); + stb.addSeparator(); + stb.add(CreateVariableFromSelectionAction.createButton(this, UiDataMessages.CREATE)); + stb.add(CreateNewVariableAction.createButton(this, UiDataMessages.CREATENEWVAR)); + stb.addSeparator(); + stb.add(CutAction.createButton(this, UiDataMessages.CUT)); + stb.add(CopyAction.createButton(this, UiDataMessages.COPY)); + stb.add(PasteAction.createButton(this, UiDataMessages.PASTE)); + stb.addSeparator(); + stb.add(undoButton); + stb.add(redoButton); + stb.addSeparator(); + stb.add(SizeColumnsToFitAction.createButton(this, UiDataMessages.FIT)); + stb.addSeparator(); + stb.add(SetPrecisionShortAction.createButton(this, UiDataMessages.SHORT)); + stb.add(SetPrecisionShorteAction.createButton(this, UiDataMessages.SHORTE)); + stb.add(SetPrecisionLongAction.createButton(this, UiDataMessages.LONG)); + stb.add(SetPrecisionLongeAction.createButton(this, UiDataMessages.LONGE)); + stb.addSeparator(); + stb.add(PlotAction.createButton(this, UiDataMessages.PLOTSELECTION)); + + return toolBar; + } + + /** + * @return a popup menu for the table + */ + public JPopupMenu createPopupMenu() { + JPopupMenu popup = new JPopupMenu(); + popup.setBorderPainted(true); + popup.add(UndoAction.createJMenuItem(this, UiDataMessages.UNDO)); + popup.add(RedoAction.createJMenuItem(this, UiDataMessages.REDO)); + popup.addSeparator(); + popup.add(CutAction.createJMenuItem(this, UiDataMessages.CUT)); + popup.add(CopyAction.createJMenuItem(this, UiDataMessages.COPY)); + popup.add(PasteAction.createJMenuItem(this, UiDataMessages.PASTE)); + popup.addSeparator(); + popup.add(CopySelectionAsScilabCommandAction.createJMenuItem(this, UiDataMessages.COPYASSCILABCOM)); + popup.add(CopySelectionAsScilabMatrixAction.createJMenuItem(this, UiDataMessages.COPYASSCILABMAT)); + popup.add(CopySelectionAsScilabMatrixWithCRAction.createJMenuItem(this, UiDataMessages.COPYASSCILABMATWITHCR)); + popup.add(ExportToCsvFromSelectionAction.createJMenuItem(this, UiDataMessages.EXPORTSELECTIONCSV)); + popup.addSeparator(); + popup.add(CreateVariableFromSelectionAction.createJMenuItem(this, UiDataMessages.CREATE)); + popup.add(CreateNewVariableAction.createJMenuItem(this, UiDataMessages.CREATENEWVAR)); + popup.add(DuplicateVariableAction.createJMenuItem(this, UiDataMessages.DUPLICATE)); + popup.add(ExportToCsvAction.createJMenuItem(this, UiDataMessages.EXPORTCSV)); + + popup.addSeparator(); + + JMenu plots = new JMenu(UiDataMessages.PLOTSELECTION); + popup.add(plots); + + plots.add(PlotAction.createJMenuItem(this, "plot2d", true)); + plots.add(PlotAction.createJMenuItem(this, "Matplot", true)); + plots.add(PlotAction.createJMenuItem(this, "grayplot", true)); + plots.add(PlotAction.createJMenuItem(this, "Sgrayplot", true)); + plots.add(PlotAction.createJMenuItem(this, "champ", true)); + plots.add(PlotAction.createJMenuItem(this, "histplot", true)); + plots.add(PlotAction.createJMenuItem(this, "mesh", true)); + plots.add(PlotAction.createJMenuItem(this, "surf", true)); + plots.add(PlotAction.createJMenuItem(this, "hist3d", true)); + plots.add(PlotAction.createJMenuItem(this, "contour2d", true)); + plots.add(PlotAction.createJMenuItem(this, "pie", true)); + + popup.addSeparator(); + + JMenu plotAll = new JMenu(UiDataMessages.PLOTALL); + popup.add(plotAll); + + plotAll.add(PlotAction.createJMenuItem(this, "plot2d", false)); + plotAll.add(PlotAction.createJMenuItem(this, "Matplot", false)); + plotAll.add(PlotAction.createJMenuItem(this, "grayplot", false)); + plotAll.add(PlotAction.createJMenuItem(this, "Sgrayplot", false)); + plotAll.add(PlotAction.createJMenuItem(this, "champ", false)); + plotAll.add(PlotAction.createJMenuItem(this, "histplot", false)); + plotAll.add(PlotAction.createJMenuItem(this, "mesh", false)); + plotAll.add(PlotAction.createJMenuItem(this, "surf", false)); + plotAll.add(PlotAction.createJMenuItem(this, "hist3d", false)); + plotAll.add(PlotAction.createJMenuItem(this, "contour2d", false)); + plotAll.add(PlotAction.createJMenuItem(this, "pie", false)); + + return popup; + } + + public MenuBar createMenuBar() { + MenuBar bar = ScilabMenuBar.createMenuBar(); + Menu file = ScilabMenu.createMenu(); + file.setText(UiDataMessages.FILE); + file.add(CreateVariableFromSelectionAction.createMenuItem(this, UiDataMessages.CREATE)); + file.add(CreateNewVariableAction.createMenuItem(this, UiDataMessages.CREATENEWVAR)); + file.add(DuplicateVariableAction.createMenuItem(this, UiDataMessages.DUPLICATE)); + file.add(ExportToCsvAction.createMenuItem(this, UiDataMessages.EXPORTCSV)); + file.addSeparator(); + file.add(CloseAction.createMenuItem(this, UiDataMessages.CLOSE)); + + bar.add(file); + Menu edition = ScilabMenu.createMenu(); + edition.setText(UiDataMessages.EDITION); + edition.add(UndoAction.createMenuItem(this, UiDataMessages.UNDO)); + edition.add(RedoAction.createMenuItem(this, UiDataMessages.REDO)); + edition.addSeparator(); + edition.add(CutAction.createMenuItem(this, UiDataMessages.CUT)); + edition.add(CopyAction.createMenuItem(this, UiDataMessages.COPY)); + edition.add(PasteAction.createMenuItem(this, UiDataMessages.PASTE)); + edition.addSeparator(); + edition.add(CopySelectionAsScilabCommandAction.createMenuItem(this, UiDataMessages.COPYASSCILABCOM)); + edition.add(CopySelectionAsScilabMatrixAction.createMenuItem(this, UiDataMessages.COPYASSCILABMAT)); + edition.add(CopySelectionAsScilabMatrixWithCRAction.createMenuItem(this, UiDataMessages.COPYASSCILABMATWITHCR)); + edition.addSeparator(); + edition.add(SizeColumnsToFitAction.createMenuItem(this, UiDataMessages.FIT)); + bar.add(edition); + + return bar; + } + + /** + * {@inheritDoc} + */ + @Override + public void setData(String name, String type, Object[][] data) { + TableVariableEditor table = new TableVariableEditor(this); + + CopyAction.registerAction(this, table); + CutAction.registerAction(this, table); + PasteAction.registerAction(this, table); + SupprAction.registerAction(this, table); + UndoAction.registerAction(this, table); + RedoAction.registerAction(this, table); + SizeColumnsToFitAction.registerAction(this, table); + SetPrecisionShortAction.registerAction(this, table); + SetPrecisionShorteAction.registerAction(this, table); + SetPrecisionLongAction.registerAction(this, table); + SetPrecisionLongeAction.registerAction(this, table); + CreateVariableFromSelectionAction.registerAction(this, table); + CreateNewVariableAction.registerAction(this, table); + + table.setComponentPopupMenu(createPopupMenu()); + + ScilabGenericCellEditor cellEditor = (ScilabGenericCellEditor) CellEditorFactory.createCellEditor(type); + int rows = Math.max(table.getMinimalRowNumber(), table.getModel().getRowCount()); + int cols = table.getModel().getColumnCount(); + + SwingEditvarTableModel dataModel = new SwingEditvarTableModel(this, name, type, data, cellEditor, rows, cols); + + dataModel.addTableModelListener(getRowHeader(table)); + getRowHeader(table).tableChanged(new TableModelEvent(dataModel)); + table.setModel(dataModel); + table.setDefaultEditor(Object.class, cellEditor); + table.setDefaultRenderer(Object.class, RendererFactory.createRenderer(type)); + + tabPane.add(PREFIX + name, table.getScrollPane()); + tabPane.setSelectedComponent(table.getScrollPane()); + } + + /** + * @param table the table to update + * @param name the name of the variable + * @param type the type of the matrix + * @param data the matrix data + */ + public void updateData(JTable table, String name, String type, Object[][] data) { + ScilabGenericCellEditor cellEditor = (ScilabGenericCellEditor) CellEditorFactory.createCellEditor(type); + int rows = Math.max(((TableVariableEditor) table).getMinimalRowNumber(), table.getModel().getRowCount()); + int cols = table.getModel().getColumnCount(); + CellsUndoManager undo = null; + if (table.getModel() instanceof SwingEditvarTableModel) { + undo = ((SwingEditvarTableModel) table.getModel()).getUndoManager(); + } + + SwingEditvarTableModel dataModel = (SwingEditvarTableModel) table.getModel(); + getRowHeader((TableVariableEditor) table).tableChanged(new TableModelEvent(dataModel)); + dataModel.changeData(type, data, cellEditor, rows, cols); + table.setDefaultEditor(Object.class, cellEditor); + table.setDefaultRenderer(Object.class, RendererFactory.createRenderer(type)); + } + + /** + * @param table the table to update + * @param name the name of the variable + * @param type the type of the matrix + * @param data the matrix datas + */ + public void updateData(JTable table, String name, String type, Object[][] data, double[] rowsIndex, double[] colsIndex) { + SwingEditvarTableModel dataModel = (SwingEditvarTableModel) table.getModel(); + if (!type.equals(dataModel.getType())) { + dataModel.refresh(); + } else { + for (int i = 0; i < rowsIndex.length; i++) { + for (int j = 0; j < colsIndex.length; j++) { + int r = (int) rowsIndex[i] - 1; + int c = (int) colsIndex[j] - 1; + dataModel.setValueAtAndUpdate(false, false, data[i][j], r, c); + } + } + } + } + + /** + * @param c the component in the tabbedpane + * @param name the name of the variable + * @param type the type of the matrix + * @param data the matrix data + */ + public void updateData(Component c, String name, String type, Object[][] data) { + tabPane.setSelectedComponent(c); + JTable table = (JTable) ((JScrollPane) c).getViewport().getComponent(0); + updateData(table, name, type, data); + } + + /** + * @param c the component in the tabbedpane + * @param name the name of the variable + * @param type the type of the matrix + * @param data the matrix datas + */ + public void updateData(Component c, String name, String type, Object[][] data, double[] rowsIndex, double[] colsIndex) { + tabPane.setSelectedComponent(c); + JTable table = (JTable) ((JScrollPane) c).getViewport().getComponent(0); + updateData(table, name, type, data, rowsIndex, colsIndex); + } + + /** + * @return the row header used in this table + */ + public RowHeader getRowHeader(TableVariableEditor table) { + return (RowHeader) table.getScrollPane().getRowHeader().getView(); + } + + /** + * {@inheritDoc} + */ + public SimpleTab getAsSimpleTab() { + return this; + } + + /** + * @param b true to enable the button + */ + public void enableUndoButton(boolean b) { + if (undoButton != null) { + undoButton.setEnabled(b); + } + } + + /** + * @param b true to enable the button + */ + public void enableRedoButton(boolean b) { + if (redoButton != null) { + redoButton.setEnabled(b); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/TableVariableEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/TableVariableEditor.java new file mode 100755 index 000000000..93b478ef4 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/TableVariableEditor.java @@ -0,0 +1,429 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Toolkit; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.util.Arrays; +import java.util.Vector; + +import javax.swing.BoundedRangeModel; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.TableModelEvent; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableCellEditor; + +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.rowheader.HeaderRenderer; +import org.scilab.modules.ui_data.rowheader.RowHeader; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.actions.InsertColumnAction; +import org.scilab.modules.ui_data.variableeditor.actions.RemoveColumnAction; + +/** + * The table + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class TableVariableEditor extends JTable { + + private JScrollPane scrollPane; + private int clickedColumn; + private int[] selectedRows = new int[0]; + private int[] selectedCols = new int[0]; + private int popupRow; + private int popupCol; + private SwingScilabVariableEditor editor; + + /** + * Default constructor + */ + public TableVariableEditor(SwingScilabVariableEditor editor) { + super(); + this.editor = editor; + scrollPane = new JScrollPane(this); + /* Modify the table size when the knob is at the bottom of the vertical scrollbar */ + scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + BoundedRangeModel brm = scrollPane.getVerticalScrollBar().getModel(); + if (brm.getMaximum() - brm.getExtent() - e.getValue() <= 1) { + addTenRows(); + } + } + }); + + /* Modify the table size when the knob is at the right of the horizontal scrollbar */ + scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + BoundedRangeModel brm = scrollPane.getHorizontalScrollBar().getModel(); + if (brm.getMaximum() - brm.getExtent() - e.getValue() <= 1) { + addTenCols(); + } + } + }); + + /* Modify the table size when the scrollpane is resized */ + scrollPane.getViewport().addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + if (((SwingEditvarTableModel) getModel()).enlarge(getMinimalRowNumber() + 1, getMinimalColumnNumber() + 1)) { + ((SwingEditvarTableModel) getModel()).fireTableChanged(new TableModelEvent(getModel())); + } + } + }); + + getTableHeader().setDefaultRenderer(new HeaderRenderer(this, false)); + + /* Handle left click on the column header */ + getTableHeader().addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if (getTableHeader().getCursor().getType() == Cursor.DEFAULT_CURSOR && SwingUtilities.isLeftMouseButton(e)) { + JTable table = TableVariableEditor.this; + int column = table.getColumnModel().getColumnIndexAtX(e.getX()); + ListSelectionModel csm = table.getColumnModel().getSelectionModel(); + int rowC = ((SwingEditvarTableModel) getModel()).getScilabMatrixRowCount(); + if (rowC == 0) { + rowC = 1; + } + + if (e.isShiftDown()) { + csm.setSelectionInterval(column, clickedColumn); + table.setRowSelectionInterval(0, rowC - 1); + } else { + if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { + if (table.isColumnSelected(column)) { + csm.removeSelectionInterval(column, column); + } else { + csm.addSelectionInterval(column, column); + table.setRowSelectionInterval(0, rowC - 1); + } + } else { + csm.setSelectionInterval(column, column); + table.setRowSelectionInterval(0, rowC - 1); + } + clickedColumn = column; + } + table.requestFocus(); + } + } + }); + + /* Handle left-click drag on the column header */ + getTableHeader().addMouseMotionListener(new MouseMotionAdapter() { + public void mouseDragged(MouseEvent e) { + if (getTableHeader().getCursor().getType() == Cursor.DEFAULT_CURSOR && SwingUtilities.isLeftMouseButton(e)) { + JTable table = TableVariableEditor.this; + Point p = e.getPoint(); + int column; + if (p.x >= table.getTableHeader().getHeaderRect(table.getColumnCount() - 1).x) { + column = table.getColumnCount() - 1; + } else { + column = table.getColumnModel().getColumnIndexAtX(p.x); + } + + ListSelectionModel csm = table.getColumnModel().getSelectionModel(); + int lead = csm.getLeadSelectionIndex(); + if (lead != column) { + if (column == getColumnCount() - 1) { + ((TableVariableEditor) table).addTenCols(); + } + table.scrollRectToVisible(table.getTableHeader().getHeaderRect(column)); + if (e.isShiftDown()) { + csm.setSelectionInterval(clickedColumn, column); + } else { + if ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0) { + if (csm.isSelectedIndex(column)) { + csm.removeSelectionInterval(lead, column); + csm.addSelectionInterval(clickedColumn, column); + } else { + csm.addSelectionInterval(clickedColumn, column); + } + } else { + csm.setSelectionInterval(clickedColumn, column); + } + } + int rowC = ((SwingEditvarTableModel) getModel()).getScilabMatrixRowCount(); + if (rowC == 0) { + rowC = 1; + } + + table.setRowSelectionInterval(0, rowC - 1); + table.requestFocus(); + } + } + } + }); + + getTableHeader().setReorderingAllowed(false); + getTableHeader().setComponentPopupMenu(createPopupMenu()); + + /* Click on the upper left corner selects all */ + scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, new JPanel()); + scrollPane.getCorner(JScrollPane.UPPER_LEFT_CORNER).addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + selectAll(); + } + }); + + /* Click on the lower left corner clear the selection */ + scrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, new JPanel()); + scrollPane.getCorner(JScrollPane.LOWER_LEFT_CORNER).addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + clearSelection(); + } + }); + + setFillsViewportHeight(true); + setRowHeight(18); + scrollPane.setRowHeaderView(new RowHeader(this)); + setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + setCellSelectionEnabled(true); + setBackground(Color.WHITE); + setAutoResizeMode(AUTO_RESIZE_OFF); + + if (getGridColor().equals(Color.WHITE)) { + setGridColor(new Color(128, 128, 128)); + } + setShowHorizontalLines(true); + setShowVerticalLines(true); + } + + /** + * {@inheritDoc} + */ + public void valueChanged(ListSelectionEvent e) { + int[] rows = getSelectedRows(); + Vector<Integer> rowDiff = getDifference(rows, selectedRows); + JTable rowHeader = ((RowHeader) scrollPane.getRowHeader().getView()).getTable(); + for (int i : rowDiff) { + rowHeader.repaint(rowHeader.getCellRect(i, 0, false)); + } + selectedRows = rows; + SwingEditvarTableModel model = (SwingEditvarTableModel) getModel(); + editor.getInfoBar().getAsSimpleTextBox().setText(model.getScilabSubMatrix(rows, getSelectedColumns())); + + super.valueChanged(e); + } + + /** + * {@inheritDoc} + */ + public void columnSelectionChanged(ListSelectionEvent e) { + int[] cols = getSelectedColumns(); + Vector<Integer> colDiff = getDifference(cols, selectedCols); + JTableHeader colHeader = getTableHeader(); + for (int i : colDiff) { + colHeader.repaint(colHeader.getHeaderRect(i)); + } + selectedCols = cols; + SwingEditvarTableModel model = (SwingEditvarTableModel) getModel(); + editor.getInfoBar().getAsSimpleTextBox().setText(model.getScilabSubMatrix(getSelectedRows(), cols)); + + super.columnSelectionChanged(e); + } + + /** + * {@inheritDoc} + */ + public void editingStopped(ChangeEvent e) { + TableCellEditor editor = getCellEditor(); + if (editor != null) { + Object value = editor.getCellEditorValue(); + if (value != null && !value.toString().isEmpty()) { + super.editingStopped(e); + } else { + editingCanceled(e); + } + } + } + + /** + * {@inheritDoc} + */ + public void selectAll() { + /* Just select the matrix not all the table */ + SwingEditvarTableModel model = (SwingEditvarTableModel) getModel(); + int rowC = model.getScilabMatrixRowCount(); + if (rowC == 0) { + rowC = 1; + } + + int colC = model.getScilabMatrixColCount(); + if (colC == 0) { + colC = 1; + } + + setColumnSelectionInterval(0, colC - 1); + setRowSelectionInterval(0, rowC - 1); + } + + /** + * @return a popup menu for the column header + */ + public JPopupMenu createPopupMenu() { + JPopupMenu popup = new JPopupMenu() { + public void show(Component invoker, int x, int y) { + setPopupColumn(getColumnModel().getColumnIndexAtX(x)); + super.show(invoker, x, y); + } + }; + popup.setBorderPainted(true); + popup.add(InsertColumnAction.createMenuItem(this, UiDataMessages.INSERTC)); + popup.add(RemoveColumnAction.createMenuItem(this, UiDataMessages.REMOVEC)); + + return popup; + } + + /** + * @return the scrollpane used to display this table + */ + public JScrollPane getScrollPane() { + return scrollPane; + } + + /** + * @return the minimal row number according to the table size + */ + public int getMinimalRowNumber() { + Dimension dim = scrollPane.getViewport().getSize(); + return (int) ((double) dim.height / getRowHeight()) + 1; + } + + /** + * @return the minimal column number according to the table size + */ + public int getMinimalColumnNumber() { + Dimension dim = scrollPane.getViewport().getSize(); + return (int) ((double) dim.width / 75) + 1; + } + + /** + * Add ten rows + */ + public void addTenRows() { + int rowCount = getRowCount(); + ((SwingEditvarTableModel) getModel()).addRows(10); + ((SwingEditvarTableModel) getModel()).fireTableRowsInserted(rowCount, rowCount + 10); + } + + /** + * Add ten columns + */ + public void addTenCols() { + ((SwingEditvarTableModel) getModel()).addColumns(10); + int count = getColumnCount(); + for (int i = count; i < count + 10; i++) { + addColumn(new TableColumn(i)); + } + } + + /** + * Resize the columns to fit contents + */ + public void sizeColumnsToFit() { + SwingEditvarTableModel model = (SwingEditvarTableModel) getModel(); + for (int i = 0; i < model.getScilabMatrixColCount(); i++) { + TableColumn col = getColumnModel().getColumn(i); + int width = 75; + for (int j = 0; j < model.getScilabMatrixRowCount(); j++) { + Component c = getCellRenderer(j, i).getTableCellRendererComponent(this, getValueAt(j, i), false, false, j, i); + if (c instanceof JLabel) { + JLabel label = (JLabel) c; + String text = label.getText(); + if (text != null && !text.isEmpty()) { + int trueWidth = SwingUtilities.computeStringWidth(label.getFontMetrics(label.getFont()), label.getText()); + width = Math.max(width, trueWidth); + } + } + } + if (width != 75) { + col.setPreferredWidth(width + 20); + } else { + col.setPreferredWidth(75); + } + } + invalidate(); + doLayout(); + repaint(); + } + + /** + * Set the row where a jpopupmenu has been shown + * @param r the row index + */ + public void setPopupRow(int r) { + popupRow = r; + } + + /** + * Get the row index where a jpopupmenu has been shown + * @return the row index + */ + public int getPopupRow() { + return popupRow; + } + + /** + * Set the column where a jpopupmenu has been shown + * @param r the column index + */ + public void setPopupColumn(int c) { + popupCol = c; + } + + /** + * Get the column index where a jpopupmenu has been shown + * @return the column index + */ + public int getPopupColumn() { + return popupCol; + } + + /** + * Computes the symmetric difference between the sorted arrays a and b + */ + private Vector<Integer> getDifference(int[] a, int[] b) { + Vector<Integer> v = new Vector<Integer>(a.length + b.length); + for (int i : a) { + if (Arrays.binarySearch(b, i) < 0) { + v.add(i); + } + } + for (int i : b) { + if (Arrays.binarySearch(a, i) < 0) { + v.add(i); + } + } + + return v; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/VariableEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/VariableEditor.java new file mode 100755 index 000000000..643b03d84 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/VariableEditor.java @@ -0,0 +1,56 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor; + +import org.scilab.modules.gui.window.SimpleWindow; + +/** + * Variable editor Interface + * Describes actions exposed to scilab. + * + */ +public interface VariableEditor extends SimpleWindow { + + /** + * Close Variable Browser. + */ + void close(); + + /** + * Set Data stored in JTable. + * @param name the name of the Scilab var + * @param type the type of the var + * @param data : the data to be stored. + */ + void updateData(String name, String type, Object[][] data); + + /** + * Set Data stored in JTable. + * @param name the name of the Scilab var + * @param type the type of the var + * @param data : the data to be stored. + */ + void updateData(String name, String type, Object[][] data, double[] rowsIndex, double[] colsIndex); + + /** + * Set the name of the variable being edited in Editvar + * @param variableName : name of the variable being edited. + */ + void setVariableName(String variableName); + + /** + * Get the name of the variable being edited in Editvar + * @return the variable name + */ + String getVariablename(); +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CloseAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CloseAction.java new file mode 100755 index 000000000..1963011bd --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CloseAction.java @@ -0,0 +1,87 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.EditVar; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * CloseAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CloseAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY Q"; + private static final String CLOSE = "Close"; + + private SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CloseAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(CLOSE, new CloseAction(editor, CLOSE)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CLOSE); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + EditVar.closeVariableEditor(); + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CloseAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopyAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopyAction.java new file mode 100755 index 000000000..cbf285e51 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopyAction.java @@ -0,0 +1,96 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * CopyAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CopyAction extends CopySelectionAction { + + private static final String KEY = "OSSCKEY C"; + private static final String COPY = "Copy"; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CopyAction(SwingScilabVariableEditor editor, String name) { + super(editor, name, "", "\n", "\t", "\n"); + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(COPY, new CopyAction(editor, COPY)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), COPY); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new CopyAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("edit-copy")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CopyAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAction.java new file mode 100755 index 000000000..4c5faf18e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAction.java @@ -0,0 +1,81 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; + +import javax.swing.JTable; + +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * CopySelectionAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +class CopySelectionAction extends CommonCallBack { + + protected SwingScilabVariableEditor editor; + private String begin; + private String end; + private String colSep; + private String rowSep; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + protected CopySelectionAction(SwingScilabVariableEditor editor, String name, String begin, String end, String colSep, String rowSep) { + super(name); + this.editor = editor; + this.begin = begin; + this.end = end; + this.colSep = colSep; + this.rowSep = rowSep; + } + + /** + * {@inheritDoc} + */ + public void callBack() { + JTable table = editor.getCurrentTable(); + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols.length > 0 && rows.length > 0) { + StringBuffer buf = new StringBuffer(begin); + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < cols.length; j++) { + String val = model.getScilabValueAt(rows[i], cols[j], false); + if (val != null) { + buf.append(val); + } + if (j < cols.length - 1) { + buf.append(colSep); + } + } + if (i < rows.length - 1) { + buf.append(rowSep); + } + } + buf.append(end); + + StringSelection sel = new StringSelection(buf.toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabCommandAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabCommandAction.java new file mode 100755 index 000000000..96fd184f6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabCommandAction.java @@ -0,0 +1,98 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; + +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * CopySelectionAsScilabCommandAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CopySelectionAsScilabCommandAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY E"; + private static final String COPYAS = "Copy as Scilab command"; + + private SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CopySelectionAsScilabCommandAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(COPYAS, new CopySelectionAsScilabCommandAction(editor, COPYAS)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), COPYAS); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + JTable table = editor.getCurrentTable(); + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols.length > 0 && rows.length > 0) { + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + String command = model.getScilabSubMatrix(rows, cols); + StringSelection sel = new StringSelection(command); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel); + } + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CopySelectionAsScilabCommandAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabMatrixAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabMatrixAction.java new file mode 100755 index 000000000..2cf9ff4b5 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabMatrixAction.java @@ -0,0 +1,75 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * CopySelectionAsScilabMatrixAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CopySelectionAsScilabMatrixAction extends CopySelectionAction { + + private static final String KEY = "OSSCKEY shift E"; + private static final String COPYAS = "Copy as Scilab matrix"; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CopySelectionAsScilabMatrixAction(SwingScilabVariableEditor editor, String name) { + super(editor, name, "[", "]", ",", ";"); + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(COPYAS, new CopySelectionAsScilabMatrixAction(editor, COPYAS)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), COPYAS); + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CopySelectionAsScilabMatrixAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabMatrixWithCRAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabMatrixWithCRAction.java new file mode 100755 index 000000000..48cc7df0e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CopySelectionAsScilabMatrixWithCRAction.java @@ -0,0 +1,75 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * CopySelectionAsScilabMatrixWithCRAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CopySelectionAsScilabMatrixWithCRAction extends CopySelectionAction { + + private static final String KEY = "OSSCKEY R"; + private static final String COPYAS = "Copy as Scilab matrix with CR"; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CopySelectionAsScilabMatrixWithCRAction(SwingScilabVariableEditor editor, String name) { + super(editor, name, "[", "]", ",", ";\n "); + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(COPYAS, new CopySelectionAsScilabMatrixWithCRAction(editor, COPYAS)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), COPYAS); + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CopySelectionAsScilabMatrixWithCRAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CreateNewVariableAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CreateNewVariableAction.java new file mode 100755 index 000000000..132b7aa43 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CreateNewVariableAction.java @@ -0,0 +1,284 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Dialog.ModalityType; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.UI_data; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CreateNewVariableAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY N"; + private static final String CREATENEW = "Create new"; + private static final int GAP = 5; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CreateNewVariableAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(CREATENEW, new CreateNewVariableAction(editor, CREATENEW)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CREATENEW); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + Object[] values = askForNewMatrix(); + if (!((String) values[0]).isEmpty()) { + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + String defaultValue = SwingEditvarTableModel.getDataAsScilabString(((String) values[3])); + if (defaultValue.isEmpty()) { + defaultValue = "0"; + } + + StringBuilder command = new StringBuilder(); + command.append("L$8625083632641564277=warning(\"query\");warning(\"off\");"); + command.append("if execstr(\""); + command.append((String) values[0]); + command.append("="); + command.append("repmat("); + command.append(defaultValue); + command.append(","); + command.append(((Integer) values[1]).toString()); + command.append(","); + command.append(((Integer) values[2]).toString()); + command.append(");editvar(\"\""); + command.append((String) values[0]); + command.append("\"\")\",\"errcatch\") <> 0 then messagebox(\"Could not create variable: \" + lasterror() + \"\""); + command.append(",\"Variable editor\",\"error\",\"modal\");"); + command.append("end;"); + command.append("warning(L$8625083632641564277);clear(\"L$8625083632641564277\");"); + command.append("updatebrowsevar()"); + + model.execCommand(command.toString()); + } + } + + public Object[] askForNewMatrix() { + final JDialog dialog = new JDialog(); + final Object[] ret = new Object[] { "", new Integer(0), new Integer(0), "" }; + dialog.setModalityType(ModalityType.APPLICATION_MODAL); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setIconImage(new ImageIcon(FindIconHelper.findIcon("rrze_table", "256x256")).getImage()); + + JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + + JLabel label = new JLabel(UiDataMessages.VARNAME); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gbc.insets = new Insets(GAP, GAP, 0, GAP); + gbc.anchor = GridBagConstraints.WEST; + panel.add(label, gbc); + + final JTextField textField = new JTextField(24 + 1); + textField.setText(UI_data.getUnnamedVariable()); + textField.selectAll(); + gbc.gridx = 1; + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(GAP, 0, 0, GAP); + panel.add(textField, gbc); + + JLabel labelRow = new JLabel(UiDataMessages.NUMROWS); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gbc.fill = GridBagConstraints.NONE; + gbc.insets = new Insets(GAP, GAP, 0, GAP); + panel.add(labelRow, gbc); + + final JSpinner spinRow = new JSpinner(); + ((SpinnerNumberModel) spinRow.getModel()).setMinimum(new Comparable<Integer>() { + @Override + public int compareTo(Integer o) { + return -o.intValue(); + } + }); + spinRow.setValue(0); + ((JSpinner.DefaultEditor) spinRow.getEditor()).getTextField().setColumns(6); + gbc.gridx = 1; + gbc.insets = new Insets(GAP, 0, 0, GAP); + panel.add(spinRow, gbc); + + JLabel labelCol = new JLabel(UiDataMessages.NUMCOLS); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.insets = new Insets(GAP, GAP, 0, GAP); + panel.add(labelCol, gbc); + + final JSpinner spinCol = new JSpinner(); + ((SpinnerNumberModel) spinCol.getModel()).setMinimum(new Comparable<Integer>() { + @Override + public int compareTo(Integer o) { + return -o.intValue(); + } + }); + spinCol.setValue(0); + ((JSpinner.DefaultEditor) spinCol.getEditor()).getTextField().setColumns(6); + gbc.gridx = 1; + gbc.insets = new Insets(GAP, 0, 0, GAP); + panel.add(spinCol, gbc); + + JLabel labelFill = new JLabel(UiDataMessages.FILLWITH); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.insets = new Insets(GAP, GAP, 0, GAP); + panel.add(labelFill, gbc); + + final JTextField fillField = new JTextField(15); + gbc.gridx = 1; + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.insets = new Insets(GAP, 0, 0, GAP); + panel.add(fillField, gbc); + + JButton cancelButton = new JButton(UiDataMessages.CANCEL); + JButton okButton = new JButton(UiDataMessages.OK); + JPanel panelButton = new JPanel(); + okButton.setPreferredSize(cancelButton.getPreferredSize()); + panelButton.setLayout(new GridLayout(1, 2, GAP, GAP)); + panelButton.setBorder(BorderFactory.createEmptyBorder(GAP, 0, 0, 0)); + panelButton.add(cancelButton); + panelButton.add(okButton); + + gbc.gridx = 1; + gbc.gridy = 4; + gbc.gridwidth = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.EAST; + panel.add(panelButton, gbc); + + dialog.setContentPane(panel); + + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + ret[0] = textField.getText(); + ret[1] = spinRow.getValue(); + ret[2] = spinCol.getValue(); + ret[3] = fillField.getText(); + } + }); + + dialog.setTitle(UiDataMessages.CREATENEWVAR); + dialog.pack(); + dialog.setResizable(false); + dialog.setLocationRelativeTo(editor); + dialog.setVisible(true); + + return ret; + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new CreateNewVariableAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("variable-new")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CreateNewVariableAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CreateVariableFromSelectionAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CreateVariableFromSelectionAction.java new file mode 100755 index 000000000..4b6a46925 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CreateVariableFromSelectionAction.java @@ -0,0 +1,222 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Dialog.ModalityType; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTextField; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.UI_data; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CreateVariableFromSelectionAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY K"; + private static final String CREATE = "Create"; + private static final int GAP = 5; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private CreateVariableFromSelectionAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(CREATE, new CreateVariableFromSelectionAction(editor, CREATE)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CREATE); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols.length > 0 && rows.length > 0) { + String varName = askForName(); + if (!varName.isEmpty()) { + int[] rowSize = new int[1]; + int[] colSize = new int[1]; + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + String datas = model.getScilabSubMatrix(rows, cols, rowSize, colSize); + model.execCommand(varName + "=" + datas + ";editvar(\"" + varName + "\")"); + } + } + } + + public String askForName() { + final JDialog dialog = new JDialog(); + final String[] ret = new String[] { "" }; + dialog.setModalityType(ModalityType.APPLICATION_MODAL); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setIconImage(new ImageIcon(FindIconHelper.findIcon("rrze_table", "256x256")).getImage()); + + JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + + JLabel label = new JLabel(UiDataMessages.VARNAME); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gbc.insets = new Insets(GAP, GAP, 0, GAP); + panel.add(label, gbc); + + final JTextField textField = new JTextField(24 + 1); + textField.setText(UI_data.getUnnamedVariable()); + textField.selectAll(); + gbc.gridx = 1; + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel.add(textField, gbc); + + JButton cancelButton = new JButton(UiDataMessages.CANCEL); + JButton okButton = new JButton(UiDataMessages.OK); + JPanel panelButton = new JPanel(); + okButton.setPreferredSize(cancelButton.getPreferredSize()); + panelButton.setLayout(new GridLayout(1, 2, GAP, GAP)); + panelButton.setBorder(BorderFactory.createEmptyBorder(GAP, 0, 0, 0)); + panelButton.add(cancelButton); + panelButton.add(okButton); + + gbc.gridx = 1; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(GAP, 0, 0, GAP); + panel.add(panelButton, gbc); + + dialog.setContentPane(panel); + + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + ret[0] = textField.getText(); + } + }); + + textField.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + int code = e.getKeyCode(); + if (code == KeyEvent.VK_ENTER) { + dialog.dispose(); + ret[0] = textField.getText(); + } else if (code == KeyEvent.VK_ESCAPE) { + dialog.dispose(); + } + } + }); + + dialog.setTitle(UiDataMessages.CREATEVAR); + dialog.pack(); + dialog.setResizable(false); + dialog.setLocationRelativeTo(editor); + dialog.setVisible(true); + + return ret[0]; + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new CreateVariableFromSelectionAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("variable-from-selection")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CreateVariableFromSelectionAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CutAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CutAction.java new file mode 100755 index 000000000..63eaa04c1 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/CutAction.java @@ -0,0 +1,163 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class CutAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY X"; + private static final String CUT = "Cut"; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public CutAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(CUT, new CutAction(editor, CUT)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CUT); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols.length > 0 && rows.length > 0) { + table.setColumnSelectionInterval(cols[0], cols[cols.length - 1]); + table.setRowSelectionInterval(rows[0], rows[rows.length - 1]); + StringBuffer buf = new StringBuffer(); + Object oldValue; + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + int oldRows = model.getScilabMatrixRowCount(); + int oldCols = model.getScilabMatrixColCount(); + + if (rows[0] >= oldRows || cols[0] >= oldCols) { + return; + } + + if ((cols.length == 1 && rows.length == 1) || (rows.length >= 2 && cols.length >= 2 && rows[1] >= oldRows && cols[1] >= oldCols)) { + oldValue = model.getValueAt(rows[0], cols[0]); + } else { + oldValue = model.cloneDatas(); + } + + for (int i = rows[0]; i <= rows[rows.length - 1]; i++) { + for (int j = cols[0]; j <= cols[cols.length - 1]; j++) { + String val = model.getScilabValueAt(i, j, false); + if (val != null) { + buf.append(val); + } + model.emptyValueAt(i, j); + if (j < cols[cols.length - 1]) { + buf.append("\t"); + } + } + buf.append("\n"); + } + for (int i = rows[rows.length - 1]; i >= rows[0]; i--) { + model.removeRow(i, cols[0], cols[cols.length - 1]); + } + for (int j = cols[cols.length - 1]; j >= cols[0]; j--) { + model.removeCol(j, rows[0], rows[rows.length - 1]); + } + + if (oldValue instanceof Vector) { + model.updateFullMatrix(oldValue, oldRows, oldCols); + } else { + model.updateMatrix(oldValue, rows[0], cols[0]); + } + + StringSelection sel = new StringSelection(buf.toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel); + } + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new CutAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("edit-cut")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new CutAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/DuplicateVariableAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/DuplicateVariableAction.java new file mode 100755 index 000000000..ed81a5a4f --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/DuplicateVariableAction.java @@ -0,0 +1,197 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Dialog.ModalityType; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.JTextField; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.UI_data; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.utils.UiDataMessages; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * DuplicateVariableAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class DuplicateVariableAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY D"; + private static final String CREATE = "Duplicate"; + private static final int GAP = 5; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private DuplicateVariableAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(CREATE, new DuplicateVariableAction(editor, CREATE)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CREATE); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + String varName = askForName(); + if (!varName.isEmpty()) { + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + model.execCommand(varName + "=" + model.getVarName() + ";editvar(\"" + varName + "\")"); + } + } + + public String askForName() { + final JDialog dialog = new JDialog(); + final String[] ret = new String[] { "" }; + dialog.setModalityType(ModalityType.APPLICATION_MODAL); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setIconImage(new ImageIcon(FindIconHelper.findIcon("rrze_table", "256x256")).getImage()); + + JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + + JLabel label = new JLabel(UiDataMessages.VARNAME); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gbc.insets = new Insets(GAP, GAP, 0, GAP); + panel.add(label, gbc); + + final JTextField textField = new JTextField(24 + 1); + textField.setText(UI_data.getUnnamedVariable()); + textField.selectAll(); + gbc.gridx = 1; + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel.add(textField, gbc); + + JButton cancelButton = new JButton(UiDataMessages.CANCEL); + JButton okButton = new JButton(UiDataMessages.OK); + JPanel panelButton = new JPanel(); + okButton.setPreferredSize(cancelButton.getPreferredSize()); + panelButton.setLayout(new GridLayout(1, 2, GAP, GAP)); + panelButton.setBorder(BorderFactory.createEmptyBorder(GAP, 0, 0, 0)); + panelButton.add(cancelButton); + panelButton.add(okButton); + + gbc.gridx = 1; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(GAP, 0, 0, GAP); + panel.add(panelButton, gbc); + + dialog.setContentPane(panel); + + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + ret[0] = textField.getText(); + } + }); + + textField.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + int code = e.getKeyCode(); + if (code == KeyEvent.VK_ENTER) { + dialog.dispose(); + ret[0] = textField.getText(); + } else if (code == KeyEvent.VK_ESCAPE) { + dialog.dispose(); + } + } + }); + + dialog.setTitle(UiDataMessages.CREATEVAR); + dialog.pack(); + dialog.setResizable(false); + dialog.setLocationRelativeTo(editor); + dialog.setVisible(true); + + return ret[0]; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new DuplicateVariableAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/ExportToCsvAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/ExportToCsvAction.java new file mode 100755 index 000000000..f7e25264c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/ExportToCsvAction.java @@ -0,0 +1,125 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2013 - S/E - Sylvestre Ledru + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.localization.Messages; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variablebrowser.SwingScilabVariableBrowser; +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.types.ScilabTypeEnum; + +import static org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.asynchronousScilabExec; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +/** + * Export to Csv class + * @author Sylvestre Ledru + */ +@SuppressWarnings(value = { "serial" }) +public final class ExportToCsvAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY S"; + private static final String CREATE = "Export to CSV"; + private static final int GAP = 5; + + private final SwingScilabDockablePanel editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public ExportToCsvAction(SwingScilabDockablePanel editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabDockablePanel editor, JTable table) { + table.getActionMap().put(CREATE, new ExportToCsvAction(editor, CREATE)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CREATE); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + String scilabCommand = "__export__csv__=uiputfile();if __export__csv__<>'' then csvWrite(%s, __export__csv__);clear __export__csv__; end;"; + if (editor instanceof SwingScilabVariableEditor) { + JTable table = ((SwingScilabVariableEditor)editor).getCurrentTable(); + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + model.execCommand(String.format(scilabCommand, model.getVarName())); + } else { + // Browse var + String variableName; + int clickedRow = ((SwingScilabVariableBrowser)editor).getTable().getSelectedRow(); + + // Does nothing if no variable selected + if (clickedRow != -1) { + variableName = ((SwingScilabVariableBrowser)editor).getTable().getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString(); + int varType = Integer.parseInt(((SwingScilabVariableBrowser)editor).getTable().getModel().getValueAt(clickedRow, BrowseVar.TYPE_COLUMN_INDEX).toString()); + + try { + // The export is only available for double (complex or not) and strings + if (varType == ScilabTypeEnum.sci_matrix.swigValue() || varType == ScilabTypeEnum.sci_strings.swigValue()) { + asynchronousScilabExec(null, String.format(scilabCommand, variableName)); + } else { + asynchronousScilabExec(null, "messagebox('" + Messages.gettext("Type not supported for this operation") + "')"); + } + } catch (InterpreterException e1) { + System.err.println("An error in the interpreter has been catched: " + e1.getLocalizedMessage()); + } + + } + } + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabDockablePanel editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new ExportToCsvAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabDockablePanel editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } + +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/ExportToCsvFromSelectionAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/ExportToCsvFromSelectionAction.java new file mode 100755 index 000000000..f52f82397 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/ExportToCsvFromSelectionAction.java @@ -0,0 +1,98 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2013 - S/E - Sylvestre Ledru + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * Export to Csv class + * @author Sylvestre Ledru + */ +@SuppressWarnings(value = { "serial" }) +public final class ExportToCsvFromSelectionAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY S"; + private static final String CREATE = "Export to CSV"; + private static final int GAP = 5; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + private ExportToCsvFromSelectionAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(CREATE, new ExportToCsvFromSelectionAction(editor, CREATE)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), CREATE); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols.length > 0 && rows.length > 0) { + int[] rowSize = new int[1]; + int[] colSize = new int[1]; + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + String datas = model.getScilabSubMatrix(rows, cols, rowSize, colSize); + model.execCommand("__export__csv__=uiputfile();__var_to_export__=" + datas + "; if __export__csv__<>'' then csvWrite(__var_to_export__ , __export__csv__);clear __export__csv__ __var_to_export__; end;"); + } + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new ExportToCsvFromSelectionAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/InsertColumnAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/InsertColumnAction.java new file mode 100755 index 000000000..addb699a0 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/InsertColumnAction.java @@ -0,0 +1,89 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.TableVariableEditor; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class InsertColumnAction extends CommonCallBack { + + private final JTable table; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public InsertColumnAction(JTable table, String name) { + super(name); + this.table = table; + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + int[] rows = table.getSelectedRows(); + int column = ((TableVariableEditor) table).getPopupColumn(); + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + model.insertColumn(column); + table.setColumnSelectionInterval(column, column); + for (int i = 0; i < rows.length; i++) { + table.addRowSelectionInterval(rows[i], rows[i]); + } + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(JTable table, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new InsertColumnAction(table, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("short")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(JTable table, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new InsertColumnAction(table, title)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/InsertRowAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/InsertRowAction.java new file mode 100755 index 000000000..8c82bcb53 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/InsertRowAction.java @@ -0,0 +1,85 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.TableVariableEditor; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class InsertRowAction extends CommonCallBack { + + private final JTable table; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public InsertRowAction(JTable table, String name) { + super(name); + this.table = table; + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + int row = ((TableVariableEditor) table).getPopupRow(); + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + model.insertRow(row); + table.setRowSelectionInterval(row, row); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(JTable table, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new InsertRowAction(table, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("short")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(JTable table, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new InsertRowAction(table, title)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/PasteAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/PasteAction.java new file mode 100755 index 000000000..f14c3de72 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/PasteAction.java @@ -0,0 +1,176 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.awt.Cursor; +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.util.StringTokenizer; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * PasteAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class PasteAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY V"; + private static final String PASTE = "Paste"; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public PasteAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(PASTE, new PasteAction(editor, PASTE)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), PASTE); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + int col = table.getSelectedColumn(); + int row = table.getSelectedRow(); + + if (col == -1) { + col = 0; + } + + if (row == -1) { + row = 0; + } + + table.setColumnSelectionInterval(col, col); + table.setRowSelectionInterval(row, row); + String str = ""; + editor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + try { + str = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this).getTransferData(DataFlavor.stringFlavor); + } catch (UnsupportedFlavorException ex1) { + System.err.println(ex1); + } catch (IOException ex2) { + System.err.println(ex2); + } + + StringTokenizer rElems = new StringTokenizer(str, "\n"); + int countRows = rElems.countTokens(); + Vector vr = new Vector(countRows); + NumberFormat format = NumberFormat.getInstance(); + ParsePosition position = new ParsePosition(0); + format.setParseIntegerOnly(false); + for (int i = 0; i < countRows; i++) { + StringTokenizer cElems = new StringTokenizer(rElems.nextToken(), "\t"); + int countCols = cElems.countTokens(); + Vector vc = new Vector(countCols); + for (int j = 0; j < countCols; j++) { + String ss = cElems.nextToken(); + Number x = format.parse(ss, position); + if (position.getIndex() == ss.length()) { + vc.addElement(x.toString()); + } else { + vc.addElement(ss); + } + position.setIndex(0); + } + vr.addElement(vc); + } + + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + int oldRows = model.getScilabMatrixRowCount(); + int oldCols = model.getScilabMatrixColCount(); + + if (vr.size() == 1 && ((Vector) vr.get(0)).size() == 1 && row < oldRows && col < oldCols) { + model.setValueAtAndUpdate(true, true, ((Vector) vr.get(0)).get(0), row, col); + } else { + Vector oldVector = model.cloneDatas(); + model.setValues(vr, row, col); + model.updateFullMatrix(oldVector, oldRows, oldCols); + } + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new PasteAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("edit-paste")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new PasteAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/PlotAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/PlotAction.java new file mode 100755 index 000000000..1f7342e8b --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/PlotAction.java @@ -0,0 +1,302 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import static org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.asynchronousScilabExec; + +import java.awt.Component; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JPopupMenu; +import javax.swing.JTable; + +import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException; +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.bridge.tab.SwingScilabDockablePanel; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.types.ScilabTypeEnumDescription; +import org.scilab.modules.ui_data.BrowseVar; +import org.scilab.modules.ui_data.EditVar; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variablebrowser.SwingScilabVariableBrowser; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class PlotAction extends CommonCallBack { + + public static final int PLOT2D = 0; + public static final int MATPLOT = 1; + public static final int GRAYPLOT = 2; + public static final int SGRAYPLOT = 3; + public static final int CHAMP = 4; + public static final int HISTPLOT = 5; + public static final int MESH = 6; + public static final int SURF = 7; + public static final int HIST3D = 8; + public static final int CONTOUR2D = 9; + public static final int PIE = 10; + + private static final Map<String, Integer> map = new HashMap<String, Integer>(); + static { + map.put("plot2d", 0); + map.put("Matplot", 1); + map.put("grayplot", 2); + map.put("Sgrayplot", 3); + map.put("champ", 4); + map.put("histplot", 5); + map.put("mesh", 6); + map.put("surf", 7); + map.put("hist3d", 8); + map.put("contour2d", 9); + map.put("pie", 10); + } + + private static final String COM_PLOT2D = "plot2d(%s)"; + private static final String COM_MATPLOT = "Matplot(%s)"; + private static final String COM_GRAYPLOT = "grayplot(1:%s,1:%s,%s)"; + private static final String COM_SGRAYPLOT = "Sgrayplot(1:%s,1:%s,%s)"; + private static final String COM_CHAMP = "champ(1:%s,1:%s,real(%s),imag(%s))"; + private static final String COM_HISTPLOT = "histplot(10,%s)"; + private static final String COM_MESH = "mesh(%s)"; + private static final String COM_SURF = "surf(%s)"; + private static final String COM_HIST3D = "hist3d(%s)"; + private static final String COM_CONTOUR2D = "L?8625083632641564278=xget(\"fpf\");xset(\"fpf\",\" \");contour2d(1:%s,1:%s,%s,10);xset(\"fpf\",L?8625083632641564278);clear(\"L?8625083632641564278\")"; + private static final String COM_PIE = "L?8625083632641564278=%s;pie(L?8625083632641564278(find(L?8625083632641564278>0&L?8625083632641564278<>%%inf&L?8625083632641564278<>%%nan)))"; + + private static final String[] COMMANDS = new String[] {COM_PLOT2D, COM_MATPLOT, COM_GRAYPLOT, COM_SGRAYPLOT, COM_CHAMP, COM_HISTPLOT, COM_MESH, COM_SURF, COM_HIST3D, COM_CONTOUR2D, COM_PIE}; + private static final String[] IMG = new String[] { + "application-x-scilab-plot2d", + "application-x-scilab-Matplot", + "application-x-scilab-grayplot", + "application-x-scilab-Sgrayplot", + "application-x-scilab-champ", + "application-x-scilab-histplot", + "application-x-scilab-mesh", + "application-x-scilab-surf", + "application-x-scilab-hist3d", + "application-x-scilab-contour2d", + "application-x-scilab-pie" + }; + + private static final String CREATE = "Create"; + + private final SwingScilabDockablePanel editor; + private final int type; + private final boolean onSelection; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public PlotAction(SwingScilabDockablePanel editor, String name, boolean onSelection) { + super(name); + this.editor = editor; + this.type = map.get(name); + this.onSelection = onSelection; + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + + String data = null; + int rowC = 0; + int colC = 0; + String modelType = null; + SwingEditvarTableModel model = null; + + if (editor instanceof SwingScilabVariableEditor) { + JTable table = ((SwingScilabVariableEditor)editor).getCurrentTable(); + model = (SwingEditvarTableModel) table.getModel(); + modelType = model.getType(); + + if (!onSelection) { + rowC = model.getScilabMatrixRowCount(); + colC = model.getScilabMatrixColCount(); + data = model.getVarName(); + } else { + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols == null || cols.length == 0 || rows == null || rows.length == 0) { + rowC = model.getScilabMatrixRowCount(); + colC = model.getScilabMatrixColCount(); + data = model.getVarName(); + } else { + if (model.getType().equals(EditVar.STRING)) { + return; + } + + int[] rowSize = new int[1]; + int[] colSize = new int[1]; + data = model.getScilabSubMatrix(rows, cols, rowSize, colSize); + if (data == null) { + return; + } + rowC = rowSize[0]; + colC = colSize[0]; + } + } + + if (!modelType.equals(EditVar.DOUBLE)) { + data = "double(" + data + ")"; + } + + } else { + // Variable Browser + int clickedRow = ((SwingScilabVariableBrowser)editor).getTable().getSelectedRow(); + + // Does nothing if no variable selected + if (clickedRow != -1) { + rowC = Integer.parseInt(((SwingScilabVariableBrowser)editor).getTable().getModel().getValueAt(clickedRow, BrowseVar.NB_ROWS_INDEX).toString()); + colC = Integer.parseInt(((SwingScilabVariableBrowser)editor).getTable().getModel().getValueAt(clickedRow, BrowseVar.NB_COLS_INDEX).toString()); + data = ((SwingScilabVariableBrowser)editor).getTable().getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString(); + } + int type = Integer.parseInt(((SwingScilabVariableBrowser)editor).getTable().getModel().getValueAt(clickedRow, BrowseVar.TYPE_COLUMN_INDEX).toString()); + + if (!ScilabTypeEnumDescription.getTypeDescriptionFromId(type).equals(EditVar.DOUBLE)) { + data = "double(" + data + ")"; + } + + } + + if (rowC == 0 || colC == 0) { + return; + } + + String com = COMMANDS[type]; + switch (type) { + case 0: + case 1: + case 5: + case 6: + case 7: + case 8: + case 10: + com = String.format(com, data); + break; + case 2: + case 3: + com = String.format(com, rowC, colC, data); + break; + case 4: + com = String.format(com, rowC, colC, data, data); + break; + case 9: + if (rowC >= 2 && colC >= 2) { + com = String.format(com, rowC, colC, data); + } else { + return; + } + break; + } + if (editor instanceof SwingScilabVariableEditor) { + model.execCommand("scf();" + com); + } else { + // Browse var case + try { + asynchronousScilabExec(null, "scf();" + com); + } catch (InterpreterException e1) { + System.err.println("An error in the interpreter has been catched: " + e1.getLocalizedMessage()); + } + + } + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabDockablePanel editor, String title) { + final JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("plot")); + button.setIcon(imageIcon); + + final JPopupMenu popup = new JPopupMenu() { + @Override + public void show(Component c, int x, int y) { + super.show(button, 0, button.getBounds(null).height); + } + }; + popup.setBorderPainted(true); + + popup.add(PlotAction.createJMenuItem(editor, "plot2d", true)); + popup.add(PlotAction.createJMenuItem(editor, "Matplot", true)); + popup.add(PlotAction.createJMenuItem(editor, "grayplot", true)); + popup.add(PlotAction.createJMenuItem(editor, "Sgrayplot", true)); + popup.add(PlotAction.createJMenuItem(editor, "champ", true)); + popup.add(PlotAction.createJMenuItem(editor, "histplot", true)); + popup.add(PlotAction.createJMenuItem(editor, "mesh", true)); + popup.add(PlotAction.createJMenuItem(editor, "surf", true)); + popup.add(PlotAction.createJMenuItem(editor, "hist3d", true)); + popup.add(PlotAction.createJMenuItem(editor, "contour2d", true)); + popup.add(PlotAction.createJMenuItem(editor, "pie", true)); + + popup.pack(); + + button.addActionListener(new CommonCallBack(null) { + @Override + public void callBack() { + if (!popup.isVisible()) { + popup.show(null, 0, 0); + } else { + popup.setVisible(false); + } + } + }); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabDockablePanel editor, String title, boolean onSelection) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new PlotAction(editor, title, onSelection)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setIcon(new ImageIcon(FindIconHelper.findIcon(IMG[map.get(title)]))); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabDockablePanel editor, String title, boolean onSelection) { + return (SwingScilabMenuItem) createMenuItem(editor, title, onSelection).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RedoAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RedoAction.java new file mode 100755 index 000000000..79dd55535 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RedoAction.java @@ -0,0 +1,110 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * RedoAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class RedoAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY Y"; + private static final String REDO = "Redo"; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public RedoAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(REDO, new RedoAction(editor, REDO)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), REDO); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + ((SwingEditvarTableModel) table.getModel()).getUndoManager().redo(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new RedoAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("edit-redo")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new RedoAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RefreshAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RefreshAction.java new file mode 100755 index 000000000..597b1086f --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RefreshAction.java @@ -0,0 +1,67 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class RefreshAction extends CommonCallBack { + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public RefreshAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + ((SwingEditvarTableModel) editor.getCurrentTable().getModel()).refreshMatrix(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new RefreshAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("view-refresh")); + button.setIcon(imageIcon); + + return button; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RemoveColumnAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RemoveColumnAction.java new file mode 100755 index 000000000..acb9177ff --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RemoveColumnAction.java @@ -0,0 +1,88 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.TableVariableEditor; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class RemoveColumnAction extends CommonCallBack { + + private final JTable table; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public RemoveColumnAction(JTable table, String name) { + super(name); + this.table = table; + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + int[] cols = table.getSelectedColumns(); + if (cols.length == 0) { + cols = new int[] {((TableVariableEditor) table).getPopupColumn()}; + } + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + model.removeColumns(cols); + table.clearSelection(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(JTable table, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new RemoveColumnAction(table, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("short")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(JTable table, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new RemoveColumnAction(table, title)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RemoveRowAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RemoveRowAction.java new file mode 100755 index 000000000..8a3902b5d --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/RemoveRowAction.java @@ -0,0 +1,88 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.TableVariableEditor; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class RemoveRowAction extends CommonCallBack { + + private final JTable table; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public RemoveRowAction(JTable table, String name) { + super(name); + this.table = table; + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + int[] rows = table.getSelectedRows(); + if (rows.length == 0) { + rows = new int[] {((TableVariableEditor) table).getPopupRow()}; + } + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + model.removeRows(rows); + table.clearSelection(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(JTable table, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new RemoveRowAction(table, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("short")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(JTable table, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new RemoveRowAction(table, title)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionLongAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionLongAction.java new file mode 100755 index 000000000..d58a0664e --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionLongAction.java @@ -0,0 +1,99 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.renderers.ScilabComplexRenderer; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SetPrecisionLongAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY L"; + private static final String PRECISION = "Long Precision"; + + private final SwingScilabVariableEditor editor; + + protected int precision; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public SetPrecisionLongAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(PRECISION, new SetPrecisionLongAction(editor, PRECISION)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), PRECISION); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + ScilabComplexRenderer.setFormat(ScilabComplexRenderer.LONG); + editor.getCurrentTable().repaint(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new SetPrecisionLongAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("long")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new SetPrecisionLongAction(editor, title)); + mi.setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionLongeAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionLongeAction.java new file mode 100755 index 000000000..36aa68f57 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionLongeAction.java @@ -0,0 +1,102 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.pushbutton.SwingScilabPushButton; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.pushbutton.PushButton; +import org.scilab.modules.gui.pushbutton.ScilabPushButton; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.renderers.ScilabComplexRenderer; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SetPrecisionLongeAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY shift L"; + private static final String PRECISION = "Long E Precision"; + + private final SwingScilabVariableEditor editor; + + protected int precision; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public SetPrecisionLongeAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(PRECISION, new SetPrecisionLongeAction(editor, PRECISION)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), PRECISION); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + ScilabComplexRenderer.setFormat(ScilabComplexRenderer.LONGE); + editor.getCurrentTable().repaint(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new SetPrecisionLongeAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("longe")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new SetPrecisionLongeAction(editor, title)); + mi.setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionShortAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionShortAction.java new file mode 100755 index 000000000..4705ef3fd --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionShortAction.java @@ -0,0 +1,97 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.renderers.ScilabComplexRenderer; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SetPrecisionShortAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY S"; + private static final String PRECISION = "Short Precision"; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public SetPrecisionShortAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(PRECISION, new SetPrecisionShortAction(editor, PRECISION)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), PRECISION); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + ScilabComplexRenderer.setFormat(ScilabComplexRenderer.SHORT); + editor.getCurrentTable().repaint(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new SetPrecisionShortAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("short")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new SetPrecisionShortAction(editor, title)); + mi.setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionShorteAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionShorteAction.java new file mode 100755 index 000000000..d91704031 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SetPrecisionShorteAction.java @@ -0,0 +1,99 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JMenuItem; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.renderers.ScilabComplexRenderer; + +/** + * Set Precision Action class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SetPrecisionShorteAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY shift S"; + private static final String PRECISION = "Short E Precision"; + + private final SwingScilabVariableEditor editor; + + protected int precision; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public SetPrecisionShorteAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(PRECISION, new SetPrecisionShorteAction(editor, PRECISION)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), PRECISION); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + ScilabComplexRenderer.setFormat(ScilabComplexRenderer.SHORTE); + editor.getCurrentTable().repaint(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new SetPrecisionShorteAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("shorte")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static JMenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + JMenuItem mi = new JMenuItem(title); + mi.addActionListener(new SetPrecisionShorteAction(editor, title)); + mi.setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return mi; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SizeColumnsToFitAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SizeColumnsToFitAction.java new file mode 100755 index 000000000..ac98806db --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SizeColumnsToFitAction.java @@ -0,0 +1,110 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; +import org.scilab.modules.ui_data.variableeditor.TableVariableEditor; + +/** + * RefreshAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SizeColumnsToFitAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY F"; + private static final String FIT = "Size to fit"; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public SizeColumnsToFitAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(FIT, new SizeColumnsToFitAction(editor, FIT)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), FIT); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + TableVariableEditor table = (TableVariableEditor) editor.getCurrentTable(); + table.sizeColumnsToFit(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new SizeColumnsToFitAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("SizeColumnsToFit")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new SizeColumnsToFitAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SupprAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SupprAction.java new file mode 100755 index 000000000..e32b8660c --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/SupprAction.java @@ -0,0 +1,124 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import java.util.Vector; + +import javax.swing.JTable; +import javax.swing.KeyStroke; + +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * SupprAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class SupprAction extends CommonCallBack { + + private static final String KEY = "DELETE"; + private static final String SUPPR = "Suppr"; + + private SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public SupprAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(SUPPR, new SupprAction(editor, SUPPR)); + table.getInputMap().put(KeyStroke.getKeyStroke(KEY), SUPPR); + } + + /** + * {@inheritDoc} + */ + public void callBack() { + JTable table = editor.getCurrentTable(); + int[] cols = table.getSelectedColumns(); + int[] rows = table.getSelectedRows(); + if (cols.length > 0 && rows.length > 0) { + Object oldValue; + SwingEditvarTableModel model = (SwingEditvarTableModel) table.getModel(); + int oldRows = model.getScilabMatrixRowCount(); + int oldCols = model.getScilabMatrixColCount(); + + if (rows[0] >= oldRows || cols[0] >= oldCols) { + return; + } + + if ((cols.length == 1 && rows.length == 1) || (rows.length >= 2 && cols.length >= 2 && rows[1] >= oldRows && cols[1] >= oldCols)) { + oldValue = model.getValueAt(rows[0], cols[0]); + } else { + oldValue = model.cloneDatas(); + } + table.setColumnSelectionInterval(cols[0], cols[cols.length - 1]); + table.setRowSelectionInterval(rows[0], rows[rows.length - 1]); + for (int i = rows[rows.length - 1]; i >= rows[0]; i--) { + for (int j = cols[cols.length - 1]; j >= cols[0]; j--) { + model.emptyValueAt(i, j); + } + model.removeRow(i, cols[0], cols[cols.length - 1]); + } + for (int j = cols[cols.length - 1]; j >= cols[0]; j--) { + model.removeCol(j, rows[0], rows[rows.length - 1]); + } + + if (oldValue instanceof Vector) { + model.updateFullMatrix(oldValue, oldRows, oldCols); + } else { + model.updateMatrix(oldValue, rows[0], cols[0]); + } + } + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new SupprAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(KeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/UndoAction.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/UndoAction.java new file mode 100755 index 000000000..69541f357 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/actions/UndoAction.java @@ -0,0 +1,110 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.actions; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; + +import org.scilab.modules.commons.gui.FindIconHelper; +import org.scilab.modules.commons.gui.ScilabLAF; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem; +import org.scilab.modules.gui.events.callback.CommonCallBack; +import org.scilab.modules.gui.menuitem.MenuItem; +import org.scilab.modules.gui.menuitem.ScilabMenuItem; +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * UndoAction class + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public final class UndoAction extends CommonCallBack { + + private static final String KEY = "OSSCKEY Z"; + private static final String UNDO = "Undo"; + + private final SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + * @param name the name of the action + */ + public UndoAction(SwingScilabVariableEditor editor, String name) { + super(name); + this.editor = editor; + } + + /** + * @param editor the editor + * @param table where to put the action + */ + public static void registerAction(SwingScilabVariableEditor editor, JTable table) { + table.getActionMap().put(UNDO, new UndoAction(editor, UNDO)); + table.getInputMap().put(ScilabKeyStroke.getKeyStroke(KEY), UNDO); + } + + /** + * {@inheritDoc} + */ + @Override + public void callBack() { + JTable table = editor.getCurrentTable(); + ((SwingEditvarTableModel) table.getModel()).getUndoManager().undo(); + } + + /** + * Create a button for a tool bar + * @param editor the associated editor + * @param title tooltip for the button + * @return the button + */ + public static JButton createButton(SwingScilabVariableEditor editor, String title) { + JButton button = new JButton(); + ScilabLAF.setDefaultProperties(button); + button.addActionListener(new UndoAction(editor, title)); + button.setToolTipText(title); + ImageIcon imageIcon = new ImageIcon(FindIconHelper.findIcon("edit-undo")); + button.setIcon(imageIcon); + + return button; + } + + /** + * Create a menu item + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static MenuItem createMenuItem(SwingScilabVariableEditor editor, String title) { + MenuItem menu = ScilabMenuItem.createMenuItem(); + menu.setCallback(new UndoAction(editor, title)); + menu.setText(title); + ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()).setAccelerator(ScilabKeyStroke.getKeyStroke(KEY)); + + return menu; + } + + /** + * Create a menu item as a SwingScilabMenuItem + * @param editor the associated editor + * @param title the menu title + * @return the menu item + */ + public static SwingScilabMenuItem createJMenuItem(SwingScilabVariableEditor editor, String title) { + return (SwingScilabMenuItem) createMenuItem(editor, title).getAsSimpleMenuItem(); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/CellEditorFactory.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/CellEditorFactory.java new file mode 100755 index 000000000..0633d1a94 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/CellEditorFactory.java @@ -0,0 +1,57 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.celleditor; + +import javax.swing.DefaultCellEditor; + +import org.scilab.modules.ui_data.EditVar; + +/** + * Renderer factory + * @author Allan SIMON + * @author Bruno JOFRET + */ +public final class CellEditorFactory { + + /** + * Constructor + */ + private CellEditorFactory() { } + + /** + * @param type the type + * @return the CellEditor + */ + public static DefaultCellEditor createCellEditor(String type) { + DefaultCellEditor editor = new ScilabStringCellEditor(); + if (type.equals(EditVar.STRING)) { + editor = new ScilabStringCellEditor(); + } else if (type.equals(EditVar.COMPLEX)) { + editor = new ScilabComplexCellEditor(); + } else if (type.equals(EditVar.DOUBLE)) { + editor = new ScilabDoubleCellEditor(); + } else if (type.equals(EditVar.BOOLEAN)) { + editor = new ScilabBooleanCellEditor(); + } else if (type.equals(EditVar.INTEGER)) { + editor = new ScilabIntegerCellEditor(); + } else if (type.equals(EditVar.SPARSE)) { + editor = new ScilabDoubleCellEditor(); + } else if (type.equals(EditVar.COMPLEXSPARSE)) { + editor = new ScilabComplexCellEditor(); + } else if (type.equals(EditVar.BOOLEANSPARSE)) { + editor = new ScilabBooleanCellEditor(); + } + + return editor; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabBooleanCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabBooleanCellEditor.java new file mode 100755 index 000000000..c51b784b6 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabBooleanCellEditor.java @@ -0,0 +1,49 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.celleditor; + +/** + * CellEditor for boolean type + * @author Allan SIMON + * @author Bruno JOFRET + */ +public class ScilabBooleanCellEditor extends ScilabGenericCellEditor { + + private static final long serialVersionUID = 3866054279955696250L; + + /** + * Constructor + */ + public ScilabBooleanCellEditor() { + super(); + } + + /** + * {@inheritDoc} + */ + public String getDataAsScilabString(Object value) { + String newValue = ""; + if (value != null && value instanceof Boolean) { + if (((Boolean) value).booleanValue()) { + newValue = "%t"; + } else { + newValue = "%f"; + } + } else if (value instanceof String) { + newValue = (String) value; + } + + return newValue; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabComplexCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabComplexCellEditor.java new file mode 100755 index 000000000..ab3c58cea --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabComplexCellEditor.java @@ -0,0 +1,97 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +package org.scilab.modules.ui_data.variableeditor.celleditor; + +/** + * CellEditor for complex type + * @author Allan SIMON + * @author Calixte DENIZET + */ +public class ScilabComplexCellEditor extends ScilabGenericCellEditor { + + private static final long serialVersionUID = 3866044279955696250L; + private static final String I = "*%i"; + private static final String PLUS = "+"; + + /** + * Constructor + */ + public ScilabComplexCellEditor() { + super(); + } + + /** + * {@inheritDoc} + */ + public String getDataAsScilabString(Object value) { + String newValue = ""; + if (value != null && value instanceof Double[]) { + newValue = convertComplex((Double[]) value); + } else if (value instanceof String) { + newValue = (String) value; + } + + return newValue; + } + + /** + * Convert a finite double, %nan or +/-%inf + * @param d the double to convert + * @return the double in String format + */ + protected static String convertDouble(Double d) { + if (d.isNaN()) { + return "%nan"; + } else if (d.isInfinite()) { + if (d.doubleValue() < 0) { + return "-%inf"; + } else { + return "%inf"; + } + } else { + return d.toString(); + } + } + + /** + * Convert a complex into a Scilab expression + * @param comp the complex + * @return the string expression + */ + private static String convertComplex(Double[] comp) { + String re = ""; + String im = ""; + if (comp[0] == 0 && comp[1] == 0) { + re = "0"; + } else { + if (comp[1] != 0) { + if (comp[1] == 1) { + im = "+%i"; + } else if (comp[1] == -1) { + im = "-%i"; + } else if (comp[1] < 0) { + im = convertDouble(comp[1]) + I; + } else { + im = PLUS + convertDouble(comp[1]) + I; + } + } + if (comp[0] != 0) { + re = convertDouble(comp[0]); + } else if (im.startsWith(PLUS)) { + im = im.substring(1); + } + } + + return re + im; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabDoubleCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabDoubleCellEditor.java new file mode 100755 index 000000000..0c9709cfb --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabDoubleCellEditor.java @@ -0,0 +1,45 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.celleditor; + +/** + * CellEditor for double type + * @author Allan SIMON + * @author Bruno JOFRET + */ +public class ScilabDoubleCellEditor extends ScilabComplexCellEditor { + + private static final long serialVersionUID = 3866054279955696250L; + + /** + * Constructor + */ + public ScilabDoubleCellEditor() { + super(); + } + + /** + * {@inheritDoc} + */ + public String getDataAsScilabString(Object value) { + String newValue = ""; + if (value != null && value instanceof Double) { + newValue = convertDouble((Double) value); + } else if (value instanceof String) { + newValue = (String) value; + } + + return newValue; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabGenericCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabGenericCellEditor.java new file mode 100755 index 000000000..3ef95bdba --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabGenericCellEditor.java @@ -0,0 +1,51 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.celleditor; + +import java.awt.Component; + +import javax.swing.BorderFactory; +import javax.swing.DefaultCellEditor; +import javax.swing.JFormattedTextField; +import javax.swing.JTable; + +/** + * @author Calixte DENIZET + */ +public class ScilabGenericCellEditor extends DefaultCellEditor { + + private static final long serialVersionUID = -5713675180587317165L; + + /** + * Constructor + */ + public ScilabGenericCellEditor() { + super(new JFormattedTextField()); + ((JFormattedTextField) getComponent()).setBorder(BorderFactory.createEmptyBorder()); + } + + /** + * @param value the value + * @return the Scilab's representation of the value + */ + public String getDataAsScilabString(Object value) { + return ""; + } + + /** + * {@inheritDoc} + */ + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int col) { + return super.getTableCellEditorComponent(table, getDataAsScilabString(value), isSelected, row, col); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabIntegerCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabIntegerCellEditor.java new file mode 100755 index 000000000..bb530d515 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabIntegerCellEditor.java @@ -0,0 +1,43 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.celleditor; + +/** + * CellEditor for integer type + * @author Calixte DENIZET + */ +public class ScilabIntegerCellEditor extends ScilabGenericCellEditor { + + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public ScilabIntegerCellEditor() { + super(); + } + + /** + * {@inheritDoc} + */ + public String getDataAsScilabString(Object value) { + String newValue = ""; + if (value != null) { + newValue = value.toString(); + } else if (value instanceof String) { + newValue = (String) value; + } + + return newValue; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabStringCellEditor.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabStringCellEditor.java new file mode 100755 index 000000000..6e7c9ef97 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/celleditor/ScilabStringCellEditor.java @@ -0,0 +1,43 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.celleditor; + +/** + * CellEditor for string type + * @author Allan SIMON + * @author Bruno JOFRET + */ +public class ScilabStringCellEditor extends ScilabGenericCellEditor { + + private static final long serialVersionUID = 3866054279955696250L; + + /** + * Constructor + */ + public ScilabStringCellEditor() { + super(); + } + + /** + * {@inheritDoc} + */ + public String getDataAsScilabString(Object value) { + String newValue = ""; + if (value != null && value instanceof String) { + newValue = (String) value; + } + + return newValue; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/RendererFactory.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/RendererFactory.java new file mode 100755 index 000000000..3603a6cad --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/RendererFactory.java @@ -0,0 +1,58 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - DIGITEO - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import javax.swing.table.DefaultTableCellRenderer; + +import org.scilab.modules.ui_data.EditVar; + +/** + * Renderer factory + * @author Allan SIMON + * @author Bruno JOFRET + */ +public final class RendererFactory { + + /** + * Constructor + */ + private RendererFactory() { } + + /** + * @param type the type + * @return the CellRenderer + */ + public static DefaultTableCellRenderer createRenderer(String type) { + DefaultTableCellRenderer renderer = new ScilabStringRenderer(); + if (type.equals(EditVar.STRING)) { + renderer = new ScilabStringRenderer(); + } else if (type.equals(EditVar.COMPLEX)) { + renderer = new ScilabComplexRenderer(); + } else if (type.equals(EditVar.DOUBLE)) { + renderer = new ScilabDoubleRenderer(); + } else if (type.equals(EditVar.BOOLEAN)) { + renderer = new ScilabBooleanRenderer(); + } else if (type.equals(EditVar.INTEGER)) { + renderer = new ScilabIntegerRenderer(); + } else if (type.equals(EditVar.SPARSE)) { + renderer = new ScilabSparseRenderer(); + } else if (type.equals(EditVar.COMPLEXSPARSE)) { + renderer = new ScilabComplexSparseRenderer(); + } else if (type.equals(EditVar.BOOLEANSPARSE)) { + renderer = new ScilabBooleanSparseRenderer(); + } + + return renderer; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabBooleanRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabBooleanRenderer.java new file mode 100755 index 000000000..e93d650c5 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabBooleanRenderer.java @@ -0,0 +1,50 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import javax.swing.table.DefaultTableCellRenderer; + +/** + * CellRenderer for boolean type + * @author Allan SIMON + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabBooleanRenderer extends DefaultTableCellRenderer { + + /** + * Constructor + */ + public ScilabBooleanRenderer() { + super(); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (value == null) { + super.setValue(""); + } else if (value instanceof String) { + super.setValue(value); + } else { + boolean b = ((Boolean) value).booleanValue(); + String bool; + if (b) { + bool = "T"; + } else { + bool = "F"; + } + super.setValue(bool); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabBooleanSparseRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabBooleanSparseRenderer.java new file mode 100755 index 000000000..f994f9971 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabBooleanSparseRenderer.java @@ -0,0 +1,62 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JTable; + +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; + +/** + * CellRenderer for boolean type + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabBooleanSparseRenderer extends ScilabBooleanRenderer { + + /** + * Constructor + */ + public ScilabBooleanSparseRenderer() { + super(); + } + + protected static boolean isNothing(Object value) { + return value == null || (value instanceof Boolean && !((Boolean) value).booleanValue()); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (isNothing(value)) { + super.setValue(null); + } else { + super.setValue(value); + } + } + + /** + * {@inheritDoc} + */ + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (isNothing(value) && !isSelected && ((SwingEditvarTableModel) table.getModel()).getScilabMatrixRowCount() > row && ((SwingEditvarTableModel) table.getModel()).getScilabMatrixColCount() > column) { + setBackground(Color.LIGHT_GRAY); + } else { + setBackground(null); + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabComplexRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabComplexRenderer.java new file mode 100755 index 000000000..35cae4c9f --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabComplexRenderer.java @@ -0,0 +1,220 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Toolkit; +import java.util.Map; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; + +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; + +/** + * CellRenderer for complex type + * @author Allan SIMON + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabComplexRenderer extends DefaultTableCellRenderer { + + public static final int SHORT = 0; + public static final int SHORTE = 1; + public static final int LONG = 2; + public static final int LONGE = 3; + + private static final NumberFormat NUMBERFORMAT = NumberFormat.getInstance(); + private static final DecimalFormatSymbols SYMBOLS = DecimalFormatSymbols.getInstance(); + private static final DecimalFormat SHORTFORMAT = new DecimalFormat("#.####"); + private static final DecimalFormat SHORTEFORMAT = new DecimalFormat("#.####E00"); + private static final DecimalFormat LONGFORMAT = new DecimalFormat("#.###############"); + private static final DecimalFormat LONGEFORMAT = new DecimalFormat("#.###############E00"); + private static final String I = "i"; + private static final String PLUS = "+"; + + static { + SYMBOLS.setInfinity("\u221E"); + SYMBOLS.setNaN("Nan"); + SYMBOLS.setExponentSeparator("e"); + SHORTFORMAT.setDecimalFormatSymbols(SYMBOLS); + SHORTEFORMAT.setDecimalFormatSymbols(SYMBOLS); + LONGFORMAT.setDecimalFormatSymbols(SYMBOLS); + LONGEFORMAT.setDecimalFormatSymbols(SYMBOLS); + } + + private static NumberFormat numberFormat = SHORTFORMAT; + private static NumberFormat numberFormatE = SHORTEFORMAT; + + private Map desktopFontHints = (Map) Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); + private boolean areHintsSet = false; + private int ascent = -1; + private Font fontFori; + + /** + * Constructor + */ + public ScilabComplexRenderer() { + super(); + } + + /** + * Set the format. + * @param format SHORT, SHORTE, LONG or LONGE. + */ + public static void setFormat(int format) { + switch (format) { + case SHORT: + numberFormat = SHORTFORMAT; + numberFormatE = SHORTFORMAT; + break; + case SHORTE: + numberFormat = SHORTEFORMAT; + numberFormatE = SHORTEFORMAT; + break; + case LONG: + numberFormat = LONGFORMAT; + numberFormatE = LONGEFORMAT; + break; + case LONGE: + numberFormat = LONGEFORMAT; + numberFormatE = LONGEFORMAT; + break; + } + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (value == null) { + super.setValue(""); + } else if (value instanceof String) { + super.setValue(value); + } else { + super.setValue(convertComplex((Double[]) value)); + } + } + + /** + * Convert a finite double, %nan or +/-%inf + * @param d the double to convert + * @return the double into String + */ + protected static String convertDouble(Double d) { + double dd = d.doubleValue(); + if ((Math.abs(dd) < 1000 && Math.abs(dd) > 0.001) || dd == 0) { + return addSignToExponent(numberFormat.format(dd)); + } else { + return addSignToExponent(numberFormatE.format(dd)); + } + } + + /** + * Add a + for the exponential notation + */ + private static String addSignToExponent(String number) { + return number.replaceAll("e([0-9])", "e+$1"); + } + + /** + * @param comp a complex + * @return the string representation of this complex. + */ + private static String convertComplex(Double[] comp) { + String re = ""; + String im = ""; + if (comp[0] == 0 && comp[1] == 0) { + return "0"; + } else { + StringBuilder buf = new StringBuilder(); + if (comp[0] != 0) { + buf.append(convertDouble(comp[0])); + } + + if (comp[1] != 0) { + if (comp[1] == 1) { + if (comp[0] == 0) { + buf.append("i"); + } else { + buf.append("+i"); + } + } else if (comp[1] == -1) { + buf.append("-i"); + } else if (comp[1] < 0) { + buf.append(convertDouble(comp[1])); + buf.append("i"); + } else { + if (comp[0] != 0) { + buf.append("+"); + } + buf.append(convertDouble(comp[1])); + buf.append("i"); + } + } + return buf.toString(); + } + } + + /** + * {@inheritDoc} + */ + public void setFont(Font f) { + super.setFont(f); + ascent = -1; + } + + /** + * {@inheritDoc} + */ + protected void paintComponent(Graphics g) { + String value = getText(); + if (!value.isEmpty() && value.charAt(value.length() - 1) == 'i') { + Font font = getFont(); + FontMetrics fm = getFontMetrics(font); + ((Graphics2D) g).addRenderingHints(desktopFontHints); + if (ascent == -1) { + ascent = fm.getAscent(); + fontFori = new Font(Font.SERIF, Font.ITALIC | Font.BOLD, font.getSize()); + } + + g.setColor(getBackground()); + g.fillRect(0, 0, getWidth(), getHeight()); + + g.setColor(getForeground()); + g.setFont(font); + + String s = value.substring(0, value.length() - 1); + int w = SwingUtilities.computeStringWidth(fm, s); + g.drawString(s, 0, ascent); + g.setFont(fontFori); + g.drawString("i", w + 1, ascent); + } else { + super.paintComponent(g); + } + } + + /** + * @param comp a complex + * @return true if it is the null complex + */ + protected static boolean isNull(Double[] comp) { + return comp == null || (comp[0] == 0 && comp[1] == 0); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabComplexSparseRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabComplexSparseRenderer.java new file mode 100755 index 000000000..bf580dd3a --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabComplexSparseRenderer.java @@ -0,0 +1,61 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.JTable; + +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; + +/** + * CellRenderer for sparse type + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabComplexSparseRenderer extends ScilabComplexRenderer { + + /** + * Constructor + */ + public ScilabComplexSparseRenderer() { + super(); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (isNothing(value)) { + value = ""; + } + super.setValue(value); + } + + protected static boolean isNothing(Object value) { + return value == null || (value instanceof Double && ((Double) value).doubleValue() == 0) || (value instanceof Double[] && isNull((Double[]) value)); + } + + /** + * {@inheritDoc} + */ + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + if (isNothing(value) && !isSelected && ((SwingEditvarTableModel) table.getModel()).getScilabMatrixRowCount() > row && ((SwingEditvarTableModel) table.getModel()).getScilabMatrixColCount() > column) { + setBackground(Color.LIGHT_GRAY); + } else { + setBackground(null); + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabDoubleRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabDoubleRenderer.java new file mode 100755 index 000000000..54b206563 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabDoubleRenderer.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +/** + * CellRenderer for double type + * @author Allan SIMON + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabDoubleRenderer extends ScilabComplexRenderer { + + /** + * Constructor + */ + public ScilabDoubleRenderer() { + super(); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (value == null) { + super.setValue(""); + } else if (value instanceof String) { + super.setValue(value); + } else { + super.setValue(convertDouble((Double) value)); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabIntegerRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabIntegerRenderer.java new file mode 100755 index 000000000..1b9da9175 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabIntegerRenderer.java @@ -0,0 +1,43 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import javax.swing.table.DefaultTableCellRenderer; + +/** + * CellRenderer for integer type + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabIntegerRenderer extends DefaultTableCellRenderer { + + /** + * Constructor + */ + public ScilabIntegerRenderer() { + super(); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (value == null) { + super.setValue(""); + } else if (value instanceof String) { + super.setValue(value); + } else { + super.setValue(value); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabSparseRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabSparseRenderer.java new file mode 100755 index 000000000..b761aa526 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabSparseRenderer.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +/** + * CellRenderer for sparse type + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabSparseRenderer extends ScilabComplexSparseRenderer { + + /** + * Constructor + */ + public ScilabSparseRenderer() { + super(); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (isNothing(value)) { + super.setValue(""); + } else if (value instanceof String) { + super.setValue(value); + } else { + super.setValue(convertDouble((Double) value)); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabStringRenderer.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabStringRenderer.java new file mode 100755 index 000000000..70bc3f032 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/renderers/ScilabStringRenderer.java @@ -0,0 +1,41 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan SIMON + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.renderers; + +import javax.swing.table.DefaultTableCellRenderer; + +/** + * CellRenderer for string type + * @author Allan SIMON + */ +@SuppressWarnings(value = { "serial" }) +public class ScilabStringRenderer extends DefaultTableCellRenderer { + + /** + * Constructor + */ + public ScilabStringRenderer() { + super(); + } + + /** + * {@inheritDoc} + */ + protected void setValue(Object value) { + if (value == null) { + super.setValue(""); + } else { + super.setValue(value); + } + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/undo/CellsUndoManager.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/undo/CellsUndoManager.java new file mode 100755 index 000000000..995126196 --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/undo/CellsUndoManager.java @@ -0,0 +1,75 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.undo; + +import javax.swing.undo.UndoableEdit; +import javax.swing.undo.UndoManager; + +import org.scilab.modules.ui_data.variableeditor.SwingScilabVariableEditor; + +/** + * Class CellsUndoManager + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class CellsUndoManager extends UndoManager { + + private SwingScilabVariableEditor editor; + + /** + * Constructor + * @param editor the editor + */ + public CellsUndoManager(SwingScilabVariableEditor editor) { + super(); + this.editor = editor; + setLimit(-1); + } + + /** + * {@inheritDoc} + */ + public void undo() { + if (canUndo()) { + super.undo(); + editor.enableRedoButton(true); + } + editor.enableUndoButton(canUndo()); + } + + /** + * {@inheritDoc} + */ + public void redo() { + if (canRedo()) { + super.redo(); + editor.enableUndoButton(true); + } + editor.enableRedoButton(canRedo()); + } + + /** + * {@inheritDoc} + */ + public boolean addEdit(UndoableEdit e) { + if (e != null) { + boolean b = super.addEdit(e); + if (b) { + editor.enableUndoButton(true); + } + return b; + } + + return false; + } +} diff --git a/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/undo/CellsUndoableEdit.java b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/undo/CellsUndoableEdit.java new file mode 100755 index 000000000..1eb383f6f --- /dev/null +++ b/modules/ui_data/src/java/org/scilab/modules/ui_data/variableeditor/undo/CellsUndoableEdit.java @@ -0,0 +1,74 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +package org.scilab.modules.ui_data.variableeditor.undo; + +import java.util.Vector; + +import javax.swing.undo.AbstractUndoableEdit; + +import org.scilab.modules.ui_data.datatable.SwingEditvarTableModel; + +/** + * Class to make undoable edits in EditVar + * @author Calixte DENIZET + */ +@SuppressWarnings(value = { "serial" }) +public class CellsUndoableEdit extends AbstractUndoableEdit { + + private Object oldValue; + private Object newValue; + private int row; + private int col; + private int newRow; + private int newCol; + private SwingEditvarTableModel model; + + /** + * Constructor + * @param model the model where the edit occurred + */ + public CellsUndoableEdit(SwingEditvarTableModel model, Object newValue, Object oldValue, int row, int col) { + this.model = model; + this.oldValue = oldValue; + this.newValue = newValue; + this.row = row; + this.col = col; + this.newRow = model.getScilabMatrixRowCount(); + this.newCol = model.getScilabMatrixColCount(); + + } + + /** + * {@inheritDoc} + */ + public void undo() { + super.undo(); + if (oldValue instanceof Vector) { + model.changeData((Vector) oldValue, row, col); + } else { + model.setValueAtAndUpdate(true, false, oldValue, row, col); + } + } + + /** + * {@inheritDoc} + */ + public void redo() { + super.redo(); + if (newValue instanceof Vector) { + model.changeData((Vector) newValue, newRow, newCol); + } else { + model.setValueAtAndUpdate(true, false, newValue, row, col); + } + } +} diff --git a/modules/ui_data/src/jni/.deps/.dirstamp b/modules/ui_data/src/jni/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/jni/.deps/.dirstamp diff --git a/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-BrowseVar.Plo b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-BrowseVar.Plo new file mode 100755 index 000000000..e720ea24e --- /dev/null +++ b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-BrowseVar.Plo @@ -0,0 +1,341 @@ +src/jni/libsciui_data_algo_la-BrowseVar.lo: src/jni/BrowseVar.cpp \ + /usr/include/stdc-predef.h src/jni/BrowseVar.hxx \ + /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + ../../modules/commons/src/jni/GiwsException.hxx + +/usr/include/stdc-predef.h: + +src/jni/BrowseVar.hxx: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +../../modules/commons/src/jni/GiwsException.hxx: diff --git a/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-EditVar.Plo b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-EditVar.Plo new file mode 100755 index 000000000..5cd8fe759 --- /dev/null +++ b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-EditVar.Plo @@ -0,0 +1,341 @@ +src/jni/libsciui_data_algo_la-EditVar.lo: src/jni/EditVar.cpp \ + /usr/include/stdc-predef.h src/jni/EditVar.hxx \ + /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + ../../modules/commons/src/jni/GiwsException.hxx + +/usr/include/stdc-predef.h: + +src/jni/EditVar.hxx: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +../../modules/commons/src/jni/GiwsException.hxx: diff --git a/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-FileBrowser.Plo b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-FileBrowser.Plo new file mode 100755 index 000000000..482ce618d --- /dev/null +++ b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-FileBrowser.Plo @@ -0,0 +1,341 @@ +src/jni/libsciui_data_algo_la-FileBrowser.lo: src/jni/FileBrowser.cpp \ + /usr/include/stdc-predef.h src/jni/FileBrowser.hxx \ + /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + ../../modules/commons/src/jni/GiwsException.hxx + +/usr/include/stdc-predef.h: + +src/jni/FileBrowser.hxx: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +../../modules/commons/src/jni/GiwsException.hxx: diff --git a/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-ui_data_wrap.Plo b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-ui_data_wrap.Plo new file mode 100755 index 000000000..63c4d1f2f --- /dev/null +++ b/modules/ui_data/src/jni/.deps/libsciui_data_algo_la-ui_data_wrap.Plo @@ -0,0 +1,135 @@ +src/jni/libsciui_data_algo_la-ui_data_wrap.lo: src/jni/ui_data_wrap.c \ + /usr/include/stdc-predef.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \ + /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h \ + ../../modules/core/includes/MALLOC.h \ + ../../modules/core/includes/sci_mem_alloc.h \ + src/jni/../../includes/ui_data.h + +/usr/include/stdc-predef.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/stdio.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +../../modules/core/includes/MALLOC.h: + +../../modules/core/includes/sci_mem_alloc.h: + +src/jni/../../includes/ui_data.h: diff --git a/modules/ui_data/src/jni/.dirstamp b/modules/ui_data/src/jni/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/jni/.dirstamp diff --git a/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-BrowseVar.o b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-BrowseVar.o Binary files differnew file mode 100755 index 000000000..2f63f60c4 --- /dev/null +++ b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-BrowseVar.o diff --git a/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-EditVar.o b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-EditVar.o Binary files differnew file mode 100755 index 000000000..6cb542b91 --- /dev/null +++ b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-EditVar.o diff --git a/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-FileBrowser.o b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-FileBrowser.o Binary files differnew file mode 100755 index 000000000..21bc4c649 --- /dev/null +++ b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-FileBrowser.o diff --git a/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-ui_data_wrap.o b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-ui_data_wrap.o Binary files differnew file mode 100755 index 000000000..e26bced05 --- /dev/null +++ b/modules/ui_data/src/jni/.libs/libsciui_data_algo_la-ui_data_wrap.o diff --git a/modules/ui_data/src/jni/BrowseVar.cpp b/modules/ui_data/src/jni/BrowseVar.cpp new file mode 100755 index 000000000..a384151ba --- /dev/null +++ b/modules/ui_data/src/jni/BrowseVar.cpp @@ -0,0 +1,416 @@ +#include "BrowseVar.hxx" +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/BrowseVar.giws.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + +namespace org_scilab_modules_ui_data { + + // Static declarations (if any) + +// Returns the current env + +JNIEnv * BrowseVar::getCurrentEnv() { +JNIEnv * curEnv = NULL; +jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +if (res != JNI_OK) { +throw GiwsException::JniException(getCurrentEnv()); +} +return curEnv; +} +// Destructor + +BrowseVar::~BrowseVar() { +JNIEnv * curEnv = NULL; +this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +curEnv->DeleteGlobalRef(this->instance); +curEnv->DeleteGlobalRef(this->instanceClass); +curEnv->DeleteGlobalRef(this->stringArrayClass);} +// Constructors +BrowseVar::BrowseVar(JavaVM * jvm_) { +jmethodID constructObject = NULL ; +jobject localInstance ; +jclass localClass ; + +const std::string construct="<init>"; +const std::string param="()V"; +jvm=jvm_; + +JNIEnv * curEnv = getCurrentEnv(); + +localClass = curEnv->FindClass( this->className().c_str() ) ; +if (localClass == NULL) { + throw GiwsException::JniClassNotFoundException(curEnv, this->className()); +} + +this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + +/* localClass is not needed anymore */ +curEnv->DeleteLocalRef(localClass); + +if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + + +constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ; +if(constructObject == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ; +if(localInstance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +this->instance = curEnv->NewGlobalRef(localInstance) ; +if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} +/* localInstance not needed anymore */ +curEnv->DeleteLocalRef(localInstance); + + /* Methods ID set to NULL */ +voidopenVariableBrowserID=NULL; +voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID=NULL; +voidupdateVariableBrowserDataID=NULL; +jbooleanisVariableBrowserOpenedID=NULL; +voidcloseVariableBrowserID=NULL; + + +} + +BrowseVar::BrowseVar(JavaVM * jvm_, jobject JObj) { + jvm=jvm_; + + JNIEnv * curEnv = getCurrentEnv(); + +jclass localClass = curEnv->GetObjectClass(JObj); + this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + curEnv->DeleteLocalRef(localClass); + + if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + + this->instance = curEnv->NewGlobalRef(JObj) ; + if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + /* Methods ID set to NULL */ + voidopenVariableBrowserID=NULL; +voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID=NULL; +voidupdateVariableBrowserDataID=NULL; +jbooleanisVariableBrowserOpenedID=NULL; +voidcloseVariableBrowserID=NULL; + + +} + +// Generic methods + +void BrowseVar::synchronize() { +if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "BrowseVar"); +} +} + +void BrowseVar::endSynchronize() { +if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "BrowseVar"); +} +} +// Method(s) + +void BrowseVar::openVariableBrowser (JavaVM * jvm_){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableBrowserID = curEnv->GetStaticMethodID(cls, "openVariableBrowser", "()V" ) ; +if (voidopenVariableBrowserID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableBrowser"); +} + + curEnv->CallStaticVoidMethod(cls, voidopenVariableBrowserID ); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void BrowseVar::setVariableBrowserData (JavaVM * jvm_, char const* const* variableNames, int variableNamesSize, int const* variableBytes, int variableBytesSize, int const* variableTypes, int variableTypesSize, int const* variableIntegerTypes, int variableIntegerTypesSize, char const* const* variableListTypes, int variableListTypesSize, char const* const* variableSize, int variableSizeSize, int const* variableNbRows, int variableNbRowsSize, int const* variableNbCols, int variableNbColsSize, char const* const* variableVisibility, int variableVisibilitySize, bool const* variableFromUser, int variableFromUserSize){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID = curEnv->GetStaticMethodID(cls, "setVariableBrowserData", "([Ljava/lang/String;[I[I[I[Ljava/lang/String;[Ljava/lang/String;[I[I[Ljava/lang/String;[Z)V" ) ; +if (voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "setVariableBrowserData"); +} +jclass stringArrayClass = curEnv->FindClass("java/lang/String"); + +// create java array of strings. +jobjectArray variableNames_ = curEnv->NewObjectArray( variableNamesSize, stringArrayClass, NULL); +if (variableNames_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +// convert each char * to java strings and fill the java array. +for ( int i = 0; i < variableNamesSize; i++) +{ +jstring TempString = curEnv->NewStringUTF( variableNames[i] ); +if (TempString == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetObjectArrayElement( variableNames_, i, TempString); + +// avoid keeping reference on too many strings +curEnv->DeleteLocalRef(TempString); +} +jintArray variableBytes_ = curEnv->NewIntArray( variableBytesSize ) ; + +if (variableBytes_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( variableBytes_, 0, variableBytesSize, (jint*)(variableBytes) ) ; + + +jintArray variableTypes_ = curEnv->NewIntArray( variableTypesSize ) ; + +if (variableTypes_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( variableTypes_, 0, variableTypesSize, (jint*)(variableTypes) ) ; + + +jintArray variableIntegerTypes_ = curEnv->NewIntArray( variableIntegerTypesSize ) ; + +if (variableIntegerTypes_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( variableIntegerTypes_, 0, variableIntegerTypesSize, (jint*)(variableIntegerTypes) ) ; + + + +// create java array of strings. +jobjectArray variableListTypes_ = curEnv->NewObjectArray( variableListTypesSize, stringArrayClass, NULL); +if (variableListTypes_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +// convert each char * to java strings and fill the java array. +for ( int i = 0; i < variableListTypesSize; i++) +{ +jstring TempString = curEnv->NewStringUTF( variableListTypes[i] ); +if (TempString == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetObjectArrayElement( variableListTypes_, i, TempString); + +// avoid keeping reference on too many strings +curEnv->DeleteLocalRef(TempString); +} + +// create java array of strings. +jobjectArray variableSize_ = curEnv->NewObjectArray( variableSizeSize, stringArrayClass, NULL); +if (variableSize_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +// convert each char * to java strings and fill the java array. +for ( int i = 0; i < variableSizeSize; i++) +{ +jstring TempString = curEnv->NewStringUTF( variableSize[i] ); +if (TempString == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetObjectArrayElement( variableSize_, i, TempString); + +// avoid keeping reference on too many strings +curEnv->DeleteLocalRef(TempString); +} +jintArray variableNbRows_ = curEnv->NewIntArray( variableNbRowsSize ) ; + +if (variableNbRows_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( variableNbRows_, 0, variableNbRowsSize, (jint*)(variableNbRows) ) ; + + +jintArray variableNbCols_ = curEnv->NewIntArray( variableNbColsSize ) ; + +if (variableNbCols_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( variableNbCols_, 0, variableNbColsSize, (jint*)(variableNbCols) ) ; + + + +// create java array of strings. +jobjectArray variableVisibility_ = curEnv->NewObjectArray( variableVisibilitySize, stringArrayClass, NULL); +if (variableVisibility_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +// convert each char * to java strings and fill the java array. +for ( int i = 0; i < variableVisibilitySize; i++) +{ +jstring TempString = curEnv->NewStringUTF( variableVisibility[i] ); +if (TempString == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetObjectArrayElement( variableVisibility_, i, TempString); + +// avoid keeping reference on too many strings +curEnv->DeleteLocalRef(TempString); +} +jbooleanArray variableFromUser_ = curEnv->NewBooleanArray( variableFromUserSize ) ; +curEnv->SetBooleanArrayRegion( variableFromUser_, 0, variableFromUserSize, (jboolean*)variableFromUser ) ; + + curEnv->CallStaticVoidMethod(cls, voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID ,variableNames_, variableBytes_, variableTypes_, variableIntegerTypes_, variableListTypes_, variableSize_, variableNbRows_, variableNbCols_, variableVisibility_, variableFromUser_); + curEnv->DeleteLocalRef(stringArrayClass); +curEnv->DeleteLocalRef(variableNames_); +curEnv->DeleteLocalRef(variableBytes_); +curEnv->DeleteLocalRef(variableTypes_); +curEnv->DeleteLocalRef(variableIntegerTypes_); +curEnv->DeleteLocalRef(variableListTypes_); +curEnv->DeleteLocalRef(variableSize_); +curEnv->DeleteLocalRef(variableNbRows_); +curEnv->DeleteLocalRef(variableNbCols_); +curEnv->DeleteLocalRef(variableVisibility_); +curEnv->DeleteLocalRef(variableFromUser_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void BrowseVar::updateVariableBrowserData (JavaVM * jvm_){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidupdateVariableBrowserDataID = curEnv->GetStaticMethodID(cls, "updateVariableBrowserData", "()V" ) ; +if (voidupdateVariableBrowserDataID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "updateVariableBrowserData"); +} + + curEnv->CallStaticVoidMethod(cls, voidupdateVariableBrowserDataID ); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +bool BrowseVar::isVariableBrowserOpened (JavaVM * jvm_){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID jbooleanisVariableBrowserOpenedID = curEnv->GetStaticMethodID(cls, "isVariableBrowserOpened", "()Z" ) ; +if (jbooleanisVariableBrowserOpenedID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "isVariableBrowserOpened"); +} + + jboolean res = static_cast<jboolean>( curEnv->CallStaticBooleanMethod(cls, jbooleanisVariableBrowserOpenedID )); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +return (res == JNI_TRUE); + +} + +void BrowseVar::closeVariableBrowser (JavaVM * jvm_){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidcloseVariableBrowserID = curEnv->GetStaticMethodID(cls, "closeVariableBrowser", "()V" ) ; +if (voidcloseVariableBrowserID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "closeVariableBrowser"); +} + + curEnv->CallStaticVoidMethod(cls, voidcloseVariableBrowserID ); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +} diff --git a/modules/ui_data/src/jni/BrowseVar.giws.xml b/modules/ui_data/src/jni/BrowseVar.giws.xml new file mode 100755 index 000000000..abe5e5d86 --- /dev/null +++ b/modules/ui_data/src/jni/BrowseVar.giws.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<package name="org.scilab.modules.ui_data"> + <object name="BrowseVar"> + <method name="openVariableBrowser" returnType="void" modifier="static"/> + <method name="setVariableBrowserData" returnType="void" modifier="static"> + <parameter type="String[]" name="variableNames"/> + <parameter type="int[]" name="variableBytes"/> + <parameter type="int[]" name="variableTypes"/> + <parameter type="int[]" name="variableIntegerTypes"/> + <parameter type="String[]" name="variableListTypes"/> + <parameter type="String[]" name="variableSize"/> + <parameter type="int[]" name="variableNbRows"/> + <parameter type="int[]" name="variableNbCols"/> + <parameter type="String[]" name="variableVisibility"/> + <parameter type="boolean[]" name="variableFromUser"/> + </method> + <methode name="updateVariableBrowserData" returnType="void" modifier="static"/> + <method name="isVariableBrowserOpened" returnType="boolean" modifier="static"/> + <method name="closeVariableBrowser" returnType="void" modifier="static"/> + </object> +</package> diff --git a/modules/ui_data/src/jni/BrowseVar.hxx b/modules/ui_data/src/jni/BrowseVar.hxx new file mode 100755 index 000000000..b979911d1 --- /dev/null +++ b/modules/ui_data/src/jni/BrowseVar.hxx @@ -0,0 +1,191 @@ +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/BrowseVar.giws.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + + +#ifndef __ORG_SCILAB_MODULES_UI_DATA_BROWSEVAR__ +#define __ORG_SCILAB_MODULES_UI_DATA_BROWSEVAR__ +#include <iostream> +#include <string> +#include <string.h> +#include <stdlib.h> +#include <jni.h> + +#include "GiwsException.hxx" + + #if defined(_MSC_VER) /* Defined anyway with Visual */ + #include <Windows.h> + #else + typedef signed char byte; + #endif + + +#ifndef GIWSEXPORT +# if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define GIWSEXPORT +# else +# define GIWSEXPORT __declspec(dllexport) +# endif +# else +# if __GNUC__ >= 4 +# define GIWSEXPORT __attribute__ ((visibility ("default"))) +# else +# define GIWSEXPORT +# endif +# endif +#endif + +namespace org_scilab_modules_ui_data { +class GIWSEXPORT BrowseVar { + +private: +JavaVM * jvm; + +protected: +jmethodID voidopenVariableBrowserID; // cache method id +jmethodID voidsetVariableBrowserDatajobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjobjectArray_java_lang_Stringjava_lang_StringjintArray_intintjintArray_intintjobjectArray_java_lang_Stringjava_lang_StringjbooleanArray_booleanbooleanID; // cache method id +jclass stringArrayClass; +jmethodID voidupdateVariableBrowserDataID; // cache method id +jmethodID jbooleanisVariableBrowserOpenedID; // cache method id +jmethodID voidcloseVariableBrowserID; // cache method id + + + +jobject instance; +jclass instanceClass; // cache class + + +// Caching (if any) + + +/** +* Get the environment matching to the current thread. +*/ +virtual JNIEnv * getCurrentEnv(); + +public: +// Constructor +/** +* Create a wrapping of the object from a JNIEnv. +* It will call the default constructor +* @param JEnv_ the Java Env +*/ +BrowseVar(JavaVM * jvm_); + +/** +* Create a wrapping of an already existing object from a JNIEnv. +* The object must have already been instantiated +* @param JEnv_ the Java Env +* @param JObj the object +*/ +BrowseVar(JavaVM * jvm_, jobject JObj); + + +/** +* This is a fake constructor to avoid the constructor +* chaining when dealing with extended giws classes +*/ +#ifdef FAKEGIWSDATATYPE +BrowseVar(fakeGiwsDataType::fakeGiwsDataType /* unused */) {} +#endif + +// Destructor +~BrowseVar(); + +// Generic method +// Synchronization methods +/** +* Enter monitor associated with the object. +* Equivalent of creating a "synchronized(obj)" scope in Java. +*/ +void synchronize(); + +/** +* Exit monitor associated with the object. +* Equivalent of ending a "synchronized(obj)" scope. +*/ +void endSynchronize(); + +// Methods +static void openVariableBrowser(JavaVM * jvm_); + +static void setVariableBrowserData(JavaVM * jvm_, char const* const* variableNames, int variableNamesSize, int const* variableBytes, int variableBytesSize, int const* variableTypes, int variableTypesSize, int const* variableIntegerTypes, int variableIntegerTypesSize, char const* const* variableListTypes, int variableListTypesSize, char const* const* variableSize, int variableSizeSize, int const* variableNbRows, int variableNbRowsSize, int const* variableNbCols, int variableNbColsSize, char const* const* variableVisibility, int variableVisibilitySize, bool const* variableFromUser, int variableFromUserSize); + +static void updateVariableBrowserData(JavaVM * jvm_); + +static bool isVariableBrowserOpened(JavaVM * jvm_); + +static void closeVariableBrowser(JavaVM * jvm_); + + + /** + * Get class name to use for static methods + * @return class name to use for static methods + */ + + static const std::string className() + { + return "org/scilab/modules/ui_data/BrowseVar"; + } + + + /** + * Get class to use for static methods + * @return class to use for static methods + */ + + static jclass initClass(JNIEnv * curEnv) + { + static jclass cls = 0; + + if (cls == 0) + { + jclass _cls = curEnv->FindClass(className().c_str()); + if (_cls) + { + cls = static_cast<jclass>(curEnv->NewGlobalRef(_cls)); + } + } + + return cls; + } + +}; + + +} +#endif diff --git a/modules/ui_data/src/jni/EditVar.cpp b/modules/ui_data/src/jni/EditVar.cpp new file mode 100755 index 000000000..549255a8d --- /dev/null +++ b/modules/ui_data/src/jni/EditVar.cpp @@ -0,0 +1,2021 @@ +#include "EditVar.hxx" +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/EditVar.giws.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + +namespace org_scilab_modules_ui_data { + + // Static declarations (if any) + +// Returns the current env + +JNIEnv * EditVar::getCurrentEnv() { +JNIEnv * curEnv = NULL; +jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +if (res != JNI_OK) { +throw GiwsException::JniException(getCurrentEnv()); +} +return curEnv; +} +// Destructor + +EditVar::~EditVar() { +JNIEnv * curEnv = NULL; +this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +curEnv->DeleteGlobalRef(this->instance); +curEnv->DeleteGlobalRef(this->instanceClass); +curEnv->DeleteGlobalRef(this->stringArrayClass);} +// Constructors +EditVar::EditVar(JavaVM * jvm_) { +jmethodID constructObject = NULL ; +jobject localInstance ; +jclass localClass ; + +const std::string construct="<init>"; +const std::string param="()V"; +jvm=jvm_; + +JNIEnv * curEnv = getCurrentEnv(); + +localClass = curEnv->FindClass( this->className().c_str() ) ; +if (localClass == NULL) { + throw GiwsException::JniClassNotFoundException(curEnv, this->className()); +} + +this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + +/* localClass is not needed anymore */ +curEnv->DeleteLocalRef(localClass); + +if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + + +constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ; +if(constructObject == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ; +if(localInstance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +this->instance = curEnv->NewGlobalRef(localInstance) ; +if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} +/* localInstance not needed anymore */ +curEnv->DeleteLocalRef(localInstance); + + /* Methods ID set to NULL */ +voidopenVariableEditorDoublejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorBooleanSparsejobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorSparsejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorStringjobjectArray__java_lang_Stringjava_lang_Stringjstringjava_lang_StringID=NULL; +voidopenVariableEditorBooleanjobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorInteger8jobjectArray__bytebytejstringjava_lang_StringID=NULL; +voidopenVariableEditorUInteger8jobjectArray__shortshortjstringjava_lang_StringID=NULL; +voidopenVariableEditorInteger16jobjectArray__shortshortjstringjava_lang_StringID=NULL; +voidopenVariableEditorUInteger16jobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorInteger32jobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorUInteger32jobjectArray__longlongjstringjava_lang_StringID=NULL; +voidrefreshVariableEditorDoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorBooleanSparsejobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorSparsejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorStringjobjectArray__java_lang_Stringjava_lang_StringjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorBooleanjobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorInteger8jobjectArray__bytebytejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorUInteger8jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorInteger16jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorUInteger16jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorInteger32jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorUInteger32jobjectArray__longlongjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidcloseVariableEditorID=NULL; + + +} + +EditVar::EditVar(JavaVM * jvm_, jobject JObj) { + jvm=jvm_; + + JNIEnv * curEnv = getCurrentEnv(); + +jclass localClass = curEnv->GetObjectClass(JObj); + this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + curEnv->DeleteLocalRef(localClass); + + if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + + this->instance = curEnv->NewGlobalRef(JObj) ; + if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + /* Methods ID set to NULL */ + voidopenVariableEditorDoublejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorBooleanSparsejobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorSparsejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID=NULL; +voidopenVariableEditorStringjobjectArray__java_lang_Stringjava_lang_Stringjstringjava_lang_StringID=NULL; +voidopenVariableEditorBooleanjobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorInteger8jobjectArray__bytebytejstringjava_lang_StringID=NULL; +voidopenVariableEditorUInteger8jobjectArray__shortshortjstringjava_lang_StringID=NULL; +voidopenVariableEditorInteger16jobjectArray__shortshortjstringjava_lang_StringID=NULL; +voidopenVariableEditorUInteger16jobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorInteger32jobjectArray__intintjstringjava_lang_StringID=NULL; +voidopenVariableEditorUInteger32jobjectArray__longlongjstringjava_lang_StringID=NULL; +voidrefreshVariableEditorDoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorBooleanSparsejobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorSparsejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorStringjobjectArray__java_lang_Stringjava_lang_StringjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorBooleanjobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorInteger8jobjectArray__bytebytejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorUInteger8jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorInteger16jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorUInteger16jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorInteger32jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidrefreshVariableEditorUInteger32jobjectArray__longlongjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID=NULL; +voidcloseVariableEditorID=NULL; + + +} + +// Generic methods + +void EditVar::synchronize() { +if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "EditVar"); +} +} + +void EditVar::endSynchronize() { +if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "EditVar"); +} +} +// Method(s) + +void EditVar::openVariableEditorDouble (JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorDoublejobjectArray__doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorDouble", "([[DLjava/lang/String;)V" ) ; +if (voidopenVariableEditorDoublejobjectArray__doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorDouble"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[D"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jdoubleArray dataLocal = curEnv->NewDoubleArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( dataLocal, 0, dataSizeCol, (jdouble*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorDoublejobjectArray__doubledoublejstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorBooleanSparse (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorBooleanSparsejobjectArray__intintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorBooleanSparse", "([[ILjava/lang/String;)V" ) ; +if (voidopenVariableEditorBooleanSparsejobjectArray__intintjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorBooleanSparse"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorBooleanSparsejobjectArray__intintjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorSparse (JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorSparsejobjectArray__doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorSparse", "([[DLjava/lang/String;)V" ) ; +if (voidopenVariableEditorSparsejobjectArray__doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorSparse"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[D"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jdoubleArray dataLocal = curEnv->NewDoubleArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( dataLocal, 0, dataSizeCol, (jdouble*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorSparsejobjectArray__doubledoublejstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorComplexSparse (JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* complexData, int complexDataSize, int complexDataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorComplexSparse", "([[D[[DLjava/lang/String;)V" ) ; +if (voidopenVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorComplexSparse"); +} + + jobjectArray realData_ = curEnv->NewObjectArray(realDataSize, curEnv->FindClass("[D"),NULL); + +if (realData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<realDataSize; i++){ + +jdoubleArray realDataLocal = curEnv->NewDoubleArray( realDataSizeCol ) ; + +if (realDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(realData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( realDataLocal, 0, realDataSizeCol, (jdouble*)(realData[i]) ) ; +curEnv->SetObjectArrayElement(realData_, i, realDataLocal); +curEnv->DeleteLocalRef(realDataLocal); +} + + jobjectArray complexData_ = curEnv->NewObjectArray(complexDataSize, curEnv->FindClass("[D"),NULL); + +if (complexData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<complexDataSize; i++){ + +jdoubleArray complexDataLocal = curEnv->NewDoubleArray( complexDataSizeCol ) ; + +if (complexDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(complexData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( complexDataLocal, 0, complexDataSizeCol, (jdouble*)(complexData[i]) ) ; +curEnv->SetObjectArrayElement(complexData_, i, complexDataLocal); +curEnv->DeleteLocalRef(complexDataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID ,realData_, complexData_, variableName_); + curEnv->DeleteLocalRef(realData_); +curEnv->DeleteLocalRef(complexData_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorComplex (JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* imgData, int imgDataSize, int imgDataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorComplex", "([[D[[DLjava/lang/String;)V" ) ; +if (voidopenVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorComplex"); +} + + jobjectArray realData_ = curEnv->NewObjectArray(realDataSize, curEnv->FindClass("[D"),NULL); + +if (realData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<realDataSize; i++){ + +jdoubleArray realDataLocal = curEnv->NewDoubleArray( realDataSizeCol ) ; + +if (realDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(realData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( realDataLocal, 0, realDataSizeCol, (jdouble*)(realData[i]) ) ; +curEnv->SetObjectArrayElement(realData_, i, realDataLocal); +curEnv->DeleteLocalRef(realDataLocal); +} + + jobjectArray imgData_ = curEnv->NewObjectArray(imgDataSize, curEnv->FindClass("[D"),NULL); + +if (imgData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<imgDataSize; i++){ + +jdoubleArray imgDataLocal = curEnv->NewDoubleArray( imgDataSizeCol ) ; + +if (imgDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(imgData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( imgDataLocal, 0, imgDataSizeCol, (jdouble*)(imgData[i]) ) ; +curEnv->SetObjectArrayElement(imgData_, i, imgDataLocal); +curEnv->DeleteLocalRef(imgDataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID ,realData_, imgData_, variableName_); + curEnv->DeleteLocalRef(realData_); +curEnv->DeleteLocalRef(imgData_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorString (JavaVM * jvm_, char const* const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorStringjobjectArray__java_lang_Stringjava_lang_Stringjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorString", "([[Ljava/lang/String;Ljava/lang/String;)V" ) ; +if (voidopenVariableEditorStringjobjectArray__java_lang_Stringjava_lang_Stringjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorString"); +} +jclass stringArrayClass = curEnv->FindClass("java/lang/String"); +// create java array of array of strings. +jobjectArray data_ = curEnv->NewObjectArray( dataSize, curEnv->FindClass("[Ljava/lang/String;"), NULL); +if (data_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +for ( int i = 0; i < dataSize; i++) +{ +jobjectArray dataLocal = curEnv->NewObjectArray( dataSizeCol, stringArrayClass, NULL); +// convert each char * to java strings and fill the java array. +for ( int j = 0; j < dataSizeCol; j++) { +jstring TempString = curEnv->NewStringUTF( data[i][j] ); + +if (TempString == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetObjectArrayElement( dataLocal, j, TempString); + +// avoid keeping reference on too many strings +curEnv->DeleteLocalRef(TempString); +} +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); + +} +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorStringjobjectArray__java_lang_Stringjava_lang_Stringjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(stringArrayClass); +curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorBoolean (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorBooleanjobjectArray__intintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorBoolean", "([[ILjava/lang/String;)V" ) ; +if (voidopenVariableEditorBooleanjobjectArray__intintjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorBoolean"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorBooleanjobjectArray__intintjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorInteger8 (JavaVM * jvm_, byte const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorInteger8jobjectArray__bytebytejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorInteger8", "([[BLjava/lang/String;)V" ) ; +if (voidopenVariableEditorInteger8jobjectArray__bytebytejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorInteger8"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[B"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jbyteArray dataLocal = curEnv->NewByteArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetByteArrayRegion( dataLocal, 0, dataSizeCol, (jbyte*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorInteger8jobjectArray__bytebytejstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorUInteger8 (JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorUInteger8jobjectArray__shortshortjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorUInteger8", "([[SLjava/lang/String;)V" ) ; +if (voidopenVariableEditorUInteger8jobjectArray__shortshortjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorUInteger8"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[S"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jshortArray dataLocal = curEnv->NewShortArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetShortArrayRegion( dataLocal, 0, dataSizeCol, (jshort*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorUInteger8jobjectArray__shortshortjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorInteger16 (JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorInteger16jobjectArray__shortshortjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorInteger16", "([[SLjava/lang/String;)V" ) ; +if (voidopenVariableEditorInteger16jobjectArray__shortshortjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorInteger16"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[S"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jshortArray dataLocal = curEnv->NewShortArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetShortArrayRegion( dataLocal, 0, dataSizeCol, (jshort*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorInteger16jobjectArray__shortshortjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorUInteger16 (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorUInteger16jobjectArray__intintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorUInteger16", "([[ILjava/lang/String;)V" ) ; +if (voidopenVariableEditorUInteger16jobjectArray__intintjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorUInteger16"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorUInteger16jobjectArray__intintjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorInteger32 (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorInteger32jobjectArray__intintjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorInteger32", "([[ILjava/lang/String;)V" ) ; +if (voidopenVariableEditorInteger32jobjectArray__intintjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorInteger32"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorInteger32jobjectArray__intintjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::openVariableEditorUInteger32 (JavaVM * jvm_, long long const* const* data, int dataSize, int dataSizeCol, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenVariableEditorUInteger32jobjectArray__longlongjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "openVariableEditorUInteger32", "([[JLjava/lang/String;)V" ) ; +if (voidopenVariableEditorUInteger32jobjectArray__longlongjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openVariableEditorUInteger32"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[J"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jlongArray dataLocal = curEnv->NewLongArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetLongArrayRegion( dataLocal, 0, dataSizeCol, (jlong*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidopenVariableEditorUInteger32jobjectArray__longlongjstringjava_lang_StringID ,data_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorDouble (JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorDoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorDouble", "([[D[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorDoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorDouble"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[D"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jdoubleArray dataLocal = curEnv->NewDoubleArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( dataLocal, 0, dataSizeCol, (jdouble*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorDoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorBooleanSparse (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorBooleanSparsejobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorBooleanSparse", "([[I[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorBooleanSparsejobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorBooleanSparse"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorBooleanSparsejobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorSparse (JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorSparsejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorSparse", "([[D[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorSparsejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorSparse"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[D"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jdoubleArray dataLocal = curEnv->NewDoubleArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( dataLocal, 0, dataSizeCol, (jdouble*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorSparsejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorComplexSparse (JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* complexData, int complexDataSize, int complexDataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorComplexSparse", "([[D[[D[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorComplexSparse"); +} + + jobjectArray realData_ = curEnv->NewObjectArray(realDataSize, curEnv->FindClass("[D"),NULL); + +if (realData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<realDataSize; i++){ + +jdoubleArray realDataLocal = curEnv->NewDoubleArray( realDataSizeCol ) ; + +if (realDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(realData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( realDataLocal, 0, realDataSizeCol, (jdouble*)(realData[i]) ) ; +curEnv->SetObjectArrayElement(realData_, i, realDataLocal); +curEnv->DeleteLocalRef(realDataLocal); +} + + jobjectArray complexData_ = curEnv->NewObjectArray(complexDataSize, curEnv->FindClass("[D"),NULL); + +if (complexData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<complexDataSize; i++){ + +jdoubleArray complexDataLocal = curEnv->NewDoubleArray( complexDataSizeCol ) ; + +if (complexDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(complexData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( complexDataLocal, 0, complexDataSizeCol, (jdouble*)(complexData[i]) ) ; +curEnv->SetObjectArrayElement(complexData_, i, complexDataLocal); +curEnv->DeleteLocalRef(complexDataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,realData_, complexData_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(realData_); +curEnv->DeleteLocalRef(complexData_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorComplex (JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* imgData, int imgDataSize, int imgDataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorComplex", "([[D[[D[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorComplex"); +} + + jobjectArray realData_ = curEnv->NewObjectArray(realDataSize, curEnv->FindClass("[D"),NULL); + +if (realData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<realDataSize; i++){ + +jdoubleArray realDataLocal = curEnv->NewDoubleArray( realDataSizeCol ) ; + +if (realDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(realData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( realDataLocal, 0, realDataSizeCol, (jdouble*)(realData[i]) ) ; +curEnv->SetObjectArrayElement(realData_, i, realDataLocal); +curEnv->DeleteLocalRef(realDataLocal); +} + + jobjectArray imgData_ = curEnv->NewObjectArray(imgDataSize, curEnv->FindClass("[D"),NULL); + +if (imgData_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<imgDataSize; i++){ + +jdoubleArray imgDataLocal = curEnv->NewDoubleArray( imgDataSizeCol ) ; + +if (imgDataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(imgData_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( imgDataLocal, 0, imgDataSizeCol, (jdouble*)(imgData[i]) ) ; +curEnv->SetObjectArrayElement(imgData_, i, imgDataLocal); +curEnv->DeleteLocalRef(imgDataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,realData_, imgData_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(realData_); +curEnv->DeleteLocalRef(imgData_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorString (JavaVM * jvm_, char const* const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorStringjobjectArray__java_lang_Stringjava_lang_StringjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorString", "([[Ljava/lang/String;[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorStringjobjectArray__java_lang_Stringjava_lang_StringjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorString"); +} +jclass stringArrayClass = curEnv->FindClass("java/lang/String"); +// create java array of array of strings. +jobjectArray data_ = curEnv->NewObjectArray( dataSize, curEnv->FindClass("[Ljava/lang/String;"), NULL); +if (data_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +for ( int i = 0; i < dataSize; i++) +{ +jobjectArray dataLocal = curEnv->NewObjectArray( dataSizeCol, stringArrayClass, NULL); +// convert each char * to java strings and fill the java array. +for ( int j = 0; j < dataSizeCol; j++) { +jstring TempString = curEnv->NewStringUTF( data[i][j] ); + +if (TempString == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetObjectArrayElement( dataLocal, j, TempString); + +// avoid keeping reference on too many strings +curEnv->DeleteLocalRef(TempString); +} +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); + +} +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorStringjobjectArray__java_lang_Stringjava_lang_StringjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(stringArrayClass); +curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorBoolean (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorBooleanjobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorBoolean", "([[I[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorBooleanjobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorBoolean"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorBooleanjobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorInteger8 (JavaVM * jvm_, byte const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorInteger8jobjectArray__bytebytejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorInteger8", "([[B[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorInteger8jobjectArray__bytebytejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorInteger8"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[B"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jbyteArray dataLocal = curEnv->NewByteArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetByteArrayRegion( dataLocal, 0, dataSizeCol, (jbyte*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorInteger8jobjectArray__bytebytejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorUInteger8 (JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorUInteger8jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorUInteger8", "([[S[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorUInteger8jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorUInteger8"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[S"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jshortArray dataLocal = curEnv->NewShortArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetShortArrayRegion( dataLocal, 0, dataSizeCol, (jshort*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorUInteger8jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorInteger16 (JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorInteger16jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorInteger16", "([[S[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorInteger16jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorInteger16"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[S"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jshortArray dataLocal = curEnv->NewShortArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetShortArrayRegion( dataLocal, 0, dataSizeCol, (jshort*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorInteger16jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorUInteger16 (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorUInteger16jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorUInteger16", "([[I[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorUInteger16jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorUInteger16"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorUInteger16jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorInteger32 (JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorInteger32jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorInteger32", "([[I[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorInteger32jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorInteger32"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[I"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jintArray dataLocal = curEnv->NewIntArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetIntArrayRegion( dataLocal, 0, dataSizeCol, (jint*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorInteger32jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::refreshVariableEditorUInteger32 (JavaVM * jvm_, long long const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidrefreshVariableEditorUInteger32jobjectArray__longlongjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "refreshVariableEditorUInteger32", "([[J[D[DLjava/lang/String;)V" ) ; +if (voidrefreshVariableEditorUInteger32jobjectArray__longlongjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "refreshVariableEditorUInteger32"); +} + + jobjectArray data_ = curEnv->NewObjectArray(dataSize, curEnv->FindClass("[J"),NULL); + +if (data_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + + for (int i=0; i<dataSize; i++){ + +jlongArray dataLocal = curEnv->NewLongArray( dataSizeCol ) ; + +if (dataLocal == NULL) +{ +// check that allocation succeed +curEnv->DeleteLocalRef(data_); +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetLongArrayRegion( dataLocal, 0, dataSizeCol, (jlong*)(data[i]) ) ; +curEnv->SetObjectArrayElement(data_, i, dataLocal); +curEnv->DeleteLocalRef(dataLocal); +} + +jdoubleArray rowsIndex_ = curEnv->NewDoubleArray( rowsIndexSize ) ; + +if (rowsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( rowsIndex_, 0, rowsIndexSize, (jdouble*)(rowsIndex) ) ; + + +jdoubleArray colsIndex_ = curEnv->NewDoubleArray( colsIndexSize ) ; + +if (colsIndex_ == NULL) +{ +// check that allocation succeed +throw GiwsException::JniBadAllocException(curEnv); +} + +curEnv->SetDoubleArrayRegion( colsIndex_, 0, colsIndexSize, (jdouble*)(colsIndex) ) ; + + +jstring variableName_ = curEnv->NewStringUTF( variableName ); +if (variableName != NULL && variableName_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidrefreshVariableEditorUInteger32jobjectArray__longlongjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID ,data_, rowsIndex_, colsIndex_, variableName_); + curEnv->DeleteLocalRef(data_); +curEnv->DeleteLocalRef(rowsIndex_); +curEnv->DeleteLocalRef(colsIndex_); +curEnv->DeleteLocalRef(variableName_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void EditVar::closeVariableEditor (JavaVM * jvm_){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidcloseVariableEditorID = curEnv->GetStaticMethodID(cls, "closeVariableEditor", "()V" ) ; +if (voidcloseVariableEditorID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "closeVariableEditor"); +} + + curEnv->CallStaticVoidMethod(cls, voidcloseVariableEditorID ); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +} diff --git a/modules/ui_data/src/jni/EditVar.giws.xml b/modules/ui_data/src/jni/EditVar.giws.xml new file mode 100755 index 000000000..389be66f5 --- /dev/null +++ b/modules/ui_data/src/jni/EditVar.giws.xml @@ -0,0 +1,165 @@ + <package name="org.scilab.modules.ui_data"> + <object name="EditVar"> + <method name="openVariableEditorDouble" returnType="void" modifier="static"> + <parameter type="double[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorBooleanSparse" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorSparse" returnType="void" modifier="static"> + <parameter type="double[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorComplexSparse" returnType="void" modifier="static"> + <parameter type="double[][]" name="realData"/> + <parameter type="double[][]" name="complexData"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorComplex" returnType="void" modifier="static"> + <parameter type="double[][]" name="realData"/> + <parameter type="double[][]" name="imgData"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorString" returnType="void" modifier="static"> + <parameter type="String[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorBoolean" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorInteger8" returnType="void" modifier="static"> + <parameter type="byte[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorUInteger8" returnType="void" modifier="static"> + <parameter type="short[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorInteger16" returnType="void" modifier="static"> + <parameter type="short[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorUInteger16" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorInteger32" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="openVariableEditorUInteger32" returnType="void" modifier="static"> + <parameter type="long[][]" name="data"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorDouble" returnType="void" modifier="static"> + <parameter type="double[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorBooleanSparse" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorSparse" returnType="void" modifier="static"> + <parameter type="double[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorComplexSparse" returnType="void" modifier="static"> + <parameter type="double[][]" name="realData"/> + <parameter type="double[][]" name="complexData"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorComplex" returnType="void" modifier="static"> + <parameter type="double[][]" name="realData"/> + <parameter type="double[][]" name="imgData"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorString" returnType="void" modifier="static"> + <parameter type="String[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorBoolean" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorInteger8" returnType="void" modifier="static"> + <parameter type="byte[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorUInteger8" returnType="void" modifier="static"> + <parameter type="short[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorInteger16" returnType="void" modifier="static"> + <parameter type="short[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorUInteger16" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorInteger32" returnType="void" modifier="static"> + <parameter type="int[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="refreshVariableEditorUInteger32" returnType="void" modifier="static"> + <parameter type="long[][]" name="data"/> + <parameter type="double[]" name="rowsIndex"/> + <parameter type="double[]" name="colsIndex"/> + <parameter type="String" name="variableName"/> + </method> + + <method name="closeVariableEditor" returnType="void" modifier="static"/> + </object> +</package> diff --git a/modules/ui_data/src/jni/EditVar.hxx b/modules/ui_data/src/jni/EditVar.hxx new file mode 100755 index 000000000..680225af7 --- /dev/null +++ b/modules/ui_data/src/jni/EditVar.hxx @@ -0,0 +1,257 @@ +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/EditVar.giws.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + + +#ifndef __ORG_SCILAB_MODULES_UI_DATA_EDITVAR__ +#define __ORG_SCILAB_MODULES_UI_DATA_EDITVAR__ +#include <iostream> +#include <string> +#include <string.h> +#include <stdlib.h> +#include <jni.h> + +#include "GiwsException.hxx" + + #if defined(_MSC_VER) /* Defined anyway with Visual */ + #include <Windows.h> + #else + typedef signed char byte; + #endif + + +#ifndef GIWSEXPORT +# if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define GIWSEXPORT +# else +# define GIWSEXPORT __declspec(dllexport) +# endif +# else +# if __GNUC__ >= 4 +# define GIWSEXPORT __attribute__ ((visibility ("default"))) +# else +# define GIWSEXPORT +# endif +# endif +#endif + +namespace org_scilab_modules_ui_data { +class GIWSEXPORT EditVar { + +private: +JavaVM * jvm; + +protected: +jmethodID voidopenVariableEditorDoublejobjectArray__doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorBooleanSparsejobjectArray__intintjstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorSparsejobjectArray__doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorStringjobjectArray__java_lang_Stringjava_lang_Stringjstringjava_lang_StringID; // cache method id +jclass stringArrayClass; +jmethodID voidopenVariableEditorBooleanjobjectArray__intintjstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorInteger8jobjectArray__bytebytejstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorUInteger8jobjectArray__shortshortjstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorInteger16jobjectArray__shortshortjstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorUInteger16jobjectArray__intintjstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorInteger32jobjectArray__intintjstringjava_lang_StringID; // cache method id +jmethodID voidopenVariableEditorUInteger32jobjectArray__longlongjstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorDoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorBooleanSparsejobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorSparsejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorComplexSparsejobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorComplexjobjectArray__doubledoublejobjectArray__doubledoublejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorStringjobjectArray__java_lang_Stringjava_lang_StringjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorBooleanjobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorInteger8jobjectArray__bytebytejdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorUInteger8jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorInteger16jobjectArray__shortshortjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorUInteger16jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorInteger32jobjectArray__intintjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidrefreshVariableEditorUInteger32jobjectArray__longlongjdoubleArray_doubledoublejdoubleArray_doubledoublejstringjava_lang_StringID; // cache method id +jmethodID voidcloseVariableEditorID; // cache method id + + + +jobject instance; +jclass instanceClass; // cache class + + +// Caching (if any) + + +/** +* Get the environment matching to the current thread. +*/ +virtual JNIEnv * getCurrentEnv(); + +public: +// Constructor +/** +* Create a wrapping of the object from a JNIEnv. +* It will call the default constructor +* @param JEnv_ the Java Env +*/ +EditVar(JavaVM * jvm_); + +/** +* Create a wrapping of an already existing object from a JNIEnv. +* The object must have already been instantiated +* @param JEnv_ the Java Env +* @param JObj the object +*/ +EditVar(JavaVM * jvm_, jobject JObj); + + +/** +* This is a fake constructor to avoid the constructor +* chaining when dealing with extended giws classes +*/ +#ifdef FAKEGIWSDATATYPE +EditVar(fakeGiwsDataType::fakeGiwsDataType /* unused */) {} +#endif + +// Destructor +~EditVar(); + +// Generic method +// Synchronization methods +/** +* Enter monitor associated with the object. +* Equivalent of creating a "synchronized(obj)" scope in Java. +*/ +void synchronize(); + +/** +* Exit monitor associated with the object. +* Equivalent of ending a "synchronized(obj)" scope. +*/ +void endSynchronize(); + +// Methods +static void openVariableEditorDouble(JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorBooleanSparse(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorSparse(JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorComplexSparse(JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* complexData, int complexDataSize, int complexDataSizeCol, char const* variableName); + +static void openVariableEditorComplex(JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* imgData, int imgDataSize, int imgDataSizeCol, char const* variableName); + +static void openVariableEditorString(JavaVM * jvm_, char const* const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorBoolean(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorInteger8(JavaVM * jvm_, byte const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorUInteger8(JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorInteger16(JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorUInteger16(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorInteger32(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void openVariableEditorUInteger32(JavaVM * jvm_, long long const* const* data, int dataSize, int dataSizeCol, char const* variableName); + +static void refreshVariableEditorDouble(JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorBooleanSparse(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorSparse(JavaVM * jvm_, double const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorComplexSparse(JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* complexData, int complexDataSize, int complexDataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorComplex(JavaVM * jvm_, double const* const* realData, int realDataSize, int realDataSizeCol, double const* const* imgData, int imgDataSize, int imgDataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorString(JavaVM * jvm_, char const* const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorBoolean(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorInteger8(JavaVM * jvm_, byte const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorUInteger8(JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorInteger16(JavaVM * jvm_, short const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorUInteger16(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorInteger32(JavaVM * jvm_, int const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void refreshVariableEditorUInteger32(JavaVM * jvm_, long long const* const* data, int dataSize, int dataSizeCol, double const* rowsIndex, int rowsIndexSize, double const* colsIndex, int colsIndexSize, char const* variableName); + +static void closeVariableEditor(JavaVM * jvm_); + + + /** + * Get class name to use for static methods + * @return class name to use for static methods + */ + + static const std::string className() + { + return "org/scilab/modules/ui_data/EditVar"; + } + + + /** + * Get class to use for static methods + * @return class to use for static methods + */ + + static jclass initClass(JNIEnv * curEnv) + { + static jclass cls = 0; + + if (cls == 0) + { + jclass _cls = curEnv->FindClass(className().c_str()); + if (_cls) + { + cls = static_cast<jclass>(curEnv->NewGlobalRef(_cls)); + } + } + + return cls; + } + +}; + + +} +#endif diff --git a/modules/ui_data/src/jni/FileBrowser.cpp b/modules/ui_data/src/jni/FileBrowser.cpp new file mode 100755 index 000000000..85f0ac8cd --- /dev/null +++ b/modules/ui_data/src/jni/FileBrowser.cpp @@ -0,0 +1,199 @@ +#include "FileBrowser.hxx" +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/FileBrowser.giws.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + +namespace org_scilab_modules_ui_data { + + // Static declarations (if any) + +// Returns the current env + +JNIEnv * FileBrowser::getCurrentEnv() { +JNIEnv * curEnv = NULL; +jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +if (res != JNI_OK) { +throw GiwsException::JniException(getCurrentEnv()); +} +return curEnv; +} +// Destructor + +FileBrowser::~FileBrowser() { +JNIEnv * curEnv = NULL; +this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +curEnv->DeleteGlobalRef(this->instance); +curEnv->DeleteGlobalRef(this->instanceClass); +} +// Constructors +FileBrowser::FileBrowser(JavaVM * jvm_) { +jmethodID constructObject = NULL ; +jobject localInstance ; +jclass localClass ; + +const std::string construct="<init>"; +const std::string param="()V"; +jvm=jvm_; + +JNIEnv * curEnv = getCurrentEnv(); + +localClass = curEnv->FindClass( this->className().c_str() ) ; +if (localClass == NULL) { + throw GiwsException::JniClassNotFoundException(curEnv, this->className()); +} + +this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + +/* localClass is not needed anymore */ +curEnv->DeleteLocalRef(localClass); + +if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + + +constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ; +if(constructObject == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ; +if(localInstance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +this->instance = curEnv->NewGlobalRef(localInstance) ; +if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} +/* localInstance not needed anymore */ +curEnv->DeleteLocalRef(localInstance); + + /* Methods ID set to NULL */ +voidopenFileBrowserID=NULL; +voidsetBaseDirjstringjava_lang_StringID=NULL; + + +} + +FileBrowser::FileBrowser(JavaVM * jvm_, jobject JObj) { + jvm=jvm_; + + JNIEnv * curEnv = getCurrentEnv(); + +jclass localClass = curEnv->GetObjectClass(JObj); + this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + curEnv->DeleteLocalRef(localClass); + + if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + + this->instance = curEnv->NewGlobalRef(JObj) ; + if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + /* Methods ID set to NULL */ + voidopenFileBrowserID=NULL; +voidsetBaseDirjstringjava_lang_StringID=NULL; + + +} + +// Generic methods + +void FileBrowser::synchronize() { +if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "FileBrowser"); +} +} + +void FileBrowser::endSynchronize() { +if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "FileBrowser"); +} +} +// Method(s) + +void FileBrowser::openFileBrowser (JavaVM * jvm_){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidopenFileBrowserID = curEnv->GetStaticMethodID(cls, "openFileBrowser", "()V" ) ; +if (voidopenFileBrowserID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "openFileBrowser"); +} + + curEnv->CallStaticVoidMethod(cls, voidopenFileBrowserID ); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +void FileBrowser::setBaseDir (JavaVM * jvm_, char const* baseDir){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidsetBaseDirjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "setBaseDir", "(Ljava/lang/String;)V" ) ; +if (voidsetBaseDirjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "setBaseDir"); +} + +jstring baseDir_ = curEnv->NewStringUTF( baseDir ); +if (baseDir != NULL && baseDir_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidsetBaseDirjstringjava_lang_StringID ,baseDir_); + curEnv->DeleteLocalRef(baseDir_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +} diff --git a/modules/ui_data/src/jni/FileBrowser.giws.xml b/modules/ui_data/src/jni/FileBrowser.giws.xml new file mode 100755 index 000000000..3362bfaf2 --- /dev/null +++ b/modules/ui_data/src/jni/FileBrowser.giws.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<package name="org.scilab.modules.ui_data"> + <object name="FileBrowser"> + <method name="openFileBrowser" returnType="void" modifier="static" /> + <method name="setBaseDir" returnType="void" modifier="static" > + <parameter type="String" name="baseDir"/> + </method> + </object> +</package> diff --git a/modules/ui_data/src/jni/FileBrowser.hxx b/modules/ui_data/src/jni/FileBrowser.hxx new file mode 100755 index 000000000..aca386579 --- /dev/null +++ b/modules/ui_data/src/jni/FileBrowser.hxx @@ -0,0 +1,181 @@ +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni/ --throws-exception-on-error --description-file src/jni/FileBrowser.giws.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + + +#ifndef __ORG_SCILAB_MODULES_UI_DATA_FILEBROWSER__ +#define __ORG_SCILAB_MODULES_UI_DATA_FILEBROWSER__ +#include <iostream> +#include <string> +#include <string.h> +#include <stdlib.h> +#include <jni.h> + +#include "GiwsException.hxx" + + #if defined(_MSC_VER) /* Defined anyway with Visual */ + #include <Windows.h> + #else + typedef signed char byte; + #endif + + +#ifndef GIWSEXPORT +# if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define GIWSEXPORT +# else +# define GIWSEXPORT __declspec(dllexport) +# endif +# else +# if __GNUC__ >= 4 +# define GIWSEXPORT __attribute__ ((visibility ("default"))) +# else +# define GIWSEXPORT +# endif +# endif +#endif + +namespace org_scilab_modules_ui_data { +class GIWSEXPORT FileBrowser { + +private: +JavaVM * jvm; + +protected: +jmethodID voidopenFileBrowserID; // cache method id +jmethodID voidsetBaseDirjstringjava_lang_StringID; // cache method id + + + +jobject instance; +jclass instanceClass; // cache class + + +// Caching (if any) + + +/** +* Get the environment matching to the current thread. +*/ +virtual JNIEnv * getCurrentEnv(); + +public: +// Constructor +/** +* Create a wrapping of the object from a JNIEnv. +* It will call the default constructor +* @param JEnv_ the Java Env +*/ +FileBrowser(JavaVM * jvm_); + +/** +* Create a wrapping of an already existing object from a JNIEnv. +* The object must have already been instantiated +* @param JEnv_ the Java Env +* @param JObj the object +*/ +FileBrowser(JavaVM * jvm_, jobject JObj); + + +/** +* This is a fake constructor to avoid the constructor +* chaining when dealing with extended giws classes +*/ +#ifdef FAKEGIWSDATATYPE +FileBrowser(fakeGiwsDataType::fakeGiwsDataType /* unused */) {} +#endif + +// Destructor +~FileBrowser(); + +// Generic method +// Synchronization methods +/** +* Enter monitor associated with the object. +* Equivalent of creating a "synchronized(obj)" scope in Java. +*/ +void synchronize(); + +/** +* Exit monitor associated with the object. +* Equivalent of ending a "synchronized(obj)" scope. +*/ +void endSynchronize(); + +// Methods +static void openFileBrowser(JavaVM * jvm_); + +static void setBaseDir(JavaVM * jvm_, char const* baseDir); + + + /** + * Get class name to use for static methods + * @return class name to use for static methods + */ + + static const std::string className() + { + return "org/scilab/modules/ui_data/FileBrowser"; + } + + + /** + * Get class to use for static methods + * @return class to use for static methods + */ + + static jclass initClass(JNIEnv * curEnv) + { + static jclass cls = 0; + + if (cls == 0) + { + jclass _cls = curEnv->FindClass(className().c_str()); + if (_cls) + { + cls = static_cast<jclass>(curEnv->NewGlobalRef(_cls)); + } + } + + return cls; + } + +}; + + +} +#endif diff --git a/modules/ui_data/src/jni/libsciui_data_algo_la-BrowseVar.lo b/modules/ui_data/src/jni/libsciui_data_algo_la-BrowseVar.lo new file mode 100755 index 000000000..a6c0dfa5e --- /dev/null +++ b/modules/ui_data/src/jni/libsciui_data_algo_la-BrowseVar.lo @@ -0,0 +1,12 @@ +# src/jni/libsciui_data_algo_la-BrowseVar.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-BrowseVar.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/jni/libsciui_data_algo_la-EditVar.lo b/modules/ui_data/src/jni/libsciui_data_algo_la-EditVar.lo new file mode 100755 index 000000000..90d079815 --- /dev/null +++ b/modules/ui_data/src/jni/libsciui_data_algo_la-EditVar.lo @@ -0,0 +1,12 @@ +# src/jni/libsciui_data_algo_la-EditVar.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-EditVar.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/jni/libsciui_data_algo_la-FileBrowser.lo b/modules/ui_data/src/jni/libsciui_data_algo_la-FileBrowser.lo new file mode 100755 index 000000000..22cb8bd82 --- /dev/null +++ b/modules/ui_data/src/jni/libsciui_data_algo_la-FileBrowser.lo @@ -0,0 +1,12 @@ +# src/jni/libsciui_data_algo_la-FileBrowser.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-FileBrowser.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/jni/libsciui_data_algo_la-ui_data_wrap.lo b/modules/ui_data/src/jni/libsciui_data_algo_la-ui_data_wrap.lo new file mode 100755 index 000000000..4b8e84d7b --- /dev/null +++ b/modules/ui_data/src/jni/libsciui_data_algo_la-ui_data_wrap.lo @@ -0,0 +1,12 @@ +# src/jni/libsciui_data_algo_la-ui_data_wrap.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_algo_la-ui_data_wrap.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/jni/ui_data.i b/modules/ui_data/src/jni/ui_data.i new file mode 100755 index 000000000..ec6ccee7a --- /dev/null +++ b/modules/ui_data/src/jni/ui_data.i @@ -0,0 +1,94 @@ +/* Allan CORNET */ +/* INRIA 2007 */ +/* HistoryManagement.i */ +/* To run this file execute the command below from current directory */ +/** + * Windows: swig -java -package org.scilab.modules.ui_data -outdir ../java/org/scilab/modules/ui_data/ ui_data.i + * Other: Use the option --enable-build-swig to the configure +*/ + +%module UI_data +%{ +#include "MALLOC.h" +#include "../../includes/ui_data.h" +%} + +%include "../../../jvm/src/jni/scilab_typemaps.i" + +/* JavaDoc for UI_dataJNI class */ +%pragma(java) jniclassclassmodifiers=%{ +/* It is generated code. Disable checkstyle */ +//CHECKSTYLE:OFF + /** + * All Scilab history management used in Java console + * @author Vincent COUVERT + * @author Allan CORNET + * @copyright INRIA + */ +class%} + +/* Constructor for UI_dataJNI class */ +%pragma(java) jniclasscode=" + /** + * Constructor + */ + protected UI_dataJNI() { + throw new UnsupportedOperationException(); + }"; + + /* static load of library */ +%pragma(java) jniclasscode=%{ + static { + try { + System.loadLibrary("sciui_data"); + } catch (SecurityException e) { + System.err.println("A security manager exists and does not allow the loading of the specified dynamic library."); + System.err.println(e.getLocalizedMessage()); + e.printStackTrace(System.err); + } catch (UnsatisfiedLinkError e) { + System.err.println("The native library sciui_data does not exist or cannot be found."); + System.err.println(e.getLocalizedMessage()); + e.printStackTrace(System.err); + } + } +%} + +/* JavaDoc for UI_data class */ +%pragma(java) moduleclassmodifiers=" + /** + * ui_data management + * @author Vincent COUVERT + * @author Allan CORNET + * @copyright INRIA + */ +public class"; + +/* Constructor for UI_data class */ +%pragma(java) modulecode=" + /** + * Constructor + */ + protected UI_data() { + throw new UnsupportedOperationException(); + }"; + + +%javamethodmodifiers putScilabVariable(char * name, char ** lines, int rows, int cols) " + /** + * Put a scilab variable as an array of strings in C envrionment + * @param lines array of string + * @param rows the number of rows + * @param cols the number of cols + */ +public"; +void putScilabVariable(char * name, char ** lines, int rows, int cols); + +%javamethodmodifiers getUnnamedVariable() " + /** + * Put a scilab variable as an array of strings in C envrionment + * @param lines array of string + * @param rows the number of rows + * @param cols the number of cols + */ +public"; +char * getUnnamedVariable(); diff --git a/modules/ui_data/src/jni/ui_data_wrap.c b/modules/ui_data/src/jni/ui_data_wrap.c new file mode 100755 index 000000000..8e053f847 --- /dev/null +++ b/modules/ui_data/src/jni/ui_data_wrap.c @@ -0,0 +1,265 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGJAVA + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } + }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + (*jenv)->ExceptionClear(jenv); + excep = (*jenv)->FindClass(jenv, except_ptr->java_exception); + if (excep) + (*jenv)->ThrowNew(jenv, excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#include "MALLOC.h" +#include "../../includes/ui_data.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT void JNICALL Java_org_scilab_modules_ui_1data_UI_1dataJNI_putScilabVariable(JNIEnv *jenv, jclass jcls, jstring jarg1, jobjectArray jarg2, jint jarg3, jint jarg4) { + char *arg1 = (char *) 0 ; + char **arg2 = (char **) 0 ; + int arg3 ; + int arg4 ; + jint size2 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0); + if (!arg1) return ; + } + { + int i = 0; + size2 = (*jenv)->GetArrayLength(jenv, jarg2); + arg2 = (char **) MALLOC((size2+1)*sizeof(char *)); + /* make a copy of each string */ + for (i = 0; i<size2; i++) { + jstring j_string = (jstring)(*jenv)->GetObjectArrayElement(jenv, jarg2, i); + const char * c_string = (*jenv)->GetStringUTFChars(jenv, j_string, 0); + arg2[i] = MALLOC((strlen(c_string)+1)*sizeof(const char *)); + strcpy(arg2[i], c_string); + (*jenv)->ReleaseStringUTFChars(jenv, j_string, c_string); + (*jenv)->DeleteLocalRef(jenv, j_string); + } + arg2[i] = 0; + } + arg3 = (int)jarg3; + arg4 = (int)jarg4; + putScilabVariable(arg1,arg2,arg3,arg4); + if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1); + { + int i; + for (i=0; i<size2-1; i++) { + FREE(arg2[i]); + arg2[i] = NULL; + } + FREE(arg2); + arg2 = NULL; + } +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_ui_1data_UI_1dataJNI_getUnnamedVariable(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getUnnamedVariable(); + { + if (result != NULL) + { + jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + FREE(result); + result = NULL; + } + } + return jresult; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/modules/ui_data/src/noui_data/.deps/.dirstamp b/modules/ui_data/src/noui_data/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/noui_data/.deps/.dirstamp diff --git a/modules/ui_data/src/noui_data/.deps/libsciui_data_disable_la-noui_data.Plo b/modules/ui_data/src/noui_data/.deps/libsciui_data_disable_la-noui_data.Plo new file mode 100755 index 000000000..1f2b32185 --- /dev/null +++ b/modules/ui_data/src/noui_data/.deps/libsciui_data_disable_la-noui_data.Plo @@ -0,0 +1,67 @@ +src/noui_data/libsciui_data_disable_la-noui_data.lo: \ + src/noui_data/noui_data.c /usr/include/stdc-predef.h \ + src/noui_data/noui_data.h \ + ../../modules/output_stream/includes/Scierror.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + ../../modules/output_stream/includes/do_error_number.h \ + ../../modules/core/includes/machine.h \ + ../../modules/localization/includes/localization.h \ + /usr/include/libintl.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/xlocale.h \ + includes/BrowseVarManager.h includes/dynlib_ui_data.h \ + includes/FileBrowserChDir.h ../../modules/core/includes/BOOL.h \ + ../../modules/core/includes/scilabmode.h \ + ../../modules/core/includes/machine.h ../../modules/core/includes/BOOL.h + +/usr/include/stdc-predef.h: + +src/noui_data/noui_data.h: + +../../modules/output_stream/includes/Scierror.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +../../modules/output_stream/includes/do_error_number.h: + +../../modules/core/includes/machine.h: + +../../modules/localization/includes/localization.h: + +/usr/include/libintl.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/xlocale.h: + +includes/BrowseVarManager.h: + +includes/dynlib_ui_data.h: + +includes/FileBrowserChDir.h: + +../../modules/core/includes/BOOL.h: + +../../modules/core/includes/scilabmode.h: + +../../modules/core/includes/machine.h: + +../../modules/core/includes/BOOL.h: diff --git a/modules/ui_data/src/noui_data/.dirstamp b/modules/ui_data/src/noui_data/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/ui_data/src/noui_data/.dirstamp diff --git a/modules/ui_data/src/noui_data/.libs/libsciui_data_disable_la-noui_data.o b/modules/ui_data/src/noui_data/.libs/libsciui_data_disable_la-noui_data.o Binary files differnew file mode 100755 index 000000000..1d30d20e2 --- /dev/null +++ b/modules/ui_data/src/noui_data/.libs/libsciui_data_disable_la-noui_data.o diff --git a/modules/ui_data/src/noui_data/libsciui_data_disable_la-noui_data.lo b/modules/ui_data/src/noui_data/libsciui_data_disable_la-noui_data.lo new file mode 100755 index 000000000..6551ecfd3 --- /dev/null +++ b/modules/ui_data/src/noui_data/libsciui_data_disable_la-noui_data.lo @@ -0,0 +1,12 @@ +# src/noui_data/libsciui_data_disable_la-noui_data.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libsciui_data_disable_la-noui_data.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/ui_data/src/noui_data/noui_data.c b/modules/ui_data/src/noui_data/noui_data.c new file mode 100755 index 000000000..dede895f3 --- /dev/null +++ b/modules/ui_data/src/noui_data/noui_data.c @@ -0,0 +1,47 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2009 - DIGITEO - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +/*--------------------------------------------------------------------------*/ +#include "noui_data.h" +#include "Scierror.h" +#include "localization.h" +#include "BrowseVarManager.h" +#include "FileBrowserChDir.h" +#include "BOOL.h" +#ifndef _MSC_VER +#include "scilabmode.h" +#endif +/*--------------------------------------------------------------------------*/ +int gw_ui_data(void) +{ +#ifndef _MSC_VER + if (getScilabMode() == SCILAB_NWNI) + { + Scierror(999, _("Scilab '%s' module disabled in -nogui or -nwni mode.\n"), "ui_data"); + } + else +#endif + { + Scierror(999, _("Scilab '%s' module not installed.\n"), "ui_data"); + } + return 0; +} +/*--------------------------------------------------------------------------*/ +void UpdateBrowseVar(BOOL b) +{ + return; +} +/*--------------------------------------------------------------------------*/ +void FileBrowserChDir(char * baseDir) +{ + return; +} +/*--------------------------------------------------------------------------*/ diff --git a/modules/ui_data/src/noui_data/noui_data.h b/modules/ui_data/src/noui_data/noui_data.h new file mode 100755 index 000000000..b620fc88d --- /dev/null +++ b/modules/ui_data/src/noui_data/noui_data.h @@ -0,0 +1,19 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2009 - DIGITEO - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +/*--------------------------------------------------------------------------*/ +/** + * This function is a wrapper / fake when Scilab is compiled without ui_data + * + * @return 0 + */ +int gw_ui_data(void); +/*--------------------------------------------------------------------------*/ diff --git a/modules/ui_data/src/noui_data/noui_data.rc b/modules/ui_data/src/noui_data/noui_data.rc new file mode 100755 index 000000000..bbe32f6a1 --- /dev/null +++ b/modules/ui_data/src/noui_data/noui_data.rc @@ -0,0 +1,97 @@ +// Microsoft Visual C++ generated resource script. +// + + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +//#include "afxres.h" +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,5,2,0 + PRODUCTVERSION 5,5,2,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "FileDescription", "noui_data module" + VALUE "FileVersion", "5, 5, 2, 0" + VALUE "InternalName", "noui_data module" + VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "OriginalFilename", "noui_data.dll" + VALUE "ProductName", " noui_data" + VALUE "ProductVersion", "5, 5, 2, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/modules/ui_data/src/noui_data/noui_data.vcxproj b/modules/ui_data/src/noui_data/noui_data.vcxproj new file mode 100755 index 000000000..e67893936 --- /dev/null +++ b/modules/ui_data/src/noui_data/noui_data.vcxproj @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{337A52F8-310E-49E3-A2BA-F19CA32EB617}</ProjectGuid> + <RootNamespace>noui_data</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../windows_tools/includes;../../../windows_tools/src/c/scilab_windows;../../../completion/includes;../../../localization/includes;../../../history_manager/includes;../../../ui_data/includes;../../../../libs/intl;../c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>../../includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../windows_tools/includes;../../../windows_tools/src/c/scilab_windows;../../../completion/includes;../../../localization/includes;../../../history_manager/includes;../../../ui_data/includes;../../../../libs/intl;../c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + </ClCompile> + <Link> + <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <WholeProgramOptimization>false</WholeProgramOptimization> + <AdditionalIncludeDirectories>../../includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../windows_tools/includes;../../../windows_tools/src/c/scilab_windows;../../../completion/includes;../../../localization/includes;../../../history_manager/includes;../../../ui_data/includes;../../../../libs/intl;../c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + </ClCompile> + <Link> + <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <WholeProgramOptimization>false</WholeProgramOptimization> + <AdditionalIncludeDirectories>../../includes;../../../output_stream/includes;../../../core/includes;../../../api_scilab/includes;../../../windows_tools/includes;../../../windows_tools/src/c/scilab_windows;../../../completion/includes;../../../localization/includes;../../../history_manager/includes;../../../ui_data/includes;../../../../libs/intl;../c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;UI_DATA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + </ClCompile> + <Link> + <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\c\DllmainUi_data.c" /> + <ClCompile Include="noui_data.c" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="noui_data.rc" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj"> + <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/ui_data/src/noui_data/noui_data.vcxproj.filters b/modules/ui_data/src/noui_data/noui_data.vcxproj.filters new file mode 100755 index 000000000..6159bae3a --- /dev/null +++ b/modules/ui_data/src/noui_data/noui_data.vcxproj.filters @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> + </Filter> + <Filter Include="Libraries Dependencies"> + <UniqueIdentifier>{5ff496c6-aae2-4ffd-9291-f53996876a58}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="noui_data.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\c\DllmainUi_data.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="noui_data.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file |