From 7317c5c172fe411eaaf26ff6bc9012b3f36a3c01 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sat, 4 Jan 2020 11:16:00 +0100 Subject: [PATCH] Integrate RCP support from Argeo Commons. --- .../META-INF/MANIFEST.MF | 2 +- pom.xml | 6 +- rcp/.gitignore | 1 + rcp/demo/.gitignore | 1 + rcp/demo/log4j.properties | 32 + rcp/dep/.gitignore | 1 + rcp/dep/org.argeo.dep.cms.e4.rcp/.gitignore | 3 + .../META-INF/.gitignore | 1 + rcp/dep/org.argeo.dep.cms.e4.rcp/bnd.bnd | 0 rcp/dep/org.argeo.dep.cms.e4.rcp/p2.inf | 2 + rcp/dep/org.argeo.dep.cms.e4.rcp/pom.xml | 755 ++++++++++++++++++ .../src/assembly/linux.x86.xml | 59 ++ .../src/assembly/linux.x86_64.xml | 59 ++ .../src/assembly/win32.x86.xml | 59 ++ rcp/dep/pom.xml | 107 +++ .../etc/argeo-companion/argeo-companion.ini | 25 + .../rpm/etc/argeo-companion/log4j.properties | 32 + .../rpm/usr/bin/argeo-companion | 54 ++ rcp/org.argeo.cms.desktop/.classpath | 7 + rcp/org.argeo.cms.desktop/.gitignore | 2 + rcp/org.argeo.cms.desktop/.project | 28 + rcp/org.argeo.cms.desktop/META-INF/.gitignore | 1 + rcp/org.argeo.cms.desktop/bnd.bnd | 2 + rcp/org.argeo.cms.desktop/build.properties | 4 + rcp/org.argeo.cms.desktop/pom.xml | 29 + .../src/org/argeo/cms/desktop/Activator.java | 30 + .../argeo/cms/desktop/CmsDesktopManager.java | 132 +++ .../org/argeo/cms/desktop/DesktopLayer.java | 96 +++ rcp/org.argeo.cms.e4.rcp/.classpath | 7 + rcp/org.argeo.cms.e4.rcp/.gitignore | 3 + rcp/org.argeo.cms.e4.rcp/.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../.settings/org.eclipse.pde.core.prefs | 3 + rcp/org.argeo.cms.e4.rcp/META-INF/.gitignore | 1 + .../argeo-companion.e4xmi | 23 + .../argeo-companion.properties | 19 + rcp/org.argeo.cms.e4.rcp/bnd.bnd | 8 + rcp/org.argeo.cms.e4.rcp/build.properties | 5 + rcp/org.argeo.cms.e4.rcp/log4j.properties | 32 + rcp/org.argeo.cms.e4.rcp/plugin.xml | 15 + rcp/org.argeo.cms.e4.rcp/pom.xml | 29 + .../argeo/cms/e4/rcp/CmsE4Application.java | 194 +++++ .../org/argeo/cms/e4/rcp/CmsRcpLifeCycle.java | 27 + rcp/org.argeo.eclipse.ui.rcp/.classpath | 9 + rcp/org.argeo.eclipse.ui.rcp/.gitignore | 2 + rcp/org.argeo.eclipse.ui.rcp/.project | 28 + .../META-INF/.gitignore | 1 + rcp/org.argeo.eclipse.ui.rcp/bnd.bnd | 17 + rcp/org.argeo.eclipse.ui.rcp/build.properties | 3 + rcp/org.argeo.eclipse.ui.rcp/pom.xml | 28 + .../ui/rcp/internal/rwt/RcpClient.java | 44 + .../rcp/internal/rwt/RcpResourceManager.java | 46 ++ .../eclipse/ui/specific/CmsFileDialog.java | 15 + .../eclipse/ui/specific/CmsFileUpload.java | 32 + .../argeo/eclipse/ui/specific/DefaultNLS.java | 29 + .../ui/specific/EclipseUiSpecificUtils.java | 36 + .../eclipse/ui/specific/FileDropAdapter.java | 48 ++ .../argeo/eclipse/ui/specific/OpenFile.java | 74 ++ .../ui/specific/SingleSourcingException.java | 15 + .../argeo/eclipse/ui/specific/UiContext.java | 53 ++ .../org/argeo/swt/desktop/MiniBrowser.java | 115 +++ .../org/argeo/swt/desktop/MiniExplorer.java | 142 ++++ .../argeo/swt/desktop/MiniImageViewer.java | 129 +++ .../org/argeo/swt/desktop/MiniTerminal.java | 314 ++++++++ .../org/argeo/swt/desktop/MiniTextEditor.java | 161 ++++ .../eclipse/rap/fileupload/FileDetails.java | 9 + .../rap/fileupload/FileUploadEvent.java | 21 + .../rap/fileupload/FileUploadHandler.java | 38 + .../rap/fileupload/FileUploadListener.java | 51 ++ .../rap/fileupload/FileUploadReceiver.java | 32 + .../src/org/eclipse/rap/rwt/RWT.java | 44 + .../org/eclipse/rap/rwt/SingletonUtil.java | 7 + .../rwt/application/AbstractEntryPoint.java | 43 + .../rap/rwt/application/Application.java | 27 + .../application/ApplicationConfiguration.java | 5 + .../rap/rwt/application/EntryPoint.java | 5 + .../rwt/application/EntryPointFactory.java | 5 + .../rap/rwt/application/ExceptionHandler.java | 5 + .../org/eclipse/rap/rwt/client/Client.java | 18 + .../org/eclipse/rap/rwt/client/WebClient.java | 10 + .../rwt/client/service/BrowserNavigation.java | 7 + .../service/BrowserNavigationEvent.java | 10 + .../service/BrowserNavigationListener.java | 5 + .../rap/rwt/client/service/ClientService.java | 6 + .../client/service/JavaScriptExecutor.java | 5 + .../rap/rwt/client/service/UrlLauncher.java | 36 + .../rap/rwt/service/ResourceLoader.java | 9 + .../rap/rwt/service/ResourceManager.java | 15 + .../rap/rwt/service/ServerPushSession.java | 12 + .../org/eclipse/rap/rwt/widgets/DropDown.java | 33 + .../eclipse/rap/rwt/widgets/FileUpload.java | 37 + rcp/pom.xml | 161 ++++ 92 files changed, 3926 insertions(+), 2 deletions(-) create mode 100644 rcp/.gitignore create mode 100644 rcp/demo/.gitignore create mode 100644 rcp/demo/log4j.properties create mode 100644 rcp/dep/.gitignore create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/.gitignore create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/META-INF/.gitignore create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/bnd.bnd create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/p2.inf create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/pom.xml create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86.xml create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86_64.xml create mode 100644 rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/win32.x86.xml create mode 100644 rcp/dep/pom.xml create mode 100644 rcp/dist/argeo-companion/rpm/etc/argeo-companion/argeo-companion.ini create mode 100644 rcp/dist/argeo-companion/rpm/etc/argeo-companion/log4j.properties create mode 100755 rcp/dist/argeo-companion/rpm/usr/bin/argeo-companion create mode 100644 rcp/org.argeo.cms.desktop/.classpath create mode 100644 rcp/org.argeo.cms.desktop/.gitignore create mode 100644 rcp/org.argeo.cms.desktop/.project create mode 100644 rcp/org.argeo.cms.desktop/META-INF/.gitignore create mode 100644 rcp/org.argeo.cms.desktop/bnd.bnd create mode 100644 rcp/org.argeo.cms.desktop/build.properties create mode 100644 rcp/org.argeo.cms.desktop/pom.xml create mode 100644 rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/Activator.java create mode 100644 rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/CmsDesktopManager.java create mode 100644 rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/DesktopLayer.java create mode 100644 rcp/org.argeo.cms.e4.rcp/.classpath create mode 100644 rcp/org.argeo.cms.e4.rcp/.gitignore create mode 100644 rcp/org.argeo.cms.e4.rcp/.project create mode 100644 rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.jdt.core.prefs create mode 100644 rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.pde.core.prefs create mode 100644 rcp/org.argeo.cms.e4.rcp/META-INF/.gitignore create mode 100644 rcp/org.argeo.cms.e4.rcp/argeo-companion.e4xmi create mode 100644 rcp/org.argeo.cms.e4.rcp/argeo-companion.properties create mode 100644 rcp/org.argeo.cms.e4.rcp/bnd.bnd create mode 100644 rcp/org.argeo.cms.e4.rcp/build.properties create mode 100644 rcp/org.argeo.cms.e4.rcp/log4j.properties create mode 100644 rcp/org.argeo.cms.e4.rcp/plugin.xml create mode 100644 rcp/org.argeo.cms.e4.rcp/pom.xml create mode 100644 rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsE4Application.java create mode 100644 rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsRcpLifeCycle.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/.classpath create mode 100644 rcp/org.argeo.eclipse.ui.rcp/.gitignore create mode 100644 rcp/org.argeo.eclipse.ui.rcp/.project create mode 100644 rcp/org.argeo.eclipse.ui.rcp/META-INF/.gitignore create mode 100644 rcp/org.argeo.eclipse.ui.rcp/bnd.bnd create mode 100644 rcp/org.argeo.eclipse.ui.rcp/build.properties create mode 100644 rcp/org.argeo.eclipse.ui.rcp/pom.xml create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpClient.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpResourceManager.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileDialog.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileUpload.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileDropAdapter.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/SingleSourcingException.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UiContext.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniBrowser.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniExplorer.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniImageViewer.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTerminal.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTextEditor.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileDetails.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadEvent.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadHandler.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadListener.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadReceiver.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/RWT.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/SingletonUtil.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/AbstractEntryPoint.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/Application.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ApplicationConfiguration.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPoint.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPointFactory.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ExceptionHandler.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/Client.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/WebClient.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigation.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationEvent.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationListener.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/ClientService.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/JavaScriptExecutor.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/UrlLauncher.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceLoader.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceManager.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ServerPushSession.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/DropDown.java create mode 100644 rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/FileUpload.java create mode 100644 rcp/pom.xml diff --git a/dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF b/dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF index 5117c8973..06864bcba 100644 --- a/dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF +++ b/dep/org.argeo.slc.dep.spring/META-INF/MANIFEST.MF @@ -5,7 +5,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: SLC Agent based on Spring Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-SymbolicName: org.argeo.slc.dep.spring -Bundle-Version: 2.1.17.SNAPSHOT-r202001040954 +Bundle-Version: 2.1.17.SNAPSHOT-r202001041014 Private-Package: !* SLC-Category: org.argeo.slc SLC-ModularDistribution: default diff --git a/pom.xml b/pom.xml index ecc424b64..90fa2b4fa 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 2.1 2.1.13 - + 2.1.85-SNAPSHOT @@ -39,12 +39,16 @@ org.argeo.slc.e4 + + rcp + legacy org.argeo.slc.client.ui org.argeo.slc.client.ui.dist org.argeo.slc.client.rap + lib dep dist diff --git a/rcp/.gitignore b/rcp/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/rcp/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/rcp/demo/.gitignore b/rcp/demo/.gitignore new file mode 100644 index 000000000..45dfa56f4 --- /dev/null +++ b/rcp/demo/.gitignore @@ -0,0 +1 @@ +/exec/ diff --git a/rcp/demo/log4j.properties b/rcp/demo/log4j.properties new file mode 100644 index 000000000..13f949ff5 --- /dev/null +++ b/rcp/demo/log4j.properties @@ -0,0 +1,32 @@ +log4j.rootLogger=WARN, development + +## Levels +log4j.logger.org.argeo=DEBUG +log4j.logger.org.argeo.jackrabbit.remote.ExtendedDispatcherServlet=WARN +log4j.logger.org.argeo.server.webextender.TomcatDeployer=INFO + +#log4j.logger.org.springframework.security=DEBUG +#log4j.logger.org.apache.commons.exec=DEBUG +#log4j.logger.org.apache.jackrabbit.webdav=DEBUG +#log4j.logger.org.apache.jackrabbit.remote=DEBUG +#log4j.logger.org.apache.jackrabbit.core.observation=DEBUG + +log4j.logger.org.apache.catalina=INFO +log4j.logger.org.apache.coyote=INFO + +log4j.logger.org.apache.directory=INFO +log4j.logger.org.apache.directory.server=ERROR +log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR + +## Appenders +# console is set to be a ConsoleAppender. +log4j.appender.console=org.apache.log4j.ConsoleAppender + +# console uses PatternLayout. +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n + +# development appender (slow!) +log4j.appender.development=org.apache.log4j.ConsoleAppender +log4j.appender.development.layout=org.apache.log4j.PatternLayout +log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss} [%16.16t] %5p %m (%F:%L) %c%n diff --git a/rcp/dep/.gitignore b/rcp/dep/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/rcp/dep/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/.gitignore b/rcp/dep/org.argeo.dep.cms.e4.rcp/.gitignore new file mode 100644 index 000000000..5e85f8d1f --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/.gitignore @@ -0,0 +1,3 @@ +/org.argeo.security.dep.node.rcp-maven.target +/target/ +/*.target diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/META-INF/.gitignore b/rcp/dep/org.argeo.dep.cms.e4.rcp/META-INF/.gitignore new file mode 100644 index 000000000..4854a41b9 --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/META-INF/.gitignore @@ -0,0 +1 @@ +/MANIFEST.MF diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/bnd.bnd b/rcp/dep/org.argeo.dep.cms.e4.rcp/bnd.bnd new file mode 100644 index 000000000..e69de29bb diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/p2.inf b/rcp/dep/org.argeo.dep.cms.e4.rcp/p2.inf new file mode 100644 index 000000000..0423aa509 --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/p2.inf @@ -0,0 +1,2 @@ +properties.1.name=org.eclipse.equinox.p2.type.category +properties.1.value=true \ No newline at end of file diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/pom.xml b/rcp/dep/org.argeo.dep.cms.e4.rcp/pom.xml new file mode 100644 index 000000000..94de62bd8 --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/pom.xml @@ -0,0 +1,755 @@ + + 4.0.0 + + org.argeo.slc.rcp + dep + 2.1.17-SNAPSHOT + .. + + org.argeo.dep.cms.e4.rcp + Node Eclipse RCP + + + + org.argeo.slc.rcp + org.argeo.eclipse.ui.rcp + 2.1.17-SNAPSHOT + + + + + org.argeo.slc.rcp + org.argeo.cms.desktop + 2.1.17-SNAPSHOT + + + + + org.argeo.slc.rcp + org.argeo.cms.e4.rcp + 2.1.17-SNAPSHOT + + + + + org.argeo.commons + org.argeo.eclipse.ui + ${version.argeo-commons} + + + org.argeo.commons + org.argeo.cms.ui + ${version.argeo-commons} + + + org.argeo.commons + org.argeo.cms.ui.theme + ${version.argeo-commons} + + + org.argeo.commons + org.argeo.cms.e4 + ${version.argeo-commons} + + + org.argeo.commons + org.argeo.dep.cms.node + ${version.argeo-commons} + pom + + + + + org.argeo.tp.equinox + org.eclipse.osgi + test + + + + + org.argeo.tp.rcp.e4 + org.eclipse.swt.gtk.linux.arm + 3.108.0.v20180905-1254 + + + + + org.argeo.tp.rcp.e4 + org.eclipse.text + + + org.argeo.tp.rcp.e4 + org.eclipse.jface.text + + + + + org.argeo.tp.rcp.e4 + org.eclipse.swt + + + org.argeo.tp.rcp.e4 + org.eclipse.jface + + + org.argeo.tp.rcp.e4 + org.eclipse.swt.gtk.linux.x86_64 + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.swt.cocoa.macosx.x86_64 + + + org.argeo.tp.rcp.e4 + org.eclipse.swt.win32.win32.x86_64 + + + + + + + + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.equinox.launcher + + + org.argeo.tp.rcp.e4 + org.eclipse.equinox.launcher.gtk.linux.x86_64 + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.equinox.launcher.cocoa.macosx.x86_64 + + + org.argeo.tp.rcp.e4 + org.eclipse.equinox.launcher.win32.win32.x86_64 + + + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.css.swt.theme + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.workbench.swt + + + org.argeo.tp.rcp.e4 + org.eclipse.core.contenttype + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.di + + + org.argeo.tp.rcp.e4 + org.eclipse.core.runtime + + + org.argeo.tp.rcp.e4 + org.eclipse.core.databinding + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.bindings + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.model.workbench + + + org.argeo.tp.rcp.e4 + org.eclipse.jface.databinding + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.workbench.addons.swt + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.services + + + org.argeo.tp.rcp.e4 + org.apache.felix.gogo.shell + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.widgets + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.commands + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.di.extensions.supplier + + + org.argeo.tp.rcp.e4 + org.eclipse.core.expressions + + + org.argeo.tp.rcp.e4 + com.ibm.icu + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.css.swt + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.swt.gtk + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.core.databinding.observable + + + org.argeo.tp.rcp.e4 + org.eclipse.rcp + + + org.argeo.tp.rcp.e4 + org.eclipse.help + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.workbench.renderers.swt + + + org.argeo.tp.rcp.e4 + org.w3c.dom.smil + + + org.argeo.tp.rcp.e4 + org.eclipse.core.databinding.property + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.di + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.dialogs + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.di.extensions + + + org.argeo.tp.rcp.e4 + org.eclipse.equinox.bidi + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.di.annotations + + + + + + + + + + + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.workbench3 + + + org.argeo.tp.rcp.e4 + org.eclipse.core.jobs + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.core.contexts + + + org.argeo.tp.rcp.e4 + org.eclipse.core.databinding.beans + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.css.core + + + org.argeo.tp.rcp.e4 + org.eclipse.ui.workbench + + + org.argeo.tp.rcp.e4 + org.eclipse.core.commands + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.services + + + org.argeo.tp.rcp.e4 + org.eclipse.ui + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.workbench + + + + + org.argeo.tp.rcp.e4 + org.eclipse.e4.ui.workbench.renderers.swt.cocoa + + + org.argeo.tp.rcp.e4 + org.eclipse.ui.cocoa + + + + + org.argeo.tp.rcp.e4 + org.w3c.css.sac + + + org.argeo.tp.rcp.e4 + org.w3c.dom.svg + + + org.argeo.tp.rcp.e4 + org.w3c.dom.events + + + org.argeo.tp.rcp.e4 + org.apache.xmlgraphics + + + org.argeo.tp.rcp.e4 + org.apache.commons.jxpath + + + org.argeo.tp.rcp.e4 + org.apache.batik.util + + + org.argeo.tp.rcp.e4 + org.apache.batik.i18n + + + org.argeo.tp.rcp.e4 + org.apache.batik.css + + + org.argeo.tp.rcp.e4 + org.apache.batik.constants + + + org.argeo.tp.rcp.e4 + org.apache.felix.gogo.runtime + + + org.argeo.tp.rcp.e4 + org.apache.felix.scr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.argeo.tp.rap.e4 + org.eclipse.emf.common + + + org.argeo.tp.rap.e4 + org.eclipse.emf.ecore + + + org.argeo.tp.rap.e4 + org.eclipse.emf.ecore.change + + + org.argeo.tp.rap.e4 + org.eclipse.emf.ecore.xmi + + + org.argeo.tp.rap.e4 + org.eclipse.e4.emf.xpath + + + + + + + + org.argeo.tp + argeo-tp-rcp-e4 + ${version.argeo-tp} + pom + import + + + + + + rpmbuild + + + + maven-assembly-plugin + + + prepare-source + package + + single + + + + a2-source + + + + + + + org.codehaus.mojo + rpm-maven-plugin + + + rpm-argeo + package + + rpm + + + argeo-cms-e4-rcp + + + /usr/share/osgi + root + root + 644 + false + + + ${project.build.directory}/${project.artifactId}-${project.version}-a2-source + + **/*.jar + + + + + + + argeo-cms-node + argeo-cms-e4-rcp-tp + + + + + + + + + + rpmbuild-tp + + + + maven-assembly-plugin + + + prepare-source-tp + package + + single + + + + a2-source-tp + + + + + + + org.codehaus.mojo + rpm-maven-plugin + + + rpm-tp + package + + rpm + + + argeo-cms-e4-rcp-tp + ${version.argeo-tp} + + + /usr/share/osgi + root + root + 644 + false + + + ${project.build.directory}/${project.artifactId}-${project.version}-a2-source-tp + + **/*.jar + + + + + + /usr/share/osgi/boot + root + root + 644 + false + + true + + org.argeo.tp.rcp.e4:org.eclipse.equinox.launcher + + + + + + argeo-cms-node-tp + + + + + + + + + + diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86.xml b/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86.xml new file mode 100644 index 000000000..0b321cdca --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86.xml @@ -0,0 +1,59 @@ + + + + + linux.x86 + argeo-node-ui + + tar.gz + + + + false + ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} + + lib + + *:jar + + + org.eclipse.swt:org.eclipse.swt*:jar + + + + false + ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} + + lib + + org.eclipse.swt:org.eclipse.swt.gtk.linux.x86:jar + + + + \ No newline at end of file diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86_64.xml b/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86_64.xml new file mode 100644 index 000000000..12a0a3278 --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/linux.x86_64.xml @@ -0,0 +1,59 @@ + + + + + linux.x86_64 + argeo-node-ui + + tar.gz + + + + false + ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} + + lib + + *:jar + + + org.eclipse.swt:org.eclipse.swt*:jar + + + + false + ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} + + lib + + org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:jar + + + + \ No newline at end of file diff --git a/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/win32.x86.xml b/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/win32.x86.xml new file mode 100644 index 000000000..15cec0da6 --- /dev/null +++ b/rcp/dep/org.argeo.dep.cms.e4.rcp/src/assembly/win32.x86.xml @@ -0,0 +1,59 @@ + + + + + win32.x86 + argeo-node-ui + + zip + + + + false + ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} + + lib + + *:jar + + + org.eclipse.swt:org.eclipse.swt*:jar + + + + false + ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} + + lib + + org.eclipse.swt:org.eclipse.swt.win32.win32.x86:jar + + + + \ No newline at end of file diff --git a/rcp/dep/pom.xml b/rcp/dep/pom.xml new file mode 100644 index 000000000..1e0e8edaf --- /dev/null +++ b/rcp/dep/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + + org.argeo.slc.rcp + argeo-rcp + 2.1.17-SNAPSHOT + .. + + dep + RCP Base Dependencies + pom + + org.argeo.dep.cms.e4.rcp + + + + + org.apache.felix + maven-bundle-plugin + + + default + + + + + org.argeo.maven.plugins + argeo-osgi-plugin + + + generate-descriptors + + descriptors + + generate-resources + + + + + maven-assembly-plugin + + + org.argeo.commons + assembly-descriptors + ${version.argeo-commons} + + + + false + + + + + + + org.argeo.tp.equinox + org.eclipse.osgi + test + + + org.argeo.tp.sdk + org.junit + test + + + org.argeo.tp.sdk + org.hamcrest + test + + + + + check-osgi + + + org.argeo.commons + org.argeo.osgi.boot + ${version.argeo-commons} + test + + + + + + org.argeo.maven.plugins + argeo-osgi-plugin + + + check-osgi + test + + equinox + + + true + + + + + + + + + \ No newline at end of file diff --git a/rcp/dist/argeo-companion/rpm/etc/argeo-companion/argeo-companion.ini b/rcp/dist/argeo-companion/rpm/etc/argeo-companion/argeo-companion.ini new file mode 100644 index 000000000..444c39d6c --- /dev/null +++ b/rcp/dist/argeo-companion/rpm/etc/argeo-companion/argeo-companion.ini @@ -0,0 +1,25 @@ +osgi.bundles=org.argeo.osgi.boot@start +osgi.clean=true + +argeo.osgi.start.2.rcp=\ +org.eclipse.core.runtime + +argeo.osgi.start.2.node=\ +org.eclipse.equinox.metatype,\ +org.eclipse.equinox.ds,\ +org.eclipse.equinox.cm,\ + +argeo.osgi.start.3.node=\ +org.argeo.cms + +applicationXMI=org.argeo.cms.e4.rcp/argeo-companion.e4xmi +lifeCycleURI=bundleclass://org.argeo.cms.e4.rcp/org.argeo.cms.e4.rcp.CmsRcpLifeCycle +clearPersistedState=true +#argeo.cms.desktop.inTray=true + +# Remote node: +#argeo.node.repo.labeledUri=http://root:demo@localhost:7070/jcr/node + +log4j.configuration=file:../../log4j.properties +argeo.node.useradmin.uris=os:/// +eclipse.application=org.argeo.cms.e4.rcp.CmsE4Application diff --git a/rcp/dist/argeo-companion/rpm/etc/argeo-companion/log4j.properties b/rcp/dist/argeo-companion/rpm/etc/argeo-companion/log4j.properties new file mode 100644 index 000000000..13f949ff5 --- /dev/null +++ b/rcp/dist/argeo-companion/rpm/etc/argeo-companion/log4j.properties @@ -0,0 +1,32 @@ +log4j.rootLogger=WARN, development + +## Levels +log4j.logger.org.argeo=DEBUG +log4j.logger.org.argeo.jackrabbit.remote.ExtendedDispatcherServlet=WARN +log4j.logger.org.argeo.server.webextender.TomcatDeployer=INFO + +#log4j.logger.org.springframework.security=DEBUG +#log4j.logger.org.apache.commons.exec=DEBUG +#log4j.logger.org.apache.jackrabbit.webdav=DEBUG +#log4j.logger.org.apache.jackrabbit.remote=DEBUG +#log4j.logger.org.apache.jackrabbit.core.observation=DEBUG + +log4j.logger.org.apache.catalina=INFO +log4j.logger.org.apache.coyote=INFO + +log4j.logger.org.apache.directory=INFO +log4j.logger.org.apache.directory.server=ERROR +log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR + +## Appenders +# console is set to be a ConsoleAppender. +log4j.appender.console=org.apache.log4j.ConsoleAppender + +# console uses PatternLayout. +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n + +# development appender (slow!) +log4j.appender.development=org.apache.log4j.ConsoleAppender +log4j.appender.development.layout=org.apache.log4j.PatternLayout +log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss} [%16.16t] %5p %m (%F:%L) %c%n diff --git a/rcp/dist/argeo-companion/rpm/usr/bin/argeo-companion b/rcp/dist/argeo-companion/rpm/usr/bin/argeo-companion new file mode 100755 index 000000000..ab25dc79e --- /dev/null +++ b/rcp/dist/argeo-companion/rpm/usr/bin/argeo-companion @@ -0,0 +1,54 @@ +#!/bin/sh +APP=argeo-companion + +JVM=java + +# Directories and files +CONF_DIR=/etc/$APP +CONF_DIRS=/etc/$APP/conf.d +BASE_POLICY_ALL=/usr/share/$APP/all.policy +BASE_CONFIG_INI=/usr/share/$APP/config.ini + +EXEC_DIR=$HOME/.local/share/argeo-companion +DATA_DIR=$EXEC_DIR/data +CONF_RW=$EXEC_DIR/state +CONFIG_INI=$CONF_RW/config.ini + +OSGI_INSTALL_AREA=/usr/share/osgi/boot +OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar +ECLIPSE_LAUNCHER=$OSGI_INSTALL_AREA/org.eclipse.equinox.launcher.jar + +# Overwrite variables +if [ -f $CONF_DIR/settings.sh ];then + . $CONF_DIR/settings.sh +fi + +RETVAL=0 + +start() { + mkdir -p $CONF_RW + mkdir -p $DATA_DIR + + # Merge config files + printf "## Equinox configuration - Generated by /usr/sbin/nodectl ##\n\n" > $CONFIG_INI +# cat $BASE_CONFIG_INI >> $CONFIG_INI + printf "\n##\n## $CONF_DIR/$APP.ini\n##\n\n" >> $CONFIG_INI + cat $CONF_DIR/$APP.ini >> $CONFIG_INI + for file in `ls -v $CONF_DIRS/*.ini`; do + printf "\n##\n## $file\n##\n\n" >> $CONFIG_INI + cat $file >> $CONFIG_INI + done; + +# $JAVA_OPTS -jar $OSGI_FRAMEWORK \ + + cd $EXEC_DIR + $JVM \ + -Dlog4j.configuration="file:$CONF_DIR/log4j.properties" \ + -Dosgi.framework=$OSGI_FRAMEWORK \ + $JAVA_OPTS -classpath $ECLIPSE_LAUNCHER org.eclipse.equinox.launcher.Main \ + -configuration "$CONF_RW" \ + -data "$DATA_DIR" +} + +start + diff --git a/rcp/org.argeo.cms.desktop/.classpath b/rcp/org.argeo.cms.desktop/.classpath new file mode 100644 index 000000000..eca7bdba8 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rcp/org.argeo.cms.desktop/.gitignore b/rcp/org.argeo.cms.desktop/.gitignore new file mode 100644 index 000000000..09e3bc9b2 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/target/ diff --git a/rcp/org.argeo.cms.desktop/.project b/rcp/org.argeo.cms.desktop/.project new file mode 100644 index 000000000..c50145246 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/.project @@ -0,0 +1,28 @@ + + + org.argeo.cms.desktop + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/rcp/org.argeo.cms.desktop/META-INF/.gitignore b/rcp/org.argeo.cms.desktop/META-INF/.gitignore new file mode 100644 index 000000000..4854a41b9 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/META-INF/.gitignore @@ -0,0 +1 @@ +/MANIFEST.MF diff --git a/rcp/org.argeo.cms.desktop/bnd.bnd b/rcp/org.argeo.cms.desktop/bnd.bnd new file mode 100644 index 000000000..f3c13bec5 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/bnd.bnd @@ -0,0 +1,2 @@ +Import-Package: org.eclipse.swt,\ +* diff --git a/rcp/org.argeo.cms.desktop/build.properties b/rcp/org.argeo.cms.desktop/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/rcp/org.argeo.cms.desktop/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/rcp/org.argeo.cms.desktop/pom.xml b/rcp/org.argeo.cms.desktop/pom.xml new file mode 100644 index 000000000..e89837840 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + org.argeo.slc.rcp + argeo-rcp + 2.1.17-SNAPSHOT + .. + + org.argeo.cms.desktop + CMS Desktop + jar + + + + org.argeo.commons + org.argeo.cms.ui + ${version.argeo-commons} + + + + org.argeo.slc.rcp + org.argeo.eclipse.ui.rcp + 2.1.17-SNAPSHOT + + + \ No newline at end of file diff --git a/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/Activator.java b/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/Activator.java new file mode 100644 index 000000000..4975bee69 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/Activator.java @@ -0,0 +1,30 @@ +package org.argeo.cms.desktop; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/CmsDesktopManager.java b/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/CmsDesktopManager.java new file mode 100644 index 000000000..737fdef0c --- /dev/null +++ b/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/CmsDesktopManager.java @@ -0,0 +1,132 @@ +package org.argeo.cms.desktop; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; + +public class CmsDesktopManager { + private Display display; + + private Shell rootShell; + private Shell toolBarShell; + + public void init() { + display = Display.getCurrent(); + if (display != null) + throw new IllegalStateException("Already a display " + display); + display = new Display(); + + int toolBarSize = 48; + + if (isFullScreen()) { + rootShell = new Shell(display, SWT.NO_TRIM); + // rootShell.setMaximized(true); + rootShell.setFullScreen(true); + Rectangle bounds = display.getBounds(); + + rootShell.setSize(bounds.width, bounds.height); +// Point realSize = rootShell.getSize(); +// rootShell.setBounds(bounds); +// Rectangle realBounds = rootShell.getBounds(); + } else { + rootShell = new Shell(display, SWT.SHELL_TRIM); + Rectangle shellArea = rootShell.computeTrim(200, 200, 800, 480); + rootShell.setSize(shellArea.width, shellArea.height); + } + + rootShell.setLayout(new GridLayout(2, false)); + Composite toolBarArea = new Composite(rootShell, SWT.NONE); + toolBarArea.setLayoutData(new GridData(toolBarSize, rootShell.getSize().y)); + + ToolBar toolBar; + if (isFullScreen()) { + toolBarShell = new Shell(rootShell, SWT.NO_TRIM | SWT.ON_TOP); + toolBar = new ToolBar(toolBarShell, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); + createDock(toolBar); + toolBarShell.pack(); + toolBarArea.setLayoutData(new GridData(toolBar.getSize().x, toolBar.getSize().y)); + } else { + toolBar = new ToolBar(toolBarArea, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); + createDock(toolBar); + toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); + } + + Composite backgroundArea = new Composite(rootShell, SWT.NONE); + backgroundArea.setLayout(new GridLayout(6, true)); + DesktopLayer desktopLayer = new DesktopLayer(); + desktopLayer.init(backgroundArea); + rootShell.open(); + // rootShell.layout(true, true); + + if (toolBarShell != null) { + toolBarShell.setLocation(new Point(0, 0)); + toolBarShell.open(); + } + } + + protected void createDock(ToolBar toolBar) { + + // toolBar.setLocation(clientArea.x, clientArea.y); + + ToolItem closeI = new ToolItem(toolBar, SWT.PUSH); + closeI.setImage(display.getSystemImage(SWT.ICON_ERROR)); + closeI.setToolTipText("Close"); + closeI.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + rootShell.dispose(); + } + + }); + + ToolItem searchI = new ToolItem(toolBar, SWT.PUSH); + searchI.setImage(display.getSystemImage(SWT.ICON_QUESTION)); + searchI.setToolTipText("Search"); + searchI.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + // rootShell.dispose(); + } + + }); + // toolBar.setSize(48, toolBar.getSize().y); + toolBar.pack(); + } + + public void run() { + while (!rootShell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + + public void dispose() { + if (!rootShell.isDisposed()) + rootShell.dispose(); + } + + protected boolean isFullScreen() { + return true; + } + + public static void main(String[] args) { + CmsDesktopManager desktopManager = new CmsDesktopManager(); + desktopManager.init(); + // Runtime.getRuntime().addShutdownHook(new Thread(() -> + // desktopManager.dispose(), "Dispose desktop manager")); + desktopManager.run(); + desktopManager.dispose(); + } + +} diff --git a/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/DesktopLayer.java b/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/DesktopLayer.java new file mode 100644 index 000000000..0565e7320 --- /dev/null +++ b/rcp/org.argeo.cms.desktop/src/org/argeo/cms/desktop/DesktopLayer.java @@ -0,0 +1,96 @@ +package org.argeo.cms.desktop; + +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; + +public class DesktopLayer { + // TODO make it configurable + private Path desktopDir = Paths.get(System.getProperty("user.home"), "tmp"); + + public void init(Composite parentShell) { +// Decorations shell = new Decorations(parentShell, SWT.CLOSE); +// shell.setLayoutData(new GridData(GridData.FILL_BOTH)); + createUi(parentShell, desktopDir); + // shell.open(); + } + + public Control createUi(Composite parent, Path context) { + // parent.setLayout(new FillLayout()); + try { + DirectoryStream ds = Files.newDirectoryStream(context); + ds.forEach((path) -> createIcon(parent, path)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return parent; + + } + + protected void createIcon(Composite parent, Path path) { + String ext = FilenameUtils.getExtension(path.getFileName().toString()); + Program program = Program.findProgram(ext); + if (program == null) { + createDefaultIcon(parent, path); + return; + } + + Display display = parent.getDisplay(); + ImageData iconData = program.getImageData(); + + Image iconImage; + if (iconData == null) { + iconImage = display.getSystemImage(SWT.ICON_INFORMATION); + iconData = iconImage.getImageData(); + } else { + iconImage = new Image(display, iconData); + } + + Composite icon = new Composite(parent, SWT.NONE); + icon.setLayoutData(new GridData(48, 72)); + icon.setLayout(new GridLayout()); + // Button + Button iconB = new Button(icon, SWT.FLAT); + iconB.setImage(iconImage); + // iconB.setLayoutData(new GridData(iconData.width, iconData.height)); + iconB.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + iconB.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + program.execute(path.toString()); + } + + }); + // Label + Label iconL = new Label(icon, SWT.WRAP); + iconL.setText(path.getFileName().toString()); + iconL.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); + } + + protected void createDefaultIcon(Composite parent, Path path) { + Composite icon = new Composite(parent, SWT.NONE); + icon.setLayout(new GridLayout()); + Label iconL = new Label(icon, SWT.NONE); + iconL.setText(path.getFileName().toString()); + iconL.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); + } +} diff --git a/rcp/org.argeo.cms.e4.rcp/.classpath b/rcp/org.argeo.cms.e4.rcp/.classpath new file mode 100644 index 000000000..eca7bdba8 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/rcp/org.argeo.cms.e4.rcp/.gitignore b/rcp/org.argeo.cms.e4.rcp/.gitignore new file mode 100644 index 000000000..710cd6893 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/.gitignore @@ -0,0 +1,3 @@ +/bin/ +/target/ +/exec diff --git a/rcp/org.argeo.cms.e4.rcp/.project b/rcp/org.argeo.cms.e4.rcp/.project new file mode 100644 index 000000000..64d561913 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/.project @@ -0,0 +1,28 @@ + + + org.argeo.cms.e4.rcp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.jdt.core.prefs b/rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0c68a61dc --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.pde.core.prefs b/rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..f29e940a0 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/rcp/org.argeo.cms.e4.rcp/META-INF/.gitignore b/rcp/org.argeo.cms.e4.rcp/META-INF/.gitignore new file mode 100644 index 000000000..4854a41b9 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/META-INF/.gitignore @@ -0,0 +1 @@ +/MANIFEST.MF diff --git a/rcp/org.argeo.cms.e4.rcp/argeo-companion.e4xmi b/rcp/org.argeo.cms.e4.rcp/argeo-companion.e4xmi new file mode 100644 index 000000000..abce62aa0 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/argeo-companion.e4xmi @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rcp/org.argeo.cms.e4.rcp/argeo-companion.properties b/rcp/org.argeo.cms.e4.rcp/argeo-companion.properties new file mode 100644 index 000000000..9288d8555 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/argeo-companion.properties @@ -0,0 +1,19 @@ +argeo.osgi.start.2.node=\ +org.eclipse.equinox.metatype,\ +org.eclipse.equinox.ds,\ +org.eclipse.equinox.cm,\ + +argeo.osgi.start.3.node=\ +org.argeo.cms + +applicationXMI=org.argeo.cms.e4.rcp/argeo-companion.e4xmi +lifeCycleURI=bundleclass://org.argeo.cms.e4.rcp/org.argeo.cms.e4.rcp.CmsRcpLifeCycle +clearPersistedState=true +#argeo.cms.desktop.inTray=true + +# Remote node: +#argeo.node.repo.labeledUri=http://root:demo@localhost:7070/jcr/node + +log4j.configuration=file:../../log4j.properties +argeo.node.useradmin.uris=os:/// +eclipse.application=org.argeo.cms.e4.rcp.CmsE4Application diff --git a/rcp/org.argeo.cms.e4.rcp/bnd.bnd b/rcp/org.argeo.cms.e4.rcp/bnd.bnd new file mode 100644 index 000000000..7759c8457 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/bnd.bnd @@ -0,0 +1,8 @@ +Bundle-SymbolicName: org.argeo.cms.e4.rcp;singleton=true + +Require-Bundle: org.eclipse.core.runtime + +Import-Package: org.argeo.node,\ +!org.eclipse.core.runtime,\ +org.eclipse.swt,\ +* diff --git a/rcp/org.argeo.cms.e4.rcp/build.properties b/rcp/org.argeo.cms.e4.rcp/build.properties new file mode 100644 index 000000000..355413e4f --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/build.properties @@ -0,0 +1,5 @@ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + argeo-companion.e4xmi +source.. = src/ diff --git a/rcp/org.argeo.cms.e4.rcp/log4j.properties b/rcp/org.argeo.cms.e4.rcp/log4j.properties new file mode 100644 index 000000000..13f949ff5 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/log4j.properties @@ -0,0 +1,32 @@ +log4j.rootLogger=WARN, development + +## Levels +log4j.logger.org.argeo=DEBUG +log4j.logger.org.argeo.jackrabbit.remote.ExtendedDispatcherServlet=WARN +log4j.logger.org.argeo.server.webextender.TomcatDeployer=INFO + +#log4j.logger.org.springframework.security=DEBUG +#log4j.logger.org.apache.commons.exec=DEBUG +#log4j.logger.org.apache.jackrabbit.webdav=DEBUG +#log4j.logger.org.apache.jackrabbit.remote=DEBUG +#log4j.logger.org.apache.jackrabbit.core.observation=DEBUG + +log4j.logger.org.apache.catalina=INFO +log4j.logger.org.apache.coyote=INFO + +log4j.logger.org.apache.directory=INFO +log4j.logger.org.apache.directory.server=ERROR +log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR + +## Appenders +# console is set to be a ConsoleAppender. +log4j.appender.console=org.apache.log4j.ConsoleAppender + +# console uses PatternLayout. +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n + +# development appender (slow!) +log4j.appender.development=org.apache.log4j.ConsoleAppender +log4j.appender.development.layout=org.apache.log4j.PatternLayout +log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss} [%16.16t] %5p %m (%F:%L) %c%n diff --git a/rcp/org.argeo.cms.e4.rcp/plugin.xml b/rcp/org.argeo.cms.e4.rcp/plugin.xml new file mode 100644 index 000000000..3e6896beb --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/plugin.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/rcp/org.argeo.cms.e4.rcp/pom.xml b/rcp/org.argeo.cms.e4.rcp/pom.xml new file mode 100644 index 000000000..c69f748d0 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + org.argeo.slc.rcp + argeo-rcp + 2.1.17-SNAPSHOT + .. + + org.argeo.cms.e4.rcp + CMS E4 RCP + jar + + + + org.argeo.commons + org.argeo.cms.ui + ${version.argeo-commons} + + + + org.argeo.slc.rcp + org.argeo.eclipse.ui.rcp + 2.1.17-SNAPSHOT + + + \ No newline at end of file diff --git a/rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsE4Application.java b/rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsE4Application.java new file mode 100644 index 000000000..f8c82cb0f --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsE4Application.java @@ -0,0 +1,194 @@ +package org.argeo.cms.e4.rcp; + +import java.security.PrivilegedExceptionAction; + +import javax.security.auth.Subject; +import javax.security.auth.login.LoginContext; +import javax.security.auth.login.LoginException; + +import org.argeo.cms.CmsException; +import org.argeo.cms.auth.CurrentUser; +import org.argeo.cms.ui.CmsImageManager; +import org.argeo.cms.ui.CmsView; +import org.argeo.cms.ui.UxContext; +import org.argeo.cms.util.SimpleUxContext; +import org.argeo.cms.widgets.auth.CmsLoginShell; +import org.argeo.node.NodeConstants; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.Platform; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.swt.widgets.Display; + +public class CmsE4Application implements IApplication, CmsView { + private LoginContext loginContext; + private IApplication e4Application; + private UxContext uxContext; + + @Override + public Object start(IApplicationContext context) throws Exception { + Subject subject = new Subject(); + Display display = createDisplay(); + CmsLoginShell loginShell = new CmsLoginShell(this); + // TODO customize CmsLoginShell to be smaller and centered + loginShell.setSubject(subject); + try { + // try pre-auth + loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, subject, loginShell); + loginContext.login(); + } catch (LoginException e) { + e.printStackTrace(); + loginShell.createUi(); + loginShell.open(); + + while (!loginShell.getShell().isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + if (CurrentUser.getUsername(getSubject()) == null) + throw new CmsException("Cannot log in"); + + // try { + // CallbackHandler callbackHandler = new DefaultLoginDialog( + // display.getActiveShell()); + // loginContext = new LoginContext( + // NodeConstants.LOGIN_CONTEXT_SINGLE_USER, subject, + // callbackHandler); + // } catch (LoginException e1) { + // throw new CmsException("Cannot initialize login context", e1); + // } + // + // // login + // try { + // loginContext.login(); + // subject = loginContext.getSubject(); + // } catch (LoginException e) { + // e.printStackTrace(); + // display.dispose(); + // try { + // Thread.sleep(2000); + // } catch (InterruptedException e1) { + // // silent + // } + // return null; + // } + + uxContext = new SimpleUxContext(); + + e4Application = getApplication(null); + Object res = Subject.doAs(subject, new PrivilegedExceptionAction() { + + @Override + public Object run() throws Exception { + return e4Application.start(context); + } + + }); + return res; + } + + @Override + public void stop() { + if (e4Application != null) + e4Application.stop(); + } + + static IApplication getApplication(String[] args) { + IExtension extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, + Platform.PT_APPLICATIONS, "org.eclipse.e4.ui.workbench.swt.E4Application"); + try { + IConfigurationElement[] elements = extension.getConfigurationElements(); + if (elements.length > 0) { + IConfigurationElement[] runs = elements[0].getChildren("run"); + if (runs.length > 0) { + Object runnable; + runnable = runs[0].createExecutableExtension("class"); + if (runnable instanceof IApplication) + return (IApplication) runnable; + } + } + } catch (Exception e) { + throw new IllegalStateException("Cannot find e4 application", e); + } + throw new IllegalStateException("Cannot find e4 application"); + } + + public static Display createDisplay() { + Display.setAppName("Argeo CMS RCP"); + + // create the display + Display newDisplay = Display.getCurrent(); + if (newDisplay == null) { + newDisplay = new Display(); + } + // Set the priority higher than normal so as to be higher + // than the JobManager. + Thread.currentThread().setPriority(Math.min(Thread.MAX_PRIORITY, Thread.NORM_PRIORITY + 1)); + return newDisplay; + } + + // + // CMS VIEW + // + + @Override + public UxContext getUxContext() { + return uxContext; + } + + @Override + public void navigateTo(String state) { + // TODO Auto-generated method stub + + } + + @Override + public void authChange(LoginContext loginContext) { + if (loginContext == null) + throw new CmsException("Login context cannot be null"); + // logout previous login context + // if (this.loginContext != null) + // try { + // this.loginContext.logout(); + // } catch (LoginException e1) { + // System.err.println("Could not log out: " + e1); + // } + this.loginContext = loginContext; + } + + @Override + public void logout() { + if (loginContext == null) + throw new CmsException("Login context should not bet null"); + try { + CurrentUser.logoutCmsSession(loginContext.getSubject()); + loginContext.logout(); + } catch (LoginException e) { + throw new CmsException("Cannot log out", e); + } + } + + @Override + public void exception(Throwable e) { + // TODO Auto-generated method stub + + } + + @Override + public CmsImageManager getImageManager() { + // TODO Auto-generated method stub + return null; + } + + protected Subject getSubject() { + return loginContext.getSubject(); + } + + @Override + public boolean isAnonymous() { + return CurrentUser.isAnonymous(getSubject()); + } + +} diff --git a/rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsRcpLifeCycle.java b/rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsRcpLifeCycle.java new file mode 100644 index 000000000..1d38fe718 --- /dev/null +++ b/rcp/org.argeo.cms.e4.rcp/src/org/argeo/cms/e4/rcp/CmsRcpLifeCycle.java @@ -0,0 +1,27 @@ +package org.argeo.cms.e4.rcp; + +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate; +import org.eclipse.e4.ui.workbench.lifecycle.PreSave; +import org.eclipse.e4.ui.workbench.lifecycle.ProcessAdditions; +import org.eclipse.e4.ui.workbench.lifecycle.ProcessRemovals; + +@SuppressWarnings("restriction") +public class CmsRcpLifeCycle { + + @PostContextCreate + void postContextCreate(IEclipseContext workbenchContext) { + } + + @PreSave + void preSave(IEclipseContext workbenchContext) { + } + + @ProcessAdditions + void processAdditions(IEclipseContext workbenchContext) { + } + + @ProcessRemovals + void processRemovals(IEclipseContext workbenchContext) { + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/.classpath b/rcp/org.argeo.eclipse.ui.rcp/.classpath new file mode 100644 index 000000000..457b11571 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/.classpath @@ -0,0 +1,9 @@ + + + + + + + diff --git a/rcp/org.argeo.eclipse.ui.rcp/.gitignore b/rcp/org.argeo.eclipse.ui.rcp/.gitignore new file mode 100644 index 000000000..0f630157f --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/.gitignore @@ -0,0 +1,2 @@ +/target/ +/bin/ diff --git a/rcp/org.argeo.eclipse.ui.rcp/.project b/rcp/org.argeo.eclipse.ui.rcp/.project new file mode 100644 index 000000000..ef2dc2dbb --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/.project @@ -0,0 +1,28 @@ + + + org.argeo.eclipse.ui.rcp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/rcp/org.argeo.eclipse.ui.rcp/META-INF/.gitignore b/rcp/org.argeo.eclipse.ui.rcp/META-INF/.gitignore new file mode 100644 index 000000000..4854a41b9 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/META-INF/.gitignore @@ -0,0 +1 @@ +/MANIFEST.MF diff --git a/rcp/org.argeo.eclipse.ui.rcp/bnd.bnd b/rcp/org.argeo.eclipse.ui.rcp/bnd.bnd new file mode 100644 index 000000000..a51cdbbad --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/bnd.bnd @@ -0,0 +1,17 @@ +Import-Package: org.apache.commons.io,\ + org.eclipse.core.commands,\ + org.argeo.eclipse.ui.utils,\ + !org.eclipse.core.runtime,\ + !org.eclipse.ui.plugin,\ + org.eclipse.swt,\ + * + +Export-Package: org.argeo.*,\ +org.eclipse.rap.fileupload.*;version="3.4",\ +org.eclipse.rap.rwt.*;version="3.4" + +# Was !org.eclipse.core.commands,\ why ? + +#Bundle-Activator: org.argeo.eclipse.ui.ArgeoUiPlugin +#Bundle-ActivationPolicy: lazy +#Ignore-Package: org.eclipse.core.commands \ No newline at end of file diff --git a/rcp/org.argeo.eclipse.ui.rcp/build.properties b/rcp/org.argeo.eclipse.ui.rcp/build.properties new file mode 100644 index 000000000..c6b651a59 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/build.properties @@ -0,0 +1,3 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/ diff --git a/rcp/org.argeo.eclipse.ui.rcp/pom.xml b/rcp/org.argeo.eclipse.ui.rcp/pom.xml new file mode 100644 index 000000000..386f4dc87 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + org.argeo.slc.rcp + argeo-rcp + 2.1.17-SNAPSHOT + .. + + org.argeo.eclipse.ui.rcp + Eclipse UI RCP + Provide RCP specific classes and behaviour in order to enable single sourcing + jar + + + org.argeo.commons + org.argeo.eclipse.ui + ${version.argeo-commons} + + + org.argeo.commons + org.argeo.util + ${version.argeo-commons} + + + \ No newline at end of file diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpClient.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpClient.java new file mode 100644 index 000000000..0d9ce481d --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpClient.java @@ -0,0 +1,44 @@ +package org.argeo.eclipse.ui.rcp.internal.rwt; + +import org.eclipse.rap.rwt.client.Client; +import org.eclipse.rap.rwt.client.service.BrowserNavigation; +import org.eclipse.rap.rwt.client.service.BrowserNavigationListener; +import org.eclipse.rap.rwt.client.service.ClientService; +import org.eclipse.rap.rwt.client.service.JavaScriptExecutor; + +public class RcpClient implements Client { + + @Override + public T getService(Class type) { + if (type.isAssignableFrom(JavaScriptExecutor.class)) + return (T) javaScriptExecutor; + else if (type.isAssignableFrom(BrowserNavigation.class)) + return (T) browserNavigation; + else + return null; + } + + private JavaScriptExecutor javaScriptExecutor = new JavaScriptExecutor() { + + @Override + public void execute(String code) { + // TODO Auto-generated method stub + + } + }; + private BrowserNavigation browserNavigation = new BrowserNavigation() { + + @Override + public void pushState(String state, String title) { + // TODO Auto-generated method stub + + } + + @Override + public void addBrowserNavigationListener( + BrowserNavigationListener listener) { + // TODO Auto-generated method stub + + } + }; +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpResourceManager.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpResourceManager.java new file mode 100644 index 000000000..91109a9de --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/rcp/internal/rwt/RcpResourceManager.java @@ -0,0 +1,46 @@ +package org.argeo.eclipse.ui.rcp.internal.rwt; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; + +import org.apache.commons.io.IOUtils; +import org.eclipse.rap.rwt.service.ResourceManager; + +public class RcpResourceManager implements ResourceManager { + private Map register = Collections + .synchronizedMap(new TreeMap()); + + @Override + public void register(String name, InputStream in) { + try { + register.put(name, IOUtils.toByteArray(in)); + } catch (IOException e) { + throw new RuntimeException("Cannot register " + name, e); + } + } + + @Override + public boolean unregister(String name) { + return register.remove(name) != null; + } + + @Override + public InputStream getRegisteredContent(String name) { + return new ByteArrayInputStream(register.get(name)); + } + + @Override + public String getLocation(String name) { + return name; + } + + @Override + public boolean isRegistered(String name) { + return register.containsKey(name); + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileDialog.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileDialog.java new file mode 100644 index 000000000..0c5d34699 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileDialog.java @@ -0,0 +1,15 @@ +package org.argeo.eclipse.ui.specific; + +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; + +public class CmsFileDialog extends FileDialog { + public CmsFileDialog(Shell parent, int style) { + super(parent, style); + } + + public CmsFileDialog(Shell parent) { + super(parent); + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileUpload.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileUpload.java new file mode 100644 index 000000000..638859a85 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/CmsFileUpload.java @@ -0,0 +1,32 @@ +package org.argeo.eclipse.ui.specific; + +import org.eclipse.rap.rwt.widgets.FileUpload; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; + +public class CmsFileUpload extends FileUpload { + public CmsFileUpload(Composite parent, int style) { + super(parent, style); + } + + @Override + public void setText(String text) { + super.setText(text); + } + + @Override + public String getFileName() { + return super.getFileName(); + } + + @Override + public String[] getFileNames() { + return super.getFileNames(); + } + + @Override + public void addSelectionListener(SelectionListener listener) { + super.addSelectionListener(listener); + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java new file mode 100644 index 000000000..1d3cd29e8 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.eclipse.ui.specific; + +/** RCP specific {@link NLS} to be extended */ +public class DefaultNLS {// extends NLS { +// public final static String DEFAULT_BUNDLE_LOCATION = "/properties/plugin"; +// +// public DefaultNLS() { +// this(DEFAULT_BUNDLE_LOCATION); +// } +// +// public DefaultNLS(String bundleName) { +// NLS.initializeMessages(bundleName, getClass()); +// } +} \ No newline at end of file diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java new file mode 100644 index 000000000..7ed0a4f22 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.eclipse.ui.specific; + +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; +import org.eclipse.jface.viewers.Viewer; + +/** Static utilities to bridge differences between RCP and RAP */ +public class EclipseUiSpecificUtils { + /** + * TootlTip support is supported for {@link ColumnViewer} in RCP + * + * @see ColumnViewerToolTipSupport#enableFor(Viewer) + */ + public static void enableToolTipSupport(Viewer viewer) { + if (viewer instanceof ColumnViewer) + ColumnViewerToolTipSupport.enableFor((ColumnViewer) viewer); + } + + private EclipseUiSpecificUtils() { + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileDropAdapter.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileDropAdapter.java new file mode 100644 index 000000000..524447ed0 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileDropAdapter.java @@ -0,0 +1,48 @@ +package org.argeo.eclipse.ui.specific; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; + +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTarget; +import org.eclipse.swt.dnd.DropTargetAdapter; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.widgets.Control; + +public class FileDropAdapter { + + public void prepareDropTarget(Control control, DropTarget dropTarget) { + dropTarget.setTransfer(new Transfer[] { FileTransfer.getInstance() }); + dropTarget.addDropListener(new DropTargetAdapter() { + @Override + public void dropAccept(DropTargetEvent event) { + if (!FileTransfer.getInstance().isSupportedType(event.currentDataType)) { + event.detail = DND.DROP_NONE; + } + } + + @Override + public void drop(DropTargetEvent event) { + handleFileDrop(control, event); + } + }); + } + + public void handleFileDrop(Control control, DropTargetEvent event) { + String fileList[] = null; + FileTransfer ft = FileTransfer.getInstance(); + if (ft.isSupportedType(event.currentDataType)) { + fileList = (String[]) event.data; + } + System.out.println(Arrays.toString(fileList)); + } + + /** Executed in UI thread */ + protected void processUpload(InputStream in, String fileName, String contentType) throws IOException { + + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java new file mode 100644 index 000000000..704079f11 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.eclipse.ui.specific; + +import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.FILE_SCHEME; +import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.SCHEME_HOST_SEPARATOR; + +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; + +import org.argeo.eclipse.ui.utils.SingleSourcingConstants; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +/** + * RCP specific command handler to open a file. + * + * The parameter "URI" is used to determine the correct method to open it. + * + * Various instances of this handler with different command ID might coexist in + * order to provide context specific open file services. + * + */ +public class OpenFile extends AbstractHandler { + // private final static Log log = LogFactory.getLog(OpenFile.class); + public final static String ID = SingleSourcingConstants.OPEN_FILE_CMD_ID; + public final static String PARAM_FILE_NAME = SingleSourcingConstants.PARAM_FILE_NAME; + public final static String PARAM_FILE_URI = SingleSourcingConstants.PARAM_FILE_URI; + + public Object execute(ExecutionEvent event) throws ExecutionException { + String fileUri = event.getParameter(PARAM_FILE_URI); + + // sanity check + if (fileUri == null || "".equals(fileUri.trim())) + return null; + + Desktop desktop = null; + if (Desktop.isDesktopSupported()) { + desktop = Desktop.getDesktop(); + } + + File file = getFileFromUri(fileUri); + if (file != null) + try { + desktop.open(file); + } catch (IOException e) { + throw new SingleSourcingException("Unable to open file with URI: " + fileUri, e); + } + return null; + } + + protected File getFileFromUri(String uri) { + if (uri.startsWith(FILE_SCHEME)) { + String path = uri.substring((FILE_SCHEME + SCHEME_HOST_SEPARATOR).length()); + return new File(path); + } + return null; + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/SingleSourcingException.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/SingleSourcingException.java new file mode 100644 index 000000000..9b7569066 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/SingleSourcingException.java @@ -0,0 +1,15 @@ +package org.argeo.eclipse.ui.specific; + +/** Exception related to SWT/RWT single sourcing. */ +public class SingleSourcingException extends RuntimeException { + private static final long serialVersionUID = -727700418055348468L; + + public SingleSourcingException(String message, Throwable cause) { + super(message, cause); + } + + public SingleSourcingException(String message) { + super(message); + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UiContext.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UiContext.java new file mode 100644 index 000000000..bb7cea2e6 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UiContext.java @@ -0,0 +1,53 @@ +package org.argeo.eclipse.ui.specific; + +import java.util.Locale; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.swt.widgets.Display; + +/** Singleton class providing single sources infos about the UI context. */ +public class UiContext { + + public static HttpServletRequest getHttpRequest() { + return null; + } + + public static HttpServletResponse getHttpResponse() { + return null; + } + + public static Locale getLocale() { + return Locale.getDefault(); + } + + public static void setLocale(Locale locale) { + Locale.setDefault(locale); + } + + /** Can always be null */ + @SuppressWarnings("unchecked") + public static T getData(String key) { + Display display = getDisplay(); + if (display == null) + return null; + return (T) display.getData(key); + } + + public static void setData(String key, Object value) { + Display display = getDisplay(); + if (display == null) + throw new SingleSourcingException( + "Not display available in RAP context"); + display.setData(key, value); + } + + private static Display getDisplay() { + return Display.getCurrent(); + } + + private UiContext() { + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniBrowser.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniBrowser.java new file mode 100644 index 000000000..3152db1a9 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniBrowser.java @@ -0,0 +1,115 @@ +package org.argeo.swt.desktop; + +import java.util.Observable; +import java.util.function.BiFunction; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.browser.LocationAdapter; +import org.eclipse.swt.browser.LocationEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** A minimalistic web browser based on {@link Browser}. */ +public class MiniBrowser implements BiFunction { + @Override + public Control apply(Composite parent, MiniBrowser.Context context) { + parent.setLayout(new GridLayout()); + Control toolBar = createToolBar(parent, context); + toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + Control body = createBody(parent, context); + body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return body; + } + + public Control createToolBar(Composite parent, MiniBrowser.Context context) { + Composite toolBar = new Composite(parent, SWT.NONE); + toolBar.setLayout(new FillLayout()); + Text addressT = new Text(toolBar, SWT.SINGLE | SWT.BORDER); + addressT.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + String url = addressT.getText().trim(); + context.setUrl(url); + } + }); + context.addObserver((o, v) -> addressT.setText(((Context) o).getUrl().toString())); + return toolBar; + } + + public Control createBody(Composite parent, MiniBrowser.Context context) { + Browser browser = new Browser(parent, SWT.WEBKIT); + browser.addLocationListener(new LocationAdapter() { + @Override + public void changing(LocationEvent event) { + if (!context.getUrl().equals(event.location)) + context.setUrl(event.location); + } + }); + browser.addTitleListener(e -> context.setTitle(e.title)); + context.addObserver((o, v) -> { + String url = ((Context) o).getUrl(); + if (!url.equals(browser.getUrl())) + browser.setUrl(url.toString()); + }); + return browser; + } + + /** The observable context of this web browser. */ + public static class Context extends Observable { + private String url; + private String title = ""; + + public void setUrl(String url) { + this.url = url; + System.out.println(url); + setChanged(); + notifyObservers(url); + } + + public String getUrl() { + return url; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + setChanged(); + notifyObservers(title); + } + + } + + public static void main(String[] args) { + Display display = Display.getCurrent() == null ? new Display() : Display.getCurrent(); + Shell shell = new Shell(display, SWT.SHELL_TRIM); + + MiniBrowser miniBrowser = new MiniBrowser(); + MiniBrowser.Context context = new MiniBrowser.Context(); + miniBrowser.apply(shell, context); + context.addObserver((o, v) -> shell.setText(((Context) o).getTitle())); + String url = args.length > 0 ? args[0] : "http://www.argeo.org"; + context.setUrl(url); + + shell.open(); + shell.setSize(new Point(800, 480)); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniExplorer.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniExplorer.java new file mode 100644 index 000000000..b88dbff31 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniExplorer.java @@ -0,0 +1,142 @@ +package org.argeo.swt.desktop; + +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; + +public class MiniExplorer { + private Path url; + private Text addressT; + private Table browser; + + private boolean showHidden = false; + + public MiniExplorer(Composite parent, int style) { + parent.setLayout(new GridLayout()); + + Composite toolBar = new Composite(parent, SWT.NONE); + toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + toolBar.setLayout(new FillLayout()); + addressT = new Text(toolBar, SWT.SINGLE | SWT.BORDER); + // addressT.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + addressT.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + setUrl(addressT.getText().trim()); + } + }); + browser = createTable(parent, this.url); + + } + + public void setUrl(Path url) { + this.url = url; + if (addressT != null) + addressT.setText(url.toString()); + if (browser != null) { + Composite parent = browser.getParent(); + browser.dispose(); + browser = createTable(parent, this.url); + parent.layout(true, true); + } + } + + protected Table createTable(Composite parent, Path path) { + Table table = new Table(parent, SWT.BORDER); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + table.addMouseListener(new MouseAdapter() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + Point pt = new Point(e.x, e.y); + TableItem item = table.getItem(pt); + Path path = (Path) item.getData(); + if (Files.isDirectory(path)) { + setUrl(path); + } else { + Program.launch(path.toString()); + } + } + }); + + if (path != null) { + if (path.getParent() != null) { + TableItem parentTI = new TableItem(table, SWT.NONE); + parentTI.setText(".."); + parentTI.setData(path.getParent()); + } + + try { + // directories + DirectoryStream ds = Files.newDirectoryStream(url, p -> Files.isDirectory(p) && isShown(p)); + ds.forEach(p -> { + TableItem ti = new TableItem(table, SWT.NONE); + ti.setText(p.getFileName().toString() + "/"); + ti.setData(p); + }); + // files + ds = Files.newDirectoryStream(url, p -> !Files.isDirectory(p) && isShown(p)); + ds.forEach(p -> { + TableItem ti = new TableItem(table, SWT.NONE); + ti.setText(p.getFileName().toString()); + ti.setData(p); + }); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + return table; + } + + protected boolean isShown(Path path) { + if (showHidden) + return true; + try { + return !Files.isHidden(path); + } catch (IOException e) { + throw new IllegalArgumentException("Cannot check " + path, e); + } + } + + public void setUrl(String url) { + setUrl(Paths.get(url)); + } + + public static void main(String[] args) { + Display display = Display.getCurrent() == null ? new Display() : Display.getCurrent(); + Shell shell = new Shell(display, SWT.SHELL_TRIM); + + MiniExplorer miniBrowser = new MiniExplorer(shell, SWT.NONE); + String url = args.length > 0 ? args[0] : System.getProperty("user.home"); + miniBrowser.setUrl(url); + + shell.open(); + shell.setSize(new Point(800, 480)); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniImageViewer.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniImageViewer.java new file mode 100644 index 000000000..d8dd663e7 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniImageViewer.java @@ -0,0 +1,129 @@ +package org.argeo.swt.desktop; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.ImageLoader; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; + +public class MiniImageViewer implements PaintListener { + private URL url; + private Canvas area; + + private Image image; + + public MiniImageViewer(Composite parent, int style) { + parent.setLayout(new GridLayout()); + + Composite toolBar = new Composite(parent, SWT.NONE); + toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + toolBar.setLayout(new RowLayout()); + Button load = new Button(toolBar, SWT.FLAT); + load.setText("\u2191");// up arrow + load.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog fileDialog = new FileDialog(area.getShell()); + String path = fileDialog.open(); + if (path != null) { + setUrl(path); + } + } + + }); + + area = new Canvas(parent, SWT.NONE); + area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + area.addPaintListener(this); + } + + protected void load(URL url) { + try { + ImageLoader imageLoader = new ImageLoader(); + ImageData[] data = imageLoader.load(url.openStream()); + image = new Image(area.getDisplay(), data[0]); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void paintControl(PaintEvent e) { + e.gc.drawImage(image, 0, 0); + + } + + protected Path url2path(URL url) { + try { + Path path = Paths.get(url.toURI()); + return path; + } catch (URISyntaxException e) { + throw new IllegalStateException("Cannot convert " + url + " to uri", e); + } + } + + public void setUrl(URL url) { + this.url = url; + if (area != null) + load(this.url); + } + + public void setUrl(String url) { + try { + setUrl(new URL(url)); + } catch (MalformedURLException e) { + // try with http + try { + setUrl(new URL("file://" + url)); + return; + } catch (MalformedURLException e1) { + // nevermind... + } + throw new IllegalArgumentException("Cannot interpret URL " + url, e); + } + } + + public static void main(String[] args) { + Display display = Display.getCurrent() == null ? new Display() : Display.getCurrent(); + Shell shell = new Shell(display, SWT.SHELL_TRIM); + + MiniImageViewer miniBrowser = new MiniImageViewer(shell, SWT.NONE); + String url = args.length > 0 ? args[0] : ""; + if (!url.trim().equals("")) { + miniBrowser.setUrl(url); + shell.setText(url); + } else { + shell.setText("*"); + } + + shell.open(); + shell.setSize(new Point(800, 480)); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTerminal.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTerminal.java new file mode 100644 index 000000000..1280d1d44 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTerminal.java @@ -0,0 +1,314 @@ +package org.argeo.swt.desktop; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.StringTokenizer; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Caret; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class MiniTerminal implements KeyListener, PaintListener { + + private Canvas area; + private Caret caret; + + private StringBuffer buf = new StringBuffer(""); + private StringBuffer userInput = new StringBuffer(""); + private List history = new ArrayList<>(); + + private Point charExtent = null; + private int charsPerLine = 0; + private String[] lines = new String[0]; + private List logicalLines = new ArrayList<>(); + + private Font mono; + private Charset charset; + + private Path currentDir; + private Path homeDir; + private String host = "localhost"; + private String username; + + private boolean running = false; + private OutputStream stdIn = null; + + public MiniTerminal(Composite parent, int style) { + charset = StandardCharsets.UTF_8; + + Display display = parent.getDisplay(); + // Linux-specific + mono = new Font(display, "Monospace", 10, SWT.NONE); + + parent.setLayout(new GridLayout()); + area = new Canvas(parent, SWT.NONE); + area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + caret = new Caret(area, SWT.NONE); + area.setCaret(caret); + + area.addKeyListener(this); + area.addPaintListener(this); + + username = System.getProperty("user.name"); + try { + host = InetAddress.getLocalHost().getHostName(); + if (host.indexOf('.') > 0) + host = host.substring(0, host.indexOf('.')); + } catch (UnknownHostException e) { + host = "localhost"; + } + homeDir = Paths.get(System.getProperty("user.home")); + currentDir = homeDir; + + buf = new StringBuffer(prompt()); + } + + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (e.keyLocation != 0) + return;// weird characters + // System.out.println(e.character); + if (e.keyCode == 0xd) {// return + markLogicalLine(); + if (!running) + processUserInput(); + // buf.append(prompt()); + } else if (e.keyCode == 0x8) {// delete + if (userInput.length() == 0) + return; + userInput.setLength(userInput.length() - 1); + if (!running && buf.length() > 0) + buf.setLength(buf.length() - 1); + } else { + // if (!running) + buf.append(e.character); + userInput.append(e.character); + } + + if (area.isDisposed()) + return; + area.redraw(); + // System.out.println("Append " + e); + + if (running) { + if (stdIn != null) { + try { + stdIn.write(Character.toString(e.character).getBytes(charset)); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + } + + protected String prompt() { + String fileName = currentDir.equals(homeDir) ? "~" : currentDir.getFileName().toString(); + String end = username.equals("root") ? "]# " : "]$ "; + return "[" + username + "@" + host + " " + fileName + end; + } + + private void displayPrompt() { + buf.append(prompt() + userInput); + } + + protected void markLogicalLine() { + String str = buf.toString().trim(); + logicalLines.add(str); + buf = new StringBuffer(""); + } + + private void processUserInput() { + String cmd = userInput.toString(); + userInput = new StringBuffer(""); + processUserInput(cmd); + history.add(cmd); + } + + protected void processUserInput(String input) { + try { + StringTokenizer st = new StringTokenizer(input); + List args = new ArrayList<>(); + while (st.hasMoreTokens()) + args.add(st.nextToken()); + if (args.size() == 0) { + displayPrompt(); + return; + } + + // change directory + if (args.get(0).equals("cd")) { + if (args.size() == 1) { + setPath(homeDir); + } else { + Path newPath = currentDir.resolve(args.get(1)); + if (!Files.exists(newPath) || !Files.isDirectory(newPath)) { + println(newPath + ": No such file or directory"); + return; + } + setPath(newPath); + } + displayPrompt(); + return; + } + // show current directory + else if (args.get(0).equals("pwd")) { + println(currentDir); + displayPrompt(); + return; + } + // exit + else if (args.get(0).equals("exit")) { + println("logout"); + area.getShell().dispose(); + return; + } + + ProcessBuilder pb = new ProcessBuilder(args); + pb.redirectErrorStream(true); + pb.directory(currentDir.toFile()); +// Process process = Runtime.getRuntime().exec(input, null, currentPath.toFile()); + Process process = pb.start(); + + stdIn = process.getOutputStream(); + Thread readOut = new Thread("Read out") { + @Override + public void run() { + running = true; + try (BufferedReader in = new BufferedReader( + new InputStreamReader(process.getInputStream(), charset))) { + String line = null; + while ((line = in.readLine()) != null) { + println(line); + } + } catch (IOException e) { + println(e.getMessage()); + } + stdIn = null; + displayPrompt(); + running = false; + } + }; + readOut.start(); + } catch (IOException e) { + println(e.getMessage()); + displayPrompt(); + } + } + + protected int linesForLogicalLine(char[] line) { + return line.length / charsPerLine + 1; + } + + protected void println(Object line) { + buf.append(line); + markLogicalLine(); + } + + protected void refreshLines(int charPerLine, int nbrOfLines) { + if (lines.length != nbrOfLines) { + lines = new String[nbrOfLines]; + Arrays.fill(lines, null); + } + if (this.charsPerLine != charPerLine) + this.charsPerLine = charPerLine; + + int currentLine = nbrOfLines - 1; + // current line + if (buf.length() > 0) { + lines[currentLine] = buf.toString(); + } else { + lines[currentLine] = ""; + } + currentLine--; + + logicalLines: for (int i = logicalLines.size() - 1; i >= 0; i--) { + char[] logicalLine = logicalLines.get(i).toCharArray(); + int linesNeeded = linesForLogicalLine(logicalLine); + for (int j = linesNeeded - 1; j >= 0; j--) { + int from = j * charPerLine; + int to = j == linesNeeded - 1 ? from + charPerLine : Math.min(from + charPerLine, logicalLine.length); + lines[currentLine] = new String(Arrays.copyOfRange(logicalLine, from, to)); +// System.out.println("Set line " + currentLine + " to : " + lines[currentLine]); + currentLine--; + if (currentLine < 0) + break logicalLines; + } + } + } + + @Override + public void paintControl(PaintEvent e) { + GC gc = e.gc; + gc.setFont(mono); + if (charExtent == null) + charExtent = gc.textExtent("a"); + + Point areaSize = area.getSize(); + int charPerLine = areaSize.x / charExtent.x; + int nbrOfLines = areaSize.y / charExtent.y; + refreshLines(charPerLine, nbrOfLines); + + for (int i = 0; i < lines.length; i++) { + String line = lines[i]; + if (line != null) + gc.drawString(line, 0, i * charExtent.y); + } +// String toDraw = buf.toString(); +// gc.drawString(toDraw, 0, 0); +// area.setCaret(caret); + } + + public void setPath(String path) { + this.currentDir = Paths.get(path); + } + + public void setPath(Path path) { + this.currentDir = path; + } + + public static void main(String[] args) { + Display display = Display.getCurrent() == null ? new Display() : Display.getCurrent(); + Shell shell = new Shell(display, SWT.SHELL_TRIM); + + MiniTerminal miniBrowser = new MiniTerminal(shell, SWT.NONE); + String url = args.length > 0 ? args[0] : System.getProperty("user.home"); + miniBrowser.setPath(url); + + shell.open(); + shell.setSize(new Point(800, 480)); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTextEditor.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTextEditor.java new file mode 100644 index 000000000..b5582f96c --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/argeo/swt/desktop/MiniTextEditor.java @@ -0,0 +1,161 @@ +package org.argeo.swt.desktop; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class MiniTextEditor { + private URL url; + private Text text; + + public MiniTextEditor(Composite parent, int style) { + parent.setLayout(new GridLayout()); + + Composite toolBar = new Composite(parent, SWT.NONE); + toolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + toolBar.setLayout(new RowLayout()); + Button load = new Button(toolBar, SWT.FLAT); + load.setText("\u2191");// up arrow + load.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog fileDialog = new FileDialog(text.getShell()); + String path = fileDialog.open(); + if (path != null) { + setUrl(path); + } + } + + }); + + Button save = new Button(toolBar, SWT.FLAT); + save.setText("\u2193");// down arrow + // save.setText("\u1F609");// emoji + save.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + save(url); + } + + }); + + text = new Text(parent, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); + text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } + + protected void load(URL url) { + text.setText(""); + // TODO deal with encoding and binary data + try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { + String line = null; + while ((line = in.readLine()) != null) { + text.append(line + "\n"); + } + text.setEditable(true); + } catch (IOException e) { + if (e instanceof FileNotFoundException) { + Path path = url2path(url); + try { + Files.createFile(path); + load(url); + return; + } catch (IOException e1) { + e = e1; + } + } + text.setText(e.getMessage()); + text.setEditable(false); + e.printStackTrace(); + // throw new IllegalStateException("Cannot load " + url, e); + } + } + + protected Path url2path(URL url) { + try { + Path path = Paths.get(url.toURI()); + return path; + } catch (URISyntaxException e) { + throw new IllegalStateException("Cannot convert " + url + " to uri", e); + } + } + + protected void save(URL url) { + if (!url.getProtocol().equals("file")) + throw new IllegalArgumentException(url.getProtocol() + " protocol is not supported for write"); + Path path = url2path(url); + try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(path)))) { + out.write(text.getText()); + } catch (IOException e) { + throw new IllegalStateException("Cannot save " + url + " to " + path, e); + } + } + + public void setUrl(URL url) { + this.url = url; + if (text != null) + load(url); + } + + public void setUrl(String url) { + try { + setUrl(new URL(url)); + } catch (MalformedURLException e) { + // try with http + try { + setUrl(new URL("file://" + url)); + return; + } catch (MalformedURLException e1) { + // nevermind... + } + throw new IllegalArgumentException("Cannot interpret URL " + url, e); + } + } + + public static void main(String[] args) { + Display display = Display.getCurrent() == null ? new Display() : Display.getCurrent(); + Shell shell = new Shell(display, SWT.SHELL_TRIM); + + MiniTextEditor miniBrowser = new MiniTextEditor(shell, SWT.NONE); + String url = args.length > 0 ? args[0] : ""; + if (!url.trim().equals("")) { + miniBrowser.setUrl(url); + shell.setText(url); + } else { + shell.setText("*"); + } + + shell.open(); + shell.setSize(new Point(800, 480)); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileDetails.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileDetails.java new file mode 100644 index 000000000..fbb36ddd4 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileDetails.java @@ -0,0 +1,9 @@ +package org.eclipse.rap.fileupload; + +public interface FileDetails { + String getContentType(); + + long getContentLength(); + + String getFileName(); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadEvent.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadEvent.java new file mode 100644 index 000000000..a7452806a --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadEvent.java @@ -0,0 +1,21 @@ +package org.eclipse.rap.fileupload; + +import java.util.EventObject; + +public abstract class FileUploadEvent extends EventObject { + + private static final long serialVersionUID = 1L; + + protected FileUploadEvent(FileUploadHandler source) { + super(source); + } + + public abstract FileDetails[] getFileDetails(); + + public abstract long getContentLength(); + + public abstract long getBytesRead(); + + public abstract Exception getException(); + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadHandler.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadHandler.java new file mode 100644 index 000000000..7d89300f3 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadHandler.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 EclipseSource and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * EclipseSource - initial API and implementation + ******************************************************************************/ +package org.eclipse.rap.fileupload; + +/** + * A file upload handler is used to accept file uploads from a client. After + * creating a file upload handler, the server will accept file uploads to the + * URL returned by getUploadUrl(). Upload listeners can be attached + * to react on progress. When the upload has finished, a FileUploadHandler has + * to be disposed of by calling its dispose() method. + * + * @noextend This class is not intended to be subclassed by clients. + */ +public class FileUploadHandler { + + public FileUploadHandler(FileUploadReceiver fileUploadReceiver) { + } + + public void dispose() { + + } + + public void addUploadListener(FileUploadListener listener) { + + } + + public String getUploadUrl() { + return null; + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadListener.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadListener.java new file mode 100644 index 000000000..b59fd39ea --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadListener.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2011, 2012 EclipseSource and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * EclipseSource - initial API and implementation + ******************************************************************************/ +package org.eclipse.rap.fileupload; + +import org.eclipse.swt.widgets.Display; + + +/** + * Listener to react on progress and completion of a file upload. + *

