4077.patch
rules/convert/language_statements.rules 2019-11-01 21:44:23 +0000 | ||
---|---|---|
862 | 862 |
</action> |
863 | 863 |
</rule> |
864 | 864 |
|
865 |
<rule>type == prog.kw_not_embeded and |
|
866 |
parent.type == prog.kw_openmime |
|
867 |
<action>createJavaAst(java.bool_true, "false", closestPeerId)</action> |
|
868 |
</rule> |
|
869 |
|
|
870 |
<rule>type == prog.kw_del_s_c and |
|
871 |
parent.type == prog.kw_openmime |
|
872 |
<action>createJavaAst(java.bool_true, "true", closestPeerId, 0)</action> |
|
873 |
</rule> |
|
874 |
|
|
865 | 875 |
<rule>type == prog.create_timer and parent.type == prog.statement |
866 | 876 |
<action> |
867 | 877 |
createPeerAst(java.static_method_call, "PSTimer.create", closestPeerId) |
src/com/goldencode/p2j/uast/progress.g 2019-11-01 21:46:23 +0000 | ||
---|---|---|
3586 | 3586 |
KW_DEL_NODE; |
3587 | 3587 |
KW_DEL_PROC; |
3588 | 3588 |
KW_DEL_R_L; |
3589 |
KW_DEL_S_C; // FWD extension |
|
3589 | 3590 |
KW_DEL_S_R; |
3590 | 3591 |
KW_DEL_S_RS; |
3591 | 3592 |
KW_DEL_WORD; |
... | ... | |
3639 | 3640 |
KW_EDIT_TAB; |
3640 | 3641 |
KW_EH_FL; // FWD extension, not real 4GL! |
3641 | 3642 |
KW_EH_SR; // FWD extension, not real 4GL! |
3643 |
KW_NOT_EMBEDED; // FWD extension |
|
3642 | 3644 |
KW_EMPTY; |
3643 | 3645 |
KW_EMPTY_DS; |
3644 | 3646 |
KW_EMPTY_SN; |
... | ... | |
7962 | 7964 |
attrsAndMethods.put( KW_DEL_LINE, METH_LOGICAL ); |
7963 | 7965 |
attrsAndMethods.put( KW_DEL_NODE, METH_LOGICAL ); |
7964 | 7966 |
attrsAndMethods.put( KW_DEL_R_L , METH_LOGICAL ); |
7967 |
attrsAndMethods.put( KW_DEL_S_C , ATTR_LOGICAL ); // FWD extension |
|
7965 | 7968 |
attrsAndMethods.put( KW_DEL_S_R , METH_LOGICAL ); |
7966 | 7969 |
attrsAndMethods.put( KW_DEL_S_RS, METH_LOGICAL ); |
7967 | 7970 |
attrsAndMethods.put( KW_DELETE , METH_LOGICAL ); |
... | ... | |
8002 | 8005 |
attrsAndMethods.put( KW_EDIT_UND, METH_LOGICAL ); |
8003 | 8006 |
attrsAndMethods.put( KW_EH_FL, ATTR_LOGICAL ); // FWD extension, not real 4GL |
8004 | 8007 |
attrsAndMethods.put( KW_EH_SR, ATTR_LOGICAL ); // FWD extension, not real 4GL |
8008 |
attrsAndMethods.put( KW_NOT_EMBEDED, ATTR_LOGICAL ); // FWD extension |
|
8005 | 8009 |
attrsAndMethods.put( KW_EMB_FILE, METH_LOGICAL ); // FWD extension, not real 4GL |
8006 | 8010 |
attrsAndMethods.put( KW_EMB_URL, METH_LOGICAL ); // FWD extension, not real 4GL |
8007 | 8011 |
attrsAndMethods.put( KW_EMPTY , ATTR_LOGICAL ); |
... | ... | |
27473 | 27477 |
|
27474 | 27478 |
/** |
27475 | 27479 |
* 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. |
|
27480 |
* pair of resource mime type character and its url character expression. If an optional |
|
27481 |
* <code>DELETE-SOURCE-CONTENT</code> is present, then it forces to delete the original input file |
|
27482 |
* when the transfer is complete. |
|
27477 | 27483 |
*/ |
27478 | 27484 |
open_mime_resource_stmt |
27479 | 27485 |
: |
27480 |
KW_OPENMIME^ expr expr (expr)? stmt_term |
|
27486 |
KW_OPENMIME^ expr expr |
|
27487 |
( options { generateAmbigWarnings = false; } |
|
27488 |
: |
|
27489 |
KW_NOT_EMBEDED |
|
27490 |
)? |
|
27491 |
( |
|
27492 |
options { generateAmbigWarnings = false; } |
|
27493 |
: |
|
27494 |
KW_DEL_S_C |
|
27495 |
) |
|
27496 |
stmt_term |
|
27481 | 27497 |
; |
27482 | 27498 |
|
27483 | 27499 |
/** |
... | ... | |
32715 | 32731 |
new Keyword("delete-result-list-entry" , 0, KW_DEL_R_L , false), |
32716 | 32732 |
new Keyword("delete-selected-row" , 0, KW_DEL_S_R , false), |
32717 | 32733 |
new Keyword("delete-selected-rows" , 0, KW_DEL_S_RS, false), |
32734 |
new Keyword("delete-source-content" , 0, KW_DEL_S_C , false), // FWD extension |
|
32718 | 32735 |
new Keyword("delete-word" , 0, KW_DEL_WORD, false), // missing in keyword index, found in prog handbook as a key function |
32719 | 32736 |
new Keyword("descending" , 4, KW_DESCEND , true ), // handles "separate keyword" desc too |
32720 | 32737 |
new Keyword("description" , 0, KW_DESCR , false), // missing in keyword index, found in customer code |
... | ... | |
32787 | 32804 |
new Keyword("else" , 0, KW_ELSE , true ), |
32788 | 32805 |
new Keyword("embed-image-by-file" , 0, KW_EMB_FILE, false), // FWD extension, not a real 4GL keyword |
32789 | 32806 |
new Keyword("embed-image-by-url" , 0, KW_EMB_URL , false), // FWD extension, not a real 4GL keyword |
32807 |
new Keyword("not-embeded-content" , 0, KW_NOT_EMBEDED, false), // FWD extension |
|
32790 | 32808 |
new Keyword("empty" , 0, KW_EMPTY , false), |
32791 | 32809 |
new Keyword("empty-dataset" , 0, KW_EMPTY_DS, false), // missing from keyword index and UNTESTED at this time |
32792 | 32810 |
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-01 08:22:13 +0000 | ||
---|---|---|
3122 | 3122 |
/** |
3123 | 3123 |
* Opens the specified resource in a browser's window. |
3124 | 3124 |
* |
3125 |
* @param deleteContent |
|
3126 |
* Indicates if the source content will be deleted after the document is loaded by |
|
3127 |
* the client. |
|
3125 | 3128 |
* @param mimeType |
3126 | 3129 |
* The resource mime type. |
3127 | 3130 |
* @param path |
... | ... | |
3129 | 3132 |
* @param embedded |
3130 | 3133 |
* The document is embedded in the template document. |
3131 | 3134 |
*/ |
3132 |
public void openMimeResource(String mimeType, String path, boolean embedded); |
|
3135 |
public void openMimeResource(boolean deletedContent, |
|
3136 |
String mimeType, |
|
3137 |
String path, |
|
3138 |
boolean embedded); |
|
3133 | 3139 | |
3134 | 3140 |
/** |
3135 | 3141 |
* Opens the specified file resource in a browser's window. |
3136 | 3142 |
* |
3143 |
* @param deleteContent |
|
3144 |
* Indicates if the source content will be deleted after the document is loaded by |
|
3145 |
* the client. |
|
3137 | 3146 |
* @param filePath |
3138 | 3147 |
* The file system path on the legacy system or the host system. If the legacy system |
3139 | 3148 |
* path is given, then it is resolved to the host system path. |
... | ... | |
3142 | 3151 |
* @param preferredMimeTypes |
3143 | 3152 |
* The preferred resource mime types. |
3144 | 3153 |
*/ |
3145 |
public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes); |
|
3154 |
public void openMimeResource(boolean deletedContent, |
|
3155 |
String filePath, |
|
3156 |
boolean embedded, |
|
3157 |
List<String> preferredMimeTypes); |
|
3146 | 3158 | |
3147 | 3159 |
/** |
3148 | 3160 |
* 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-01 08:29:28 +0000 | ||
---|---|---|
23021 | 23021 |
/** |
23022 | 23022 |
* Opens the specified resource in a browser's window. |
23023 | 23023 |
* |
23024 |
* @param deleteContent |
|
23025 |
* Indicates if the source content will be deleted after the document is loaded by |
|
23026 |
* the client. |
|
23024 | 23027 |
* @param mimeType |
23025 | 23028 |
* The resource mime type. |
23026 | 23029 |
* @param urlString |
... | ... | |
23029 | 23032 |
* The document is embedded in the template document. |
23030 | 23033 |
*/ |
23031 | 23034 |
@Override |
23032 |
public void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
23035 |
public void openMimeResource(boolean deleteContent, |
|
23036 |
String mimeType, |
|
23037 |
String urlString, |
|
23038 |
boolean embedded) |
|
23033 | 23039 |
{ |
23034 | 23040 |
urlString = UiUtils.resolveResourceUrl(urlString); |
23035 | 23041 |
try |
23036 | 23042 |
{ |
23037 |
tk.getInstanceDriver().openMimeResource(mimeType, urlString, embedded); |
|
23043 |
tk.getInstanceDriver().openMimeResource(deleteContent, mimeType, urlString, embedded);
|
|
23038 | 23044 |
} |
23039 | 23045 |
catch (MalformedURLException e) |
23040 | 23046 |
{ |
... | ... | |
23045 | 23051 |
/** |
23046 | 23052 |
* Opens the specified file resource in a browser's window. |
23047 | 23053 |
* |
23054 |
* @param deleteContent |
|
23055 |
* Indicates if the source content will be deleted after the document is loaded by |
|
23056 |
* the client. |
|
23048 | 23057 |
* @param filePath |
23049 | 23058 |
* The file system path on the legacy system or the host system. If the legacy system |
23050 | 23059 |
* path is given, then it is resolved to the host system path. |
... | ... | |
23053 | 23062 |
* @param preferredMimeTypes |
23054 | 23063 |
* The preferred resource mime types. |
23055 | 23064 |
*/ |
23056 |
public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes) |
|
23065 |
public void openMimeResource(boolean deleteContent, |
|
23066 |
String filePath, |
|
23067 |
boolean embedded, |
|
23068 |
List<String> preferredMimeTypes) |
|
23057 | 23069 |
{ |
23058 | 23070 |
// getting FSD instance |
23059 | 23071 |
FileSystemDaemon fsd = getFileSystemDaemon(); |
... | ... | |
23070 | 23082 |
|
23071 | 23083 |
if (mimeType != null && preferredMimeTypes.contains(mimeType)) |
23072 | 23084 |
{ |
23073 |
openMimeResource(mimeType, "file:///" + fName, embedded); |
|
23085 |
openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
|
|
23074 | 23086 |
} |
23075 | 23087 |
else |
23076 | 23088 |
{ |
23077 | 23089 |
mimeType = preferredMimeTypes.get(0); // takes the default mime type |
23078 | 23090 |
|
23079 |
openMimeResource(mimeType, "file:///" + fName, embedded); |
|
23091 |
openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
|
|
23080 | 23092 |
} |
23081 | 23093 |
} |
23082 | 23094 |
} |
src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java 2019-11-01 08:27:16 +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/swing/SwingGuiDriver.java 2019-11-01 21:50:30 +0000 | ||
---|---|---|
723 | 723 |
consumer.accept(os); |
724 | 724 |
} |
725 | 725 |
|
726 |
openMimeResource(format.getMimeType(), outFile.toURI().normalize().toASCIIString(), true); |
|
726 |
openMimeResource(false, |
|
727 |
format.getMimeType(), |
|
728 |
outFile.toURI().normalize().toASCIIString(), |
|
729 |
true); |
|
727 | 730 |
} |
728 | 731 |
catch (IOException e) |
729 | 732 |
{ |
... | ... | |
741 | 744 |
/** |
742 | 745 |
* Opens the specified resource in a browser's window. |
743 | 746 |
* |
747 |
* @param deleteContent |
|
748 |
* Indicates if the source content will be deleted after the document is loaded by |
|
749 |
* the client. |
|
744 | 750 |
* @param mimeType |
745 | 751 |
* The resource mime type. |
746 | 752 |
* @param urlString |
... | ... | |
752 | 758 |
* If the string presentation of the target resource url is malformed. |
753 | 759 |
*/ |
754 | 760 |
@Override |
755 |
public void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
761 |
public void openMimeResource(boolean deleteContent, |
|
762 |
String mimeType, |
|
763 |
String urlString, |
|
764 |
boolean embedded) |
|
756 | 765 |
throws MalformedURLException |
757 | 766 |
{ |
758 | 767 |
// test that urlString is well-formed. |
... | ... | |
768 | 777 |
{ |
769 | 778 |
throw new MalformedURLException(ex.getMessage()); |
770 | 779 |
} |
780 |
// set file stamp |
|
781 |
long current = System.currentTimeMillis(); |
|
782 |
File sourceContent = Paths.get(uri).toFile(); |
|
783 |
if (!sourceContent.setLastModified(current)) |
|
784 |
{ |
|
785 |
current = sourceContent.lastModified(); |
|
786 |
} |
|
771 | 787 |
|
772 | 788 |
if (embedded) |
773 | 789 |
{ |
... | ... | |
789 | 805 |
{ |
790 | 806 |
throw new RuntimeException(ex); |
791 | 807 |
} |
808 |
|
|
809 |
long elapsed = 0; |
|
810 |
|
|
811 |
long start = System.currentTimeMillis(); |
|
812 |
|
|
813 |
while(sourceContent.lastModified() == current) |
|
814 |
{ |
|
815 |
try |
|
816 |
{ |
|
817 |
Thread.currentThread().sleep(1000); |
|
818 |
} |
|
819 |
catch (InterruptedException e) |
|
820 |
{ |
|
821 |
|
|
822 |
} |
|
823 |
|
|
824 |
elapsed = System.currentTimeMillis() - start; |
|
825 |
|
|
826 |
if (elapsed > 60 * 1000) |
|
827 |
{ |
|
828 |
break; |
|
829 |
} |
|
830 |
} |
|
831 |
|
|
832 |
if (deleteContent) |
|
833 |
{ |
|
834 |
sourceContent.delete(); |
|
835 |
} |
|
792 | 836 |
} |
793 | 837 | |
794 | 838 |
/** |
src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java 2019-11-01 08:46:12 +0000 | ||
---|---|---|
212 | 212 |
import java.util.*; |
213 | 213 | |
214 | 214 |
import com.goldencode.p2j.ui.client.driver.*; |
215 | ||
215 | 216 |
import org.eclipse.jetty.server.*; |
216 | 217 |
import org.eclipse.jetty.util.resource.*; |
217 | 218 | |
... | ... | |
2571 | 2572 |
/** |
2572 | 2573 |
* Opens the specified resource in a browser's window. |
2573 | 2574 |
* |
2575 |
* @param deleteContent |
|
2576 |
* Indicates if the source content will be deleted after the document is loaded by |
|
2577 |
* the client. |
|
2574 | 2578 |
* @param mimeType |
2575 | 2579 |
* The resource mime type. |
2576 | 2580 |
* @param urlString |
... | ... | |
2584 | 2588 |
* For other IO errors during file operations. |
2585 | 2589 |
*/ |
2586 | 2590 |
@Override |
2587 |
public void openMimeResource(String mimeType, String urlString, boolean embedded) |
|
2591 |
public void openMimeResource(boolean deleteContent, |
|
2592 |
String mimeType, |
|
2593 |
String urlString, |
|
2594 |
boolean embedded) |
|
2588 | 2595 |
throws MalformedURLException |
2589 | 2596 |
{ |
2590 | 2597 |
// test that urlString is well-formed. |
... | ... | |
2611 | 2618 |
{ |
2612 | 2619 |
local = true; |
2613 | 2620 |
|
2614 |
id = resolveResourceId(mimeType, url); |
|
2621 |
id = resolveResourceId(deleteContent, mimeType, url);
|
|
2615 | 2622 |
} |
2616 | 2623 |
} |
2617 | 2624 |
|
... | ... | |
2621 | 2628 |
/** |
2622 | 2629 |
* Resolve the document ID used to retrieve the specified resource. |
2623 | 2630 |
* |
2631 |
* @param deleteContent |
|
2632 |
* Indicates if the source content will be deleted after the document is loaded by |
|
2633 |
* the client. |
|
2624 | 2634 |
* @param mimeType |
2625 | 2635 |
* The resource mime type. |
2626 | 2636 |
* @param url |
2627 | 2637 |
* The resource URL - must be a local resource. |
2638 |
* |
|
2639 |
* @throws MalformedURLException |
|
2640 |
* If the string presentation of the target resource url is malformed. |
|
2628 | 2641 |
*/ |
2629 |
String resolveResourceId(String mimeType, URL url) |
|
2642 |
String resolveResourceId(boolean deleteContent, String mimeType, URL url) |
|
2643 |
throws MalformedURLException |
|
2630 | 2644 |
{ |
2631 |
final File temporaryFile; |
|
2632 |
try |
|
2645 |
final File resourceFile; |
|
2646 |
|
|
2647 |
if (deleteContent) |
|
2633 | 2648 |
{ |
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);
|
|
2649 |
try
|
|
2650 |
{
|
|
2651 |
resourceFile = Paths.get(url.toURI()).toFile();
|
|
2652 |
}
|
|
2653 |
catch (URISyntaxException ex)
|
|
2654 |
{ |
|
2655 |
throw new MalformedURLException(ex.getMessage());
|
|
2641 | 2656 |
} |
2642 | 2657 |
} |
2643 |
catch (IOException ex)
|
|
2658 |
else
|
|
2644 | 2659 |
{ |
2645 |
throw new RuntimeException(ex); |
|
2660 |
try |
|
2661 |
{ |
|
2662 |
resourceFile = File.createTempFile("openMimeResource", |
|
2663 |
null, |
|
2664 |
new File(tmpDir)); |
|
2665 |
try(InputStream input = url.openStream(); |
|
2666 |
FileOutputStream output = new FileOutputStream(resourceFile)) |
|
2667 |
{ |
|
2668 |
ByteStreams.copy(input, output); |
|
2669 |
} |
|
2670 |
} |
|
2671 |
catch (IOException ex) |
|
2672 |
{ |
|
2673 |
throw new RuntimeException(ex); |
|
2674 |
} |
|
2646 | 2675 |
} |
2647 | 2676 |
|
2648 | 2677 |
Consumer<OutputStream> consumer = output -> |
2649 | 2678 |
{ |
2650 |
try(FileInputStream input = new FileInputStream(temporaryFile))
|
|
2679 |
try(FileInputStream input = new FileInputStream(resourceFile))
|
|
2651 | 2680 |
{ |
2652 | 2681 |
ByteStreams.copy(input, output); |
2653 | 2682 |
} |
... | ... | |
2657 | 2686 |
} |
2658 | 2687 |
}; |
2659 | 2688 |
|
2660 |
Runnable finalizer = () -> { temporaryFile.delete(); };
|
|
2689 |
Runnable finalizer = () -> { resourceFile.delete(); };
|
|
2661 | 2690 |
|
2662 | 2691 |
UUID uuid = UUID.randomUUID(); |
2663 | 2692 |
DocumentOutput docOut = new DocumentOutput(consumer, |
src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java 2019-11-01 19:18:28 +0000 | ||
---|---|---|
72 | 72 |
import com.goldencode.p2j.ui.chui.ThinClient; |
73 | 73 |
import com.goldencode.p2j.ui.client.*; |
74 | 74 |
import com.goldencode.p2j.util.*; |
75 | ||
75 | 76 |
import org.eclipse.jetty.http.*; |
76 | 77 |
import org.eclipse.jetty.server.*; |
77 | 78 |
import org.eclipse.jetty.server.handler.*; |
... | ... | |
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 |