4077a_up_to_rev11340.patch
rules/convert/language_statements.rules 2019-11-04 17:49:50 +0000 | ||
---|---|---|
76 | 76 |
** 047 CA 20190611 Legacy ANNOTATION nodes which are not hidden must be emitted as Java |
77 | 77 |
** annotations. |
78 | 78 |
** 048 CA 20190903 Added GLOBAL support for SUBSCRIBE/UNSUBSCRIBE (cross-session messaging). |
79 |
** 049 SBI 20191004 Added DELETE-SOURCE-CONTENT and NOT-EMBEDDED-CONTENT optional flags |
|
80 |
** for OPEN-MIME-RESOURCE. |
|
79 | 81 |
*/ |
80 | 82 |
--> |
81 | 83 |
|
... | ... | |
862 | 864 |
</action> |
863 | 865 |
</rule> |
864 | 866 |
|
867 |
<rule>type == prog.kw_not_embedded and |
|
868 |
parent.type == prog.kw_openmime |
|
869 |
<action>createJavaAst(java.bool_false, "false", closestPeerId)</action> |
|
870 |
</rule> |
|
871 |
|
|
872 |
<rule>type == prog.kw_del_s_c and |
|
873 |
parent.type == prog.kw_openmime |
|
874 |
<action>createJavaAst(java.bool_true, "true", closestPeerId, 0)</action> |
|
875 |
</rule> |
|
876 |
|
|
865 | 877 |
<rule>type == prog.create_timer and parent.type == prog.statement |
866 | 878 |
<action> |
867 | 879 |
createPeerAst(java.static_method_call, "PSTimer.create", closestPeerId) |
src/com/goldencode/p2j/uast/progress.g 2019-11-04 17:50:35 +0000 | ||
---|---|---|
1985 | 1985 |
** HC 20190819 Added missing definitions for TABSET:COLOR attribute. |
1986 | 1986 |
** CA 20190903 Added GLOBAL support for SUBSCRIBE/UNSUBSCRIBE (cross-session messaging). |
1987 | 1987 |
** 377 HC 20190911 Added new method and attributes to HTML-BROWSER widget. |
1988 |
** 378 SBI 20191004 Added DELETE-SOURCE-CONTENT and NOT-EMBEDDED-CONTENT optional flags |
|
1989 |
** for OPEN-MIME-RESOURCE. |
|
1988 | 1990 |
*/ |
1989 | 1991 | |
1990 | 1992 |
/* |
... | ... | |
3586 | 3588 |
KW_DEL_NODE; |
3587 | 3589 |
KW_DEL_PROC; |
3588 | 3590 |
KW_DEL_R_L; |
3591 |
KW_DEL_S_C; // FWD extension |
|
3589 | 3592 |
KW_DEL_S_R; |
3590 | 3593 |
KW_DEL_S_RS; |
3591 | 3594 |
KW_DEL_WORD; |
... | ... | |
3639 | 3642 |
KW_EDIT_TAB; |
3640 | 3643 |
KW_EH_FL; // FWD extension, not real 4GL! |
3641 | 3644 |
KW_EH_SR; // FWD extension, not real 4GL! |
3645 |
KW_NOT_EMBEDDED; // FWD extension |
|
3642 | 3646 |
KW_EMPTY; |
3643 | 3647 |
KW_EMPTY_DS; |
3644 | 3648 |
KW_EMPTY_SN; |
... | ... | |
7962 | 7966 |
attrsAndMethods.put( KW_DEL_LINE, METH_LOGICAL ); |
7963 | 7967 |
attrsAndMethods.put( KW_DEL_NODE, METH_LOGICAL ); |
7964 | 7968 |
attrsAndMethods.put( KW_DEL_R_L , METH_LOGICAL ); |
7969 |
attrsAndMethods.put( KW_DEL_S_C , ATTR_LOGICAL ); // FWD extension |
|
7965 | 7970 |
attrsAndMethods.put( KW_DEL_S_R , METH_LOGICAL ); |
7966 | 7971 |
attrsAndMethods.put( KW_DEL_S_RS, METH_LOGICAL ); |
7967 | 7972 |
attrsAndMethods.put( KW_DELETE , METH_LOGICAL ); |
... | ... | |
8002 | 8007 |
attrsAndMethods.put( KW_EDIT_UND, METH_LOGICAL ); |
8003 | 8008 |
attrsAndMethods.put( KW_EH_FL, ATTR_LOGICAL ); // FWD extension, not real 4GL |
8004 | 8009 |
attrsAndMethods.put( KW_EH_SR, ATTR_LOGICAL ); // FWD extension, not real 4GL |
8010 |
attrsAndMethods.put( KW_NOT_EMBEDDED, ATTR_LOGICAL ); // FWD extension |
|
8005 | 8011 |
attrsAndMethods.put( KW_EMB_FILE, METH_LOGICAL ); // FWD extension, not real 4GL |
8006 | 8012 |
attrsAndMethods.put( KW_EMB_URL, METH_LOGICAL ); // FWD extension, not real 4GL |
8007 | 8013 |
attrsAndMethods.put( KW_EMPTY , ATTR_LOGICAL ); |
... | ... | |
27473 | 27479 |
|
27474 | 27480 |
/** |
27475 | 27481 |
* Matches the FWD-extension language statement <code>OPEN-MIME-RESOURCE</code> and a mandatory |
27476 |
* pair of resource mime type character and its url character expression. |
|
27482 |
* pair of resource mime type character and its url character expression. If an optional |
|
27483 |
* <code>DELETE-SOURCE-CONTENT</code> is present, then it forces to delete the original input file |
|
27484 |
* when the transfer is complete. |
|
27477 | 27485 |
*/ |
27478 | 27486 |
open_mime_resource_stmt |
27479 | 27487 |
: |
27480 |
KW_OPENMIME^ expr expr (expr)? stmt_term |
|
27488 |
KW_OPENMIME^ expr expr |
|
27489 |
( options { generateAmbigWarnings = false; } |
|
27490 |
: |
|
27491 |
KW_NOT_EMBEDDED |
|
27492 |
)? |
|
27493 |
( |
|
27494 |
options { generateAmbigWarnings = false; } |
|
27495 |
: |
|
27496 |
KW_DEL_S_C |
|
27497 |
) |
|
27498 |
stmt_term |
|
27481 | 27499 |
; |
27482 | 27500 |
|
27483 | 27501 |
/** |
... | ... | |
32715 | 32733 |
new Keyword("delete-result-list-entry" , 0, KW_DEL_R_L , false), |
32716 | 32734 |
new Keyword("delete-selected-row" , 0, KW_DEL_S_R , false), |
32717 | 32735 |
new Keyword("delete-selected-rows" , 0, KW_DEL_S_RS, false), |
32736 |
new Keyword("delete-source-content" , 0, KW_DEL_S_C , false), // FWD extension |
|
32718 | 32737 |
new Keyword("delete-word" , 0, KW_DEL_WORD, false), // missing in keyword index, found in prog handbook as a key function |
32719 | 32738 |
new Keyword("descending" , 4, KW_DESCEND , true ), // handles "separate keyword" desc too |
32720 | 32739 |
new Keyword("description" , 0, KW_DESCR , false), // missing in keyword index, found in customer code |
... | ... | |
32787 | 32806 |
new Keyword("else" , 0, KW_ELSE , true ), |
32788 | 32807 |
new Keyword("embed-image-by-file" , 0, KW_EMB_FILE, false), // FWD extension, not a real 4GL keyword |
32789 | 32808 |
new Keyword("embed-image-by-url" , 0, KW_EMB_URL , false), // FWD extension, not a real 4GL keyword |
32809 |
new Keyword("not-embedded-content" , 0, KW_NOT_EMBEDDED, false), // FWD extension |
|
32790 | 32810 |
new Keyword("empty" , 0, KW_EMPTY , false), |
32791 | 32811 |
new Keyword("empty-dataset" , 0, KW_EMPTY_DS, false), // missing from keyword index and UNTESTED at this time |
32792 | 32812 |
new Keyword("empty-selection" , 0, KW_EMPTY_SN, false), // missing in keyword index, found elsewhere in lang ref |
src/com/goldencode/p2j/ui/ClientExports.java 2019-11-04 17:58:48 +0000 | ||
---|---|---|
246 | 246 |
** Triggering events directly from server must lookup the trigger on |
247 | 247 |
** the client. |
248 | 248 |
** 154 SVL 20191002 Added rowEntryCreated/Deleted and checkDeleteEntryRowIndex. |
249 |
** 155 SBI 20191004 Added deleteContent parameter for openMimeResource. |
|
249 | 250 |
*/ |
250 | 251 | |
251 | 252 |
/* |
... | ... | |
3122 | 3123 |
/** |
3123 | 3124 |
* Opens the specified resource in a browser's window. |
3124 | 3125 |
* |
3126 |
* @param deleteContent |
|
3127 |
* Indicates if the source content will be deleted after the document is loaded by |
|
3128 |
* the client. |
|
3125 | 3129 |
* @param mimeType |
3126 | 3130 |
* The resource mime type. |
3127 | 3131 |
* @param path |
... | ... | |
3129 | 3133 |
* @param embedded |
3130 | 3134 |
* The document is embedded in the template document. |
3131 | 3135 |
*/ |
3132 |
public void openMimeResource(String mimeType, String path, boolean embedded); |
|
3136 |
public void openMimeResource(boolean deleteContent, |
|
3137 |
String mimeType, |
|
3138 |
String path, |
|
3139 |
boolean embedded); |
|
3133 | 3140 | |
3134 | 3141 |
/** |
3135 | 3142 |
* Opens the specified file resource in a browser's window. |
3136 | 3143 |
* |
3144 |
* @param deleteContent |
|
3145 |
* Indicates if the source content will be deleted after the document is loaded by |
|
3146 |
* the client. |
|
3137 | 3147 |
* @param filePath |
3138 | 3148 |
* The file system path on the legacy system or the host system. If the legacy system |
3139 | 3149 |
* path is given, then it is resolved to the host system path. |
... | ... | |
3142 | 3152 |
* @param preferredMimeTypes |
3143 | 3153 |
* The preferred resource mime types. |
3144 | 3154 |
*/ |
3145 |
public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes); |
|
3155 |
public void openMimeResource(boolean deleteContent, |
|
3156 |
String filePath, |
|
3157 |
boolean embedded, |
|
3158 |
List<String> preferredMimeTypes); |
|
3146 | 3159 | |
3147 | 3160 |
/** |
3148 | 3161 |
* Set an attribute for a widget implemented at the driver level. These are custom attributes |
src/com/goldencode/p2j/ui/chui/ThinClient.java 2019-11-04 17:52:25 +0000 | ||
---|---|---|
2536 | 2536 |
** Triggering events directly from server must lookup the trigger on |
2537 | 2537 |
** the client. |
2538 | 2538 |
** 910 SVL 20191002 Added rowEntryCreated/Deleted and checkDeleteEntryRowIndex. |
2539 |
** 911 SBI 20191104 Added deleteContent parameter for openMimeResource. |
|
2539 | 2540 |
*/ |
2540 | 2541 | |
2541 | 2542 |
/* |
... | ... | |
23021 | 23022 |
/** |
23022 | 23023 |
* Opens the specified resource in a browser's window. |
23023 | 23024 |
* |
23025 |
* @param deleteContent |
|
23026 |
* Indicates if the source content will be deleted after the document is loaded by |
|
23027 |
* the client. |
|
23024 | 23028 |
* @param mimeType |
23025 | 23029 |
* The resource mime type. |
23026 | 23030 |
* @param urlString |
... | ... | |
23029 | 23033 |
* The document is embedded in the template document. |
23030 | 23034 |
*/ |
23031 | 23035 |
@Override |
23032 |
public void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
23036 |
public void openMimeResource(boolean deleteContent, |
|
23037 |
String mimeType, |
|
23038 |
String urlString, |
|
23039 |
boolean embedded) |
|
23033 | 23040 |
{ |
23034 | 23041 |
urlString = UiUtils.resolveResourceUrl(urlString); |
23035 | 23042 |
try |
23036 | 23043 |
{ |
23037 |
tk.getInstanceDriver().openMimeResource(mimeType, urlString, embedded); |
|
23044 |
tk.getInstanceDriver().openMimeResource(deleteContent, mimeType, urlString, embedded);
|
|
23038 | 23045 |
} |
23039 | 23046 |
catch (MalformedURLException e) |
23040 | 23047 |
{ |
... | ... | |
23045 | 23052 |
/** |
23046 | 23053 |
* Opens the specified file resource in a browser's window. |
23047 | 23054 |
* |
23055 |
* @param deleteContent |
|
23056 |
* Indicates if the source content will be deleted after the document is loaded by |
|
23057 |
* the client. |
|
23048 | 23058 |
* @param filePath |
23049 | 23059 |
* The file system path on the legacy system or the host system. If the legacy system |
23050 | 23060 |
* path is given, then it is resolved to the host system path. |
... | ... | |
23053 | 23063 |
* @param preferredMimeTypes |
23054 | 23064 |
* The preferred resource mime types. |
23055 | 23065 |
*/ |
23056 |
public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes) |
|
23066 |
public void openMimeResource(boolean deleteContent, |
|
23067 |
String filePath, |
|
23068 |
boolean embedded, |
|
23069 |
List<String> preferredMimeTypes) |
|
23057 | 23070 |
{ |
23058 | 23071 |
// getting FSD instance |
23059 | 23072 |
FileSystemDaemon fsd = getFileSystemDaemon(); |
... | ... | |
23070 | 23083 |
|
23071 | 23084 |
if (mimeType != null && preferredMimeTypes.contains(mimeType)) |
23072 | 23085 |
{ |
23073 |
openMimeResource(mimeType, "file:///" + fName, embedded); |
|
23086 |
openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
|
|
23074 | 23087 |
} |
23075 | 23088 |
else |
23076 | 23089 |
{ |
23077 | 23090 |
mimeType = preferredMimeTypes.get(0); // takes the default mime type |
23078 | 23091 |
|
23079 |
openMimeResource(mimeType, "file:///" + fName, embedded); |
|
23092 |
openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
|
|
23080 | 23093 |
} |
23081 | 23094 |
} |
23082 | 23095 |
} |
src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java 2019-11-04 09:50:33 +0000 | ||
---|---|---|
405 | 405 |
/** |
406 | 406 |
* Opens the specified resource in a browser's window. |
407 | 407 |
* |
408 |
* @param deleteContent |
|
409 |
* Indicates if the source content will be deleted after the document is loaded by |
|
410 |
* the client. |
|
408 | 411 |
* @param mimeType |
409 | 412 |
* The resource mime type. |
410 | 413 |
* @param urlString |
... | ... | |
415 | 418 |
* @throws MalformedURLException |
416 | 419 |
* If the string presentation of the target resource url is malformed. |
417 | 420 |
*/ |
418 |
public default void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
421 |
public default void openMimeResource(boolean deleteContent, |
|
422 |
String mimeType, |
|
423 |
String urlString, |
|
424 |
boolean embedded) |
|
419 | 425 |
throws MalformedURLException |
420 | 426 |
{ |
421 | 427 |
// do nothing |
src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2019-11-04 18:01:52 +0000 | ||
---|---|---|
107 | 107 |
** HC 20190313 Initial implementation of TREELIST widget. TREEVIEW widget refactored to make |
108 | 108 |
** it the base for the TREELIST widget. |
109 | 109 |
** 051 HC 20190911 Implemented command invocation on driver widgets. |
110 |
** 052 SBI 20191004 Added common methods for initializing a temporary directory and coping, moving |
|
111 |
** resources. |
|
110 | 112 |
*/ |
111 | 113 | |
112 | 114 |
/* |
... | ... | |
166 | 168 | |
167 | 169 |
// this usage of AWT events is intentional, they are being used separately from the |
168 | 170 |
// AWT/Swing event model itself; no other AWT/Swing usage is occurring in this class |
171 | ||
169 | 172 |
import java.awt.event.MouseEvent; |
170 | 173 | |
171 | 174 |
// WARNING: these AWT/ImageIO dependencies are being intentionally used in this generic GUI code |
... | ... | |
177 | 180 |
import javax.imageio.stream.*; |
178 | 181 | |
179 | 182 |
import java.io.*; |
183 |
import java.net.*; |
|
184 |
import java.nio.file.*; |
|
180 | 185 |
import java.text.*; |
181 | 186 |
import java.util.*; |
182 | 187 |
import java.util.concurrent.*; |
... | ... | |
195 | 200 |
import com.goldencode.p2j.ui.client.driver.*; |
196 | 201 |
import com.goldencode.p2j.ui.client.widget.*; |
197 | 202 |
import com.goldencode.p2j.util.*; |
203 |
import com.google.common.io.ByteStreams; |
|
198 | 204 | |
199 | 205 |
/** |
200 | 206 |
* Simple base class for GUI-specific screen driver implementation features. ChUI-specific |
... | ... | |
211 | 217 |
extends AbstractDriver<GuiPrimitives, GuiOutputManager> |
212 | 218 |
implements GuiDriver<F, BufferedImage> |
213 | 219 |
{ |
220 |
/** Define the file schema to get local resources */ |
|
221 |
private static final String FILE_SCHEMA = "file"; |
|
222 |
|
|
214 | 223 |
/** Logger. */ |
215 | 224 |
protected static final Logger LOG = LogHelper.getLogger(AbstractGuiDriver.class.getName()); |
216 | 225 |
|
226 |
/** Temporary files directory. */ |
|
227 |
protected String tmpDir; |
|
228 |
|
|
217 | 229 |
/** Currently selected window emulator. */ |
218 | 230 |
protected EmulatedWindowState ews = null; |
219 | 231 |
|
... | ... | |
297 | 309 |
} |
298 | 310 |
|
299 | 311 |
/** |
312 |
* Initializes client specific internal variables used with drag-n-drop. |
|
313 |
* |
|
314 |
* @param srv |
|
315 |
* Server to make config related calls. |
|
316 |
*/ |
|
317 |
public void initDragAndDrop(ServerExports srv) |
|
318 |
{ |
|
319 |
// this is used in client only and only once |
|
320 |
if (tmpDir != null) |
|
321 |
{ |
|
322 |
return; |
|
323 |
} |
|
324 | ||
325 |
// setting up temporary files upload directory |
|
326 |
try |
|
327 |
{ |
|
328 |
Path tmpFile = Files.createTempFile("tmp-file", ".tmp"); |
|
329 |
String absolutePath = tmpFile.toAbsolutePath().toString(); |
|
330 |
tmpDir = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator) + 1); |
|
331 |
Files.delete(tmpFile); |
|
332 |
} |
|
333 |
catch (IOException e) |
|
334 |
{ |
|
335 |
// for the case the regular way above does not work |
|
336 |
tmpDir = System.getProperty("user.home"); |
|
337 |
} |
|
338 |
// create separate directory for fwd files |
|
339 |
tmpDir = tmpDir.concat("fwd"); |
|
340 |
File tmpDirObj = new File(tmpDir); |
|
341 |
if (!tmpDirObj.exists()) |
|
342 |
{ |
|
343 |
tmpDirObj.mkdir(); |
|
344 |
} |
|
345 |
// adding file separator to the end |
|
346 |
tmpDir = tmpDir.concat(File.separator); |
|
347 |
|
|
348 |
// getting the file size limit values considering overrides in server's directory |
|
349 |
int [] uploadLimits = srv.getUploadFileSizeLimits(); |
|
350 |
// set up gui driver |
|
351 |
if (uploadLimits[0] > 0 && uploadLimits[1] > uploadLimits[0]) |
|
352 |
{ |
|
353 |
setUploadFileSizeLimits(uploadLimits[0], uploadLimits[1]); |
|
354 |
} |
|
355 |
} |
|
356 |
|
|
357 |
/** |
|
300 | 358 |
* Notify the driver which side has control (client-side (when <code>true</code>) or server, |
301 | 359 |
* otherwise). |
302 | 360 |
* |
... | ... | |
3837 | 3895 |
} |
3838 | 3896 |
|
3839 | 3897 |
/** |
3898 |
* Makes a copy of the given resource and saves its content in a temporary file. |
|
3899 |
* |
|
3900 |
* @param url |
|
3901 |
* The resource url. |
|
3902 |
* @param deleteOnExit |
|
3903 |
* Requests to delete this temporary file if JVM terminates normally. |
|
3904 |
* |
|
3905 |
* @return The temporary file that contains a copy of the given resource. |
|
3906 |
* |
|
3907 |
* @throws IOException |
|
3908 |
* If an exception is thrown during this 3-stages process of creating new file, |
|
3909 |
* opening the given url and coping the target resource. |
|
3910 |
*/ |
|
3911 |
protected File copyResource(URL url, boolean deleteOnExit) |
|
3912 |
throws IOException |
|
3913 |
{ |
|
3914 |
File resourceFile = File.createTempFile("copiedResource", null, new File(tmpDir)); |
|
3915 |
|
|
3916 |
try(InputStream input = url.openStream(); |
|
3917 |
FileOutputStream output = new FileOutputStream(resourceFile)) |
|
3918 |
{ |
|
3919 |
ByteStreams.copy(input, output); |
|
3920 |
} |
|
3921 |
|
|
3922 |
if (deleteOnExit) |
|
3923 |
{ |
|
3924 |
resourceFile.deleteOnExit(); |
|
3925 |
} |
|
3926 |
|
|
3927 |
return resourceFile; |
|
3928 |
} |
|
3929 |
|
|
3930 |
/** |
|
3931 |
* Moves the given resource into a temporary file. |
|
3932 |
* |
|
3933 |
* @param url |
|
3934 |
* The resource url. |
|
3935 |
* @param deleteOnExit |
|
3936 |
* Requests to delete this temporary file if JVM terminates normally. |
|
3937 |
* |
|
3938 |
* @return The temporary file that contains the given resource. |
|
3939 |
* |
|
3940 |
* @throws IOException |
|
3941 |
* If an exception is thrown when moving into a temporary file. |
|
3942 |
* @throws URISyntaxException |
|
3943 |
* If the given url can't be converted into URI. |
|
3944 |
*/ |
|
3945 |
protected File moveResource(URL url, boolean deleteOnExit) |
|
3946 |
throws IOException, |
|
3947 |
URISyntaxException |
|
3948 |
{ |
|
3949 |
StringBuilder fileName = new StringBuilder(UUID.randomUUID().toString()); |
|
3950 |
|
|
3951 |
Path target = Paths.get(tmpDir, fileName.append(System.currentTimeMillis()).toString()); |
|
3952 |
|
|
3953 |
Path source = Paths.get(url.toURI()); |
|
3954 |
|
|
3955 |
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING); |
|
3956 |
|
|
3957 |
File file = target.toFile(); |
|
3958 |
|
|
3959 |
if (deleteOnExit) |
|
3960 |
{ |
|
3961 |
file.deleteOnExit(); |
|
3962 |
} |
|
3963 |
|
|
3964 |
return file; |
|
3965 |
} |
|
3966 |
|
|
3967 |
/** |
|
3968 |
* Tests if the given url represents the local file resource. |
|
3969 |
* |
|
3970 |
* @param url |
|
3971 |
* The given resource |
|
3972 |
* |
|
3973 |
* @return True if the given url represents the local file resource, otherwise false. |
|
3974 |
*/ |
|
3975 |
protected boolean isLocalResource(URL url) |
|
3976 |
{ |
|
3977 |
if (FILE_SCHEMA.equalsIgnoreCase(url.getProtocol())) |
|
3978 |
{ |
|
3979 |
if (url.getHost() == null || url.getHost().isEmpty()) |
|
3980 |
{ |
|
3981 |
return true; |
|
3982 |
} |
|
3983 |
} |
|
3984 |
|
|
3985 |
return false; |
|
3986 |
} |
|
3987 |
|
|
3988 |
/** |
|
3840 | 3989 |
* Register the tooltip worker if this process was dalayed with regular registration. Internal |
3841 | 3990 |
* version. |
3842 | 3991 |
* |
src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2019-11-04 17:46:25 +0000 | ||
---|---|---|
97 | 97 |
** 060 OM 20181001 Tracked document output using an UUID. |
98 | 98 |
** 061 HC 20181212 Implemented support for asynchronous key state read emulation. |
99 | 99 |
** 062 CA 20190309 Added infrastructure for driver implemented widgets. |
100 |
** 063 SBI 20191104 Implemented DELETE-SOURCE-CONTENT of OPEN-MIME-RESOURCE. |
|
100 | 101 |
*/ |
101 | 102 | |
102 | 103 |
/* |
... | ... | |
723 | 724 |
consumer.accept(os); |
724 | 725 |
} |
725 | 726 |
|
726 |
openMimeResource(format.getMimeType(), outFile.toURI().normalize().toASCIIString(), true); |
|
727 |
openMimeResource(false, |
|
728 |
format.getMimeType(), |
|
729 |
outFile.toURI().normalize().toASCIIString(), |
|
730 |
true); |
|
727 | 731 |
} |
728 | 732 |
catch (IOException e) |
729 | 733 |
{ |
... | ... | |
741 | 745 |
/** |
742 | 746 |
* Opens the specified resource in a browser's window. |
743 | 747 |
* |
748 |
* @param deleteContent |
|
749 |
* Indicates if the source content will be deleted after the document is loaded by |
|
750 |
* the client. |
|
744 | 751 |
* @param mimeType |
745 | 752 |
* The resource mime type. |
746 | 753 |
* @param urlString |
... | ... | |
752 | 759 |
* If the string presentation of the target resource url is malformed. |
753 | 760 |
*/ |
754 | 761 |
@Override |
755 |
public void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
762 |
public void openMimeResource(boolean deleteContent, |
|
763 |
String mimeType, |
|
764 |
String urlString, |
|
765 |
boolean embedded) |
|
756 | 766 |
throws MalformedURLException |
757 | 767 |
{ |
758 | 768 |
// test that urlString is well-formed. |
759 | 769 |
URL url = new URL(urlString); |
760 | 770 |
|
761 |
URI uri;
|
|
771 |
URI sourceURI;
|
|
762 | 772 |
|
763 | 773 |
try |
764 | 774 |
{ |
765 |
uri = url.toURI();
|
|
775 |
sourceURI = url.toURI();
|
|
766 | 776 |
} |
767 | 777 |
catch (URISyntaxException ex) |
768 | 778 |
{ |
769 | 779 |
throw new MalformedURLException(ex.getMessage()); |
770 | 780 |
} |
771 | 781 |
|
782 |
boolean local = isLocalResource(url); |
|
783 |
|
|
784 |
URI uri; |
|
785 |
|
|
786 |
if (local) |
|
787 |
{ |
|
788 |
File fileResource; |
|
789 |
|
|
790 |
try |
|
791 |
{ |
|
792 |
if (deleteContent) |
|
793 |
{ |
|
794 |
try |
|
795 |
{ |
|
796 |
fileResource = moveResource(url, true); |
|
797 |
} |
|
798 |
catch (URISyntaxException ex) |
|
799 |
{ |
|
800 |
throw new MalformedURLException(ex.getMessage()); |
|
801 |
} |
|
802 |
} |
|
803 |
else |
|
804 |
{ |
|
805 |
fileResource = copyResource(url, true); |
|
806 |
} |
|
807 |
} |
|
808 |
catch (IOException ex) |
|
809 |
{ |
|
810 |
throw new RuntimeException(ex); |
|
811 |
} |
|
812 |
|
|
813 |
uri = fileResource.toURI(); |
|
814 |
} |
|
815 |
else |
|
816 |
{ |
|
817 |
uri = sourceURI; |
|
818 |
} |
|
819 |
|
|
772 | 820 |
if (embedded) |
773 | 821 |
{ |
774 | 822 |
try |
775 | 823 |
{ |
776 |
uri = buildOpenResourcePage(mimeType, urlString);
|
|
824 |
uri = buildOpenResourcePage(mimeType, uri.normalize().toASCIIString());
|
|
777 | 825 |
} |
778 | 826 |
catch (IOException ex) |
779 | 827 |
{ |
src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2019-11-04 17:47:08 +0000 | ||
---|---|---|
139 | 139 |
** hierarchy. |
140 | 140 |
** 060 SBI 20190925 Added the web client storage setup. |
141 | 141 |
** 061 HC 20190911 Implemented ad-hoc handler registration. |
142 |
** 062 SBI 20191104 Implemented DELETE-SOURCE-CONTENT of OPEN-MIME-RESOURCE. |
|
142 | 143 |
*/ |
143 | 144 | |
144 | 145 |
/* |
... | ... | |
212 | 213 |
import java.util.*; |
213 | 214 | |
214 | 215 |
import com.goldencode.p2j.ui.client.driver.*; |
216 | ||
215 | 217 |
import org.eclipse.jetty.server.*; |
216 | 218 |
import org.eclipse.jetty.util.resource.*; |
217 | 219 | |
... | ... | |
256 | 258 |
/** Welcome page. */ |
257 | 259 |
private static final String WELCOME_PAGE = "/index.html"; |
258 | 260 |
|
259 |
/** Define the file schema to get local resources */ |
|
260 |
private static final String FILE_SCHEMA = "file:"; |
|
261 |
|
|
262 | 261 |
/** A bogus AWT component used to raise mouse events, on notification from the JS code. */ |
263 | 262 |
private static final Component BOGUS_AWT_COMPONENT = new Component() |
264 | 263 |
{ |
... | ... | |
286 | 285 |
|
287 | 286 |
/** Text sample to calculate scaling factor for monospace fonts. */ |
288 | 287 |
private static final String TEXT_SAMPLE_MONO = "0.0"; |
289 | ||
290 |
/** Temporary files directory. */ |
|
291 |
private static String tmpDir = null; |
|
292 | 288 |
|
293 | 289 |
/** Delgated implementation for the embedded web server. */ |
294 | 290 |
private EmbeddedWebServerImpl websrv; |
... | ... | |
546 | 542 |
{ |
547 | 543 |
websrv.removeHandler(handler); |
548 | 544 |
} |
549 | ||
550 |
/** |
|
551 |
* Initializes several web client specific internal variables used with drag-n-drop. |
|
552 |
* |
|
553 |
* @param srv |
|
554 |
* Server to make config related calls. |
|
555 |
*/ |
|
556 |
public void initDragAndDrop(ServerExports srv) |
|
557 |
{ |
|
558 |
// this is used in web client only and only once |
|
559 |
if (tmpDir != null) |
|
560 |
{ |
|
561 |
return; |
|
562 |
} |
|
563 | ||
564 |
// setting up temporary files upload directory |
|
565 |
try |
|
566 |
{ |
|
567 |
Path tmpFile = Files.createTempFile("tmp-file", ".tmp"); |
|
568 |
String absolutePath = tmpFile.toAbsolutePath().toString(); |
|
569 |
tmpDir = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator) + 1); |
|
570 |
Files.delete(tmpFile); |
|
571 |
} |
|
572 |
catch (IOException e) |
|
573 |
{ |
|
574 |
// for the case the regular way above does not work |
|
575 |
tmpDir = System.getProperty("user.home"); |
|
576 |
} |
|
577 |
// create separate directory for fwd files |
|
578 |
tmpDir = tmpDir.concat("fwd"); |
|
579 |
File tmpDirObj = new File(tmpDir); |
|
580 |
if (!tmpDirObj.exists()) |
|
581 |
{ |
|
582 |
tmpDirObj.mkdir(); |
|
583 |
} |
|
584 |
// adding file separator to the end |
|
585 |
tmpDir = tmpDir.concat(File.separator); |
|
586 |
|
|
587 |
// getting the file size limit values considering overrides in server's directory |
|
588 |
int [] uploadLimits = srv.getUploadFileSizeLimits(); |
|
589 |
// set up gui driver |
|
590 |
if (uploadLimits[0] > 0 && uploadLimits[1] > uploadLimits[0]) |
|
591 |
{ |
|
592 |
setUploadFileSizeLimits(uploadLimits[0], uploadLimits[1]); |
|
593 |
} |
|
594 |
} |
|
595 | 545 |
|
596 | 546 |
/** |
597 | 547 |
* This is a special API which is used to delegate a call from converted 4GL code |
... | ... | |
2571 | 2521 |
/** |
2572 | 2522 |
* Opens the specified resource in a browser's window. |
2573 | 2523 |
* |
2524 |
* @param deleteContent |
|
2525 |
* Indicates if the source content will be deleted after the document is loaded by |
|
2526 |
* the client. |
|
2574 | 2527 |
* @param mimeType |
2575 | 2528 |
* The resource mime type. |
2576 | 2529 |
* @param urlString |
... | ... | |
2584 | 2537 |
* For other IO errors during file operations. |
2585 | 2538 |
*/ |
2586 | 2539 |
@Override |
2587 |
public void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
2540 |
public void openMimeResource(boolean deleteContent, |
|
2541 |
String mimeType, |
|
2542 |
String urlString, |
|
2543 |
boolean embedded) |
|
2588 | 2544 |
throws MalformedURLException |
2589 | 2545 |
{ |
2590 | 2546 |
// test that urlString is well-formed. |
... | ... | |
2605 | 2561 |
|
2606 | 2562 |
boolean local = false; |
2607 | 2563 |
|
2608 |
if (urlString.startsWith(FILE_SCHEMA))
|
|
2564 |
if (isLocalResource(url))
|
|
2609 | 2565 |
{ |
2610 |
if (url.getHost() == null || url.getHost().isEmpty()) |
|
2611 |
{ |
|
2612 |
local = true; |
|
2613 |
|
|
2614 |
id = resolveResourceId(mimeType, url); |
|
2615 |
} |
|
2566 |
local = true; |
|
2567 |
|
|
2568 |
id = resolveResourceId(deleteContent, mimeType, url); |
|
2616 | 2569 |
} |
2617 | 2570 |
|
2618 | 2571 |
websock.openMimeResource(id, mimeType, embedded, local); |
... | ... | |
2621 | 2574 |
/** |
2622 | 2575 |
* Resolve the document ID used to retrieve the specified resource. |
2623 | 2576 |
* |
2577 |
* @param deleteContent |
|
2578 |
* Indicates if the source content will be deleted after the document is loaded by |
|
2579 |
* the client. |
|
2624 | 2580 |
* @param mimeType |
2625 | 2581 |
* The resource mime type. |
2626 | 2582 |
* @param url |
2627 | 2583 |
* The resource URL - must be a local resource. |
2584 |
* |
|
2585 |
* @throws MalformedURLException |
|
2586 |
* If the string presentation of the target resource url is malformed. |
|
2628 | 2587 |
*/ |
2629 |
String resolveResourceId(String mimeType, URL url) |
|
2588 |
String resolveResourceId(boolean deleteContent, String mimeType, URL url) |
|
2589 |
throws MalformedURLException |
|
2630 | 2590 |
{ |
2631 |
final File temporaryFile; |
|
2632 |
try |
|
2591 |
final File resourceFile; |
|
2592 |
|
|
2593 |
if (deleteContent) |
|
2633 | 2594 |
{ |
2634 |
temporaryFile = File.createTempFile("openMimeResource",
|
|
2635 |
null,
|
|
2636 |
new File(tmpDir));
|
|
2637 |
try(InputStream input = url.openStream();
|
|
2638 |
FileOutputStream output = new FileOutputStream(temporaryFile))
|
|
2639 |
{ |
|
2640 |
ByteStreams.copy(input, output);
|
|
2595 |
try
|
|
2596 |
{
|
|
2597 |
resourceFile = Paths.get(url.toURI()).toFile();
|
|
2598 |
}
|
|
2599 |
catch (URISyntaxException ex)
|
|
2600 |
{ |
|
2601 |
throw new MalformedURLException(ex.getMessage());
|
|
2641 | 2602 |
} |
2642 | 2603 |
} |
2643 |
catch (IOException ex)
|
|
2604 |
else
|
|
2644 | 2605 |
{ |
2645 |
throw new RuntimeException(ex); |
|
2606 |
try |
|
2607 |
{ |
|
2608 |
resourceFile = copyResource(url, false); |
|
2609 |
} |
|
2610 |
catch (IOException ex) |
|
2611 |
{ |
|
2612 |
throw new RuntimeException(ex); |
|
2613 |
} |
|
2646 | 2614 |
} |
2647 | 2615 |
|
2648 | 2616 |
Consumer<OutputStream> consumer = output -> |
2649 | 2617 |
{ |
2650 |
try(FileInputStream input = new FileInputStream(temporaryFile))
|
|
2618 |
try(FileInputStream input = new FileInputStream(resourceFile))
|
|
2651 | 2619 |
{ |
2652 | 2620 |
ByteStreams.copy(input, output); |
2653 | 2621 |
} |
... | ... | |
2657 | 2625 |
} |
2658 | 2626 |
}; |
2659 | 2627 |
|
2660 |
Runnable finalizer = () -> { temporaryFile.delete(); };
|
|
2628 |
Runnable finalizer = () -> { resourceFile.delete(); };
|
|
2661 | 2629 |
|
2662 | 2630 |
UUID uuid = UUID.randomUUID(); |
2663 | 2631 |
DocumentOutput docOut = new DocumentOutput(consumer, |
src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java 2019-11-04 18:07:58 +0000 | ||
---|---|---|
8 | 8 |
** 001 CA 20190310 Created initial version. |
9 | 9 |
** 002 HC 20190911 Implemented BeforeNavigate2 event emit when existing page is navigated. |
10 | 10 |
** Implemented resource loading. |
11 |
** 003 SBI 20191004 Changed openUrl due to gd.resolveResourceId parameter changes. |
|
11 | 12 |
*/ |
12 | 13 | |
13 | 14 |
/* |
... | ... | |
72 | 73 |
import com.goldencode.p2j.ui.chui.ThinClient; |
73 | 74 |
import com.goldencode.p2j.ui.client.*; |
74 | 75 |
import com.goldencode.p2j.util.*; |
76 | ||
75 | 77 |
import org.eclipse.jetty.http.*; |
76 | 78 |
import org.eclipse.jetty.server.*; |
77 | 79 |
import org.eclipse.jetty.server.handler.*; |
78 |
import org.eclipse.jetty.util.*; |
|
79 | 80 |
import org.eclipse.jetty.util.resource.*; |
80 | 81 | |
81 | 82 |
import javax.servlet.*; |
... | ... | |
263 | 264 |
local = true; |
264 | 265 |
ThinClient tc = ThinClient.getInstance(); |
265 | 266 |
GuiWebDriver gd = (GuiWebDriver) tc.getOutputManager().getInstanceDriver(); |
266 |
id = gd.resolveResourceId(mimeType, url); |
|
267 |
try |
|
268 |
{ |
|
269 |
id = gd.resolveResourceId(false, mimeType, url); |
|
270 |
} |
|
271 |
catch (MalformedURLException ex) |
|
272 |
{ |
|
273 |
ex.printStackTrace(); |
|
274 |
return false; |
|
275 |
} |
|
267 | 276 |
} |
268 | 277 |
} |
269 | 278 |
src/com/goldencode/p2j/util/WebBrowserManager.java 2019-11-04 17:53:09 +0000 | ||
---|---|---|
10 | 10 |
** 003 ECF 20180510 Added API variants to handle additional combinations of parameter types. |
11 | 11 |
** 004 SBI 20180528 Fixed embedded optional parameter to be true by default. |
12 | 12 |
** 005 SBI 20181207 Added openMimeResource(String filePath, boolean embedded). |
13 |
** 006 SBI 20191104 Added deleteContent parameter for openMimeResource. |
|
13 | 14 |
*/ |
14 | 15 |
/* |
15 | 16 |
** This program is free software: you can redistribute it and/or modify |
... | ... | |
87 | 88 |
*/ |
88 | 89 |
public static void openMimeResource(String mimeType, String path) |
89 | 90 |
{ |
90 |
openMimeResource(mimeType, path, true); |
|
91 |
openMimeResource(false, mimeType, path, true);
|
|
91 | 92 |
} |
92 | 93 | |
93 | 94 |
/** |
94 | 95 |
* Opens the specified resource in a browser's window. |
95 | 96 |
* |
96 |
* @param mimeType |
|
97 |
* The resource mime type. |
|
98 |
* @param path |
|
99 |
* The url path to the target resource. |
|
100 |
* @param embedded |
|
101 |
* The document is embedded in the template document. |
|
102 |
*/ |
|
103 |
public static void openMimeResource(String mimeType, String path, boolean embedded) |
|
104 |
{ |
|
105 |
LogicalTerminal.getClient().openMimeResource(mimeType, path, embedded); |
|
97 |
* @param deleteContent |
|
98 |
* Indicates if the source content will be deleted after the document is loaded by |
|
99 |
* the client. |
|
100 |
* @param mimeType |
|
101 |
* The resource mime type. |
|
102 |
* @param path |
|
103 |
* The url path to the target resource. |
|
104 |
* @param embedded |
|
105 |
* The document is embedded in the template document. |
|
106 |
*/ |
|
107 |
public static void openMimeResource(boolean deleteContent, |
|
108 |
String mimeType, |
|
109 |
String path, |
|
110 |
boolean embedded) |
|
111 |
{ |
|
112 |
LogicalTerminal.getClient().openMimeResource(deleteContent, mimeType, path, embedded); |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Opens the specified resource in a browser's window. |
|
117 |
* |
|
118 |
* @param mimeType |
|
119 |
* The resource mime type. |
|
120 |
* @param path |
|
121 |
* The url path to the target resource. |
|
122 |
* @param embedded |
|
123 |
* The document is embedded in the template document. |
|
124 |
*/ |
|
125 |
public static void openMimeResource(String mimeType, String path, boolean embedded) |
|
126 |
{ |
|
127 |
openMimeResource(false, mimeType, path, embedded); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Opens the specified file resource in a browser's window. |
|
132 |
* |
|
133 |
* @param deleteContent |
|
134 |
* Indicates if the source content will be deleted after the document is loaded by |
|
135 |
* the client. |
|
136 |
* @param filePath |
|
137 |
* The file path to the target resource. |
|
138 |
* @param embedded |
|
139 |
* The document is embedded in the template document. |
|
140 |
* @param preferredMimeTypes |
|
141 |
* The preferred resource mime types. |
|
142 |
*/ |
|
143 |
public static void openMimeResource(boolean deleteContent, |
|
144 |
String filePath, |
|
145 |
boolean embedded, |
|
146 |
List<String> preferredMimeTypes) |
|
147 |
{ |
|
148 |
LogicalTerminal.getClient().openMimeResource(deleteContent, |
|
149 |
filePath, |
|
150 |
embedded, |
|
151 |
preferredMimeTypes); |
|
106 | 152 |
} |
107 | 153 |
|
108 | 154 |
/** |
... | ... | |
119 | 165 |
boolean embedded, |
120 | 166 |
List<String> preferredMimeTypes) |
121 | 167 |
{ |
122 |
LogicalTerminal.getClient().openMimeResource(filePath, embedded, preferredMimeTypes);
|
|
168 |
openMimeResource(false, filePath, embedded, preferredMimeTypes);
|
|
123 | 169 |
} |
124 | 170 |
|
125 | 171 |
/** |
... | ... | |
155 | 201 |
/** |
156 | 202 |
* Opens the specified resource in a browser's window. |
157 | 203 |
* |
204 |
* @param deleteContent |
|
205 |
* Indicates if the source content will be deleted after the document is loaded by |
|
206 |
* the client. |
|
207 |
* @param mimeType |
|
208 |
* The resource mime type. |
|
209 |
* @param path |
|
210 |
* The url path to the target resource. |
|
211 |
* @param embedded |
|
212 |
* The document is embedded in the template document. |
|
213 |
*/ |
|
214 |
public static void openMimeResource(boolean deleteContent, |
|
215 |
character mimeType, |
|
216 |
character path, |
|
217 |
boolean embedded) |
|
218 |
{ |
|
219 |
openMimeResource(deleteContent, mimeType.toJavaType(), path.toJavaType(), embedded); |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* Opens the specified resource in a browser's window. |
|
224 |
* |
|
225 |
* @param deleteContent |
|
226 |
* Indicates if the source content will be deleted after the document is loaded by |
|
227 |
* the client. |
|
228 |
* @param mimeType |
|
229 |
* The resource mime type. |
|
230 |
* @param path |
|
231 |
* The url path to the target resource. |
|
232 |
* @param embedded |
|
233 |
* The document is embedded in the template document. |
|
234 |
*/ |
|
235 |
public static void openMimeResource(boolean deleteContent, |
|
236 |
character mimeType, |
|
237 |
String path, |
|
238 |
boolean embedded) |
|
239 |
{ |
|
240 |
openMimeResource(deleteContent, mimeType.toJavaType(), path, embedded); |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* Opens the specified resource in a browser's window. |
|
245 |
* |
|
246 |
* @param deleteContent |
|
247 |
* Indicates if the source content will be deleted after the document is loaded by |
|
248 |
* the client. |
|
249 |
* @param mimeType |
|
250 |
* The resource mime type. |
|
251 |
* @param path |
|
252 |
* The url path to the target resource. |
|
253 |
* @param embedded |
|
254 |
* The document is embedded in the template document. |
|
255 |
*/ |
|
256 |
public static void openMimeResource(boolean deleteContent, |
|
257 |
String mimeType, |
|
258 |
character path, |
|
259 |
boolean embedded) |
|
260 |
{ |
|
261 |
openMimeResource(deleteContent, mimeType, path.toJavaType(), embedded); |
|
262 |
} |
|
263 |
|
|
264 |
/** |
|
265 |
* Opens the specified resource in a browser's window. |
|
266 |
* |
|
158 | 267 |
* @param mimeType |
159 | 268 |
* The resource mime type. |
160 | 269 |
* @param path |
... | ... | |
259 | 368 |
*/ |
260 | 369 |
public static void openURL(String path) |
261 | 370 |
{ |
262 |
LogicalTerminal.getClient().openMimeResource("application/octet-stream", path, false); |
|
371 |
LogicalTerminal.getClient().openMimeResource(false, "application/octet-stream", path, false);
|
|
263 | 372 |
} |
264 | 373 |
|
265 | 374 |
/** |