+ * Note: This listener will be called from a different thread than the UI thread. + * Implementations must use {@link Display#asyncExec(Runnable)} to access the UI. + *

+ * + * @see FileUploadEvent + */ +public interface FileUploadListener { + + /** + * Called when new information about an in-progress upload is available. + * + * @param event event object that contains information about the uploaded file + * @see FileUploadEvent#getBytesRead() + */ + void uploadProgress( FileUploadEvent event ); + + /** + * Called when a file upload has finished successfully. + * + * @param event event object that contains information about the uploaded file + * @see FileUploadEvent + */ + void uploadFinished( FileUploadEvent event ); + + /** + * Called when a file upload failed. + * + * @param event event object that contains information about the uploaded file + * @see FileUploadEvent#getErrorMessage() + */ + void uploadFailed( FileUploadEvent event ); + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadReceiver.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadReceiver.java new file mode 100644 index 000000000..3f4cf47c4 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/fileupload/FileUploadReceiver.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2011, 2013 EclipseSource and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * EclipseSource - initial API and implementation + ******************************************************************************/ +package org.eclipse.rap.fileupload; + +import java.io.IOException; +import java.io.InputStream; + + +/** + * Instances of this interface are responsible for reading and processing the data from a file + * upload. + */ +public abstract class FileUploadReceiver { + + /** + * Reads and processes all data from the provided input stream. + * + * @param stream the stream to read from + * @param details the details of the uploaded file like file name, content-type and size + * @throws IOException if an input / output error occurs + */ + public abstract void receive( InputStream stream, FileDetails details ) throws IOException; + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/RWT.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/RWT.java new file mode 100644 index 000000000..b53c76c54 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/RWT.java @@ -0,0 +1,44 @@ +package org.eclipse.rap.rwt; + +import java.util.Locale; + +import javax.servlet.http.HttpServletRequest; + +import org.argeo.eclipse.ui.rcp.internal.rwt.RcpClient; +import org.argeo.eclipse.ui.rcp.internal.rwt.RcpResourceManager; +import org.eclipse.rap.rwt.client.Client; +import org.eclipse.rap.rwt.service.ResourceManager; + +public class RWT { + public final static String CUSTOM_VARIANT = "argeo-rcp:CUSTOM_VARIANT"; + public final static String MARKUP_ENABLED = "argeo-rcp:MARKUP_ENABLED"; + public final static String CUSTOM_ITEM_HEIGHT = "argeo-rcp:CUSTOM_ITEM_HEIGHT"; + public final static String ACTIVE_KEYS = "argeo-rcp:ACTIVE_KEYS"; + public final static String CANCEL_KEYS = "argeo-rcp:CANCEL_KEYS"; + public final static String DEFAULT_THEME_ID = "argeo-rcp:DEFAULT_THEME_ID"; + + public final static int HYPERLINK = 0; + + private static Locale locale = Locale.getDefault(); + private static RcpClient client = new RcpClient(); + private static ResourceManager resourceManager = new RcpResourceManager(); + static { + + } + + public static Locale getLocale() { + return locale; + } + + public static HttpServletRequest getRequest() { + return null; + } + + public static ResourceManager getResourceManager() { + return resourceManager; + } + + public static Client getClient() { + return client; + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/SingletonUtil.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/SingletonUtil.java new file mode 100644 index 000000000..6e30aa635 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/SingletonUtil.java @@ -0,0 +1,7 @@ +package org.eclipse.rap.rwt; + +public class SingletonUtil { + public static T getSessionInstance(Class clss) { + return null; + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/AbstractEntryPoint.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/AbstractEntryPoint.java new file mode 100644 index 000000000..980a81854 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/AbstractEntryPoint.java @@ -0,0 +1,43 @@ +package org.eclipse.rap.rwt.application; + +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public abstract class AbstractEntryPoint implements EntryPoint { + private Display display; + private Shell shell; + + protected Shell createShell(Display display) { + return new Shell(display); + } + + protected void createContents(Composite parent) { + + } + + public int createUI() { + display = new Display(); + shell = createShell(display); + shell.setLayout(new GridLayout(1, false)); + createContents(shell); + if (shell.getMaximized()) { + shell.layout(); + } else { + shell.pack(); + } + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + display.dispose(); + return 0; + } + + protected Shell getShell() { + return shell; + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/Application.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/Application.java new file mode 100644 index 000000000..6cb5f29d2 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/Application.java @@ -0,0 +1,27 @@ +package org.eclipse.rap.rwt.application; + +import java.util.Map; + +import org.eclipse.rap.rwt.service.ResourceLoader; + +public interface Application { + public static enum OperationMode { + JEE_COMPATIBILITY, SWT_COMPATIBILITY, + } + + void setOperationMode(OperationMode operationMode); + + void addResource(String name, ResourceLoader resourceLoader); + + void setExceptionHandler(ExceptionHandler exceptionHandler); + + void addEntryPoint(String path, EntryPointFactory entryPointFactory, + Map properties); + + void addEntryPoint(String path, Class entryPoint, + Map properties); + + void addStyleSheet(String themeId, String styleSheetLocation, + ResourceLoader resourceLoader); + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ApplicationConfiguration.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ApplicationConfiguration.java new file mode 100644 index 000000000..961ad70f6 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ApplicationConfiguration.java @@ -0,0 +1,5 @@ +package org.eclipse.rap.rwt.application; + +public interface ApplicationConfiguration { + void configure(Application application); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPoint.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPoint.java new file mode 100644 index 000000000..c0d559a2b --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPoint.java @@ -0,0 +1,5 @@ +package org.eclipse.rap.rwt.application; + +public interface EntryPoint { + int createUI(); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPointFactory.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPointFactory.java new file mode 100644 index 000000000..d5b24d8fe --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/EntryPointFactory.java @@ -0,0 +1,5 @@ +package org.eclipse.rap.rwt.application; + +public interface EntryPointFactory { + public EntryPoint create(); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ExceptionHandler.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ExceptionHandler.java new file mode 100644 index 000000000..13daf2195 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/application/ExceptionHandler.java @@ -0,0 +1,5 @@ +package org.eclipse.rap.rwt.application; + +public interface ExceptionHandler { + public void handleException(Throwable throwable); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/Client.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/Client.java new file mode 100644 index 000000000..934feaea6 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/Client.java @@ -0,0 +1,18 @@ +package org.eclipse.rap.rwt.client; + +import java.io.Serializable; + +import org.eclipse.rap.rwt.client.service.ClientService; + +public interface Client extends Serializable { + + /** + * Returns this client's implementation of a given service, if available. + * + * @param type the type of the requested service, must be a subtype of ClientService + * @return the requested service if provided by this client, otherwise null + * @see ClientService + */ + T getService( Class type ); + +} \ No newline at end of file diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/WebClient.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/WebClient.java new file mode 100644 index 000000000..1f19bdd7c --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/WebClient.java @@ -0,0 +1,10 @@ +package org.eclipse.rap.rwt.client; + +public interface WebClient { + public final static String FAVICON = "rcp:FAVICON"; + public final static String PAGE_TITLE = "rcp:PAGE_TITLE"; + public final static String BODY_HTML = "rcp:BODY_HTML"; + public final static String THEME_ID = "rcp:THEME_ID"; + public final static String HEAD_HTML = "rcp:HEAD_HTML"; + public final static String PAGE_OVERFLOW = "rcp:PAGE_OVERFLOW"; +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigation.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigation.java new file mode 100644 index 000000000..ffba4e43e --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigation.java @@ -0,0 +1,7 @@ +package org.eclipse.rap.rwt.client.service; + +public interface BrowserNavigation extends ClientService { + void pushState(String state, String title); + + void addBrowserNavigationListener(BrowserNavigationListener listener); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationEvent.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationEvent.java new file mode 100644 index 000000000..3e1b3eb72 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationEvent.java @@ -0,0 +1,10 @@ +package org.eclipse.rap.rwt.client.service; + +public class BrowserNavigationEvent { + private String state; + + public String getState() { + return state; + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationListener.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationListener.java new file mode 100644 index 000000000..8319c03f7 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/BrowserNavigationListener.java @@ -0,0 +1,5 @@ +package org.eclipse.rap.rwt.client.service; + +public interface BrowserNavigationListener { + public void navigated(BrowserNavigationEvent event); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/ClientService.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/ClientService.java new file mode 100644 index 000000000..9f479d139 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/ClientService.java @@ -0,0 +1,6 @@ +package org.eclipse.rap.rwt.client.service; + +import java.io.Serializable; + +public interface ClientService extends Serializable { +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/JavaScriptExecutor.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/JavaScriptExecutor.java new file mode 100644 index 000000000..6c44c729c --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/JavaScriptExecutor.java @@ -0,0 +1,5 @@ +package org.eclipse.rap.rwt.client.service; + +public interface JavaScriptExecutor extends ClientService { + public void execute( String code ); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/UrlLauncher.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/UrlLauncher.java new file mode 100644 index 000000000..9dae811c7 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/client/service/UrlLauncher.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2012 EclipseSource and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * EclipseSource - initial API and implementation + ******************************************************************************/ +package org.eclipse.rap.rwt.client.service; + +/** + * The UrlLauncher service allows loading an URL in an external window, application or save dialog. + * + * @since 2.0 + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface UrlLauncher extends ClientService { + + /** + * Opens the given URL. + * + * Any HTTP URL or relative URL will be opened in a new window. + * Modern browser may block any attempt to open new windows, but will usually prompt the user to + * accept or ignore. Even if accepted, the decision may be applied to only this attempt, or only + * to future attempts. It could also trigger a document reload, causing a session restart. + * + * Non-HTTP URLs like "mailto" will not create a new browser window, but require the client + * to have a matching protocol handler registered. + * + * @param url the URL to open + */ + void openURL( String url ); + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceLoader.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceLoader.java new file mode 100644 index 000000000..7e7116cf3 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceLoader.java @@ -0,0 +1,9 @@ +package org.eclipse.rap.rwt.service; + +import java.io.IOException; +import java.io.InputStream; + +public interface ResourceLoader { + public InputStream getResourceAsStream(String resourceName) + throws IOException; +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceManager.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceManager.java new file mode 100644 index 000000000..c3379ea66 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ResourceManager.java @@ -0,0 +1,15 @@ +package org.eclipse.rap.rwt.service; + +import java.io.InputStream; + +public interface ResourceManager { + public void register(String name, InputStream in); + + boolean unregister(String name); + + public InputStream getRegisteredContent(String name); + + public String getLocation(String name); + + public boolean isRegistered(String name); +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ServerPushSession.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ServerPushSession.java new file mode 100644 index 000000000..bed194f31 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/service/ServerPushSession.java @@ -0,0 +1,12 @@ +package org.eclipse.rap.rwt.service; + +/** Mock, does nothing as this is irrelevant for RCP. */ +public class ServerPushSession { + public void start() { + + } + + public void stop() { + + } +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/DropDown.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/DropDown.java new file mode 100644 index 000000000..b2a2005e7 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/DropDown.java @@ -0,0 +1,33 @@ +package org.eclipse.rap.rwt.widgets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Widget; + +public class DropDown { + private boolean visible=false; + + public DropDown(Widget parent, int style) { + // FIXME implement a shell + } + + public DropDown(Widget parent) { + this(parent, SWT.NONE); + } + + public void setVisible(boolean visible) { + this.visible = visible; + } + + public boolean isVisible() { + return visible; + } + + public void setItems( String[] items ) { + + } + + public void setSelectionIndex( int selection ) { + + } + +} diff --git a/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/FileUpload.java b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/FileUpload.java new file mode 100644 index 000000000..cbf1449e0 --- /dev/null +++ b/rcp/org.argeo.eclipse.ui.rcp/src/org/eclipse/rap/rwt/widgets/FileUpload.java @@ -0,0 +1,37 @@ +package org.eclipse.rap.rwt.widgets; + +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; + +public class FileUpload extends Composite { + + public FileUpload(Composite parent, int style) { + super(parent, style); + } + + public void addSelectionListener(SelectionListener listener) { + + } + + public void submit(String url) { + + } + + public void setImage(Image image) { + + } + + public void setText(String text) { + + } + + public String getFileName() { + return null; + } + + public String[] getFileNames() { + return null; + } + +} diff --git a/rcp/pom.xml b/rcp/pom.xml new file mode 100644 index 000000000..54994e2d8 --- /dev/null +++ b/rcp/pom.xml @@ -0,0 +1,161 @@ + + + 4.0.0 + + org.argeo.slc + argeo-slc + 2.1.17-SNAPSHOT + .. + + org.argeo.slc.rcp + argeo-rcp + Argeo RCP + pom + + org.argeo.eclipse.ui.rcp + org.argeo.cms.desktop + org.argeo.cms.e4.rcp + dep + + + + + org.argeo.tp + argeo-tp + ${version.argeo-tp} + provided + + + + + + + + + + + + + + org.argeo.tp.rap.platform + org.eclipse.rap.ui.forms + + + org.argeo.tp.rap.platform + org.eclipse.rap.rwt + + + org.argeo.tp.rap.platform + org.eclipse.rap.jface + + + org.argeo.tp.rap.platform + org.eclipse.rap.ui + + + org.argeo.tp.rap.platform + org.eclipse.rap.ui.views + + + org.argeo.tp.rap.platform + org.eclipse.rap.ui.workbench + + + org.argeo.tp.rap.platform + org.eclipse.rap.rwt.osgi + + + org.argeo.tp.rap.platform + org.eclipse.rap.jface.databinding + + + org.argeo.tp.rap.platform + org.eclipse.core.jobs + + + org.argeo.tp.rap.platform + org.eclipse.core.expressions + + + org.argeo.tp.rap.platform + org.eclipse.core.databinding.observable + + + org.argeo.tp.rap.platform + org.eclipse.help + + + org.argeo.tp.rap.platform + org.eclipse.core.databinding + + + org.argeo.tp.rap.platform + org.eclipse.core.databinding.beans + + + org.argeo.tp.rap.platform + org.eclipse.core.runtime + + + org.argeo.tp.rap.platform + org.eclipse.core.databinding.property + + + org.argeo.tp.rap.platform + com.ibm.icu.base + + + org.argeo.tp.rap.platform + org.eclipse.core.contenttype + + + org.argeo.tp.rap.platform + org.eclipse.core.commands + + + + + org.argeo.tp.rap.platform + org.eclipse.rap.filedialog + + + org.argeo.tp.rap.platform + org.eclipse.rap.fileupload + + + + + org.argeo.tp + argeo-tp-rcp-e4 + ${version.argeo-tp} + provided + + + org.argeo.tp.rcp.platform + org.eclipse.osgi + + + org.argeo.tp.rcp.platform + org.eclipse.osgi.services + + + + + + + + + + + + + + org.argeo.tp + argeo-tp-rcp-e4 + ${version.argeo-tp} + pom + import + + + + -- 2.39.2