diff options
| author | slewis | 2005-01-30 06:47:20 +0000 |
|---|---|---|
| committer | slewis | 2005-01-30 06:47:20 +0000 |
| commit | ab0df326fc1201f35449c8aff282529a2b4ec511 (patch) | |
| tree | fa7a14956a0b530d675a6d8cad8014a3d0b78072 | |
| parent | d824cd56d02f125a4a03548aecaa211f99929e27 (diff) | |
| download | org.eclipse.ecf-ab0df326fc1201f35449c8aff282529a2b4ec511.tar.gz org.eclipse.ecf-ab0df326fc1201f35449c8aff282529a2b4ec511.tar.xz org.eclipse.ecf-ab0df326fc1201f35449c8aff282529a2b4ec511.zip | |
Initial checkin for collab example application
69 files changed, 8965 insertions, 0 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/.classpath b/examples/bundles/org.eclipse.ecf.example.collab/.classpath new file mode 100644 index 000000000..065ac06e1 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/.cvsignore b/examples/bundles/org.eclipse.ecf.example.collab/.cvsignore new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/examples/bundles/org.eclipse.ecf.example.collab/.options b/examples/bundles/org.eclipse.ecf.example.collab/.options new file mode 100644 index 000000000..184bddbcf --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/.options @@ -0,0 +1,8 @@ +org.eclipse.ecf.example.collab/debug = true +org.eclipse.ecf.example.collab/debug/filter = * +org.eclipse.ecf.example.collab/debug/flag = true +org.eclipse.ecf.example.collab/debug/genericsharedobject = true +org.eclipse.ecf.example.collab/debug/transactionsharedobject = true +org.eclipse.ecf.example.collab/debug/urlsharedobject = true +org.eclipse.ecf.example.collab/debug/progsharedobject = true +org.eclipse.ecf.example.collab/debug/filetransfersharedobject = true diff --git a/examples/bundles/org.eclipse.ecf.example.collab/.project b/examples/bundles/org.eclipse.ecf.example.collab/.project new file mode 100644 index 000000000..87f7d0126 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.ecf.example.collab</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF new file mode 100644 index 000000000..3acdc9b77 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-Name: ECF Example Collaboration Client +Bundle-SymbolicName: org.eclipse.ecf.example.collab +Bundle-Version: 0.2.0 +Bundle-ClassPath: client.jar +Bundle-Activator: org.eclipse.ecf.example.collab.ClientPlugin +Bundle-Vendor: Eclipse.org +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.jdt.core, + org.eclipse.team.cvs.core, + org.eclipse.team.cvs.ui, + org.eclipse.core.resources, + org.eclipse.team.ui, + org.eclipse.ecf, + org.eclipse.help.base, + org.eclipse.team.core, + org.eclipse.jface.text, + org.junit +Export-Package: org.eclipse.ecf.example.collab.share, org.eclipse.ecf.example.collab.share.url, org.eclipse.ecf.example.collab.share.io +Eclipse-AutoStart: true diff --git a/examples/bundles/org.eclipse.ecf.example.collab/build.properties b/examples/bundles/org.eclipse.ecf.example.collab/build.properties new file mode 100644 index 000000000..ccd839b35 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/build.properties @@ -0,0 +1,5 @@ +source.client.jar = src/ +output.client.jar = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + client.jar diff --git a/examples/bundles/org.eclipse.ecf.example.collab/icons/person.gif b/examples/bundles/org.eclipse.ecf.example.collab/icons/person.gif Binary files differnew file mode 100644 index 000000000..608d2d165 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/icons/person.gif diff --git a/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Collab Server.launch b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Collab Server.launch new file mode 100644 index 000000000..81c1f8e4d --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Collab Server.launch @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> +<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.provider.app.ServerApplication"/> +<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="org.eclipse.ecf.provider" path="1" type="4"/> "/> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento project="org.eclipse.ecf.provider"/> </runtimeClasspathEntry> "/> +<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="org.eclipse.ecf.client" type="1"/> "/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.client"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.ecf.provider.Trace=true -Dorg.eclipse.ecf.Trace=true"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +</launchConfiguration> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch new file mode 100644 index 000000000..436d1f55e --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch @@ -0,0 +1,243 @@ +<?xml version="1.0" encoding="UTF-8"?> +<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> +<stringAttribute key="product" value="org.eclipse.platform.ide"/> +<booleanAttribute key="usefeatures" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<booleanAttribute key="useProduct" value="false"/> +<booleanAttribute key="tracing" value="true"/> +<stringAttribute key="location2" value="C:\eclipse3.1m4\eclipse\second-runtime-workspace"/> +<mapAttribute key="tracingOptions"> +<mapEntry key="org.eclipse.ecf.example.collab/debug/urlsharedobject" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/syncchangeevents" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/xmppsharedobject" value="true"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/smackconnection" value="true"/> +<mapEntry key="org.eclipse.help.webapp/debug/workingsets" value="false"/> +<mapEntry key="org.eclipse.core.runtime/strings" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/loader" value="*"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/actions" value="false"/> +<mapEntry key="org.eclipse.core.runtime/timing/shutdown" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/connect" value="false"/> +<mapEntry key="org.eclipse.jface.text/debug/ContentAssistSubjectAdapters" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/markers" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/needbuild" value="false"/> +<mapEntry key="org.eclipse.ui/trace/graphics" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/resolution" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/ssh_protocol" value="false"/> +<mapEntry key="org.eclipse.update.configurator/debug" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/filter" value="*"/> +<mapEntry key="org.eclipse.osgi/monitor/activation" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packages" value="false"/> +<mapEntry key="org.eclipse.ui/debug/showSystemJobs" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/monitor/listeners" value="false"/> +<mapEntry key="org.eclipse.ant.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/classes" value="false"/> +<mapEntry key="org.eclipse.update.core/debug" value="true"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/converter/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/debug/context" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser" value="false"/> +<mapEntry key="org.eclipse.ui/debug/swtdebug" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/containerfactory" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javamodel" value="false"/> +<mapEntry key="org.eclipse.team.core/streams" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/locks" value="false"/> +<mapEntry key="org.eclipse.ecf/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/keyBindings" value="false"/> +<mapEntry key="org.eclipse.ui.intro/trace/printHTML" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/dump" value=""/> +<mapEntry key="org.eclipse.jdt.ui/debug/TypeConstraints" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta/verbose" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.expressions/tracePropertyResolving" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/filter" value="*"/> +<mapEntry key="org.eclipse.ecf.ui/debug/flag" value="true"/> +<mapEntry key="org.eclipse.osgi/trace/filename" value="runtime.traces"/> +<mapEntry key="org.eclipse.update.core/debug/web" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/progsharedobject" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/containerfactory" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/flag" value="true"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/resolve" value="false"/> +<mapEntry key="org.eclipse.osgi/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/delta" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/activation" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/search" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/idfactory" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/connectionfactory" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/genericsharedobject" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/compiler" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/filetransfersharedobject" value="true"/> +<mapEntry key="org.eclipse.jface.text/debug/AnnotationPainter" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectmanager" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/connection" value="true"/> +<mapEntry key="org.eclipse.jdt.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/events/plugin" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/configuration" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/factoryinit" value="true"/> +<mapEntry key="org.eclipse.ui/trace/part.activate" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/filters" value="trace.properties"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/events/extension" value="false"/> +<mapEntry key="org.eclipse.help.webapp/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/transactionsharedobject" value="true"/> +<mapEntry key="org.eclipse.core.resources/refresh" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/debug" value="false"/> +<mapEntry key="org.eclipse.team.core/backgroundevents" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/cpresolution" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/threading" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/flag" value="true"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/flag" value="true"/> +<mapEntry key="org.eclipse.update.core/debug/warning" value="false"/> +<mapEntry key="org.eclipse.core.resources/save" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/install" value="false"/> +<mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/flag" value="true"/> +<mapEntry key="org.eclipse.core.runtime/jobs/errorondeadlock" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser/inprocess" value="false"/> +<mapEntry key="org.eclipse.core.resources/debug" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug" value="true"/> +<mapEntry key="org.eclipse.update.core/debug/parsing" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/syncinfo" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/cvsprotocol" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/postaction" value="false"/> +<mapEntry key="org.eclipse.ui/trace/perspective.listeners" value="false"/> +<mapEntry key="org.eclipse.team.core/threading" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachelookup" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packageadmin/timing" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/reconciler" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/security" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/manifest" value="false"/> +<mapEntry key="org.eclipse.help/debug/context" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/builder" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/syncinfo" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/resource" value="*"/> +<mapEntry key="org.eclipse.ecf.ui/debug/filter" value="*"/> +<mapEntry key="org.eclipse.ecf.provider/debug/basesharedobject" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/services" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/activateplugin" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/monitor/builders" value="false"/> +<mapEntry key="org.eclipse.ui/trace/handlers.verbose" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/markers" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/installhandler" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/startlevel" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/filter" value="*"/> +<mapEntry key="org.eclipse.ecf.provider/debug/gmm" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/resources" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> +<mapEntry key="org.eclipse.core.resources/preferences" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> +<mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.create" value="false"/> +<mapEntry key="org.eclipse.help/debug/protocols" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/snapshots" value="false"/> +<mapEntry key="org.eclipse.core.resources/natures" value="false"/> +<mapEntry key="org.eclipse.help.base/debug/search" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/dirtycaching" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/native" value="*"/> +<mapEntry key="org.eclipse.jdt.core/debug/zipaccess" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/properties" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/create" value="false"/> +<mapEntry key="org.eclipse.ui/trace/include.timings" value="true"/> +<mapEntry key="org.eclipse.ui/trace/keyBindings.verbose" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/bundleTime" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/beginend" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/metafiles" value="false"/> +<mapEntry key="org.eclipse.team.core/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/events" value="false"/> +<mapEntry key="org.eclipse.core.runtime/compatibility/debug" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectcontext" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/monitorbundles" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="false"/> +<mapEntry key="org.eclipse.pde.build/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/location" value="false"/> +<mapEntry key="org.eclipse.ui/trace/contexts.verbose" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectwrapper" value="false"/> +<mapEntry key="org.eclipse.help.base/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug/pluginstopper" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/smackdebug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/workbench.start" value="false"/> +<mapEntry key="org.eclipse.core.runtime/contenttypes/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/metainfo" value="false"/> +<mapEntry key="org.eclipse.core.runtime/timing/startup" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/connectionping" value="false"/> +<mapEntry key="org.eclipse.ui/trace/contexts" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/invoking" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/failure" value="false"/> +<mapEntry key="org.eclipse.ui/debug/uijob.longwarning" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/type" value="false"/> +<mapEntry key="org.eclipse.ui/trace/page.listeners" value="false"/> +<mapEntry key="org.eclipse.ui/debug/job.stale" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/allTypesCache" value="false"/> +<mapEntry key="org.eclipse.core.resources/history" value="false"/> +<mapEntry key="org.eclipse.team.core/refreshjob" value="false"/> +<mapEntry key="org.eclipse.ui.intro/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/completion" value="false"/> +<mapEntry key="org.eclipse.jdt.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug" value="false"/> +<mapEntry key="org.eclipse.debug.core/debug" value="true"/> +<mapEntry key="org.eclipse.help/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/perspective" value="false"/> +<mapEntry key="org.eclipse.ui/debug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/indexmanager" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packageadmin" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/loader" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/failure" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/container" value="true"/> +<mapEntry key="org.eclipse.ui/trace/handlers" value="false"/> +<mapEntry key="org.eclipse.ecf.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/save/tree" value="false"/> +<mapEntry key="org.eclipse.core.runtime/config/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/classLoading" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore/metainfo" value="false"/> +<mapEntry key="org.eclipse.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> +<mapEntry key="org.eclipse.jdt.debug/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug" value="false"/> +<mapEntry key="org.eclipse.ui/trace/handlers.verbose.commandId" value=""/> +<mapEntry key="org.eclipse.jdt.core/debug/buffermanager" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/filter" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.listeners" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/ASTProvider" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/success" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/mastertable" value="false"/> +<mapEntry key="org.eclipse.ui.intro/trace/logInfo" value="true"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/filter" value="*"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/class" value="*"/> +<mapEntry key="org.eclipse.ecf.provider/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/preferences/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/timing" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/failure" value="false"/> +</mapAttribute> +<stringAttribute key="selectedPlugin" value="org.eclipse.ecf.provider"/> +<booleanAttribute key="automaticAdd" value="true"/> +<stringAttribute key="checked" value="org.eclipse.ecf.example.collab,org.eclipse.ecf.provider"/> +<booleanAttribute key="includeFragments" value="false"/> +<stringAttribute key="configLocation" value=""/> +<booleanAttribute key="clearws" value="false"/> +<stringAttribute key="location1" value="C:\eclipse3.1m4\eclipse\runtime-workspace"/> +<stringAttribute key="templateConfig" value=""/> +<booleanAttribute key="default" value="false"/> +<stringAttribute key="vmargs" value="-Dsmack.debugEnabled=true"/> +<booleanAttribute key="clearConfig" value="false"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<stringAttribute key="extplugins" value="org.apache.ant;org.apache.lucene;org.eclipse.compare;org.eclipse.core.expressions;org.eclipse.core.filebuffers;org.eclipse.core.resources;org.eclipse.core.runtime;org.eclipse.core.runtime.compatibility;org.eclipse.core.variables;org.eclipse.debug.core;org.eclipse.debug.ui;org.eclipse.help;org.eclipse.help.appserver;org.eclipse.help.base;org.eclipse.jdt.core;org.eclipse.jdt.debug;org.eclipse.jdt.debug.ui;org.eclipse.jdt.junit;org.eclipse.jdt.junit.runtime;org.eclipse.jdt.launching;org.eclipse.jdt.ui;org.eclipse.jface;org.eclipse.jface.text;org.eclipse.ltk.core.refactoring;org.eclipse.ltk.ui.refactoring;org.eclipse.osgi;org.eclipse.search;org.eclipse.swt;org.eclipse.swt.win32;org.eclipse.team.core;org.eclipse.team.cvs.core;org.eclipse.team.cvs.ui;org.eclipse.team.ui;org.eclipse.text;org.eclipse.ui;org.eclipse.ui.console;org.eclipse.ui.editors;org.eclipse.ui.forms;org.eclipse.ui.ide;org.eclipse.ui.views;org.eclipse.ui.workbench;org.eclipse.ui.workbench.texteditor;org.eclipse.update.configurator;org.eclipse.update.core;org.eclipse.update.ui;org.junit;"/> +<booleanAttribute key="useDefaultConfigArea" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="progargs" value=""/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<stringAttribute key="wsproject" value="com.composent.identity;com.composent.client;com.composent.comm;org.eclipse.ecf.test.ui;com.composent.api;"/> +<booleanAttribute key="askclear" value="true"/> +<stringAttribute key="location0" value="C:\eclipse3.1m4\eclipse\runtime-workspace"/> +</launchConfiguration> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 2.launch b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 2.launch new file mode 100644 index 000000000..193da3412 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 2.launch @@ -0,0 +1,243 @@ +<?xml version="1.0" encoding="UTF-8"?> +<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> +<stringAttribute key="product" value="org.eclipse.platform.ide"/> +<booleanAttribute key="usefeatures" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<booleanAttribute key="useProduct" value="false"/> +<booleanAttribute key="tracing" value="true"/> +<stringAttribute key="location2" value="C:\eclipse3.1m4\eclipse\runtime-workspace"/> +<mapAttribute key="tracingOptions"> +<mapEntry key="org.eclipse.ecf.example.collab/debug/urlsharedobject" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/xmppsharedobject" value="true"/> +<mapEntry key="org.eclipse.team.cvs.core/syncchangeevents" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/smackconnection" value="true"/> +<mapEntry key="org.eclipse.help.webapp/debug/workingsets" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/strings" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/loader" value="*"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/actions" value="false"/> +<mapEntry key="org.eclipse.core.runtime/timing/shutdown" value="false"/> +<mapEntry key="org.eclipse.jface.text/debug/ContentAssistSubjectAdapters" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/connect" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/markers" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/needbuild" value="false"/> +<mapEntry key="org.eclipse.ui/trace/graphics" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/resolution" value="false"/> +<mapEntry key="org.eclipse.update.configurator/debug" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/ssh_protocol" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/filter" value="*"/> +<mapEntry key="org.eclipse.osgi/monitor/activation" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packages" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug" value="false"/> +<mapEntry key="org.eclipse.ui/debug/showSystemJobs" value="false"/> +<mapEntry key="org.eclipse.core.resources/monitor/listeners" value="false"/> +<mapEntry key="org.eclipse.ant.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/classes" value="false"/> +<mapEntry key="org.eclipse.update.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug/context" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/converter/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser" value="false"/> +<mapEntry key="org.eclipse.ui/debug/swtdebug" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/containerfactory" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javamodel" value="false"/> +<mapEntry key="org.eclipse.team.core/streams" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/locks" value="false"/> +<mapEntry key="org.eclipse.ecf/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/keyBindings" value="false"/> +<mapEntry key="org.eclipse.ui.intro/trace/printHTML" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/TypeConstraints" value="false"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/dump" value=""/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta/verbose" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug" value="true"/> +<mapEntry key="org.eclipse.core.expressions/tracePropertyResolving" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore" value="false"/> +<mapEntry key="org.eclipse.ecf.ui/debug/flag" value="true"/> +<mapEntry key="org.eclipse.ecf/debug/filter" value="*"/> +<mapEntry key="org.eclipse.osgi/trace/filename" value="runtime.traces"/> +<mapEntry key="org.eclipse.update.core/debug/web" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/progsharedobject" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/containerfactory" value="true"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/flag" value="true"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/resolve" value="false"/> +<mapEntry key="org.eclipse.osgi/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/activation" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/delta" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/search" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/idfactory" value="true"/> +<mapEntry key="org.eclipse.ecf/debug/connectionfactory" value="true"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/genericsharedobject" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/compiler" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/filetransfersharedobject" value="true"/> +<mapEntry key="org.eclipse.jface.text/debug/AnnotationPainter" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectmanager" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/connection" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/events/plugin" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/configuration" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/factoryinit" value="true"/> +<mapEntry key="org.eclipse.ui/trace/part.activate" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/filters" value="trace.properties"/> +<mapEntry key="org.eclipse.core.runtime/registry/debug/events/extension" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> +<mapEntry key="org.eclipse.help.webapp/debug" value="true"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/transactionsharedobject" value="true"/> +<mapEntry key="org.eclipse.team.cvs.core/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/refresh" value="false"/> +<mapEntry key="org.eclipse.team.core/backgroundevents" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/cpresolution" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/threading" value="false"/> +<mapEntry key="org.eclipse.ecf/debug/flag" value="true"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/flag" value="true"/> +<mapEntry key="org.eclipse.update.core/debug/warning" value="false"/> +<mapEntry key="org.eclipse.core.resources/save" value="false"/> +<mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/install" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/errorondeadlock" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/flag" value="true"/> +<mapEntry key="org.eclipse.core.resources/debug" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser/inprocess" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug" value="true"/> +<mapEntry key="org.eclipse.update.core/debug/parsing" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/syncinfo" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/cvsprotocol" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/postaction" value="false"/> +<mapEntry key="org.eclipse.ui/trace/perspective.listeners" value="false"/> +<mapEntry key="org.eclipse.team.core/threading" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachelookup" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packageadmin/timing" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/reconciler" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/security" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/manifest" value="false"/> +<mapEntry key="org.eclipse.help/debug/context" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/builder" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/syncinfo" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/resource" value="*"/> +<mapEntry key="org.eclipse.ecf.ui/debug/filter" value="*"/> +<mapEntry key="org.eclipse.ecf.provider/debug/basesharedobject" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/services" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/activateplugin" value="false"/> +<mapEntry key="org.eclipse.core.resources/monitor/builders" value="false"/> +<mapEntry key="org.eclipse.ui/trace/handlers.verbose" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/markers" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/filter" value="*"/> +<mapEntry key="org.eclipse.osgi/debug/startlevel" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/installhandler" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/gmm" value="false"/> +<mapEntry key="org.eclipse.osgi/monitor/resources" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/javadelta" value="false"/> +<mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> +<mapEntry key="org.eclipse.core.resources/preferences" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.create" value="false"/> +<mapEntry key="org.eclipse.help/debug/protocols" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/snapshots" value="false"/> +<mapEntry key="org.eclipse.help.base/debug/search" value="false"/> +<mapEntry key="org.eclipse.core.resources/natures" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/dirtycaching" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/native" value="*"/> +<mapEntry key="org.eclipse.jdt.core/debug/zipaccess" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/properties" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/create" value="false"/> +<mapEntry key="org.eclipse.ui/trace/include.timings" value="true"/> +<mapEntry key="org.eclipse.ui/trace/keyBindings.verbose" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/bundleTime" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/beginend" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/metafiles" value="false"/> +<mapEntry key="org.eclipse.team.core/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/events" value="false"/> +<mapEntry key="org.eclipse.core.runtime/compatibility/debug" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectcontext" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/monitorbundles" value="false"/> +<mapEntry key="org.eclipse.pde.build/debug" value="false"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/location" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectwrapper" value="false"/> +<mapEntry key="org.eclipse.ui/trace/contexts.verbose" value="false"/> +<mapEntry key="org.eclipse.help.base/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/jobs" value="false"/> +<mapEntry key="org.eclipse.core.runtime/debug/pluginstopper" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/smackdebug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/workbench.start" value="false"/> +<mapEntry key="org.eclipse.core.runtime/contenttypes/debug" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/metainfo" value="false"/> +<mapEntry key="org.eclipse.core.runtime/timing/startup" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/connectionping" value="false"/> +<mapEntry key="org.eclipse.ui/trace/contexts" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/invoking" value="false"/> +<mapEntry key="org.eclipse.ui/debug/uijob.longwarning" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/failure" value="false"/> +<mapEntry key="org.eclipse.update.core/debug/type" value="false"/> +<mapEntry key="org.eclipse.ui/trace/page.listeners" value="false"/> +<mapEntry key="org.eclipse.ui/debug/job.stale" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/allTypesCache" value="false"/> +<mapEntry key="org.eclipse.core.resources/history" value="false"/> +<mapEntry key="org.eclipse.team.core/refreshjob" value="false"/> +<mapEntry key="org.eclipse.ui.intro/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/completion" value="false"/> +<mapEntry key="org.eclipse.jdt.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.debug.core/debug" value="true"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug" value="false"/> +<mapEntry key="org.eclipse.help/debug" value="true"/> +<mapEntry key="org.eclipse.ui/trace/perspective" value="false"/> +<mapEntry key="org.eclipse.ui/debug" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/indexmanager" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/packageadmin" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/loader" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/container" value="false"/> +<mapEntry key="org.eclipse.core.resources/build/failure" value="false"/> +<mapEntry key="org.eclipse.ui/trace/handlers" value="false"/> +<mapEntry key="org.eclipse.ecf.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/save/tree" value="false"/> +<mapEntry key="org.eclipse.core.runtime/config/debug" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug" value="true"/> +<mapEntry key="org.eclipse.osgi/trace/classLoading" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/metainfo" value="false"/> +<mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> +<mapEntry key="org.eclipse.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.debug/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/debug" value="false"/> +<mapEntry key="org.eclipse.ui/trace/handlers.verbose.commandId" value=""/> +<mapEntry key="org.eclipse.osgi/debug/filter" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/buffermanager" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/ASTProvider" value="false"/> +<mapEntry key="org.eclipse.ui/trace/part.listeners" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/success" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/filter" value="*"/> +<mapEntry key="org.eclipse.ui.intro/trace/logInfo" value="true"/> +<mapEntry key="org.eclipse.core.resources/restore/mastertable" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/filter/class" value="*"/> +<mapEntry key="org.eclipse.ecf.provider/debug" value="true"/> +<mapEntry key="org.eclipse.core.runtime/preferences/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/timing" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/failure" value="false"/> +</mapAttribute> +<stringAttribute key="selectedPlugin" value="org.eclipse.ecf.example.collab"/> +<booleanAttribute key="automaticAdd" value="true"/> +<stringAttribute key="checked" value="org.eclipse.ecf,org.eclipse.ecf.example.collab,org.eclipse.ecf.provider"/> +<booleanAttribute key="includeFragments" value="false"/> +<stringAttribute key="configLocation" value=""/> +<booleanAttribute key="clearws" value="false"/> +<stringAttribute key="location1" value="C:\eclipse3.1m4\eclipse\second-runtime-workspace"/> +<stringAttribute key="templateConfig" value=""/> +<stringAttribute key="vmargs" value=""/> +<booleanAttribute key="default" value="false"/> +<booleanAttribute key="clearConfig" value="false"/> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<stringAttribute key="extplugins" value="org.apache.ant;org.apache.lucene;org.eclipse.compare;org.eclipse.core.expressions;org.eclipse.core.filebuffers;org.eclipse.core.resources;org.eclipse.core.runtime;org.eclipse.core.runtime.compatibility;org.eclipse.core.variables;org.eclipse.debug.core;org.eclipse.debug.ui;org.eclipse.help;org.eclipse.help.appserver;org.eclipse.help.base;org.eclipse.jdt.core;org.eclipse.jdt.debug;org.eclipse.jdt.debug.ui;org.eclipse.jdt.junit;org.eclipse.jdt.junit.runtime;org.eclipse.jdt.launching;org.eclipse.jdt.ui;org.eclipse.jface;org.eclipse.jface.text;org.eclipse.ltk.core.refactoring;org.eclipse.ltk.ui.refactoring;org.eclipse.osgi;org.eclipse.search;org.eclipse.swt;org.eclipse.swt.win32;org.eclipse.team.core;org.eclipse.team.cvs.core;org.eclipse.team.cvs.ui;org.eclipse.team.ui;org.eclipse.text;org.eclipse.ui;org.eclipse.ui.console;org.eclipse.ui.editors;org.eclipse.ui.forms;org.eclipse.ui.ide;org.eclipse.ui.views;org.eclipse.ui.workbench;org.eclipse.ui.workbench.texteditor;org.eclipse.update.configurator;org.eclipse.update.core;org.eclipse.update.ui;org.junit;"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<booleanAttribute key="useDefaultConfigArea" value="true"/> +<booleanAttribute key="useDefaultConfig" value="true"/> +<stringAttribute key="progargs" value=""/> +<stringAttribute key="wsproject" value="com.composent.identity;com.composent.client;com.composent.comm;org.eclipse.ecf.test.ui;com.composent.api;"/> +<booleanAttribute key="askclear" value="true"/> +<stringAttribute key="location0" value="C:\eclipse3.1m4\eclipse\second-runtime-workspace"/> +</launchConfiguration> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml b/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml new file mode 100644 index 000000000..98238114f --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/plugin.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<plugin> + <extension + point="org.eclipse.ui.views"> + <view + icon="icons/person.gif" + class="org.eclipse.ecf.example.collab.ui.LineChatView" + category="org.eclipse.ecf.client.category" + name="ECF Collaboration" + id="org.eclipse.ecf.example.collab.ui.LineChatView"/> + <category + name="ECF" + id="org.eclipse.ecf.client.category"/> + </extension> + <extension + point="org.eclipse.ui.actionSets"> + <actionSet + label="Test Actions" + visible="true" + id="org.eclipse.ecf.example.collab.actionSet"> + </actionSet> + </extension> + <extension + point="org.eclipse.ui.popupMenus"> + <objectContribution + adaptable="true" + objectClass="org.eclipse.core.resources.IProject" + id="org.eclipse.ecf.example.collab.contribution1"> + <menu + label="ECF" + path="additions" + id="org.eclipse.ecf.example.collab.menu1"> + <separator name="group1"/> + <separator name="group2"/> + </menu> + <action + label="Join ECF Collaboration..." + class="org.eclipse.ecf.example.collab.ui.JoinGroupWizardAction" + menubarPath="org.eclipse.ecf.example.collab.menu1/group1" + id="org.eclipse.ecf.client.joingroupwizardaction"/> + <action + label="Join Test Collaboration (Composent)" + class="org.eclipse.ecf.example.collab.actions.ProjectPopupComposentAction" + menubarPath="org.eclipse.ecf.example.collab.menu1/group2" + id="org.eclipse.ecf.example.collab.newAction"/> + <action + label="Join Test Collaboration (Localhost)" + class="org.eclipse.ecf.example.collab.actions.ProjectPopupLocalhostAction" + menubarPath="org.eclipse.ecf.example.collab.menu1/group2" + id="org.eclipse.ecf.example.collab.newAction1"/> + </objectContribution> + </extension> + +</plugin> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java new file mode 100644 index 000000000..9b367771d --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java @@ -0,0 +1,144 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Vector; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Platform; +import org.eclipse.ecf.core.ISharedObjectContainer; +import org.eclipse.ecf.core.SharedObjectContainerFactory; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject; +import org.eclipse.ecf.example.collab.share.SharedObjectEventListener; +import org.eclipse.ecf.example.collab.share.TreeItem; +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +public class Client { + private static final int CONTAINER_DISPOSE = 1000; + public static final String JOIN_TIME_FORMAT = "hh:mm:ss a z"; + public static final String GENERIC_CONTAINER_CLIENT_NAME = "org.eclipse.ecf.provider.generic.Client"; + public static final String GENERIC_CONTAINER_SERVER_NAME = "org.eclipse.ecf.provider.generic.Server"; + public static final String DEFAULT_SERVER_ID = "ecftcp://localhost:3282//server"; + public static final String COLLAB_SHARED_OBJECT_ID = "chat"; + public static final String FILE_DIRECTORY = "received_files"; + public static final String USERNAME = System.getProperty("user.name"); + public static final String ECFDIRECTORY = "ECF_" + FILE_DIRECTORY + "/"; + static ISharedObjectContainer client = null; + static EclipseCollabSharedObject sharedObject = null; + static ID defaultGroupID = null; + static ID groupID = null; + static ID sharedObjectID = null; + + public Client() throws Exception { + defaultGroupID = IDFactory.makeStringID(DEFAULT_SERVER_ID); + } + + protected User getUserData(String containerType, ID clientID, String usernick, String proj) { + Vector topElements = new Vector(); + String contType = containerType.substring(containerType.lastIndexOf(".")+1); + topElements.add(new TreeItem("Project", proj)); + SimpleDateFormat sdf = new SimpleDateFormat(JOIN_TIME_FORMAT); + topElements.add(new TreeItem("Join Time",sdf.format(new Date()))); + topElements.add(new TreeItem("Container Type",contType)); + return new User(clientID, usernick, topElements); + } + + protected String getSharedFileDirectoryForProject(IProject proj) { + String eclipseDir = Platform.getLocation().lastSegment(); + if (proj == null) + return eclipseDir + "/" + ECFDIRECTORY; + else return FILE_DIRECTORY; + } + + protected IProject getFirstProjectFromWorkspace() throws Exception { + IWorkspace ws = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot wr = ws.getRoot(); + IProject[] projects = wr.getProjects(); + if (projects == null) + return null; + return projects[0]; + } + + protected void makeAndAddSharedObject(ISharedObjectContainer client, + IProject proj, User user, String fileDir) throws Exception { + IWorkbenchWindow ww = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + sharedObject = new EclipseCollabSharedObject(proj, ww, + user, fileDir); + sharedObject.setListener(new SharedObjectEventListener() { + public void memberRemoved(ID member) { + if (member.equals(groupID)) { + disposeClient(); + } + } + public void memberAdded(ID member) {} + public void otherActivated(ID other) {} + public void otherDeactivated(ID other) {} + public void windowClosing() { + disposeClient(); + } + }); + ID newID = IDFactory.makeStringID(COLLAB_SHARED_OBJECT_ID); + client.getSharedObjectManager().addSharedObject(newID, sharedObject, + new HashMap(), null); + } + + protected void addObjectToClient(ISharedObjectContainer client, + String username, IProject proj) throws Exception { + IProject project = (proj == null) ? getFirstProjectFromWorkspace() + : proj; + String fileDir = getSharedFileDirectoryForProject(project); + String projName = (project == null) ? "<workspace>" : project.getName(); + User user = getUserData(client.getClass().getName(),client.getConfig().getID(), + (username == null) ? USERNAME : username, projName); + makeAndAddSharedObject(client, project, user, fileDir); + } + + public synchronized boolean isConnected() { + return (client != null); + } + + public synchronized void createAndConnectClient(String type, ID gID, String username, + Object data, IProject proj) throws Exception { + String containerType = (type==null)?GENERIC_CONTAINER_CLIENT_NAME:type; + client = SharedObjectContainerFactory + .makeSharedObjectContainer(containerType); + if (gID == null) { + groupID = defaultGroupID; + } else { + groupID = gID; + } + addObjectToClient(client, username, proj); + if (groupID == null) + client.joinGroup(defaultGroupID, data); + else + client.joinGroup(groupID, data); + } + + public synchronized void disposeClient() { + if (isConnected()) { + try { + if (sharedObject != null) sharedObject.destroySelf(); + } catch (Exception e) {} + sharedObject = null; + } + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPlugin.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPlugin.java new file mode 100644 index 000000000..a832e5eac --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPlugin.java @@ -0,0 +1,129 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab; + +import java.net.URL; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The main plugin class to be used in the desktop. + */ +public class ClientPlugin extends AbstractUIPlugin implements ClientPluginConstants { + + public static final String PLUGIN_ID = "org.eclipse.ecf.example.collab"; + + //The shared instance. + private static ClientPlugin plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + + private static String appShareBinPath; + private static URL pluginLocation; + + private ImageRegistry registry = null; + + public static String getAppShareBinPath() { + return appShareBinPath; + } + public static URL getPluginTopLocation() { + return pluginLocation; + } + public static void log(String message) { + getDefault().getLog().log(new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, null)); + } + + public static void log(String message, Throwable e) { + getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Caught exception", e)); + } + + /** + * The constructor. + */ + public ClientPlugin() { + super(); + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + resourceBundle = null; + } + + + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry() + */ + protected ImageRegistry createImageRegistry() { + registry = super.createImageRegistry(); + + + registry.put(ClientPluginConstants.DECORATION_PROJECT, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)); + registry.put(ClientPluginConstants.DECORATION_USER, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE)); + registry.put(ClientPluginConstants.DECORATION_TIME, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD)); + registry.put(ClientPluginConstants.DECORATION_TASK, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)); + return registry; + } + /** + * Returns the shared instance. + */ + public static ClientPlugin getDefault() { + return plugin; + } + + /** + * Returns the string from the plugin's resource bundle, + * or 'key' if not found. + */ + public static String getResourceString(String key) { + ResourceBundle bundle = ClientPlugin.getDefault().getResourceBundle(); + try { + return (bundle != null) ? bundle.getString(key) : key; + } catch (MissingResourceException e) { + return key; + } + } + + /** + * Returns the plugin's resource bundle, + */ + public ResourceBundle getResourceBundle() { + try { + if (resourceBundle == null) + resourceBundle = ResourceBundle.getBundle("org.eclipse.ecf.example.collab.ClientPluginResources"); + } catch (MissingResourceException x) { + resourceBundle = null; + } + return resourceBundle; + } + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPlugin.properties b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPlugin.properties new file mode 100644 index 000000000..9bcfd575c --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPlugin.properties @@ -0,0 +1,3 @@ +appsharewin32display=true +filetransferchunksize=1024 +filetransferdelay=10 diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java new file mode 100644 index 000000000..feb31f721 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ClientPluginConstants.java @@ -0,0 +1,26 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab; + +public interface ClientPluginConstants { + public static final String DEFAULT_WIN32_APPSHARE_NAME = "appsharewin32display"; + public static final String DEFAULT_FILE_TRANSFER_CHUNKTIME_NAME = "filetransferchunksize"; + public static final String DEFAULT_FILE_TRANSFER_DELAY_NAME= "filetransferdelay"; + + public static final String USE_CHAT_WINDOW = "useChatWindow"; + + public static final String DECORATION_PROJECT = "project"; + public static final String DECORATION_USER = "user"; + public static final String DECORATION_TIME = "time"; + public static final String DECORATION_TASK = "task"; + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Trace.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Trace.java new file mode 100644 index 000000000..9fbf20116 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Trace.java @@ -0,0 +1,113 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.eclipse.core.runtime.Platform; + +public class Trace { + public static final String tracePrefix = "(trace)"; + + public static boolean ON = false; + protected static boolean isEclipse = false; + protected static String pluginName = ""; + protected static String debugPrefix = "/debug/"; + static { + try { + ON = Platform.inDebugMode(); + isEclipse = true; + pluginName = ClientPlugin.PLUGIN_ID; + } catch (Exception e) { + try { + String val = System.getProperty(ClientPlugin.PLUGIN_ID+".Trace"); + if (val != null) { + setTrace(true); + isEclipse = false; + // No eclipse Platform available + System.out.println("WARNING: Eclipse platform not available for trace...using system.out for org.eclipse.ecf"); + } else { + System.out.println(Trace.class.getName()+": OFF"); + } + } catch (Exception except) { + } + } + } + public static void setTrace(boolean on) { + ON = on; + } + + public static Trace create(String key) { + if (isEclipse) { + String res = Platform + .getDebugOption(pluginName + debugPrefix + key); + if (res != null) { + Boolean on = new Boolean(res); + if (on.booleanValue()) + return new Trace(pluginName + "(" + key + ")"); + else + return null; + } else { + return null; + } + } else + return new Trace(key); + } + + String name; + + public void dumpStack(Throwable e, String msg) { + msg(msg); + e.printStackTrace(System.err); + } + + public void msg(String msg) { + StringBuffer sb = new StringBuffer(name); + sb.append(getTimeString()).append(msg); + System.out.println(sb.toString()); + } + + protected static String getTimeString() { + Date d = new Date(); + SimpleDateFormat df = new SimpleDateFormat("[MM/dd/yy;HH:mm:ss:SSS]"); + return df.format(d); + } + + protected Trace(String str) { + name = tracePrefix+str; + } + public static String convertStringAToString(String [] strings) { + if (strings==null) return ""; + StringBuffer sb = new StringBuffer(); + for(int i=0; i < strings.length; i++) { + if (strings[i]==null) sb.append("(null)"); + else sb.append(strings[i]); + if (i != (strings.length-1)) sb.append(";"); + } + return sb.toString(); + } + public static String convertObjectAToString(Object [] objs) { + if (objs==null) return ""; + StringBuffer sb = new StringBuffer(); + for(int i=0; i < objs.length; i++) { + if (objs[i]==null) sb.append("(null)"); + else sb.append(objs[i].toString()); + if (i != (objs.length-1)) sb.append(";"); + } + return sb.toString(); + } + + public static void setThreadDebugGroup(Object obj) { + // Do nothing + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java new file mode 100644 index 000000000..ff64edb78 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectAction.java @@ -0,0 +1,112 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.actions; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.example.collab.Client; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class ClientConnectAction implements IWorkbenchWindowActionDelegate { + private IWorkbenchWindow window; + + public static final String DEFAULT_SERVER_ID = "ecftcp://localhost:3282//server"; + + public void setData(Object data) { + this.data = data; + } + public void setProject(IProject project) { + this.project = project; + if (project==null) { + projectName = "<workspace>"; + } else { + projectName = project.getName(); + } + } + public void setTargetID(ID targetID) { + this.targetID = targetID; + } + public void setUsername(String username) { + this.username = username; + } + public void setContainerType(String type) { + this.containerType = type; + } + protected String containerType = null; + protected ID targetID = null; + protected String username = null; + protected Object data = null; + protected IProject project = null; + protected String projectName = null; + + public ClientConnectAction() { + try { + targetID = IDFactory.makeStringID(DEFAULT_SERVER_ID); + } catch (Exception e) { + + } + } + + public ClientConnectAction(ID targetID, String username, Object data, IProject project) { + this.targetID = targetID; + this.username = username; + this.data = data; + setProject(project); + } + public class ClientConnectJob extends Job { + public ClientConnectJob(String name) { + super(name); + } + public IStatus run(IProgressMonitor pm) { + Client ct = null; + try { + ct = new Client(); + // Make sure we're disconnected + if (ct.isConnected()) { + ct.disposeClient(); + } + // Actually create and connect client + ct.createAndConnectClient(containerType,targetID,username,data,project); + return new Status(IStatus.OK,ClientPlugin.PLUGIN_ID,IStatus.OK,"Connected",null); + } catch (Exception e) { + if (ct != null) { + ct.disposeClient(); + } + return new Status(IStatus.ERROR,ClientPlugin.PLUGIN_ID,IStatus.OK,"Could not connect to group '"+targetID.getName()+"'",e); + } + } + } + public void run(IAction action) { + ClientConnectJob clientConnect = new ClientConnectJob("Collaboration for '"+projectName+"'"); + clientConnect.schedule(); + } + + public void selectionChanged(IAction action, ISelection selection) { + } + + public void dispose() { + + } + + public void init(IWorkbenchWindow window) { + this.window = window; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java new file mode 100644 index 000000000..56471bd59 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ClientConnectComposentAction.java @@ -0,0 +1,29 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.actions; + +import org.eclipse.ecf.core.identity.IDFactory; + + +public class ClientConnectComposentAction extends ClientConnectAction { + + public static final String COMPOSENT_TARGET = "ecftcp://composent.com:3282/server"; + + public ClientConnectComposentAction() { + super(); + try { + targetID = IDFactory.makeStringID(COMPOSENT_TARGET); + } catch (Exception e) { + // + } + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ProjectPopupComposentAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ProjectPopupComposentAction.java new file mode 100644 index 000000000..21cd8cd52 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ProjectPopupComposentAction.java @@ -0,0 +1,64 @@ +package org.eclipse.ecf.example.collab.actions; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.part.IShowInSource; +import org.eclipse.ui.part.ShowInContext; + +public class ProjectPopupComposentAction implements IObjectActionDelegate { + + /** + * Constructor for Action1. + */ + public ProjectPopupComposentAction() { + super(); + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + project = null; + Object o = targetPart.getAdapter(IShowInSource.class); + if (o != null) { + IShowInSource sis = (IShowInSource) o; + ShowInContext sc = sis.getShowInContext(); + ISelection s = sc.getSelection(); + if (s instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) s; + Object obj = ss.getFirstElement(); + if (obj instanceof IJavaProject) { + IJavaProject ij = (IJavaProject) obj; + project = ij.getProject(); + } + if (obj instanceof IProject) { + project = (IProject) obj; + } + } + } + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + ClientConnectComposentAction caction = new ClientConnectComposentAction(); + caction.setProject(project); + caction.run(action); + } + + IProject project; + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ProjectPopupLocalhostAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ProjectPopupLocalhostAction.java new file mode 100644 index 000000000..f6c87058f --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/actions/ProjectPopupLocalhostAction.java @@ -0,0 +1,64 @@ +package org.eclipse.ecf.example.collab.actions; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.part.IShowInSource; +import org.eclipse.ui.part.ShowInContext; + +public class ProjectPopupLocalhostAction implements IObjectActionDelegate { + + /** + * Constructor for Action1. + */ + public ProjectPopupLocalhostAction() { + super(); + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + project = null; + Object o = targetPart.getAdapter(IShowInSource.class); + if (o != null) { + IShowInSource sis = (IShowInSource) o; + ShowInContext sc = sis.getShowInContext(); + ISelection s = sc.getSelection(); + if (s instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) s; + Object obj = ss.getFirstElement(); + if (obj instanceof IJavaProject) { + IJavaProject ij = (IJavaProject) obj; + project = ij.getProject(); + } + if (obj instanceof IProject) { + project = (IProject) obj; + } + } + } + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + ClientConnectAction caction = new ClientConnectAction(); + caction.setProject(project); + caction.run(action); + } + + IProject project; + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java new file mode 100644 index 000000000..bc26bd83a --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseCollabSharedObject.java @@ -0,0 +1,1032 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Date; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.ecf.core.ISharedObjectContext; +import org.eclipse.ecf.core.SharedObjectContainerJoinException; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.ecf.example.collab.share.io.EclipseFileTransfer; +import org.eclipse.ecf.example.collab.share.io.FileTransferParams; +import org.eclipse.ecf.example.collab.ui.FileReceiverUI; +import org.eclipse.ecf.example.collab.ui.LineChatClientView; +import org.eclipse.ecf.example.collab.ui.LineChatHandler; +import org.eclipse.ecf.example.collab.ui.LineChatView; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.internal.ccvs.core.client.Command; +import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + +public class EclipseCollabSharedObject extends GenericSharedObject implements + LineChatHandler, EclipseProject { + protected static final String CHAT_VIEW_ID = LineChatView.class.getName(); + protected static String DEFAULTTREETOPLABEL = "Presence"; + public static final String ECLIPSEOBJECTNAME = "chat"; + public static final String INIT_TEXT = "Collaboration for '"; + Date creationTime = new Date(); + String downloaddir = ""; + protected LineChatClientView localGUI; + IProject localProject; + User localUser; + String localVersion = ""; + ID serverID; + SharedObjectEventListener sessionListener; + IWorkbenchWindow shellWindow; + String treeTopLabel; + String windowtitle = "Chat"; + URL[] projectCodebase = null; + + public EclipseCollabSharedObject() { + } + + public EclipseCollabSharedObject(IProject proj, IWorkbenchWindow shell, + User user, String downloaddir) { + this.localProject = proj; + this.shellWindow = shell; + this.localUser = user; + this.downloaddir = downloaddir; + localGUI = getOutputWindow(); + if (localGUI == null) + throw new NullPointerException( + "Local GUI cannot be created...exiting"); + } + + public void activated(ID[] others) { + super.activated(others); + if (localGUI == null) { + try { + if (!getContext().isGroupServer()) + destroySelfLocal(); + } catch (Exception e) { + debugdump(e, "Unable to check whether we are server instance"); + destroySelfLocal(); + } + } + } + + public void chatException(Exception e, String text) { + debugdump(e, text); + } + + public void chatGUIDestroy() { + debugmsg("chatGUIDestroy()"); + if (sessionListener != null) { + sessionListener.windowClosing(); + } + destroySelf(); + } + + protected void checkRegisterProxyPolicy(String operation, User sender, + String proxyClass) throws SecurityException { + // by default let it through; + } + + public void deactivated() { + super.deactivated(); + synchronized (this) { + if (localGUI != null) { + localGUI.disposeClient(); + localGUI = null; + } + } + if (sessionListener != null) { + sessionListener = null; + } + if (shellWindow != null) { + shellWindow = null; + } + if (localProject != null) { + localProject = null; + } + } + + public void debugdump(Exception e, String aString) { + } + + public void debugmsg(String aString) { + // ClientPlugin.log(aString); + } + + public void destroySelf() { + // Make sure we disconnect + try { + if (isHost()) { + try { + // try to disconnect + leaveGroup(); + } catch (Exception e) { + debugdump(e, "Exception leaving space"); + } + } + } catch (Exception e) { + debugdump(e,"Exception in destroySelf"); + } + // Destroy self + super.destroySelfLocal(); + } + + public String getDownloaddir(String dir) { + return downloaddir; + } + + public SharedObjectEventListener getListener() { + return sessionListener; + } + + public String getLocalFullProjectPath() { + String eclipseDir = null; + String result = null; + try { + eclipseDir = Platform.getLocation().toOSString(); + } catch (Exception e) { + debugdump(e, + "EclipseCollabSharedObject. Exception getting local project path"); + } + if (eclipseDir==null) { + eclipseDir = "."; + } + String projectDir = null; + if (getProject()==null) { + projectDir = downloaddir; + } else { + projectDir = getProject().getFullPath().toOSString(); + } + File fresult = new File(eclipseDir,projectDir); + return fresult.getAbsolutePath(); + } + + public String getLocalFullDownloadPath() { + String projectPath = getLocalFullProjectPath(); + File downloadpath = new File(projectPath,downloaddir); + return downloadpath.getAbsolutePath(); + } + public ID getObjectID() { + return getID(); + } + + protected LineChatClientView getOutputWindow() { + final String pn = (localProject==null)?"<workspace>":localProject.getName(); + final String projectName = pn; + final String init = INIT_TEXT + pn + + "' project\n\n"; + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (LineChatView.isDisposed()) + showView(); + localGUI = LineChatView.makeClientView( + EclipseCollabSharedObject.this, projectName, init, + getLocalFullDownloadPath()); + } catch (Exception e) { + debugdump(e, + "Exception creating output window in getOutputWindow"); + } + } + }); + return localGUI; + } + + public IProject getProject() { + return localProject; + } + + protected SharedObjectDescription getReplicaDescription(ID remoteID) { + // no replication...depend upon clients to create + // local instance of their own copy of this object...with local + // data. + return null; + } + + public ID getServerID() { + return serverID; + } + + public String getTreeTopLabel() { + return DEFAULTTREETOPLABEL; + } + + public ID getUniqueID() { + try { + return getLocalContainerID(); + } catch (Exception e) { + debugdump(e, "Exception getting unique id"); + return null; + } + } + + public User getUser() { + return localUser; + } + + public User getUserForID(final ID user) { + if (localGUI != null) { + return localGUI.getUser(user); + } + return null; + } + + public String getUserName() { + return localUser.getNickname(); + } + + public String getVersionString() { + return localVersion; + } + + public String getWindowTitle() { + return windowtitle; + } + + public IWorkbenchWindow getWorkbenchWindow() { + return shellWindow; + } + + // SharedObjectMsg handlers + protected void handleCreateObject(SharedObjectDescription cons) { + try { + makeObject(cons.getID(), cons.getClassname(), cons.getProperties()); + } catch (Exception e) { + debugdump(e, "Exception creating local object " + cons); + } + } + + public void handleNotifyUserAdded(User user) { + boolean add = false; + try { + ID[] members = getContext().getGroupMemberIDs(); + for (int i = 0; i < members.length; i++) { + if (members[i].equals(user.getUserID())) { + add = true; + break; + } + } + } catch (Exception e) { + debugdump(e, "Exception checking for membership"); + } + if (add) { + boolean addUserResult = false; + if (localGUI != null) { + addUserResult = localGUI.addUser(user); + } + // If addUserResult is false, it means that this is a new user + // And we need to report our own existence to them + if (addUserResult) { + sendNotifyUserAdded(); + } + } + } + + protected void handleRegisterProxy(User sender, String proxyClass, + String name) { + if (sender == null || proxyClass == null || name == null) + throw new NullPointerException("sender or proxyClass is null"); + try { + checkRegisterProxyPolicy("register", sender, proxyClass); + } catch (SecurityException e) { + debugdump(e, "SecurityException with registering Eclipse proxy"); + throw e; + } + localRegisterProxy(sender, proxyClass, name); + } + + protected void handleRequestUserUpdate(ID requestor) { + sendUserUpdate(requestor); + } + + protected void handleShowPrivateTextMsg(final User remote, final String aString) { + // Show line on local interface + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) + localGUI.showPrivate(remote.getUserID(), aString); + } catch (Exception e) { + debugdump(e, + "Exception in showLineOnGUI"); + } + } + }); + } + + protected void handleShowTextMsg(ID remote, String aString) { + // Show line on local interface + showLineOnGUI(remote, aString); + } + + protected void handleUnregisterProxy(User sender, String name) { + if (sender == null || name == null) + throw new NullPointerException("sender or proxyClass is null"); + // loadClass and create instance if possible + EclipseProjectComponent ec = null; + try { + checkRegisterProxyPolicy("deregister", sender, name); + } catch (SecurityException e) { + debugdump(e, "SecurityException with deregistering Eclipse proxy"); + throw e; + } + localUnregisterProxy(sender, name); + } + + protected void handleUpdateTreeDisplay(final ID fromID, final TreeItem item) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) + localGUI.updateTreeDisplay(fromID, item); + } catch (Exception e) { + debugdump(e, + "Exception in showLineOnGUI"); + } + } + }); + } + + protected void handleUserUpdate(final User ud) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) + localGUI.changeUser(ud); + } catch (Exception e) { + debugdump(e, + "Exception in showLineOnGUI"); + } + } + }); + } + + protected void handleUserMessage(final User sender, String msg) { + // Show line on local interface + final String username = sender.getNickname(); + final String message = msg; + if (sender == null) + return; + if (localGUI != null) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + Display.getDefault().beep(); + Shell[] shells = Display.getDefault().getShells(); + if (shells != null && shells.length > 0) { + shells[0].setActive(); + } + MessageDialog.openInformation(null, + "Private Message from " + sender.getNickname(), + message); + } + }); + } + } + + protected synchronized void handleStartedTyping(User user) { + if (localGUI != null) + localGUI.startedTyping(user); + } + + public void sendStartedTyping() { + try { + forwardMsgTo(null, SharedObjectMsg.makeMsg(null, + "handleStartedTyping", localUser)); + } catch (Exception e) { + debugdump(e, "Exception on sendStartedTyping to remote clients"); + } + } + + public void inputText(String aString) { + sendShowTextMsg(aString); + } + + public boolean isHost() { + return super.isHost(); + } + + public void joinGroup(ID remote, Object data) + throws SharedObjectContainerJoinException { + ISharedObjectContext crs = getContext(); + if (crs == null) { + throw new SharedObjectContainerJoinException( + "Cannot join remote space " + remote + + ". Have no local space access capability."); + } else { + if (remote != null) { + // Do it. + if (localGUI != null) { + String name = remote.getName(); + localGUI.showLine(getID(), "Connecting to: " + name); + } + crs.joinGroup(remote, data); + if (localGUI != null) { + localGUI.showLine(getID(), "Connected."); + } + // Success + } else { + throw new SharedObjectContainerJoinException( + "Invalid remote space ID " + remote); + } + } + } + + public void leaveGroup() { + ISharedObjectContext crs = getContext(); + if (crs == null) { + } else { + // Do it. + crs.leaveGroup(); + } + } + + public URL[] getCodeBase() { + return null; + } + + public void localRegisterProxy(User sender, String proxyClass, String name) { + EclipseProjectComponent ec = null; + try { + ClassLoader classLoader = getClass().getClassLoader(); + URL[] codeBase = getCodeBase(); + URLClassLoader ucl = new URLClassLoader(codeBase, classLoader); + Class cl = Class.forName(proxyClass, true, ucl); + ec = (EclipseProjectComponent) cl.newInstance(); + } catch (Exception e) { + debugdump(e, + "Exception loading proxy class or creating proxy instance for user " + + sender.getNickname()); + throw new RuntimeException("Exception creating proxy instance", e); + } + try { + ec.register(this, sender); + } catch (Exception e) { + debugdump(e, "Exception initializing EclipseProjectComponent"); + throw new RuntimeException( + "Exception initializing EclipseProjectComponent", e); + } + // OK, we have new instance...now we add it to our registered proxies + registerProxy(ec, name, EclipseProjectComponent.INVOKE_METHOD_NAME); + } + + public void localUnregisterProxy(User ud, String name) { + MsgMap m = null; + Object removed = null; + synchronized (msgMapLock) { + // Get entry (if exists) + m = (MsgMap) ((msgMap == null) ? null : (msgMap.get(name))); + if (m == null) + throw new RuntimeException( + "deregisterProxy: No proxy registered for " + name); + // Then remove + removed = msgMap.remove(name); + } + if (removed != null) { + try { + MsgMap mm = (MsgMap) removed; + EclipseProjectComponent ec = (EclipseProjectComponent) mm + .getObject(); + // Call it to give it a chance to clean up + if (ec != null) + ec.deregister(this); + } catch (Exception e) { + debugdump(e, "Exception deregistering component with name " + + name + " with User " + ud); + } + } + } + + public Object getObject(ID obj) { + ISharedObjectContext crs = getContext(); + if (crs == null) + return null; + return crs.getSharedObjectManager().getSharedObject(obj); + } + + public void makeProxyObject(ID target, String proxyClass, String name) { + ID[] targets = new ID[1]; + targets[0] = target; + if (name == null) + name = proxyClass; + registerEclipseProxy((target == null), targets, proxyClass, name); + } + + public void memberAdded(ID member) { + if (sessionListener != null) { + sessionListener.memberAdded(member); + } + super.memberAdded(member); + sendNotifyUserAdded(); + } + + public void memberRemoved(final ID member) { + if (sessionListener != null) { + sessionListener.memberRemoved(member); + } + super.memberRemoved(member); + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) { + localGUI.removeUser(member); + } + } catch (Exception e) { + debugdump(e, + "Exception in showLineOnGUI"); + } + } + }); + } + + public void messageProxyObject(ID target, String classname, String meth, + Object[] args) { + SharedObjectMsg m = SharedObjectMsg.makeMsg(null, classname, meth, + (Object[]) args); + try { + forwardMsgTo(target, m); + if (target == null) { + sendSelf(m); + } + } catch (Exception e) { + debugdump(e, "Exception sending message to proxy object"); + } + } + + public void otherActivated(ID object) { + if (sessionListener != null) { + sessionListener.otherActivated(object); + } + super.otherActivated(object); + } + + public void otherDeactivated(ID object) { + if (sessionListener != null) { + sessionListener.otherDeactivated(object); + } + super.otherDeactivated(object); + } + + public void refreshProject() { + if (localProject != null) { + try { + localProject.refreshLocal(IResource.DEPTH_INFINITE, + new NullProgressMonitor()); + } catch (Exception e) { + debugdump(e, "Exception refreshing project " + + localProject.getName()); + } + } + } + + public void registerEclipseProxy(boolean localAlso, ID[] toReceivers, + String proxyClass, String name) { + // first, do it locally if this is what is desired + if (localAlso) { + try { + localRegisterProxy(localUser, proxyClass, name); + } catch (Exception e) { + debugdump(e, "Exception registering proxy class " + proxyClass + + " locally"); + throw new RuntimeException( + "registerEclipseProxy. Local registration failed", e); + } + } + // Now send register message to appropriate receiver(s). + if (toReceivers == null) + sendRegisterProxy(null, proxyClass, name); + else if (toReceivers.length == 1) + sendRegisterProxy(toReceivers[0], proxyClass, name); + else { + for (int i = 0; i < toReceivers.length; i++) { + try { + sendRegisterProxy(toReceivers[i], proxyClass, name); + } catch (Exception e) { + debugdump(e, "Exception sending register proxy message to " + + toReceivers[i]); + } + } + } + } + + public void removeProxyObject(ID target, String name) { + ID[] targets = new ID[1]; + targets[0] = target; + unregisterEclipseProxy((target == null), targets, name); + } + + // SharedObjectMsg senders + public void sendNotifyUserAdded() { + try { + forwardMsgTo(null, SharedObjectMsg.makeMsg(null, + "handleNotifyUserAdded", localUser)); + } catch (Exception e) { + debugdump(e, "Exception on sendNotifyUserAdded to remote clients"); + } + } + + public void sendPrivateMessageToUser(User touser, String msg) { + try { + forwardMsgTo(touser.getUserID(), SharedObjectMsg.makeMsg(null, + "handleShowPrivateTextMsg", localUser, msg)); + } catch (Exception e) { + debugdump(e, + "Exception on sendShowPrivateTextMsg to remote clients"); + } + } + + public void sendRegisterProxy(ID toID, String proxyClass, String name) { + try { + forwardMsgTo(toID, SharedObjectMsg.makeMsg(null, + "handleRegisterProxy", localUser, proxyClass, name)); + } catch (IOException e) { + debugdump(e, "Exception sendRegisterProxy"); + } + } + + public void sendRequestUserUpdate(ID requestTarget) { + try { + forwardMsgTo(requestTarget, SharedObjectMsg.makeMsg(null, + "handleRequestUserUpdate", getUniqueID())); + } catch (Exception e) { + debugdump(e, "Exception on sendRequestUserUpdate to remote clients"); + } + } + + public void sendCVSProjectUpdateRequest(User touser, String msg) { + ID receiver = null; + if (touser != null) { + receiver = touser.getUserID(); + } + try { + SharedObjectMsg m = SharedObjectMsg.makeMsg(null, + "handleCVSProjectUpdateRequest", getUser(), msg); + forwardMsgTo(receiver, m); + if (receiver == null) { + sendSelf(m); + } + } catch (Exception e) { + debugdump(e, "Exception on sendCVSProjectUpdateRequest to " + + touser); + } + } + + public boolean isCVSShared() { + try { + return CVSWorkspaceRoot.isSharedWithCVS(getProject()); + } catch (Exception e) { + ClientPlugin + .log( + "CVS Exception calling isSharedWithCVS in TeamUpdateAction", + e); + return false; + } + } + + protected void doCVSUpdateOperation(IProject proj, User fromUser) { + IResource[] resources = new IResource[1]; + resources[0] = proj; + try { + new UpdateOperation(getViewPart(), resources, + Command.NO_LOCAL_OPTIONS, null).run(); + } catch (InvocationTargetException e) { + ClientPlugin.log("Exception calling update operation from user " + + fromUser, e); + CVSUIPlugin.openError(Display.getDefault().getActiveShell(), null, + null, e); + } catch (InterruptedException e) { + } + } + + protected void handleCVSProjectUpdateRequest(final User fromUser, + final String msg) { + final IProject proj = getProject(); + // If project doesn't actually exist, just return silently + if (!proj.exists() || !isCVSShared()) + return; + doCVSUpdateOperation(proj, fromUser); + } + + public void sendRingMessageToUser(User user, String msg) { + ID receiver = null; + if (user != null) { + receiver = user.getUserID(); + } + try { + SharedObjectMsg m = SharedObjectMsg.makeMsg(null, + "handleUserMessage", this.localUser, msg); + forwardMsgTo(receiver, m); + if (receiver == null) + sendSelf(m); + } catch (Exception e) { + debugdump(e, "Exception on sendMessageToUser to " + user); + } + } + + public void sendShowTextMsg(String msg) { + try { + trace("sendShowTextMsg(" + msg + ")"); + forwardMsgTo(null, SharedObjectMsg.makeMsg(null, + "handleShowTextMsg", getUniqueID(), msg)); + } catch (Exception e) { + debugdump(e, "Exception on sendShowTextMsg to remote clients"); + } + } + + public void sendUnregisterProxy(ID toID, String proxyClass) { + try { + forwardMsgTo(toID, SharedObjectMsg.makeMsg(null, + "handleUnregisterProxy", localUser, proxyClass)); + } catch (IOException e) { + debugdump(e, "Exception sendRegisterProxy"); + } + } + + public void sendUpdateTreeDisplay(ID target, TreeItem item) { + try { + forwardMsgTo(target, SharedObjectMsg.makeMsg(null, + "handleUpdateTreeDisplay", getUniqueID(), item)); + } catch (Exception e) { + debugdump(e, "Exception on sendUpdateTreeDisplay to remote clients"); + } + } + + public void sendUserUpdate(ID target) { + try { + forwardMsgTo(target, SharedObjectMsg.makeMsg(null, + "handleUserUpdate", localUser)); + } catch (Exception e) { + debugdump(e, "Exception on sendUserUpdate to remote clients"); + } + } + + public void setListener(SharedObjectEventListener l) { + sessionListener = l; + } + + public void setServerID(ID server) { + serverID = server; + } + + public void setVersionString(String ver) { + localVersion = ver; + } + + public void setWindowTitle(String title) { + windowtitle = title; + synchronized (this) { + if (localGUI != null) { + localGUI.setTitle(title); + } + } + } + + public void show(final boolean show) { + if (localGUI != null) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + localGUI.setVisible(show); + localGUI.toFront(); + } + }); + } + } + + public void showLineOnGUI(final ID remote, final String line) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) + localGUI.showLine(remote, line); + } catch (Exception e) { + debugdump(e, + "Exception in showLineOnGUI"); + } + } + }); + } + + public void showRawLine(final ID sender, final String line) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) { + localGUI.showRawLine(sender, line); + } + } catch (Exception e) { + debugdump(e, + "Exception in showLineOnGUI"); + } + } + }); + } + + public void showView() { + try { + showView(CHAT_VIEW_ID); + } catch (Exception e) { + debugdump(e, "Exception showing view"); + } + } + + public void sendShowViewWithID(User touser, String id, String secID, + Integer mode) { + ID receiver = null; + if (touser != null) { + receiver = touser.getUserID(); + } + try { + SharedObjectMsg m = SharedObjectMsg.makeMsg(null, + "handleShowViewWithID", getUser(), id, secID, mode); + forwardMsgTo(receiver, m); + if (receiver == null) { + sendSelf(m); + } + } catch (Exception e) { + debugdump(e, "Exception on handleShowViewWithID to " + touser); + } + } + + public void sendShowView(User touser, String id) { + ID receiver = null; + if (touser != null) { + receiver = touser.getUserID(); + } + try { + SharedObjectMsg m = SharedObjectMsg.makeMsg(null, "handleShowView", + getUser(), id); + forwardMsgTo(receiver, m); + if (receiver == null) { + sendSelf(m); + } + } catch (Exception e) { + debugdump(e, "Exception on sendCVSProjectUpdateRequest to " + + touser); + } + } + + protected void handleShowViewWithID(User fromUser, final String id, + final String secID, final Integer mode) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + showViewWithID(id, secID, mode.intValue()); + } catch (Exception e) { + debugdump(e, "Exception in showing view id=" + id + + ";secID=" + secID + ";mode=" + mode); + } + } + }); + } + + protected void handleShowView(User fromUser, final String id) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + showView(id); + } catch (Exception e) { + debugdump(e, "Exception in showing view id=" + id); + } + } + }); + } + + protected IViewPart showViewWithID(String id, String secID, int mode) + throws PartInitException { + IWorkbenchWindow ww = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + IWorkbenchPage wp = ww.getActivePage(); + if (wp == null) + throw new NullPointerException("showViewWithID(" + id + ") " + + "workbench page is null"); + return wp.showView(id, secID, mode); + } + + protected IViewPart showView(String id) throws PartInitException { + IWorkbenchWindow ww = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + IWorkbenchPage wp = ww.getActivePage(); + if (wp == null) + throw new NullPointerException("showView(" + id + ") " + + "workbench page is null"); + return wp.showView(id); + } + + public void unregisterEclipseProxy(boolean localAlso, ID[] toReceivers, + String name) { + // first, do it locally if this is what is desired + if (localAlso) { + try { + localUnregisterProxy(getUser(), name); + } catch (Exception e) { + debugdump(e, "Exception deregistering " + name + " locally"); + throw new RuntimeException( + "deregisterEclipseProxy. Local deregistration failed", + e); + } + } + // Now send register message to appropriate receiver(s). + if (toReceivers == null) + sendUnregisterProxy(null, name); + else if (toReceivers.length == 1) + sendUnregisterProxy(toReceivers[0], name); + else { + for (int i = 0; i < toReceivers.length; i++) { + try { + sendUnregisterProxy(toReceivers[i], name); + } catch (Exception e) { + debugdump(e, "Exception sending register proxy message to " + + toReceivers[i]); + } + } + } + } + + public FileReceiverUI getFileReceiverUI(EclipseFileTransfer transfer, + FileTransferParams params) { + return new FileReceiverUI() { + public void receiveStart(ID from, File aFile, long length, + float rate) { + User user = getUserForID(from); + String nick = "<unknown>"; + if (user != null) { + nick = user.getNickname(); + } + showRawLine(from, "\t" + nick + " is sending you '" + + aFile.getName() + "'"); + } + + public void receiveData(ID from, File aFile, int dataLength) { + } + + public void receiveDone(ID from, File aFile, Exception e) { + User user = getUserForID(from); + String nick = "<unknown>"; + if (user != null) { + nick = user.getNickname(); + } + showRawLine(from, "\t'" + aFile.getName() + "' from " + nick + + " has arrived " + aFile.getAbsolutePath()); + refreshProject(); + } + }; + } + + public void updateTreeDisplay(final TreeItem item) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + if (localGUI != null) { + localGUI.updateTreeDisplay(getUniqueID(), item); + } + } catch (Exception e) { + debugdump(e, + "Exception in updateTreeDisplay"); + } + } + }); + // Send update message to all replicas + sendUpdateTreeDisplay(null, item); + } + + public ViewPart getViewPart() { + if (localGUI == null) + return null; + return localGUI.getView(); + } + + public Control getTreeControl() { + if (localGUI == null) + return null; + return localGUI.getTreeControl(); + } + + public Control getTextControl() { + if (localGUI == null) + return null; + return localGUI.getTextControl(); + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java new file mode 100644 index 000000000..ccf0feafe --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseMessage.java @@ -0,0 +1,92 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.SharedObjectInitException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.Trace; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; + + +public class EclipseMessage extends GenericSharedObject { + + public static final Trace trace = Trace.create("eclipsemessagesharedobject"); + + String message; + String sender; + + public EclipseMessage() { + sender = "<unknown>"; + message = " says hello"; + } + public EclipseMessage(String message, String sender) { + this.message = message; + this.sender = sender; + } + protected void trace(String msg) { + if (Trace.ON && trace != null) { + trace.msg(msg); + } + } + protected void traceDump(String msg, Throwable e) { + if (Trace.ON && trace != null) { + trace.dumpStack(e,msg); + } + } + public void init(ISharedObjectConfig config) throws SharedObjectInitException { + super.init(config); + Map aMap = config.getProperties(); + Object [] args = (Object []) aMap.get("args"); + if (args != null && args.length == 2) { + this.message = (String) args[0]; + this.sender = (String) args[1]; + } + } + public void activated(ID[] others) { + // Note: be sure to call super.activated first so + // replication gets done + super.activated(others); + showMessage(message, sender); + } + protected SharedObjectDescription getReplicaDescription(ID remoteID) { + Object[] remoteArgs = { message, sender }; + HashMap map = new HashMap(); + map.put("args",remoteArgs); + return new SharedObjectDescription( + getHomeContainerID(), + getClass().getName(),map, + replicateID++); + } + protected void showMessage(final String message, final String sender) { + final String msg = sender + " says '" + message + "'"; + try { + Display.getDefault().syncExec(new Runnable() { + public void run() { + Display.getDefault().beep(); + MessageDialog.openInformation( + null, + "Message from " + sender, + msg); + } + }); + } catch (Exception e) { + traceDump("Exception showing message dialog ",e); + } + destroySelf(); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java new file mode 100644 index 000000000..c5b3c5245 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProject.java @@ -0,0 +1,50 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import org.eclipse.core.resources.IProject; +import org.eclipse.ecf.core.ISharedObjectContext; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.part.ViewPart; + + +/** + * Interface describing access to the Eclipse project that is associated + * with a given collaboration group. + * + * @author slewis + */ +public interface EclipseProject { + + public ID getID(); + + public IProject getProject(); + public IWorkbenchWindow getWorkbenchWindow(); + + public ISharedObjectContext getContext(); + + public void makeProxyObject(ID target,String classname,String name); + public void messageProxyObject(ID target, String name, String meth, Object [] args); + public void removeProxyObject(ID target,String name); + + public User getUser(); + public User getUserForID(ID user); + public void sendPrivateMessageToUser(User touser, String msg); + public void sendShowTextMsg(String msg); + + public ViewPart getViewPart(); + public Control getTreeControl(); + public Control getTextControl(); + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProjectComponent.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProjectComponent.java new file mode 100644 index 000000000..4930165a2 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/EclipseProjectComponent.java @@ -0,0 +1,60 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + + +/* + * Interface contract for dynamic component registration/ + * deregistration with a Eclipse Project and it's associated + * group. + * + * @author slewis + */ +public interface EclipseProjectComponent { + + public static final String INVOKE_METHOD_NAME = "invoke"; + + /** + * Method called when this component is instantiated and + * registered with the associated EclipseProject. Component implementers + * may override this method in order to initialize, setup ui for + * this component, or perform some other component startup functions + * + * @param obj + * @param requestor + * @throws Exception + */ + public void register(EclipseProject obj, User requestor) + throws Exception; + + /** + * This method is invoked when a message is sent to the given + * component + * + * @param meth + * @param args + * @return + */ + public Object invoke(String meth, Object[] args); + + /** + * Method called when this component is removed from the + * associated EclipseProject. Component implementers + * may override this method in order to cleanup during component shutdown + * + * @param obj + * @param requestor + * @throws Exception + */ + public void deregister(EclipseProject obj); + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java new file mode 100644 index 000000000..2ddbef2bc --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/GenericSharedObject.java @@ -0,0 +1,517 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.io.IOException; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.Map; +import java.util.Random; +import org.eclipse.ecf.core.ISharedObject; +import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.ISharedObjectContainerTransaction; +import org.eclipse.ecf.core.ISharedObjectContext; +import org.eclipse.ecf.core.ISharedObjectManager; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.SharedObjectInitException; +import org.eclipse.ecf.core.events.ISharedObjectActivatedEvent; +import org.eclipse.ecf.core.events.ISharedObjectContainerDepartedEvent; +import org.eclipse.ecf.core.events.ISharedObjectContainerJoinedEvent; +import org.eclipse.ecf.core.events.ISharedObjectCreateResponseEvent; +import org.eclipse.ecf.core.events.ISharedObjectDeactivatedEvent; +import org.eclipse.ecf.core.events.ISharedObjectMessageEvent; +import org.eclipse.ecf.core.events.RemoteSharedObjectEvent; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.core.util.Event; +import org.eclipse.ecf.core.util.QueueEnqueue; +import org.eclipse.ecf.core.util.QueueException; +import org.eclipse.ecf.example.collab.Trace; + +/** + * @author slewis + * + */ +public class GenericSharedObject implements ISharedObject { + protected static final class MsgMap { + String meth; + Object obj; + + MsgMap(Object o, String m) { + obj = o; + meth = m; + } + + public Object getObject() { + return obj; + } + } + + protected static long replicateID = 0; + ISharedObjectConfig config; + protected SharedObjectMsg currentMsg; + protected ID currentMsgFromContainerID; + protected ID currentMsgFromObjID; + protected Hashtable msgMap; + protected Object msgMapLock = new Object(); + static final Trace trace = Trace.create("genericsharedobject"); + + ID localContainerID; + + public void activated(ID[] ids) { + trace("activated(" + Arrays.asList(ids) + ")"); + if (isHost()) { + replicate(null); + } + } + + public void deactivated() { + trace("deactivated()"); + } + + public void destroyRemote(ID remoteID) throws IOException { + ISharedObjectContext context = getContext(); + if (context != null) { + context.sendDispose(remoteID); + } + } + + public void destroySelf() { + if (isHost()) { + try { + // Send destroy message to all known remotes + destroyRemote(null); + } catch (IOException e) { + traceDump("Exception sending destroy message to remotes", e); + } + } + destroySelfLocal(); + } + + public void destroySelfLocal() { + try { + ISharedObjectConfig config = getConfig(); + if (config != null) { + ID myID = config.getSharedObjectID(); + ISharedObjectContext context = getContext(); + if (context != null) { + ISharedObjectManager manager = context.getSharedObjectManager(); + if (manager != null) { + manager.removeSharedObject(myID); + } + } + } + } catch (Exception e) { + traceDump("Exception in destroySelfLocal()",e); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#dispose(org.eclipse.ecf.core.identity.ID) + */ + public void dispose(ID containerID) { + config = null; + } + + protected void execMsg(ID fromID, SharedObjectMsg msg) { + try { + MsgMap m = null; + synchronized (msgMapLock) { + m = (MsgMap) ((msgMap == null) ? null : (msgMap.get(msg + .getMethodName()))); + } + Object o = this; + String methName = null; + if (m != null) { + if (m.obj != null) { + o = m.obj; + } + if (m.meth != null) { + methName = m.meth; + } + } + trace("execMsg(" + fromID + "," + msg + ")"); + trace(" msg method=" + msg.getMethodName()); + trace(" proxy msg=" + methName); + trace(" o=" + o); + if (methName != null) { + msg = SharedObjectMsg.makeMsg(msg.getClassName(), methName, msg + .getArgs()); + } + if (currentMsgFromObjID == null) + currentMsgFromObjID = getID(); + currentMsgFromContainerID = fromID; + currentMsg = msg; + // Actually invoke msg on given object. Typically will be 'this'. + execMsgInvoke(msg, currentMsgFromObjID, o); + currentMsg = null; + currentMsgFromContainerID = null; + } catch (Throwable e) { + msgException(this, msg, e); + } + } + + protected void execMsgInvoke(SharedObjectMsg msg, ID fromID, Object o) + throws Exception { + try { + msg.invoke(o); + } catch (NoSuchMethodException e) { + msg.invokeFrom(fromID, o); + } + } + + protected void forwardMsgHome(SharedObjectMsg msg) throws IOException { + forwardMsgTo(config.getHomeContainerID(), msg); + } + + protected void forwardMsgTo(ID toID, SharedObjectMsg msg) + throws IOException { + ISharedObjectContext context = getContext(); + if (context != null) { + context.sendMessage(toID, new RemoteSharedObjectMsgEvent(getID(), toID, + msg)); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#getAdapter(java.lang.Class) + */ + public Object getAdapter(Class clazz) { + return null; + } + + public ISharedObjectContext getContext() { + ISharedObjectConfig config = getConfig(); + if (config != null) return config.getContext(); + else return null; + } + + public ISharedObjectConfig getConfig() { + return config; + } + protected ID getHomeContainerID() { + ISharedObjectConfig config = getConfig(); + if (config != null) { + return config.getHomeContainerID(); + } else return null; + } + + public ID getID() { + ISharedObjectConfig config = getConfig(); + if (config != null) { + return config.getSharedObjectID(); + } else return null; + } + + protected long getIdentifier() { + return replicateID++; + } + + public ID getLocalContainerID() { + return localContainerID; + } + + protected SharedObjectDescription getReplicaDescription(ID receiver) { + ISharedObjectConfig config = getConfig(); + if (config != null) { + return new SharedObjectDescription(getID(), getClass().getName(), + config.getProperties(), replicateID++); + } else return null; + } + + protected void handleCreateResponse(ID fromID, Throwable t, Long identifier) { + trace("got create response " + fromID + " e=" + t + " id=" + identifier); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#handleEvent(org.eclipse.ecf.core.util.Event) + */ +public void handleEvent(Event event) { + trace("handleEvent("+event+")"); + if (event instanceof ISharedObjectActivatedEvent) { + ISharedObjectActivatedEvent ae = (ISharedObjectActivatedEvent) event; + ID myID = getID(); + if (myID == null) return; + if (myID.equals(ae.getActivatedID())) { + activated(ae.getGroupMemberIDs()); + } else { + otherActivated(ae.getActivatedID()); + } + } else if (event instanceof ISharedObjectDeactivatedEvent) { + ISharedObjectDeactivatedEvent ae = (ISharedObjectDeactivatedEvent) event; + ID myID = getID(); + if (myID == null) return; + if (myID.equals(ae.getDeactivatedID())) { + deactivated(); + } else { + otherDeactivated(ae.getDeactivatedID()); + } + } else if (event instanceof ISharedObjectContainerJoinedEvent) { + memberAdded(((ISharedObjectContainerJoinedEvent)event).getJoinedContainerID()); + } else if (event instanceof ISharedObjectContainerDepartedEvent) { + memberRemoved(((ISharedObjectContainerDepartedEvent)event).getDepartedContainerID()); + } else if (event instanceof ISharedObjectMessageEvent) { + handleSharedObjectMessageEvent(((ISharedObjectMessageEvent)event)); + } else { + System.err.println("Got unexpected event: "+event); + trace("Got unexpected event: "+event); + } + } + protected void handleSharedObjectMessageEvent( + ISharedObjectMessageEvent event) { + if (event instanceof RemoteSharedObjectEvent) { + if (event instanceof ISharedObjectCreateResponseEvent) { + handleCreateResponseMessageEvent((ISharedObjectCreateResponseEvent) event); + } else if (event instanceof RemoteSharedObjectMsgEvent) { + handleSelfSendMessageEvent((RemoteSharedObjectMsgEvent) event); + } else { + RemoteSharedObjectMsgEvent me = (RemoteSharedObjectMsgEvent) event + .getData(); + SharedObjectMsg msg = me.getMsg(); + execMsg(me.getRemoteContainerID(), msg); + } + } else { + System.err.println("Got unexpected ISharedObjectMessageEvent: " + + event); + trace("Got unexpected ISharedObjectMessageEvent: " + event); + } + } + protected void handleSelfSendMessageEvent(RemoteSharedObjectMsgEvent event) { + trace("handleSelfSendMessageEvent("+event+")"); + execMsg(event.getRemoteContainerID(),event.getMsg()); + } + protected void handleCreateResponseMessageEvent(ISharedObjectCreateResponseEvent event) { + trace("handleCreateResponseMessageEvent("+event+")"); + handleCreateResponse(event.getRemoteContainerID(),event.getException(),new Long(event.getSequence())); + } + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#handleEvents(org.eclipse.ecf.core.util.Event[]) + */ + public void handleEvents(Event[] events) { + for (int i = 0; i < events.length; i++) { + handleEvent(events[i]); + } + } + + public void handleRemoteData(ID spaceID, Serializable msg) { + SharedObjectMsg aMsg = (SharedObjectMsg) msg; + if (isReplicaMsgAllowed(spaceID, aMsg) != null) { + execMsg(spaceID, aMsg); + } else { + ignoreReplicaMsg(spaceID, aMsg); + } + } + + protected void ignoreReplicaMsg(ID fromID, SharedObjectMsg msg) { + // Do nothing + trace("IGNORED msg from " + fromID + ": " + msg + " "); + } + + protected void ignoreSharedObjectMsg(ID fromID, SharedObjectMsg aMsg) { + // Do nothing + trace("ignored message from " + fromID + ": " + aMsg); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.ISharedObject#init(org.eclipse.ecf.core.ISharedObjectConfig) + */ + public void init(ISharedObjectConfig initData) + throws SharedObjectInitException { + this.config = initData; + localContainerID = getContext().getLocalContainerID(); + } + + public boolean isHost() { + ID homeContainerID = getHomeContainerID(); + if (homeContainerID == null) return false; + else return (homeContainerID.equals(getLocalContainerID())); + } + + protected Object isMsgAllowed(ID fromID, SharedObjectMsg aMsg) { + return this; + } + + protected Object isReplicaMsgAllowed(ID fromID, SharedObjectMsg aMsg) { + return this; + } + + public boolean isServer() { + ISharedObjectContext context = getContext(); + if (context != null) { + return getContext().isGroupServer(); + } else return false; + } + + public void memberAdded(ID member) { + trace("memberAdded(" + member + ")"); + if (isHost()) { + replicate(member); + } + } + + public void memberRemoved(ID member) { + trace("memberRemoved(" + member + ")"); + } + + public void msgException(Object target, SharedObjectMsg aMsg, Throwable e) { + trace("msgException(" + getID() + "," + aMsg + "," + e + ")"); + if (e != null) { + e.printStackTrace(System.err); + } + } + + public void otherActivated(ID member) { + trace("otherActivated(" + member + ")"); + } + + public void otherDeactivated(ID member) { + trace("otherDeactivated(" + member + ")"); + } + + public void registerProxy(Object object, String msg) { + registerProxy(object, msg, null); + } + + protected void registerProxy(Object object, String msg, String method) { + if (msg == null || object == null) + throw new NullPointerException( + "registerProxy: params cannot be null"); + synchronized (msgMapLock) { + // Create table lazily + if (msgMap == null) + msgMap = new Hashtable(); + else if (msgMap.containsKey(msg)) + throw new IllegalArgumentException( + "registerProxy: proxy already registered for " + + method + " by " + object); + // Then put entry into table with msg as key + msgMap.put(msg, new MsgMap(object, method)); + } + } + + protected void replicate(ID remote) { + trace("replicate(" + remote + ")"); + try { + // Get current group membership + ISharedObjectContext context = getContext(); + if (context == null) return; + ID[] group = context.getGroupMemberIDs(); + if (group == null || group.length < 1) { + // we're done + return; + } + SharedObjectDescription createInfo = getReplicaDescription(remote); + if (createInfo != null) { + context.sendCreate(remote, createInfo); + } else { + return; + } + } catch (IOException e) { + traceDump("Exception in replicate", e); + return; + } + } + + protected void sendSelf(SharedObjectMsg msg) { + ISharedObjectContext context = getContext(); + if (context == null) return; + QueueEnqueue queue = context.getQueue(); + try { + queue.enqueue(new RemoteSharedObjectMsgEvent(getID(), getContext() + .getLocalContainerID(), msg)); + } catch (QueueException e) { + traceDump("QueueException enqueing message to self", e); + return; + } + } + + public void sharedObjectMsg(ID fromID, SharedObjectMsg msg) { + if (isMsgAllowed(fromID, msg) != null) { + currentMsgFromObjID = fromID; + execMsg(getLocalContainerID(), msg); + currentMsgFromObjID = null; + } else { + ignoreSharedObjectMsg(fromID, msg); + } + } + + protected void trace(String msg) { + if (Trace.ON && trace != null) { + trace.msg(msg); + } + } + + protected void traceDump(String msg, Throwable t) { + if (Trace.ON && trace != null) { + trace.dumpStack(t, msg); + } + } + + public ID makeObject(ID target, String className, Map map) throws Exception { + ISharedObjectContext crs = getContext(); + ID newID = IDFactory.makeStringID(getNewUniqueIDString()); + if (crs == null) { + throw new InstantiationException( + "Cannot make object. Have no local creation capability because context is null"); + } else { + if (className != null && !className.equals("")) { + trace("Creating new replicated object with class: " + className); + if (target == null) { + try { + Class clazz = Class.forName(className); + Object inst = clazz.newInstance(); + if (!(inst instanceof ISharedObject)) { + throw new InstantiationException("Exception creating instance of class: "+className+". Does not implement ISharedObject"); + } + if (inst instanceof ISharedObjectContainerTransaction) { + crs.getSharedObjectManager().addSharedObject(newID,(ISharedObject) inst,map,(ISharedObjectContainerTransaction)inst); + } else { + SharedObjectDescription sd = new SharedObjectDescription(newID + , + className, map); + crs.getSharedObjectManager() + .createSharedObject(sd, null); + } + } catch (Exception e) { + traceDump("Exception creating replicated object.", e); + throw e; + } + } else { + throw new Exception( + "Server hasn't given permission for this operation"); + } + // Success + return newID; + } else { + trace("Invalid classname '" + className + + "'. Cannot make object."); + throw new InstantiationException("Invalid classname '" + + className); + } + } + } + + public String getNewUniqueIDString() { + return String.valueOf((new Random()).nextLong()); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/RemoteSharedObjectMsgEvent.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/RemoteSharedObjectMsgEvent.java new file mode 100644 index 000000000..ad831f157 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/RemoteSharedObjectMsgEvent.java @@ -0,0 +1,40 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import org.eclipse.ecf.core.events.RemoteSharedObjectEvent; +import org.eclipse.ecf.core.identity.ID; + +/** + * + */ +public class RemoteSharedObjectMsgEvent extends RemoteSharedObjectEvent { + /** + * @param senderObj + * @param remoteCont + * @param data + */ + public RemoteSharedObjectMsgEvent(ID senderObj, ID remoteCont, SharedObjectMsg msg) { + super(senderObj, remoteCont, msg); + } + + public SharedObjectMsg getMsg() { + return (SharedObjectMsg) super.getData(); + } + + public String toString() { + StringBuffer buf = new StringBuffer("RemoteSharedObjectMsgEvent["); + buf.append(getSenderSharedObjectID()).append(";").append(getRemoteContainerID()).append(";").append(getMsg()); + buf.append("]"); + return buf.toString(); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SenderID.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SenderID.java new file mode 100644 index 000000000..a0d69a9d8 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SenderID.java @@ -0,0 +1,28 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import org.eclipse.ecf.core.identity.ID; + +public final class SenderID { + + private ID myID; + + // No instances other than ones created in SharedObjectMsg.invokeFrom/2 + protected SenderID(ID theID) { + myID = theID; + } + + public ID getID() { + return myID; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SharedObjectEventListener.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SharedObjectEventListener.java new file mode 100644 index 000000000..b4c20e406 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SharedObjectEventListener.java @@ -0,0 +1,25 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import org.eclipse.ecf.core.identity.ID; + +public interface SharedObjectEventListener { + + public void memberRemoved(ID member); + public void memberAdded(ID member); + public void otherActivated(ID other); + public void otherDeactivated(ID other); + + public void windowClosing(); + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SharedObjectMsg.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SharedObjectMsg.java new file mode 100644 index 000000000..1cea43468 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/SharedObjectMsg.java @@ -0,0 +1,377 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.io.NotSerializableException; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import org.eclipse.ecf.core.identity.ID; + +public class SharedObjectMsg implements Serializable { + static final long serialVersionUID = 571132189626558278L; + public static final Object[] nullArgs = new Object[0]; + public static final Class[] nullTypes = new Class[0]; + + // Static factory methods for creating SharedObjectMsg instances + public static SharedObjectMsg makeMsg(String className, String methodName, + Object[] param) { + if (methodName == null || param == null) { + throw new NullPointerException( + "Invalid SharedObjectMsg construction"); + } + return new SharedObjectMsg(className, methodName, param); + } + + public static SharedObjectMsg makeMsg(String methodName, Object[] param) { + return makeMsg((String) null, methodName, param); + } + + public static SharedObjectMsg makeMsg(String methodName) { + return makeMsg((String) null, methodName, nullArgs); + } + + public static SharedObjectMsg makeMsg(String className, String methodName) { + return makeMsg(className, methodName, nullArgs); + } + + public static SharedObjectMsg makeMsg(String className, String methodName, + Object arg) { + Object args[] = { arg }; + return makeMsg(className, methodName, args); + } + + public static SharedObjectMsg makeMsg(String methodName, Object arg) { + return makeMsg((String) null, methodName, arg); + } + + public static SharedObjectMsg makeMsg(String className, String methodName, + Object arg1, Object arg2) { + Object args[] = { arg1, arg2 }; + return makeMsg(className, methodName, args); + } + + public static SharedObjectMsg makeMsg(String className, String methodName, + Object arg1, Object arg2, Object arg3) { + Object args[] = { arg1, arg2, arg3 }; + return makeMsg(className, methodName, args); + } + + public static SharedObjectMsg makeMsg(String className, String methodName, + Object arg1, Object arg2, Object arg3, Object arg4) { + Object args[] = { arg1, arg2, arg3, arg4 }; + return makeMsg(className, methodName, args); + } + + public static SharedObjectMsg makeMsg(String className, String methodName, + Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) { + Object args[] = { arg1, arg2, arg3, arg4, arg5 }; + return makeMsg(className, methodName, args); + } + + /** + * Utility for getting a Class instance from a String class name. Calls + * Class.forName(). + * + * @param loader + * the ClassLoader to use to load the given class + * @param name + * of Class to load + * @return Class instance found. If not found, a ClassNotFoundException is + * thrown + * @exception ClassNotFoundException + * thrown if specified class is not found + */ + public static Class getClass(ClassLoader loader, String name) + throws ClassNotFoundException { + if (name == null) + return null; + return Class.forName(name, true, loader); + } + + /** + * Get name for given class. + * + * @param clazz + * the Class to retrieve the name from + * @return String name of given class + */ + public static String getName(Class clazz) { + return clazz.getName(); + } + + /** + * Get array of argument types from array of objects + * + * @param args[] + * the arguments to get types for + * @return Class[] of types for objects in given Object array + */ + public static Class[] getArgTypes(Object args[]) { + Class argTypes[] = null; + if (args == null || args.length == 0) + argTypes = nullTypes; + else { + argTypes = new Class[args.length]; + for (int i = 0; i < args.length; i++) { + if (args[i] == null) + argTypes[i] = null; + else + argTypes[i] = args[i].getClass(); + } + } + return argTypes; + } + + /** + * Find a Method instance on given class. This method searches for a method + * on the given class (first parameter), of the given name (second + * parameter), and of arity defined by the third parameter. Calls + * searchForMethod to actually do the searching. + * + * @param clazz + * the Class to look on + * @param meth + * the method name to look for + * @param args + * the arguments that will be passed to the method on the invoke + * call + * @return Method instance found on given class. Null if none found. + */ + static Method findMethod(final Class clazz, String meth, Class args[]) { + Method methods[] = null; + try { + methods = (Method[]) AccessController + .doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return clazz.getDeclaredMethods(); + } + }); + } catch (PrivilegedActionException e) { + return null; + } + return searchForMethod(methods, meth, args); + } + + public static Method searchForMethod(Method meths[], String meth, + Class args[]) { + // Find it from among the given set of Method objects + for (int i = 0; i < meths.length; i++) { + Method test = meths[i]; + if (test.getName().equals(meth)) { + if (test.getParameterTypes().length == args.length) + return test; + } + } + return null; + } + + /** + * Find a Method instance on given class, and recursively search the class' + * superclass tree for given method. + * + * @param clazz + * the Class to look upon + * @param meth + * the String name of the method to look for + * @param args + * the array of Object arguments that will be passed to the + * method for execution + * @return Method instance if found, null if not found + */ + public static Method findMethodRecursive(Class clazz, String meth, + Class args[]) { + Method aMethod = findMethod(clazz, meth, args); + if (aMethod == null) { + Class superclazz = clazz.getSuperclass(); + if (superclazz != null) + return findMethodRecursive(superclazz, meth, args); + else + return null; + } else { + return aMethod; + } + } + + /** + * Check a given msg to verify that all Objects in args array implement the + * Serializable interface. + * + * @param aMsg + * the Message to check + * @exception NotSerializableException + * thrown if any objects in args array do not implement the + * Serializable interface + */ + public static void checkForSerializable(SharedObjectMsg aMsg) + throws NotSerializableException { + Object args[] = aMsg.getArgs(); + for (int i = 0; i < args.length; i++) { + if (args[i] != null && !(args[i] instanceof Serializable)) + throw new NotSerializableException("Parameter " + i + + " not Serializable"); + } + } + + // Instance fields + /** + * @serial myClassName the class name for the message + */ + String myClassName; + /** + * @serial myMethodName the method name of the message + */ + String myMethodName; + /** + * @serial myArgs arguments + */ + Object[] myArgs; + + // Constructor + SharedObjectMsg(String className, String methodName, Object[] args) { + myClassName = className; + myMethodName = methodName; + myArgs = args; + } + + /** + * Constructor for TypedMsg's. + */ + SharedObjectMsg(String methodName) { + this(null, methodName, null); + } + + public final String getMethodName() { + return myMethodName; + } + + public final void setMethodName(String name) { + checkAlterMsg(); + if (name == null) + throw new NullPointerException("methodname cannot be null"); + myMethodName = name; + } + + /** + * Check if it is permitted to alter the state of this message (args, class + * name, method name). Default: NOP; subclasses should override as + * appropriate. To disallow, throw a java.lang.RuntimeException. + */ + protected void checkAlterMsg() { + // NOP; subclasses should override as appropriate + } + + public final String getClassName() { + return myClassName; + } + + public final void setClassName(String name) { + checkAlterMsg(); + myClassName = name; + } + + public Object[] getArgs() // TypedMsg overrides + { + return myArgs; + } + + public final void setArgs(Object[] args) { + checkAlterMsg(); + myArgs = (args == null) ? nullArgs : args; + } + + protected Class[] getArgTypes() { + return getArgTypes(getArgs()); + } + + protected final Method findMethod(Class clazz) { + return findMethod(clazz, getMethodName(), getArgTypes()); + } + + protected final Method findMethodRecursive(Class clazz) { + return findMethodRecursive(clazz, getMethodName(), getArgTypes()); + } + + public final Object invoke(Object target) throws Exception { + return doInvoke(target); + } + + Object doInvoke(final Object target) // package scope for security + throws Exception { + if (target == null) + throw new NoSuchMethodException("Null target"); + Method meth = null; + if (myClassName == null) { + // If not specific class is specified by SharedObjectMsg instance, + // then use the target's class + meth = findMethodRecursive(target.getClass()); + } else { + // If it is specified, then load the specified class, using the + // target object's classloader + meth = findMethod(getClass(target.getClass().getClassLoader(), + myClassName)); + } + // If no method was found, then throw + if (meth == null) + throw new NoSuchMethodException(getMethodName()); + final Method toCall = meth; + // Make priveleged call to set the method as accessible + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + if (!toCall.isAccessible()) + toCall.setAccessible(true); + return null; + } + }); + // Actually invoke method + return toCall.invoke(target, getArgs()); + } + + public final Object invokeFrom(ID fromID, final Object target) + throws Exception { + // Setup new array of arguments with the fromID on the front + Object[] newParams = null; + SenderID sender = new SenderID(fromID); + Object args[] = getArgs(); + if (args == null) { + newParams = new Object[1]; + newParams[0] = sender; + } else { + newParams = new Object[myArgs.length + 1]; + newParams[0] = sender; + System.arraycopy(args, 0, newParams, 1, args.length); + } + // Reset arguments before method search + myArgs = newParams; + // Now just call invoke/1 + return invoke(target); + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("SharedObjectMsg[").append(myClassName).append(":").append( + myMethodName).append("("); + if (myArgs == null) { + sb.append(myArgs); + } else { + for (int i = 0; i < myArgs.length; i++) { + if (i > 0) + sb.append(","); + sb.append(myArgs[i]); + } + } + sb.append(")]"); + return sb.toString(); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TestEclipseSessionComponent.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TestEclipseSessionComponent.java new file mode 100644 index 000000000..17c9e1819 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TestEclipseSessionComponent.java @@ -0,0 +1,67 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; + +public class TestEclipseSessionComponent implements EclipseProjectComponent { + EclipseProject repobj = null; + User requestor = null; + + public TestEclipseSessionComponent() { + super(); + } + + public Object invoke(String meth, Object[] args) { + String argStr = ""; + if (args != null) { + for (int i = 0; i < args.length; i++) { + argStr = argStr + "\t\t" + args[i].toString() + "\n"; + } + } + showMsg("EclipseProjectComponent " + this.getClass().getName() + + " invoke", "Method: '" + meth + "' \n\tArgs:\n" + argStr); + return null; + } + + public void register(EclipseProject obj, final User requestor) + throws Exception { + this.repobj = obj; + this.requestor = requestor; + showMsg("Registration request from " + requestor.getNickname() + + ". ID: " + requestor.getUserID(), + "EclipseProjectComponent '" + this.getClass().getName() + + "' registered"); + } + + public void showMessage(String msg) { + showMsg("EclipseProjectComponent Message", msg); + } + + protected void showMsg(final String title, final String msg) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, title, msg); + } + }); + } + + public void deregister(EclipseProject obj) { + showMsg("Deregistration request from " + requestor.getNickname() + + ". ID: " + requestor.getUserID(), + "EclipseProjectComponent '" + this.getClass().getName() + + "' deregistered"); + repobj = null; + requestor = null; + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TransactionSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TransactionSharedObject.java new file mode 100644 index 000000000..0dcaf377f --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TransactionSharedObject.java @@ -0,0 +1,292 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.util.Hashtable; +import java.util.Vector; + +import org.eclipse.ecf.core.ISharedObjectContainerTransaction; +import org.eclipse.ecf.core.SharedObjectAddAbortException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.Trace; + +public class TransactionSharedObject extends GenericSharedObject implements ISharedObjectContainerTransaction { + + static Trace trace = Trace.create("transactionsharedobject"); + + // If the "replicaCommit" method name is changed, the name of this variable should + // change + public static final String REPLICA_COMMIT_METHOD = "replicaCommit"; + + public static int DEFAULT_TIMEOUT = 30000; + // Dummy inner class to provide lock + static final class Lock {} + + // Timeout value associated with this object's replication within a RepSpace + protected int timeout; + // Replication state this object is currently in. + protected byte state; + // A lock variable + protected Lock lock; + protected Vector participantIDs; + protected Hashtable failedParticipants; + + public TransactionSharedObject(int timeout) + { + this.timeout = timeout; + init(); + } + public TransactionSharedObject() + { + this(DEFAULT_TIMEOUT); + } + + protected void traceDump(String msg, Throwable t) { + if (Trace.ON && trace != null) { + trace.dumpStack(t, msg); + } + } + protected void init() + { + state = ISharedObjectContainerTransaction.ACTIVE; + lock = new Lock(); + participantIDs = new Vector(); + failedParticipants = new Hashtable(); + trace("TransactionSharedObject.init() with timeout: "+timeout); + } + public void activated(ID [] others) + { + if (Trace.ON && trace != null) { + trace.msg("activated() on "+getID()); + } + // No other state changes while this is going on + synchronized (lock) { + if (isHost()) { + replicate(null); + addRemoteParticipants(getContext().getGroupMemberIDs()); + state = ISharedObjectContainerTransaction.VOTING; + // Clients + } else { + try { + // Try to respond with create success message back to host + getContext().sendCreateResponse(getHomeContainerID(), null, getIdentifier()); + // If above succeeds, we're now in prepared state + state = ISharedObjectContainerTransaction.PREPARED; + } catch (Exception e) { + // If throws exception, we're doomed + state = ISharedObjectContainerTransaction.ABORTED; + traceDump("unable to send create response to "+getHomeContainerID(),e); + } + } + // Notify any threads waiting on state change + lock.notifyAll(); + } + } + + public void memberAdded(ID member) + { + if (isHost()) { + // If we are currently in VOTING state, then add the new member to list of participants + // and send replicate message. If not in voting state, just send replicate message + synchronized (lock) { + replicate(member); + if (getTransactionState() == ISharedObjectContainerTransaction.VOTING) addRemoteParticipants(new ID[] { member}); + else replicate(member); + } + } + } + + protected void addRemoteParticipants(ID ids[]) + { + if (ids != null && participantIDs != null) { + for(int i=0; i < ids.length; i++) { + if (!getHomeContainerID().equals(ids[i])) participantIDs.addElement(ids[i]); + } + } + + } + + protected void removeRemoteParticipant(ID id) + { + if (id != null && participantIDs != null) { + int index = participantIDs.indexOf(id); + if (index != -1) participantIDs.removeElementAt(index); + } + } + + protected void addRemoteParticipantFailed(ID remote, Throwable failure) + { + if (remote != null && failure != null && failedParticipants != null) { + failedParticipants.put(remote, failure); + } + } + public void handleCreateResponse(ID fromID, Throwable e, Long identifier) + { + // If no exception, remove + synchronized (lock) { + if (state == ISharedObjectContainerTransaction.VOTING) { + if (e == null) { + removeRemoteParticipant(fromID); + } else { + addRemoteParticipantFailed(fromID, e); + } + } else { + handleVotingCompletedCreateResponse(fromID, e, identifier); + } + lock.notifyAll(); + } + } + + protected void handleVotingCompletedCreateResponse(ID fromID, Throwable e, Long identifier) + { + // If remote creation was successful, simply send commit message back. + if (e == null) { + // send commit message right back. + try { + forwardMsgTo(fromID, SharedObjectMsg.makeMsg((String) null,REPLICA_COMMIT_METHOD)); + } catch (Exception except) { + traceDump("Exception sending commit message to "+fromID,except); + } + } + } + + public void memberRemoved(ID member) + { + // We only care about this if we are the host. + if (isHost()) { + synchronized (lock) { + if (state == ISharedObjectContainerTransaction.VOTING) { + addRemoteParticipantFailed(member, new Exception("Member "+member+" left")); + } + lock.notifyAll(); + } + } + } + public void waitToCommit() throws SharedObjectAddAbortException + { + synchronized (lock) { + long end = System.currentTimeMillis() + timeout; + try { + while (!votingCompleted()) { + long wait = end - System.currentTimeMillis(); + trace("waitForFinish waiting "+wait+"ms on "+getID()); + if (wait <= 0L) throw new SharedObjectAddAbortException("Timeout waiting for create responses"); + // Actually wait right here + lock.wait(wait); + } + } catch (InterruptedException e) { + throw new SharedObjectAddAbortException("Wait interrupted"); + } catch (SharedObjectAddAbortException e1) { + // Aborted for some reason. Clean up. + doAbort(e1); + } + // Success. Send commit to remotes and clean up before returning. + doCommit(); + } + } + + public byte getTransactionState() + { + synchronized (lock) { + return state; + } + } + + protected void doAbort(SharedObjectAddAbortException e) throws SharedObjectAddAbortException + { + trace("doAbort(). Commit ABORTED on "+getID()+" with exception "+e); + // Send destroy message here so all remotes get destroyed, and we remove + // ourselves from local space as well. + destroySelf(); + // Set our own state variable to ABORTED + state = ISharedObjectContainerTransaction.ABORTED; + // throw so caller gets exception and can deal with it + throw e; + } + + public void doCommit() throws SharedObjectAddAbortException + { + // Get current membership + int others = 0; + others = getContext().getGroupMemberIDs().length; + // Only forward commit message if the participantIDs array is not yet null, + // and the current membership is > 0 (we're connected to something) + if (participantIDs != null && others > 0) { + // Send replicaCommit message to all remote clients + try { + forwardMsgTo(null, SharedObjectMsg.makeMsg((String) null,REPLICA_COMMIT_METHOD)); + } catch (Exception e2) { + doAbort(new SharedObjectAddAbortException("Exception sending commit message", e2)); + } + } + // Set state variable to committed. + state = ISharedObjectContainerTransaction.COMMITTED; + // Call local committed message + committed(); + participantIDs = null; + failedParticipants = null; + } + + protected void execMsgInvoke(SharedObjectMsg msg, ID fromID, Object o) + throws Exception + { + if (o == this) + { + // Object[] args = msg.getArgs(); + String name = msg.getMethodName(); + if (name.equals("replicaCommit")) + { + replicaCommit(); + return; + } + } + super.execMsgInvoke(msg, fromID, o); + } + + public final void replicaCommit() + { + synchronized (lock) { + state = COMMITTED; + lock.notifyAll(); + participantIDs = null; + failedParticipants = null; + } + // Call subclass overrideable method + committed(); + } + + protected void committed() + { + trace("committed()"); + // Subclasses may override as appropriate + } + + protected boolean votingCompleted() throws SharedObjectAddAbortException + { + // The test here is is we've received any indication of failed participants in + // the transaction. If so, we throw. + if (failedParticipants != null && failedParticipants.size() > 0) { + ID remoteID = (ID) failedParticipants.keys().nextElement(); + Exception e = (Exception) failedParticipants.get(remoteID); + trace("failed participant "+remoteID+" causing abort"); + // Abort! + throw new SharedObjectAddAbortException("Abort received from RepSpace "+remoteID, e); + // If no problems, and the number of participants to here from is 0, then we're done + } else if (state == ISharedObjectContainerTransaction.VOTING && participantIDs.size() == 0) { + // Success! + trace("votingCompleted"); + return true; + } + // Else continue waiting + return false; + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TreeItem.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TreeItem.java new file mode 100644 index 000000000..7361b71fe --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/TreeItem.java @@ -0,0 +1,95 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.io.Serializable; + +public class TreeItem implements Serializable { + + public static final String DEFAULT_SEPARATOR = ": "; + protected String label; + protected String labelValue; + protected String name; + protected String separator; + protected Object value; + + public TreeItem(String name, String labelValue) { + this(name, labelValue, null); + } + + public TreeItem(String name, String labelValue, Object value) { + this(name, name, labelValue, value); + } + + public TreeItem(String name, String label, String labelValue, Object val) { + this(name, label, DEFAULT_SEPARATOR, labelValue, val); + } + + public TreeItem( + String name, + String label, + String separator, + String labelValue, + Object value) { + this.name = name; + this.label = label; + this.separator = separator; + this.labelValue = labelValue; + this.value = value; + } + + public boolean equals(Object o) { + if (name == null) + return false; + if (o instanceof TreeItem) { + return name.equals(((TreeItem) o).name); + } else + return false; + } + + public String getLabel() { + return label; + } + + public String getLabelValue() { + return labelValue; + } + + public String getName() { + return name; + } + + public String getSeparator() { + return separator; + } + + public Object getValue() { + return value; + } + + public int hashCode() { + return name.hashCode(); + } + + public void setLabelValue(String lv) { + this.labelValue = lv; + } + + public String toString() { + String labelValue = getLabelValue(); + if (labelValue == null || labelValue.equals("")) { + return getLabel(); + } else + return getLabel() + getSeparator() + getLabelValue(); + } + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/User.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/User.java new file mode 100644 index 000000000..c6711036a --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/User.java @@ -0,0 +1,55 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share; + +import java.io.Serializable; +import java.util.Vector; + +import org.eclipse.ecf.core.identity.ID; + +public class User implements Serializable { + + protected Vector userFields; + protected ID userID; + protected String nickname; + + public User(ID userID, String username, Vector userFields) { + this.userID = userID; + this.nickname = username; + this.userFields = userFields; + } + + public Vector getUserFields() { + return userFields; + } + + public ID getUserID() { + return userID; + } + public String getNickname() { + return nickname; + } + + public void setUserFields(Vector uF) { + this.userFields = uF; + } + public void setNickname(String name) { + this.nickname = name; + } + + public String toString() { + if (nickname != null) + return nickname; + else + return userID.getName(); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java new file mode 100644 index 000000000..5d15607d4 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransfer.java @@ -0,0 +1,210 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.File; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.ISharedObjectContainerTransaction; +import org.eclipse.ecf.core.SharedObjectAddAbortException; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.SharedObjectInitException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject; +import org.eclipse.ecf.example.collab.ui.FileReceiverUI; +import org.eclipse.ecf.example.collab.ui.FileSenderUI; + + +public class EclipseFileTransfer + extends FileTransferSharedObject + implements FileTransferListener { + + FileSenderUI senderUI; + ID eclipseStageID; + + public EclipseFileTransfer( + FileSenderUI view, + ID target, + InputStream ins, + FileTransferParams params, + ID receiverID) { + super(target, ins, params); + senderUI = view; + progressListener = this; + this.eclipseStageID = receiverID; + } + protected SharedObjectDescription getReplicaDescription(ID remoteMember) + { + HashMap map = new HashMap(); + map.put("args",new Object [] { transferParams, eclipseStageID }); + map.put("types",new String [] { FileTransferParams.class.getName(), ID.class.getName() }); + return new SharedObjectDescription(getID(), + getClass().getName(),map, + replicateID++); + } + + public void init(ISharedObjectConfig config) throws SharedObjectInitException { + super.init(config); + Map props = config.getProperties(); + trace("args is "+props); + Object [] args = (Object []) props.get("args"); + if (args != null && args.length == 2) { + transferParams = (FileTransferParams) args[0]; + eclipseStageID = (ID) args[1]; + progressListener = this; + } + if (args != null && args.length == 5) { + senderUI = (FileSenderUI) args[0]; + targetReceiver = (ID) args[1]; + setInputStream((InputStream) args[2]); + transferParams = (FileTransferParams) args[3]; + eclipseStageID = (ID) args[4]; + progressListener = this; + } + } + /** + * Client constructor + * + * @param params the file send parameters associated with this file delivery + */ + public EclipseFileTransfer(FileTransferParams params, ID receiverID) { + super(params); + this.progressListener = this; + this.eclipseStageID = receiverID; + } + public EclipseFileTransfer() { + super(); + } + public void sendStart(FileTransferSharedObject obj, long length, float rate) { + if (senderUI != null) { + senderUI.sendStart(transferParams.getRemoteFile(), length, rate); + } else { + System.out.println("Sending file: "+transferParams.getRemoteFile()+", length: "+length); + } + } + public void sendData(FileTransferSharedObject obj, int dataLength) { + if (senderUI != null) { + senderUI.sendData(transferParams.getRemoteFile(), dataLength); + } else { + System.out.println("Sending data: "+dataLength+" bytes"); + } + } + public void sendDone(FileTransferSharedObject obj, Exception e) { + if (senderUI != null) { + senderUI.sendDone(transferParams.getRemoteFile(), e); + } else { + System.out.println("Sending done for: "+transferParams.getRemoteFile()); + } + } + + protected File makePath( + EclipseCollabSharedObject stage, + boolean server, + File file, + long length, + float rate) { + + String downloadpath = null; + // First, find EclipseCollabSharedObject if available + try { + if (stage != null) { + downloadpath = stage.getLocalFullDownloadPath(); + } + } catch (Exception e) { + } + File downloadDir = new File(downloadpath); + // create directories if we need them + downloadDir.mkdirs(); + // Then create new file + File retFile = new File(downloadDir,file.getName()); + return retFile; + } + + protected File localFile = null; + protected FileReceiverUI receiverUI = null; + protected EclipseCollabSharedObject receiverStage = null; + + public void receiveStart( + FileTransferSharedObject obj, + File aFile, + long length, + float rate) { + boolean isServer = false; + + // First, find out if our local environment has access to an EclipseCollabSharedObject instance + try { + receiverStage = (EclipseCollabSharedObject) getContext().getSharedObjectManager().getSharedObject(eclipseStageID); + } catch (Exception e) { + // Should never happen + e.printStackTrace(System.err); + } + + try { + isServer = getContext().isGroupServer(); + } catch (Exception e) { + e.printStackTrace(System.err); + } + + if (receiverStage != null) { + receiverUI = receiverStage.getFileReceiverUI(this,transferParams); + } + localFile = makePath(receiverStage,isServer, aFile, length, rate); + // Our superclass depends upon the transferParams.getRemoteFile() call to give a valid file. + // We modify this to the new local file we've decided upon + transferParams.setRemoteFile(localFile); + + if (receiverUI != null) { + receiverUI.receiveStart(getHomeContainerID(),localFile,length,rate); + } else { + System.out.println("Receiving to local file: "+localFile); + } + } + public void receiveData(FileTransferSharedObject obj, int dataLength) { + if (receiverUI != null) { + receiverUI.receiveData(getHomeContainerID(),localFile,dataLength); + } else { + System.out.println("Receiving data: "+dataLength+" bytes"); + } + } + public void receiveDone(FileTransferSharedObject obj, Exception e) { + // Need GUI progress indicator here + if (receiverUI != null) { + receiverUI.receiveDone(getHomeContainerID(),localFile,e); + } else { + System.out.println("Receiving done for: "+localFile); + } + } + + protected boolean votingCompleted() throws SharedObjectAddAbortException + { + // The test here is is we've received any indication of failed participants in + // the transaction. If so, we throw. + if (failedParticipants != null && failedParticipants.size() > 0) { + ID remoteID = (ID) failedParticipants.keys().nextElement(); + Exception e = (Exception) failedParticipants.get(remoteID); + // In this case, we're going to go ahead and continue anyway + return true; + // Abort! + //throw new AbortException("Abort received from RepSpace "+remoteID, e); + // If no problems, and the number of participants to here from is 0, then we're done + } else if (state == ISharedObjectContainerTransaction.VOTING && participantIDs.size() == 0) { + // Success! + return true; + } + // Else continue waiting + return false; + } + +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java new file mode 100644 index 000000000..52e7171d8 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/EclipseFileTransferAndLaunch.java @@ -0,0 +1,63 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.ecf.example.collab.ui.MessageLoader; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Display; + + +public class EclipseFileTransferAndLaunch + extends EclipseFileTransfer { + + public EclipseFileTransferAndLaunch() { + + } + public void sendDone(FileTransferSharedObject obj, Exception e) { + if (senderUI != null) { + senderUI.sendDone(transferParams.getRemoteFile(), e); + } else { + System.out.println("Sending done for: "+transferParams.getRemoteFile()); + } + // Now launch file locally + if (e == null) launchFile(transferParams.getRemoteFile().getAbsolutePath()); + } + protected void launchFile(String fileName) { + try { + Program.launch(fileName); + } catch (final IllegalArgumentException e1) { + ClientPlugin.log("Exception launching local file "+localFile,e1); + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, + MessageLoader.getString("Program Launch Failed"), + MessageLoader.getString("Program launch failed for file '"+localFile.getAbsolutePath()+"'\nException: "+e1.getMessage())); + } + }); + } + } + public void receiveDone(FileTransferSharedObject obj, Exception e) { + // Need GUI progress indicator here + if (receiverUI != null) { + receiverUI.receiveDone(getHomeContainerID(),localFile,e); + } else { + System.out.println("Receiving done for: "+localFile); + } + // Now...we launch the file + if (e == null) { + launchFile(localFile.getAbsolutePath()); + } + } + +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileData.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileData.java new file mode 100644 index 000000000..83a9919a0 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileData.java @@ -0,0 +1,55 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Serializable; + +public class FileData implements Serializable +{ + static final long serialVersionUID = 469244980886541978L; + byte [] myData; + int read; + + FileData(InputStream ins, int chunkSize) throws IOException + { + myData = new byte[chunkSize]; + read = ins.read(myData); + } + + FileData() + { + read = -1; + } + + void saveData(OutputStream aFileStream) throws IOException + { + if (read != -1) aFileStream.write(myData, 0, read); + } + + boolean isDone() + { + return (read==-1); + } + + int getDataSize() + { + return read; + } + + public String toString() + { + return "FileData["+read+";"+isDone()+"]"; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferListener.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferListener.java new file mode 100644 index 000000000..aa88e3efc --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferListener.java @@ -0,0 +1,26 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.File; +import java.io.Serializable; + +public interface FileTransferListener extends Serializable +{ + public void sendStart(FileTransferSharedObject obj, long length, float rate); + public void sendData(FileTransferSharedObject obj, int dataLength); + public void sendDone(FileTransferSharedObject obj, Exception e); + + public void receiveStart(FileTransferSharedObject obj, File aFile, long length, float rate); + public void receiveData(FileTransferSharedObject obj, int dataLength); + public void receiveDone(FileTransferSharedObject obj, Exception e); +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferParams.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferParams.java new file mode 100644 index 000000000..2f9f9b100 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferParams.java @@ -0,0 +1,158 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.File; +import java.io.Serializable; +import java.util.Date; + +public class FileTransferParams implements Serializable +{ + protected static int DEFAULT_CHUNK_SIZE = 1024; + protected static int DEFAULT_WAIT_TIME = 1000; + protected static int DEFAULT_FILE_LENGTH = -1; + protected static boolean DEFAULT_INCLUDE_SERVER = false; + // Suggested remote file name + protected File remoteFile; + protected int chunkSize; + protected int waitTime; + protected Date startDate; + protected boolean includeServer; + protected long length; + protected float rate; + protected FileTransferListener progressListener; + + static { + try { + String str = System.getProperty(FileTransferParams.class.getName()+".FILECHUNKSIZE", ""+DEFAULT_CHUNK_SIZE); + DEFAULT_CHUNK_SIZE = Integer.parseInt(str); + str = System.getProperty(FileTransferParams.class.getName()+".FILEWAITTIME", DEFAULT_WAIT_TIME+""); + DEFAULT_WAIT_TIME = Integer.parseInt(str); + str = System.getProperty(FileTransferParams.class.getName()+".FILELENGTH", DEFAULT_FILE_LENGTH+""); + DEFAULT_FILE_LENGTH = Integer.parseInt(str); + str = System.getProperty(FileTransferParams.class.getName()+".FILEINCLUDESERVER", "false"); + DEFAULT_INCLUDE_SERVER = Boolean.valueOf(str).booleanValue(); + } catch (Exception e) { + } + } + + public FileTransferParams(File aFile, int chunkSize, + int waitTime, Date startDate, + boolean includeServer, long length, + FileTransferListener listener) + { + remoteFile = aFile; + if (chunkSize == -1) this.chunkSize = DEFAULT_CHUNK_SIZE; + else this.chunkSize = chunkSize; + this.waitTime = waitTime; + if (waitTime == -1) this.waitTime = DEFAULT_WAIT_TIME; + else this.waitTime = waitTime; + this.startDate = startDate; + this.includeServer = includeServer; + this.length = length; + this.rate = (chunkSize*8)/((float) waitTime/(float) 1000); + this.progressListener = listener; + } + + public FileTransferParams() + { + this(null, DEFAULT_CHUNK_SIZE, + DEFAULT_WAIT_TIME, null, + DEFAULT_INCLUDE_SERVER, DEFAULT_FILE_LENGTH, null); + } + + public File getRemoteFile() + { + return remoteFile; + } + + public void setRemoteFile(File aFile) + { + remoteFile = aFile; + } + + public int getChunkSize() + { + return chunkSize; + } + + public void setChunkSize(int size) + { + chunkSize = size; + } + + public int getWaitTime() + { + return waitTime; + } + + public void setWaitTime(int wait) + { + waitTime = wait; + } + + public Date getStartDate() + { + return startDate; + } + + public void setStartDate(Date aDate) + { + startDate = aDate; + } + + public boolean getIncludeServer() + { + return includeServer; + } + + public void setIncludeServer(boolean include) + { + includeServer = include; + } + + public long getLength() + { + return length; + } + + public void setLength(long len) + { + length = len; + } + + public float getRate() + { + return rate; + } + + protected FileTransferListener getProgressListener() + { + return progressListener; + } + + protected void setProgressListener(FileTransferListener list) + { + progressListener = list; + } + + public String toString() + { + StringBuffer sb = new StringBuffer("FileTransferParams["); + sb.append(remoteFile).append(";").append(chunkSize).append(";"); + sb.append(waitTime).append(";"); + sb.append(startDate).append(";").append(includeServer).append(";"); + sb.append(length).append(";").append(rate).append(";"); + sb.append(progressListener).append("]"); + return sb.toString(); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java new file mode 100644 index 000000000..97c7ed36b --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/FileTransferSharedObject.java @@ -0,0 +1,447 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.SharedObjectInitException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.Trace; +import org.eclipse.ecf.example.collab.share.TransactionSharedObject; +import org.eclipse.ecf.example.collab.share.SharedObjectMsg; + + +public class FileTransferSharedObject extends TransactionSharedObject +{ + public static final Trace debug = Trace.create("filetransfersharedobject"); + + public static final int DEFAULT_START_WAIT_INTERVAL = 5000; + + public static final String recvMethodName = "handleData"; + public static final String doneMethodName = "handleDone"; + public static final String startMethodName = "startSendToAll"; + // Both host and client + protected FileTransferParams transferParams; + protected FileTransferListener progressListener; + // Host only + protected ID targetReceiver; + protected InputStream inputStream; + // Client only + protected OutputStream outputStream; + protected long dataWritten = -1; + + public FileTransferSharedObject(ID receiver, InputStream ins, FileTransferParams params) + { + targetReceiver = receiver; + if (ins == null) throw new NullPointerException("Input stream cannot be null"); + setInputStream(ins); + if (params == null) { + transferParams = new FileTransferParams(); + } else transferParams = params; + progressListener = transferParams.getProgressListener(); + debug("<init>("+receiver+", "+ins+", "+params+")"); + } + public FileTransferSharedObject() { + super(); + } + protected void setInputStream(InputStream src) + { + inputStream = src; + } + + protected void setOutputStream(OutputStream src) + { + outputStream = src; + } + + public FileTransferSharedObject(InputStream ins, FileTransferParams params) + { + this(null, ins, params); + } + + public FileTransferSharedObject(InputStream ins) + { + this(null, ins, null); + } + + public FileTransferSharedObject(FileTransferParams params) + { + if (params == null) { + transferParams = new FileTransferParams(); + } else transferParams = params; + progressListener = transferParams.getProgressListener(); + debug("<init>("+params+")"); + } + public void activated(ID [] others) + { + debug("activated()"); + try { + // Only try to open output file if this is not the host instance + if (!isHost() && !getContext().isGroupServer()) { + // Then notify listener about starting the receive + if (progressListener != null) { + progressListener.receiveStart(this, transferParams.getRemoteFile(), transferParams.getLength(), transferParams.getRate()); + } + openOutputFile(); + long len = transferParams.getLength(); + if (len != -1) { + dataWritten = 0; + } + } else { + // Just notify listener (if any) about the sending + if (progressListener != null) { + progressListener.sendStart(this, transferParams.getLength(), transferParams.getRate()); + } + } + } catch (Exception e) { + debug(e,"Exception sending failure back to host"); + try { + // Respond with create failure message back to host + getContext().sendCreateResponse(getHomeContainerID(), e, getIdentifier()); + } catch (Exception e1) { + debug(e1,"Exception sending failure back to host"); + } + return; + } + // Finally, call activated to report success + super.activated(others); + } + protected void debug(Throwable e, String msg) { + if (Trace.ON && debug != null) { + debug.dumpStack(e, msg); + } + } + protected void debug(String msg) { + if (Trace.ON && debug != null) { + debug.msg(msg); + } + } + /** + */ + protected void postOpenFile() + { + debug("postOpenFile()"); + } + protected void openOutputFile() throws IOException + { + File aFile = transferParams.getRemoteFile(); + if (aFile == null) throw new IOException("File is null"); + // If this is a server, and we shouldn't create a copy of ourselves on a server + // then we skip the file creation totally + if (getContext().isGroupServer() && !transferParams.getIncludeServer()) { + // Set myFile to null and outputStream to null + debug("File "+aFile+" not created on server."); + setOutputStream(null); + } else { + debug("File "+aFile+" being created"); + try { + String parent = aFile.getParent(); + + if (parent != null && new File(parent).mkdirs()) + /**/; + } catch(Exception ex) { + // Ignore this exception. + debug(ex, "Exception creating local directory for "+aFile); + } + setOutputStream(new BufferedOutputStream(new FileOutputStream(aFile))); + } + postOpenFile(); + } + + protected void replicate(ID remoteMember) + { + // If we don't have a specific receiver, simply allow superclass to handle replication. + if (targetReceiver == null) { super.replicate(remoteMember); return; } + // If we do have a specific receiver, only send create message to the specific receiver + // if we're replicating on activation + else if (remoteMember == null) { + try { + SharedObjectDescription createInfo = getReplicaDescription(targetReceiver); + if (createInfo != null) { + getContext().sendCreate(targetReceiver, createInfo); + return; + } + } catch (IOException e) { + traceDump("Exception in replicateSelf",e); + return; + } + } + } + public void init(ISharedObjectConfig config) throws SharedObjectInitException { + super.init(config); + Map map = config.getProperties(); + Object [] args = (Object []) map.get("args"); + if (args != null && args.length == 1) { + transferParams = (FileTransferParams) args[0]; + progressListener = transferParams.getProgressListener(); + } + } + protected SharedObjectDescription getReplicaDescription(ID remoteMember) + { + HashMap map = new HashMap(); + map.put("args",new Object [] { transferParams }); + map.put("types",new String [] { FileTransferParams.class.getName() }); + return new SharedObjectDescription(getID(), + getClass().getName(),map, + replicateID++); + } + + protected boolean sendData(ID rcvr, FileData data) throws IOException + { + // Send it. This does all data delivery. + forwardMsgTo(rcvr, SharedObjectMsg.makeMsg(recvMethodName, data)); + return data.isDone(); + } + + protected boolean sendChunk(ID rcvr) throws IOException + { + FileData data = new FileData(inputStream, transferParams.getChunkSize()); + int size = data.getDataSize(); + if (progressListener != null && size != -1) progressListener.sendData(this, size); + return sendData(rcvr, data); + } + + protected void handleData(FileData data) + { + preSaveData(data); + // Then save the file data. + int size = data.getDataSize(); + if (progressListener != null && size != -1) progressListener.receiveData(this, size); + saveData(data); + } + + protected void preSaveData(FileData data) + { + if (data.myData != null && outputStream != null) { + debug("Saving "+data.read+" bytes."); + } else { + debug("Not saving data locally"); + } + } + + /** + * Save data to File. This method is called by handleData to actually + * save data received (on the clients only) to the appropriate file. + * + * @param data the FileData to save + */ + protected void saveData(FileData data) + { + // Save data locally...if we have an output stream + try { + if (outputStream != null) { + debug("saveData("+data+")"); + long len = transferParams.getLength(); + dataWritten += data.getDataSize(); + if (len != -1 && dataWritten > len) throw new IOException("File larger than "+len); + data.saveData(outputStream); + // Flush to verify that data was saved. + outputStream.flush(); + } + } catch (Exception e) { + debug(e,"Exception saving data"); + // Give subclasses opportunity to deal with this + notifyExceptionOnSave(e); + // Report failure back to host if we're not disconnected + try { + // Send it. This does the done msg delivery. + forwardMsgHome(SharedObjectMsg.makeMsg(doneMethodName, e)); + // Make sure everything is cleaned up + hardClose(); + } catch (Exception e1) { + // If this fails...then we should be outta here + debug(e1, "Exception sending done msg back to host"); + } + if (progressListener != null) progressListener.receiveDone(this, e); + return; + } + Exception except = null; + // If everything saved OK, and that was the last piece, then close + // and report success. + if (data.isDone()) { + try { + // Make sure everything is cleaned up + hardClose(); + } catch (Exception e1) { + // If this fails...then we should be outta here + debug(e1,"Exception saving file."); + except = e1; + notifyExceptionOnClose(except); + } + // Calling the progress listener first, so that the reference + // to ourselves will be valid even if doneReceiving kills this + // object + if (progressListener != null) progressListener.receiveDone(this, except); + try { + forwardMsgHome(SharedObjectMsg.makeMsg(doneMethodName, except)); + } catch (Exception e) { + debug(e,"Exception sending done message home"); + } + // Now call doneReceiving...which may destroy us + doneReceiving(); + } + } + + protected void notifyExceptionOnSave(Throwable t) + { + // By default, do nothing + } + + protected void notifyExceptionOnClose(Throwable t) + { + // By default, do nothing + } + + public void doneReceiving() + { + debug("File "+transferParams.getRemoteFile()+" received."); + } + /** + * Handler for done msg. NOTE: If this method name is changed, + * then the static variable 'doneMethodName' should be changed to match. + * + * @param data the FileData involved in the failure + */ + public void handleDone(Exception e) + { + debug("handleDone("+e+")"); + } + + protected void preStartWaiting() + { + debug("preStartWaiting()"); + } + + protected void preStartSending() + { + debug("preStartSending()"); + } + + protected void preChunkSent() + { + debug("preChunkSent()"); + } + + protected void chunkSent() + { + debug("chunkSent()"); + } + + protected void doneSending(Exception e) + { + debug("doneSending("+e+")"); + if (progressListener != null) progressListener.sendDone(this, e); + } + + protected void committed() + { + debug("committed()"); + preStartWaiting(); + start(); + } + + protected void preWait() + { + debug("preWait() until "+transferParams.getStartDate()); + } + + protected void start() + { + debug("start()"); + if (isHost()) { + Date start = transferParams.getStartDate(); + if (start != null && start.after(new Date())) { + try { + preWait(); + synchronized (this) { + wait(DEFAULT_START_WAIT_INTERVAL); + } + // Asynchronous tail recursion. + sendSelf(SharedObjectMsg.makeMsg("start")); + } catch (Exception e) {} + } else { + preStartSending(); + // Actually begin + startSendToAll(); + } + } + } + /** + * Start sending data to all clients. This is the entry point method for sending + * the desired data to remotes. + */ + protected void startSendToAll() + { + // Send chunks to all remotes until done. + try { + // Call subclass overrideable method before sending chunk + preChunkSent(); + // Send chunk + boolean res = sendChunk(targetReceiver); + // Call subclass overrideable method after sending chunk + chunkSent(); + if (!res) { + synchronized (this) { + int waittime = transferParams.getWaitTime(); + if (waittime <=0) waittime = 10; + wait(waittime); + } + // If all data not sent, send message to self. This results + // in this method iterating until entire file is sent. + sendSelf(SharedObjectMsg.makeMsg(startMethodName)); + } else { + // Close input stream. + hardClose(); + doneSending(null); + } + } catch (Exception e) { + doneSending(e); + } + } + + protected void hardClose() throws IOException + { + if (inputStream != null) { + try { + inputStream.close(); + } catch (Exception e) {} + inputStream = null; + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (Exception e) {} + outputStream = null; + } + } + + public void deactivated() + { + super.deactivated(); + debug("deactivated()"); + // Make sure things are cleaned up properly in case of wrong trousers + try { + hardClose(); + } catch (Exception e) {} + } + +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/InputStreamSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/InputStreamSharedObject.java new file mode 100644 index 000000000..aa6c8c711 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/InputStreamSharedObject.java @@ -0,0 +1,90 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPInputStream; + +import org.eclipse.ecf.core.util.SimpleQueueImpl; + +public class InputStreamSharedObject extends InputStream +{ + protected SimpleQueueImpl myQueue = new SimpleQueueImpl(); + + int currentLength; + int currentRead; + boolean useCompression; + ByteArrayInputStream myBIS; + GZIPInputStream myGZIP; + + public InputStreamSharedObject(boolean compression) + { + useCompression = compression; + } + + public InputStreamSharedObject() + { + this(OutputStreamSharedObject.DEFAULT_COMPRESSION); + } + + protected final void resetStreams(Data d) + throws IOException + { + currentRead = 0; + myBIS = new ByteArrayInputStream(d.getData()); + currentLength = d.getLength(); + if (useCompression) { + myGZIP = new GZIPInputStream(myBIS); + } + } + public final int read() throws IOException + { + if (currentRead >= currentLength) { + Data d = (Data)myQueue.dequeue(); + if (d == null) throw new IOException("No data"); + resetStreams(d); + } + currentRead++; + return streamRead(); + } + protected final int streamRead() throws IOException + { + if (useCompression) { + return myGZIP.read(); + } else return myBIS.read(); + } + // Method for replicated object to add data to stream + public void add(int length, byte [] d) + { + myQueue.enqueue(new Data(length,d)); + } + + protected static class Data { + int myLength; + byte [] myData; + protected Data(int length, byte [] d) + { + myLength = length; + myData = d; + } + protected int getLength() + { + return myLength; + } + protected byte [] getData() + { + return myData; + } + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/OutputStreamSharedObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/OutputStreamSharedObject.java new file mode 100644 index 000000000..0fc6462a8 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/OutputStreamSharedObject.java @@ -0,0 +1,94 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.zip.GZIPOutputStream; + +public class OutputStreamSharedObject extends OutputStream +{ + public static final int DEFAULT_BUFF_SIZE = 900; + public static final boolean DEFAULT_COMPRESSION = true; + + protected StreamSender myObj; + protected ByteArrayOutputStream myOuts; + protected GZIPOutputStream myGZIP; + protected int myDefaultLength; + protected int currentCount = 0; + protected boolean useCompression; + + public OutputStreamSharedObject(StreamSender obj, int size, boolean compression) + throws IOException + { + myObj = obj; + myDefaultLength = size; + useCompression = compression; + resetStreams(); + } + public OutputStreamSharedObject(StreamSender obj) throws IOException + { + this(obj, DEFAULT_BUFF_SIZE, DEFAULT_COMPRESSION); + } + public OutputStreamSharedObject(StreamSender obj, int size) throws IOException + { + this(obj, size, DEFAULT_COMPRESSION); + } + public OutputStreamSharedObject(StreamSender obj, boolean compression) throws IOException + { + this(obj, DEFAULT_BUFF_SIZE, compression); + } + protected void resetStreams() throws IOException + { + myOuts = new ByteArrayOutputStream(myDefaultLength); + if (useCompression) { + myGZIP = new GZIPOutputStream(myOuts); + } + } + public void close() throws IOException + { + if (useCompression) { + myGZIP.close(); + } else myOuts.close(); + } + + public void flush() throws IOException + { + sendMsgAndResetStream(); + } + protected final void sendMsgAndResetStream() throws IOException + { + if (useCompression) { + myGZIP.flush(); + myGZIP.finish(); + } else myOuts.flush(); + // Actually ask our StreamSender to send msg with count of size and data + myObj.sendDataMsg(currentCount, myOuts.toByteArray()); + resetStreams(); + currentCount = 0; + } + public void write(int a) throws IOException + { + if (currentCount >= myDefaultLength) { + sendMsgAndResetStream(); + } + currentCount++; + streamWrite(a); + } + protected void streamWrite(int a) throws IOException + { + if (useCompression) { + myGZIP.write(a); + } else myOuts.write(a); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/StreamSender.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/StreamSender.java new file mode 100644 index 000000000..570fe0582 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/io/StreamSender.java @@ -0,0 +1,28 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.io; + +public interface StreamSender +{ + /** + * Send a message with data to remote replica(s). This method is called by + * the OutputStreamSharedObject when sends some data via the replicated object. + * The replicated object that implements this interface should send a message + * to one or all remote replicas that contains the information contained in + * this method signature. Remote replicas should then turn around and call the + * 'add' method on their InputStreamSharedObject to receive the data. + * + * @param currentCount the length of the data (assuming data are compressed) + * @param data the actual data to send + */ + public void sendDataMsg(int currentCount, byte [] data); +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecProg.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecProg.java new file mode 100644 index 000000000..b130179d4 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecProg.java @@ -0,0 +1,185 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.url; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.SharedObjectInitException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.Trace; +import org.eclipse.ecf.example.collab.share.GenericSharedObject; + + +public class ExecProg extends GenericSharedObject +{ + public static Trace myDebug = Trace.create("progsharedobject"); + public static final Boolean DEFAULT_INCLUDE_SERVER = Boolean.FALSE; + // Host values + protected String [] cmds; + protected String [] env; + // Values specifically for replicas + protected String [] replicaCmds; + protected String [] replicaEnv; + + protected ID receiver; + protected Process proc = null; + public Boolean includeHost; + protected Boolean includeServer; + + public ExecProg() { + + } + public ExecProg(ID rcvr, String cmds[], String env[], + Boolean includeHost, Boolean includeServer) throws Exception + { + receiver = rcvr; + this.cmds = cmds; + this.env = ((env == null)?new String[0]:env); + this.includeHost = includeHost; + if (includeServer == null) this.includeServer = DEFAULT_INCLUDE_SERVER; + else this.includeServer = includeServer; + } + protected void debug(String msg) { + if (Trace.ON && myDebug != null) { + myDebug.msg(msg); + } + } + protected void debug(Throwable t, String msg) { + if (Trace.ON && myDebug != null) { + myDebug.dumpStack(t,msg); + } + } + public ExecProg(ID rcvr, String hostCmds[], String hostEnv[], + String replicaCmds[], String replicaEnv[], Boolean includeHost, Boolean includeServer) + throws Exception + { + this(rcvr, hostCmds, hostEnv, includeHost, includeServer); + this.replicaCmds = replicaCmds; + this.replicaEnv = replicaEnv; + } + + public ExecProg(ID rcvr, String cmds[], String env[]) throws Exception + { + this(rcvr, cmds, env, Boolean.FALSE, null); + } + + protected void replicate(ID remoteMember) + { + debug("replicateSelf("+remoteMember+")"); + // If we don't have a specific receiver, simply allow superclass to handle replication. + if (receiver == null) { super.replicate(remoteMember); return; } + // If we do have a specific receiver, only send create message to the specific receiver + // if we're replicating on activation + else if (remoteMember == null) { + try { + SharedObjectDescription createInfo = getReplicaDescription(receiver); + if (createInfo != null) { + getContext().sendCreate(receiver, createInfo); + } + } catch (IOException e) { + traceDump("Exception in replicateSelf",e); + return; + } + } + } + + public void init(ISharedObjectConfig config) throws SharedObjectInitException { + super.init(config); + Map props = config.getProperties(); + debug("props is "+props); + Object [] args = (Object []) props.get("args"); + debug("args is "+args); + if (args != null && args.length > 4) { + receiver = (ID) args[0]; + cmds = (String []) args[1]; + env = (String []) args[2]; + includeHost = (Boolean) args[3]; + includeServer = (Boolean) args[4]; + } + + } + protected SharedObjectDescription getReplicaDescription(ID remoteMember) + { + String types[] = { ID.class.getName(), String.class.getName(),String.class.getName(), "[Ljava.lang.String;", Boolean.class.getName(), Boolean.class.getName() }; + Object args[] = { receiver, (replicaCmds==null)?cmds:replicaCmds, (replicaEnv==null)?env:replicaEnv, includeHost, includeServer }; + HashMap map = new HashMap(); + map.put("args",args); + map.put("types",types); + return new SharedObjectDescription(getHomeContainerID(), + getClass().getName(), + map, + replicateID++); + } + + public void activated(ID [] others) + { + debug("activated()"); + try { + if (!getContext().isGroupServer() || includeServer.equals(Boolean.TRUE)) { + startup(); + } else { + debug("Not executing commands because is server"); + } + } catch (Exception e) { + debug(e, "Exception on startup()"); + /* + * For now, just ignore failure. + */ + } + super.activated(others); + postActivated(); + } + + /** + * Method called within the 'activated' message handler. This method is called after the + * activated method completes its operations. + */ + protected void postActivated() + { + debug("postActivated()"); + } + + protected void startup() throws Exception + { + debug("startup()"); + if (cmds != null) { + // This is all trace output + if (Trace.ON && myDebug != null) { + myDebug.msg("Executing command line:"); + if (cmds != null) { + for(int i=0; i < cmds.length; i++) { + myDebug.msg(" "+cmds[i]+" "); + } + } + myDebug.msg("With enviromnent:"); + if (env != null) { + for(int i=0; i < env.length; i++) { + myDebug.msg(" "+env[i]+" "); + } + } + } + // Here's the real action + if (env==null || env.length==0) { + if (cmds.length ==1) { + proc = Runtime.getRuntime().exec(cmds[0]); + } else proc = Runtime.getRuntime().exec(cmds); + } else { + proc = Runtime.getRuntime().exec(cmds, (env.length==0)?null:env); + } + } + } + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java new file mode 100644 index 000000000..964fd765f --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/ExecURL.java @@ -0,0 +1,121 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.url; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ecf.core.ISharedObjectConfig; +import org.eclipse.ecf.core.SharedObjectDescription; +import org.eclipse.ecf.core.SharedObjectInitException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.Trace; +import org.eclipse.ecf.example.collab.share.GenericSharedObject; + + +public class ExecURL extends GenericSharedObject { + + public static Trace debug = Trace.create("urlsharedobject"); + + ID receiver; + String url; + + // Host + public ExecURL(ID rcvr, String url) { + this.receiver = rcvr; + this.url = url; + } + public ExecURL() { + + } + public void init(ISharedObjectConfig config) throws SharedObjectInitException { + super.init(config); + Map props = config.getProperties(); + debug("props is "+props); + Object [] args = (Object []) props.get("args"); + debug("args is "+args); + if (args != null && args.length > 1) { + receiver = (ID) args[0]; + url = (String) args[1]; + debug("url is now "+url); + } + } + public ExecURL(String url) { + this.url = url; + } + protected void debug(String msg) { + if (Trace.ON && debug != null) { + debug.msg(msg); + } + } + protected void debug(Throwable t, String msg) { + if (Trace.ON && debug != null) { + debug.dumpStack(t,msg); + } + } + protected String getURL() { + return url; + } + protected SharedObjectDescription getReplicaDescription(ID remoteMember) + { + String types[] = { String.class.getName()}; + Object args[] = { url }; + HashMap map = new HashMap(); + map.put("args",args); + map.put("types",types); + return new SharedObjectDescription(getHomeContainerID(), + getClass().getName(), + map, + replicateID++); + } + + protected void replicate(ID remoteMember) + { + debug("replicateSelf("+remoteMember+")"); + // If we don't have a specific receiver, simply allow superclass to handle replication. + if (receiver == null) { super.replicate(remoteMember); return; } + // If we do have a specific receiver, only send create message to the specific receiver + // if we're replicating on activation + else if (remoteMember == null) { + try { + SharedObjectDescription createInfo = getReplicaDescription(receiver); + if (createInfo != null) { + getContext().sendCreate(receiver, createInfo); + } + } catch (IOException e) { + traceDump("Exception in replicateSelf",e); + return; + } + } + } + + public void activated(ID [] others) { + debug("activated()"); + try { + if (!getContext().isGroupServer()) { + GetExec.showURL(url,true); + } else { + debug("Not executing commands because is server"); + } + } catch (Exception e) { + debug(e, "Exception on startup()"); + /* + * For now, just ignore failure. + */ + } + super.activated(others); + destroySelfLocal(); + } + + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/GetExec.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/GetExec.java new file mode 100644 index 000000000..dec4ee446 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/share/url/GetExec.java @@ -0,0 +1,126 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.share.url; + +import java.io.File; + +import org.eclipse.help.browser.IBrowser; +import org.eclipse.help.internal.browser.BrowserManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Display; + +public class GetExec { + private static String DEFAULT_UNIX_BROWSER = "mozilla"; + private static final String EMBEDDED_VALUE = "embedded"; + + // The flag to display a url. + private static final String UNIX_FLAG = ""; + // The flag to display a url. + private static final String WIN_FLAG = "url.dll,FileProtocolHandler"; + + // Used to identify the windows platform. + private static final String WIN_ID = "Windows"; + // The default system browser under windows. + private static final String WIN_PATH = "rundll32"; + protected static void displayURL(String url, boolean considerInternal) { + boolean useEmbedded = false; + boolean win32 = SWT.getPlatform().equals("win32"); + + if (win32 && considerInternal) { + useEmbedded = getUseEmbeddedBrowser(); + } + if (useEmbedded) { + IBrowser browser = BrowserManager.getInstance() + .createBrowser(false); + try { + browser.displayURL(url); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + if (win32) { + Program.launch(url); + } else { + // defect 11483 + IBrowser browser = BrowserManager.getInstance().createBrowser(); + try { + browser.displayURL(url); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + public static String getBrowserExec(String unixBrowser, String url) { + boolean windows = isWindowsPlatform(); + String cmd = null; + if (windows) + return WIN_PATH + " " + WIN_FLAG + " " + url; + else { + String browser = unixBrowser; + if (browser == null) + browser = DEFAULT_UNIX_BROWSER; + return browser + " " + UNIX_FLAG + url; + } + } + + public static String getFileExec(String fileName) { + if (isWindowsPlatform()) + return WIN_PATH + " " + WIN_FLAG + " " + fileName; + else + return fileName; + } + + protected static boolean getUseEmbeddedBrowser() { + return true; + } + + public static boolean isWindowsPlatform() { + String os = System.getProperty("os.name"); + if (os != null && os.startsWith(WIN_ID)) + return true; + else + return false; + } + + public static String mangleFileName(String fileName) { + if (fileName == null) + return null; + if (isWindowsPlatform()) + return fileName.replace('/', File.separatorChar).replace('|', ':'); + else + return fileName.replace('\\', File.separatorChar); + } + public static void setDefaultUnixBrowser(String unixBrowser) { + DEFAULT_UNIX_BROWSER = unixBrowser; + } + public static void showURL( + final String url, + final boolean considerInternal) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + displayURL(url, considerInternal); + } catch (Exception e) { + try { + Runtime.getRuntime().exec(getBrowserExec(null, url)); + } catch (Exception e1) { + // give up + return; + } + } + } + }); + } + +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java new file mode 100644 index 000000000..ff394a181 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatComposite.java @@ -0,0 +1,1119 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.io.File; +import java.io.IOException; +import java.util.Date; +import java.util.StringTokenizer; +import org.eclipse.core.runtime.Platform; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.ecf.example.collab.share.io.FileTransferParams; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.TextViewer; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + + + +public class ChatComposite extends Composite { + private final LineChatClientView view; + + Action appShare = null; + + ChatLayout cl = null; + Action coBrowseURL = null; + Action messageEclipseComponent = null; + Action outputClear = null; + Action outputCopy = null; + Action outputPaste = null; + Action outputSelectAll = null; + Action removeEclipseComponent = null; + Action sendComponent = null; + Action sendComponentToServer = null; + Action sendEclipseComponent = null; + Action sendFileToGroup = null; + Action sendFileToGroupAndLaunch = null; + Action sendMessage = null; + Action startProgram = null; + Action closeGroup = null; + Action sendCVSUpdateRequest = null; + + Action sendShowViewRequest = null; + + Action showChatWindow; + + protected final String TEXT_INPUT_INIT = MessageLoader + .getString("LineChatClientView.textinputinit"); + protected static final int DEFAULT_INPUT_HEIGHT = 25; + protected static final int DEFAULT_INPUT_SEPARATOR = 5; + + Text textinput = null; + TextViewer textoutput = null; + ChatTreeViewer treeView = null; + ChatDropTarget chatDropTarget = null; + TreeDropTarget treeDropTarget = null; + + ChatWindow chatWindow; + boolean typing; + + ChatComposite(LineChatClientView view, Composite parent, ChatTreeViewer tree, int options, + String initText) { + this(view, parent, tree, options, initText, null); + } + + ChatComposite(LineChatClientView view, Composite parent, ChatTreeViewer tree, int options, + String initText, ChatWindow chatWindow) { + super(parent, options); + this.view = view; + this.chatWindow = chatWindow; + cl = new ChatLayout(DEFAULT_INPUT_HEIGHT, DEFAULT_INPUT_SEPARATOR); + setLayout(cl); + treeView = tree; + textoutput = new TextViewer(this, SWT.V_SCROLL | SWT.H_SCROLL + | SWT.WRAP); + textoutput.setDocument(new Document(initText)); + textoutput.setEditable(false); + textinput = new Text(this, SWT.SINGLE | SWT.BORDER); + cl.setInputTextHeight(textinput.getFont().getFontData()[0] + .getHeight() + 2); + textinput.setText(TEXT_INPUT_INIT); + textinput.selectAll(); + textinput.addKeyListener(new KeyListener() { + public void keyPressed(KeyEvent evt) { + handleKeyPressed(evt); + } + + public void keyReleased(KeyEvent evt) { + handleKeyReleased(evt); + } + }); + textinput.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + String t = textinput.getText(); + if (t.equals(TEXT_INPUT_INIT)) { + textinput.selectAll(); + } + } + + public void focusLost(FocusEvent e) { + } + }); + textinput.addMouseListener(new MouseListener() { + public void mouseDoubleClick(MouseEvent e) { + } + + public void mouseDown(MouseEvent e) { + } + + public void mouseUp(MouseEvent e) { + String t = textinput.getText(); + if (t.equals(TEXT_INPUT_INIT)) { + textinput.selectAll(); + } + } + }); + textinput.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + if (typing && textinput.getText().trim().length() == 0) + typing = false; + else if (!typing) { + typing = true; + ChatComposite.this.view.lch.sendStartedTyping(); + } + } + }); + // make actions + makeActions(); + hookContextMenu(); + initializeDropTargets(); + } + + ChatComposite(LineChatClientView view, Composite parent, ChatTreeViewer tree, String initText) { + this(view, parent, tree, SWT.NULL, initText); + } + + public void appendText(String text) { + if (text == null || textoutput == null) + return; + StyledText st = textoutput.getTextWidget(); + if (st == null) + return; + st.append(text); + String t = st.getText(); + if (t == null) + return; + st.setSelection(t.length()); + } + + protected void clearInput() { + textinput.setText(""); + } + + private void contributeToActionBars() { + IActionBars bars = this.view.view.getViewSite().getActionBars(); + fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + protected void copyFileLocally(String inputFile, String outputFile) + throws IOException { + File aFile = new java.io.File(outputFile); + File dir = aFile.getParentFile(); + dir.mkdirs(); + java.io.BufferedInputStream ins = new java.io.BufferedInputStream( + new java.io.FileInputStream(inputFile)); + byte[] buf = new byte[1024]; + java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream( + new java.io.FileOutputStream(aFile)); + // Actually copy file + while (ins.read(buf) != -1) + bos.write(buf); + // Close input and output streams + ins.close(); + bos.close(); + } + + protected void enableProxyMessage(boolean val) { + messageEclipseComponent.setEnabled(val); + removeEclipseComponent.setEnabled(val); + } + + private void fillContextMenu(IMenuManager manager) { + if (chatWindow != null) { + manager.add(showChatWindow); + manager.add(new Separator()); + } + + manager.add(outputCopy); + manager.add(outputPaste); + manager.add(outputClear); + manager.add(new Separator()); + manager.add(outputSelectAll); + manager.add(new Separator()); + manager.add(sendFileToGroup); + manager.add(sendFileToGroupAndLaunch); + manager.add(coBrowseURL); + //manager.add(startProgram); + //appShare.setEnabled(!LineChatView.appShareActive()); + //manager.add(appShare); + manager.add(new Separator()); + manager.add(sendMessage); + manager.add(sendCVSUpdateRequest); + manager.add(sendShowViewRequest); + //manager.add(new Separator()); + //manager.add(sendEclipseComponent); + //manager.add(messageEclipseComponent); + //manager.add(removeEclipseComponent); + /* + * manager.add(new Separator()); manager.add(sendComponent); + * manager.add(sendComponentToServer); + */ + manager.add(new Separator()); + manager.add(closeGroup); + // Other plug-ins can contribute there actions here + manager.add(new Separator("Additions")); + } + + private void fillLocalPullDown(IMenuManager manager) { + if (chatWindow != null) { + manager.add(showChatWindow); + manager.add(new Separator()); + } + + manager.add(outputCopy); + manager.add(outputPaste); + manager.add(outputClear); + manager.add(new Separator()); + manager.add(outputSelectAll); + manager.add(new Separator()); + manager.add(sendFileToGroup); + manager.add(coBrowseURL); + //manager.add(startProgram); + manager.add(appShare); + manager.add(new Separator()); + manager.add(sendMessage); + manager.add(sendCVSUpdateRequest); + manager.add(sendShowViewRequest); + /* + * manager.add(new Separator()); manager.add(sendComponent); + * manager.add(sendComponentToServer); + * manager.add(sendEclipseComponent); + */ + manager.add(new Separator()); + manager.add(closeGroup); + } + + private void fillLocalToolBar(IToolBarManager manager) { + manager.add(outputCopy); + manager.add(outputPaste); + manager.add(outputClear); + manager.add(new Separator()); + manager.add(outputSelectAll); + manager.add(new Separator()); + manager.add(sendFileToGroup); + manager.add(coBrowseURL); + manager.add(startProgram); + manager.add(appShare); + manager.add(new Separator()); + manager.add(sendMessage); + /* + * manager.add(new Separator()); manager.add(sendComponent); + * manager.add(sendComponentToServer); + * manager.add(sendEclipseComponent); + */ + manager.add(new Separator()); + manager.add(closeGroup); + } + + private void fillTreeContextMenu(IMenuManager manager) { + User ud = treeView.getSelectionUser(); + if (ud != null) { + fillTreeContextMenuUser(manager, ud); + } else { + fillContextMenu(manager); + } + } + + private void fillTreeContextMenuUser(IMenuManager man, final User user) { + boolean toUs = false; + if (this.view.userdata != null) { + if (this.view.userdata.getUserID().equals(user.getUserID())) { + // this is us...so we have a special menu + toUs = true; + } + } + if (!toUs) { + Action sendFileToUser = new Action() { + public void run() { + sendFileToUser(user,false); + } + }; + sendFileToUser.setText("Send File to " + user.getNickname() + + "..."); + sendFileToUser.setImageDescriptor(PlatformUI.getWorkbench() + .getSharedImages().getImageDescriptor( + ISharedImages.IMG_OBJ_FILE)); + man.add(sendFileToUser); + + Action sendFileToUserAndLaunch = new Action() { + public void run() { + sendFileToUser(user,true); + } + }; + sendFileToUserAndLaunch.setText("Send File to " + user.getNickname()+" and Launch..."); + sendFileToUserAndLaunch.setImageDescriptor(PlatformUI.getWorkbench() + .getSharedImages().getImageDescriptor( + ISharedImages.IMG_OBJ_FILE)); + man.add(sendFileToUserAndLaunch); + + Action coBrowseToUser = new Action() { + public void run() { + sendCoBrowseToUser(user); + } + }; + coBrowseToUser.setText("Co-Browse Web with " + + user.getNickname() + "..."); + man.add(coBrowseToUser); + /* + * Action startProgramToUser = new Action() { public void run() { + * startProgram(user); } }; startProgramToUser.setText( "Start + * Program for " + user.getNickname() + "..."); + * man.add(startProgramToUser); + */ + man.add(new Separator()); + + Action startAppShareToUser = new Action() { + public void run() { + sendAppShare(user.getUserID()); + } + }; + startAppShareToUser.setText("Start Application Share with " + + user.getNickname() + "..."); + man.add(startAppShareToUser); + //startAppShareToUser.setEnabled(Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)&& !LineChatView.appShareActive()); + + man.add(new Separator()); + Action ringUser = new Action() { + public void run() { + sendRingMessageToUser(user); + } + }; + ringUser.setText("Ring " + user.getNickname() + "..."); + man.add(ringUser); + Action sendMessageToUser = new Action() { + public void run() { + sendPrivateTextMsg(user); + } + }; + sendMessageToUser.setText("Send Private Message to " + + user.getNickname() + "..."); + man.add(sendMessageToUser); + + Action sendCVSUpdateRequest = new Action() { + public void run() { + sendCVSUpdateRequest(user); + } + }; + sendCVSUpdateRequest.setText("Send CVS Update Request to "+user.getNickname()+"..."); + man.add(sendCVSUpdateRequest); + + Action sendShowViewRequest = new Action() { + public void run() { + sendShowViewRequest(user); + } + }; + sendShowViewRequest.setText("Send Show View Request to "+user.getNickname()+"..."); + man.add(sendShowViewRequest); + /* + man.add(new Separator()); + Action createProxy = new Action() { + public void run() { + sendEclipseComponent(user); + } + }; + createProxy.setText("Send EclipseProjectComponent to " + + user.getNickname() + "..."); + man.add(createProxy); + + Action messageProxy = new Action() { + public void run() { + messageEclipseComponent(user); + } + }; + messageProxy.setText("Message EclipseProjectComponent for " + + user.getNickname() + "..."); + messageProxy.setEnabled(this.view.proxyObjects.size() > 0); + + man.add(messageProxy); + Action removeProxy = new Action() { + public void run() { + removeEclipseComponent(user); + } + }; + removeProxy.setText("Remove EclipseProjectComponent for " + + user.getNickname() + "..."); + removeProxy.setEnabled(this.view.proxyObjects.size() > 0); + man.add(removeProxy); + */ + /* + * man.add(new Separator()); + * + * Action createObject = new Action() { public void run() { + * sendRepObjectToGroup(user); } }; createObject.setText( "Send + * Replicated Object to " + user.getNickname() + "..."); + * man.add(createObject); + */ + + } else { + // This is a menu to us + Action sendMessageToUser = new Action() { + public void run() { + MessageDialog.openError(null, "Message to " + + user.getNickname(), + "Talking to yourself again aren't you!!\n\n\tUsername: " + + user.getNickname() + "\n\tID: " + + user.getUserID().getName()); + } + }; + sendMessageToUser.setText("Send Message to Yourself"); + man.add(sendMessageToUser); + } + // Other plug-ins can contribute there actions here + man.add(new Separator("Additions")); + } + + protected String[] getArgs(String aString) { + StringTokenizer st = new StringTokenizer(aString); + int argscount = st.countTokens() - 1; + if (argscount < 1) + return null; + String[] newArray = new String[argscount]; + st.nextToken(); + int i = 0; + while (st.hasMoreTokens()) { + newArray[i++] = st.nextToken(); + } + return newArray; + } + + protected String getCommand(String aString) { + StringTokenizer st = new StringTokenizer(aString); + return st.nextToken(); + } + + private String getID(String title, String message, String initialValue) { + InputDialog id = new InputDialog(this.view.view.getSite().getShell(), title, + message, initialValue, null); + id.setBlockOnOpen(true); + int res = id.open(); + if (res == InputDialog.OK) + return id.getValue(); + else + return null; + } + + protected void handleEnter() { + if(textinput.getText().trim().length() > 0) + this.view.handleTextInput(textinput.getText()); + + clearInput(); + typing = false; + } + + protected void handleKeyPressed(KeyEvent evt) { + if (evt.keyCode == SWT.CR) { + handleEnter(); + } else if (evt.keyCode == SWT.ESC && chatWindow != null) { + chatWindow.getShell().setVisible(false); + } + } + + protected void handleKeyReleased(KeyEvent evt) { + } + + private void hookContextMenu() { + MenuManager menuMgr = new MenuManager("#PopupMenu"); + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + fillContextMenu(manager); + } + }); + Menu menu = menuMgr.createContextMenu(textoutput.getControl()); + textoutput.getControl().setMenu(menu); + this.view.view.getSite().registerContextMenu(menuMgr, textoutput); + + MenuManager treeMenuMgr = new MenuManager("#PopupMenu"); + treeMenuMgr.setRemoveAllWhenShown(true); + treeMenuMgr.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + fillTreeContextMenu(manager); + } + }); + Menu treeMenu = treeMenuMgr + .createContextMenu(treeView.getControl()); + treeView.getControl().setMenu(treeMenu); + this.view.view.getSite().registerContextMenu(treeMenuMgr, treeView); + } + + protected Control getTreeControl() { + return treeView.getControl(); + } + + protected Control getTextControl() { + return textoutput.getControl(); + } + + protected void makeActions() { + outputSelectAll = new Action() { + public void run() { + outputSelectAll(); + } + }; + outputSelectAll.setText(MessageLoader + .getString("LineChatClientView.contextmenu.selectall")); + outputSelectAll + .setToolTipText(MessageLoader + .getString("LineChatClientView.contextmenu.selectall.tooltip")); + outputSelectAll.setAccelerator(SWT.CTRL | 'A'); + outputCopy = new Action() { + public void run() { + outputCopy(); + } + }; + outputCopy.setText(MessageLoader + .getString("LineChatClientView.contextmenu.copy")); + outputCopy.setToolTipText(MessageLoader + .getString("LineChatClientView.contextmenu.copy.tooltip")); + outputCopy.setAccelerator(SWT.CTRL | 'C'); + outputCopy.setImageDescriptor(PlatformUI.getWorkbench() + .getSharedImages().getImageDescriptor( + ISharedImages.IMG_TOOL_COPY)); + + outputClear = new Action() { + public void run() { + outputClear(); + } + }; + outputClear.setText(MessageLoader + .getString("LineChatClientView.contextmenu.clear")); + outputClear.setToolTipText(MessageLoader + .getString("LineChatClientView.contextmenu.clear.tooltip")); + + outputPaste = new Action() { + public void run() { + outputPaste(); + } + }; + outputPaste.setText(MessageLoader + .getString("LineChatClientView.contextmenu.paste")); + outputPaste.setToolTipText(MessageLoader + .getString("LineChatClientView.contextmenu.paste.tooltip")); + outputCopy.setAccelerator(SWT.CTRL | 'V'); + outputPaste.setImageDescriptor(PlatformUI.getWorkbench() + .getSharedImages().getImageDescriptor( + ISharedImages.IMG_TOOL_PASTE)); + + sendFileToGroup = new Action() { + public void run() { + sendFileToGroup(false); + } + }; + sendFileToGroup.setText(MessageLoader + .getString("LineChatClientView.contextmenu.sendfile")); + sendFileToGroup.setImageDescriptor(PlatformUI.getWorkbench() + .getSharedImages().getImageDescriptor( + ISharedImages.IMG_OBJ_FILE)); + + sendFileToGroupAndLaunch = new Action() { + public void run() { + sendFileToGroup(true); + } + }; + sendFileToGroupAndLaunch.setText(MessageLoader + .getString("LineChatClientView.contextmenu.sendfileandlaunch")); + sendFileToGroupAndLaunch.setImageDescriptor(PlatformUI.getWorkbench() + .getSharedImages().getImageDescriptor( + ISharedImages.IMG_OBJ_FILE)); + + coBrowseURL = new Action() { + public void run() { + sendCoBrowseToUser(null); + } + }; + coBrowseURL.setText(MessageLoader + .getString("LineChatClientView.contextmenu.cobrowse")); + + startProgram = new Action() { + public void run() { + startProgram(null); + } + }; + startProgram.setText(MessageLoader + .getString("LineChatClientView.contextmenu.runprogram")); + + appShare = new Action() { + public void run() { + sendAppShare(null); + } + }; + appShare.setText(MessageLoader + .getString("LineChatClientView.contextmenu.appshare")); + appShare.setEnabled(Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)); + + sendMessage = new Action() { + public void run() { + sendMessageToGroup(); + } + }; + sendMessage.setText(MessageLoader + .getString("LineChatClientView.contextmenu.sendmessage")); + sendComponent = new Action() { + public void run() { + sendRepObjectToGroup(null); + } + }; + sendComponent.setText(MessageLoader + .getString("LineChatClientView.contextmenu.repobject")); + sendComponentToServer = new Action() { + public void run() { + sendRepObjectToServer(); + } + }; + sendComponentToServer + .setText(MessageLoader + .getString("LineChatClientView.contextmenu.repobjectserver")); + sendComponentToServer.setEnabled(false); + + sendEclipseComponent = new Action() { + public void run() { + sendEclipseComponent(null); + } + }; + sendEclipseComponent.setText(MessageLoader + .getString("LineChatClientView.contextmenu.send")); + + messageEclipseComponent = new Action() { + public void run() { + messageEclipseComponent(null); + } + }; + messageEclipseComponent.setText(MessageLoader + .getString("LineChatClientView.contextmenu.message")); + messageEclipseComponent.setEnabled(false); + removeEclipseComponent = new Action() { + public void run() { + removeEclipseComponent(null); + } + }; + removeEclipseComponent.setText(MessageLoader + .getString("LineChatClientView.contextmenu.remove")); + removeEclipseComponent.setEnabled(false); + // Close projectGroup + closeGroup = new Action() { + public void run() { + closeProjectGroup(null); + } + }; + closeGroup.setText(MessageLoader + .getString("LineChatClientView.contextmenu.leaveGroup")); + closeGroup.setEnabled(true); + + sendCVSUpdateRequest = new Action() { + public void run() { + sendCVSUpdateRequest(null); + } + }; + sendCVSUpdateRequest.setText(MessageLoader.getString("LineChatClientView.contextmenu.sendCVSUpdateRequest")); + sendCVSUpdateRequest.setEnabled(this.view.lch.isCVSShared()); + + sendShowViewRequest = new Action() { + public void run() { + sendShowViewRequest(null); + } + }; + sendShowViewRequest.setText(MessageLoader.getString("LineChatClientView.contextmenu.sendShowViewRequest")); + sendShowViewRequest.setEnabled(true); + + if (chatWindow != null) { + showChatWindow = new Action() { + public void run() { + chatWindow.open(); + if (!chatWindow.hasFocus()) + chatWindow.getShell().forceActive(); + } + }; + showChatWindow.setText("Show chat window"); + } + } + protected void sendShowViewRequest(User touser) { + String viewid = null; + IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IWorkbenchPage page = ww.getActivePage(); + if (page == null) + return; + ShowViewsDialog dlg = new ShowViewsDialog(getShell(),view.lch); + dlg.open(); + if (dlg.getReturnCode() == Window.CANCEL) + return; + dlg.showViews(touser); + } + protected void sendCVSUpdateRequest(User touser) { + //String initStr = MessageLoader.getString("LineChatClientView.contextmenu.sendCVSUpdateRequestInitStr"); + //String res = getID(MessageLoader.getString("LineChatClientView.contextmenu.sendCVSUpdateRequestTitle"), + // MessageLoader.getString("LineChatClientView.contextmenu.sendCVSUpdateRequestMessage"), initStr); + this.view.lch.sendCVSProjectUpdateRequest(touser,null); + } + + protected void closeProjectGroup(User user) { + if (MessageDialog.openConfirm(null, + MessageLoader.getString("LineChatClientView.contextmenu.closeMessageTitle"), + MessageLoader.getString("LineChatClientView.contextmenu.closeMessageMessage")+ this.view.name + + "'?")) { + this.view.lch.chatGUIDestroy(); + + } + + } + + protected void messageEclipseComponent(User user) { + String res = null; + ID userID = null; + + String initStr = ""; + if (this.view.proxyObjects.size() > 0) { + initStr = (String) this.view.proxyObjects.get(this.view.proxyObjects.size() - 1); + } + res = initStr; + if (user != null) { + res = getID("Message EclipseProjectComponent for " + + user.getNickname(), "EclipseProjectComponent Message:", + initStr); + userID = user.getUserID(); + } else { + res = getID("Message EclipseProjectComponent for Group", + "EclipseProjectComponent Message:", initStr); + } + if (res != null) { + String className = getCommand(res); + // Find proxy object in local vector + if (this.view.proxyObjects.contains(className)) { + String[] args = getArgs(res); + String meth = ""; + Object[] actualArgs = new Object[0]; + if (args != null && args.length >= 2) { + meth = args[0]; + actualArgs = new Object[args.length - 1]; + for (int i = 1; i < args.length; i++) { + actualArgs[i - 1] = args[i]; + } + } + // Send message + this.view.messageProxyObject(userID, className, meth, actualArgs); + } + } + } + + protected void outputClear() { + if (MessageDialog.openConfirm(null, "Confirm Clear Text Output", + "Are you sure you want to clear output?")) + textoutput.getTextWidget().setText(""); + } + + protected void outputCopy() { + String t = textoutput.getTextWidget().getSelectionText(); + if (t == null || t.length() == 0) { + textoutput.getTextWidget().selectAll(); + } + textoutput.getTextWidget().copy(); + textoutput.getTextWidget().setSelection( + textoutput.getTextWidget().getText().length()); + } + + protected void outputPaste() { + textinput.paste(); + } + + protected void outputSelectAll() { + textoutput.getTextWidget().selectAll(); + } + + protected int getChunkPreference() { + IPreferenceStore pstore = ClientPlugin.getDefault() + .getPreferenceStore(); + int chunksize = pstore + .getInt(ClientPlugin.DEFAULT_FILE_TRANSFER_CHUNKTIME_NAME); + if (chunksize <= 0) { + chunksize = 1024; + } + return chunksize; + } + + protected int getDelayPreference() { + IPreferenceStore pstore = ClientPlugin.getDefault() + .getPreferenceStore(); + int delay = pstore + .getInt(ClientPlugin.DEFAULT_FILE_TRANSFER_DELAY_NAME); + if (delay <= 0) { + delay = 10; + } + return delay; + } + + protected void readStreamAndSend(java.io.InputStream local, + String fileName, Date startDate, ID target, final boolean launch) { + try { + ID eclipseStageID = IDFactory + .makeStringID(org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject.ECLIPSEOBJECTNAME); + java.io.BufferedInputStream ins = new java.io.BufferedInputStream( + local); + java.io.File remoteFile = new File((new File(fileName)).getName()); + FileTransferParams sp = new FileTransferParams(remoteFile, + getChunkPreference(), getDelayPreference(), null, true, + -1, null); + final Object[] args = { view, target, ins, + sp, eclipseStageID }; + // Do it + new Thread(new Runnable() { + public void run() { + if (launch) { + ChatComposite.this.view.makeObject( + null, + org.eclipse.ecf.example.collab.share.io.EclipseFileTransferAndLaunch.class + .getName(), new String[] { + FileSenderUI.class.getName(), + ID.class.getName(), + java.io.InputStream.class.getName(), + FileTransferParams.class.getName(), + ID.class.getName() }, args); + } else { + ChatComposite.this.view.makeObject( + null, + org.eclipse.ecf.example.collab.share.io.EclipseFileTransfer.class + .getName(), new String[] { + FileSenderUI.class.getName(), + ID.class.getName(), + java.io.InputStream.class.getName(), + FileTransferParams.class.getName(), + ID.class.getName() }, args); + } + } + }, "FileRepObject creator").start(); + } catch (Exception e) { + if (this.view.lch != null) + this.view.lch.chatException(e, "readStreamAndSend()"); + } + + } + + protected void removeEclipseComponent(User user) { + String initStr = LineChatClientView.DEFAULT_ECLIPSE_COMPONENT_CLASS; + + String res = null; + ID userID = null; + if (user != null) { + res = getID( + "Remove EclipseProjectComponent for " + user.getNickname(), + "EclipseProjectComponent Class:", initStr); + userID = user.getUserID(); + } else { + res = getID("Remove EclipseProjectComponent", + "EclipseProjectComponent Class:", initStr); + } + if (res != null) + this.view.removeProxyObject(userID, res); + } + + protected void sendAppShare(ID receiver) { + if (this.view.lch == null) + return; + /* + try { + if (LineChatView.appShareActive()) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, + MessageLoader.getString("LineChatClientView.contextmenu.appshare.activetitle"), + MessageLoader.getString("LineChatClientView.contextmenu.appshare.activemessage")); + } + }); + return; + } + if (MessageDialog.openConfirm(null, MessageLoader.getString("LineChatClientView.contextmenu.appshare.confirmtitle"), + MessageLoader.getString("LineChatClientView.contextmenu.appshare.confirmmessage"))) { + + VNCParams p = new VNCParams(); + p.setHostname(this.view.userdata.getNickname()); + p.setGroupname(this.view.name); + Object[] args = new Object[] { receiver, p }; + HashMap map = new HashMap(); + map.put("args",args); + map.put("types",LineChatClientView.APPSHAREARGTYPES); + ID serverID = this.view.lch.makeObject(null, LineChatClientView.APPSHARECLASSNAME, map); + EclipseAppShareServer server = (EclipseAppShareServer) this.view.lch.getObject(serverID); + if (server != null) { + LineChatView.setAppShareID(serverID,server); + this.view.setAppShareID(serverID); + } + + } + } catch (final Exception e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, + MessageLoader.getString("LineChatClientView.contextmenu.appshare.cancelledtitle"), + MessageLoader.getString("LineChatClientView.contextmenu.appshare.cancelledmessage")); + ClientPlugin.log("Exception starting application share",e); + } + }); + } + */ + } + + protected void sendCoBrowseToUser(User user) { + String res = null; + ID userID = null; + if (user != null) { + res = getID("Co-Browse URL to " + user.getNickname(), + "URL to Browse:", "http://"); + userID = user.getUserID(); + } else { + res = getID("Co-Browse URL", "URL to Browse:", "http://"); + } + if (res != null) { + Object[] args = { userID, res }; + // Do it + this.view.makeObject(null, LineChatClientView.SHOWURLCLASSNAME, LineChatClientView.SHOWURLARGTYPES, + args); + } + } + + protected void sendEclipseComponent(User user) { + String initStr = LineChatClientView.DEFAULT_ECLIPSE_COMPONENT_CLASS; + + String res = null; + ID userID = null; + if (user != null) { + res = getID("Send EclipseProjectComponent to " + user.getNickname(), + "EclipseProjectComponent Class:", initStr); + userID = user.getUserID(); + } else { + res = getID("Send EclipseProjectComponent", "EclipseProjectComponent Class:", + initStr); + } + if (res != null) + this.view.makeProxyObject(userID, res); + } + + protected void sendFile(String pathName, final String fileName, + Date startDate, ID target,boolean launch) { + + try { + copyFileLocally(pathName, fileName); + } catch (final IOException e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openError(null, "Local File Copy Error", + "Exception copying file locally. Cancelling file transfer.\nException: " + + e); + } + }); + if (this.view.lch != null) + this.view.lch.chatException(e, "sendFile(" + pathName + "/" + + fileName + ")"); + return; + } + + java.io.FileInputStream ins = null; + try { + ins = new java.io.FileInputStream(pathName); + } catch (final java.io.FileNotFoundException e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openError(null, "File Open Error", + "File '" + fileName + + "' not found\nException: " + e); + } + }); + if (this.view.lch != null) + this.view.lch.chatException(e, "File '" + fileName + "' not found."); + } + readStreamAndSend(ins, fileName, startDate, target,launch); + } + + protected void sendFileToGroup(boolean launch) { + FileDialog fd = new FileDialog(Display.getDefault() + .getActiveShell(), SWT.OPEN); + fd.setFilterPath(System.getProperty("user.dir")); + fd.setText("Select File for Group"); + String res = fd.open(); + if (res != null) { + java.io.File selected = new java.io.File(res); + File localTarget = new File(this.view.downloaddir,selected.getName()); + sendFile(selected.getPath(), localTarget.getAbsolutePath(), + null, null,launch); + } + } + + protected void sendFileToUser(User user,boolean launch) { + FileDialog fd = new FileDialog(Display.getDefault() + .getActiveShell(), SWT.OPEN); + fd.setFilterPath(System.getProperty("user.dir")); + fd.setText("Select File for " + user.getNickname()); + String res = fd.open(); + if (res != null) { + java.io.File selected = new java.io.File(res); + File localTarget = new File(this.view.downloaddir,selected.getName()); + sendFile(selected.getPath(), localTarget.getAbsolutePath(), + null, user.getUserID(),launch); + } + } + + protected void sendMessageToGroup() { + String res = getID("Send Message to Group", "Message For Group:", + ""); + if (res != null & !res.equals("")) { + String[] args = { res, this.view.userdata.getNickname() }; + this.view.makeObject(null, LineChatClientView.MESSAGECLASSNAME, args); + } + } + + protected void sendPrivateTextMsg(User data) { + if (this.view.lch != null) { + String res = getID("Private Message for " + data.getNickname(), + "Message: ", ""); + if (res != null) + this.view.lch.sendPrivateMessageToUser(data, res); + } + } + + protected void sendRepObjectToGroup(User user) { + String result = getID( + "Send Replicated Object", + "Replicated Object Class and Args (separated by whitespace):", + ""); + if (result != null && !result.equals("")) { + this.view.makeObject(null, getCommand(result), getArgs(result)); + } + } + + protected void sendRepObjectToServer() { + // XXX TODO + } + + protected void sendRingMessageToUser(User data) { + String res = null; + if (this.view.lch != null) { + if (data != null) { + res = getID("Ring " + data.getNickname(), "Ring Message: ", + ""); + } else { + res = getID("Ring Group", "Ring Message: ", ""); + } + if (res != null) + this.view.lch.sendRingMessageToUser(data, res); + } + } + + protected void startProgram(User ud) { + String res = null; + ID receiver = null; + if (ud == null) { + res = getID("Start Program for Group", "Program to Start:", ""); + } else { + res = getID("Start Program for " + ud.getNickname(), + "Program to Start for " + ud.getNickname() + ":", ""); + receiver = ud.getUserID(); + } + if (res != null) + this.view.runProgram(receiver, res, null); + } + + protected void initializeDropTargets() { + chatDropTarget = new ChatDropTarget(view,textoutput.getControl(), this); + treeDropTarget = new TreeDropTarget(view,treeView.getControl(), this); + } + +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatDropTarget.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatDropTarget.java new file mode 100644 index 000000000..95aa6e853 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatDropTarget.java @@ -0,0 +1,103 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.io.File; + +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTarget; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.DropTargetListener; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.widgets.Control; + +class ChatDropTarget implements DropTargetListener { + private final LineChatClientView view; + DropTarget dropTarget = null; + TextTransfer textTransfer = null; + FileTransfer fileTransfer = null; + ChatComposite composite = null; + User selectedUser = null; + public ChatDropTarget(LineChatClientView view, Control control, ChatComposite comp) { + dropTarget = new DropTarget(control, DND.DROP_MOVE | DND.DROP_COPY + | DND.DROP_DEFAULT); + this.view = view; + textTransfer = TextTransfer.getInstance(); + fileTransfer = FileTransfer.getInstance(); + Transfer[] types = new Transfer[] { fileTransfer, textTransfer }; + dropTarget.setTransfer(types); + dropTarget.addDropListener(this); + composite = comp; + } + public void dragEnter(DropTargetEvent event) { + if (event.detail == DND.DROP_DEFAULT) { + if ((event.operations & DND.DROP_COPY) != 0) { + event.detail = DND.DROP_COPY; + } else { + event.detail = DND.DROP_NONE; + } + } + // will accept text but prefer to have files dropped + for (int i = 0; i < event.dataTypes.length; i++) { + if (fileTransfer.isSupportedType(event.dataTypes[i])) { + event.currentDataType = event.dataTypes[i]; + // files should only be copied + if (event.detail != DND.DROP_COPY) { + event.detail = DND.DROP_NONE; + } + break; + } + } + } + public void dragOver(DropTargetEvent event) { + event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL; + } + public void dragOperationChanged(DropTargetEvent event) { + if (event.detail == DND.DROP_DEFAULT) { + if ((event.operations & DND.DROP_COPY) != 0) { + event.detail = DND.DROP_COPY; + } else { + event.detail = DND.DROP_NONE; + } + } + // allow text to be moved but files should only be copied + if (fileTransfer.isSupportedType(event.currentDataType)) { + if (event.detail != DND.DROP_COPY) { + event.detail = DND.DROP_NONE; + } + } + } + public void dragLeave(DropTargetEvent event) { + } + public void dropAccept(DropTargetEvent event) { + } + public void drop(DropTargetEvent event) { + if (fileTransfer.isSupportedType(event.currentDataType)) { + String[] files = (String[]) event.data; + for (int i = 0; i < files.length; i++) { + ID target = (selectedUser == null) ? null : selectedUser + .getUserID(); + // Send file to user + File file = new File(files[i]); + if (file.exists() && !file.isDirectory() + && composite != null) { + composite.sendFile(file.getPath(), this.view.downloaddir + + file.getName(), null, target,false); + } + } + } + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatLayout.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatLayout.java new file mode 100644 index 000000000..030053050 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatLayout.java @@ -0,0 +1,62 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Layout; + + +class ChatLayout extends Layout { + protected static final int TEXT_HEIGHT_FUDGE = 8; + Point iExtent, tExtent; + int inputSize = 15; + int separatorSize = 5; + int textHeight = -1; + ChatLayout(int defaultInputSize, int sepSize) { + this.inputSize = defaultInputSize; + this.separatorSize = sepSize; + } + protected Point computeSize(Composite composite, int wHint, int hHint, + boolean changed) { + Control[] children = composite.getChildren(); + if (changed || iExtent == null || tExtent == null) { + iExtent = children[0].computeSize(SWT.DEFAULT, SWT.DEFAULT, + false); + tExtent = children[1].computeSize(SWT.DEFAULT, SWT.DEFAULT, + false); + } + int width = iExtent.x + 5 + tExtent.x; + int height = Math.max(iExtent.y, tExtent.y); + return new Point(width + 2, height + 2); + } + protected void layout(Composite composite, boolean changed) { + Control[] children = composite.getChildren(); + Point windowSize = composite.getSize(); + children[0].setBounds(1, 1, windowSize.x, windowSize.y + - (inputSize + separatorSize)); + children[1].setBounds(1, children[0].getSize().y + separatorSize, + windowSize.x, inputSize); + if (changed || iExtent == null || tExtent == null) { + iExtent = children[0].computeSize(SWT.DEFAULT, SWT.DEFAULT, + false); + tExtent = children[1].computeSize(SWT.DEFAULT, SWT.DEFAULT, + false); + } + } + protected void setInputTextHeight(int height) { + textHeight = height; + inputSize = textHeight + TEXT_HEIGHT_FUDGE; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatTreeViewer.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatTreeViewer.java new file mode 100644 index 000000000..295ec8ed4 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatTreeViewer.java @@ -0,0 +1,55 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.util.Iterator; + +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.Composite; + +class ChatTreeViewer extends TreeViewer { + ChatTreeViewer(Composite parent, int options) { + super(parent, options); + } + + private User findUserNode(TreeObject to) { + if (to == null) + return null; + if (to instanceof TreeUser) { + TreeUser tu = (TreeUser) to; + return tu.getUser(); + } + if (to instanceof TreeParent) { + return findUserNode(((TreeParent) to).getParent()); + } + return null; + } + + public User getSelectionUser() { + User result = null; + ViewContentProvider cp = (ViewContentProvider) getContentProvider(); + ISelection s = getSelection(); + if (s != null && s instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) s; + for (Iterator i = ss.iterator(); i.hasNext();) { + Object o = i.next(); + result = findUserNode((TreeObject) o); + if (result != null) + return result; + } + } + return null; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatWindow.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatWindow.java new file mode 100644 index 000000000..5dacf214b --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ChatWindow.java @@ -0,0 +1,231 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.core.runtime.Path; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.window.ApplicationWindow; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.ShellAdapter; +import org.eclipse.swt.events.ShellEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +/** + * @author pnehrer + * + */ +public class ChatWindow extends ApplicationWindow { + + private static final long FLASH_INTERVAL = 600; + + private LineChatClientView view; + + private ChatTreeViewer tree; + + private String initText; + + private ChatComposite chat; + + private Image image; + + private Image blank; + + private boolean flashing; + + private final Runnable flipImage = new Runnable() { + public void run() { + Shell shell = getShell(); + if (!shell.isDisposed()) + if (blank == shell.getImage()) { + if (image != null && !image.isDisposed()) + shell.setImage(image); + } else { + if (blank != null && !blank.isDisposed()) + shell.setImage(blank); + } + } + }; + + private final Runnable showImageRunnable = new Runnable() { + public void run() { + Shell shell = getShell(); + if (!shell.isDisposed() && image != null && !image.isDisposed()) + shell.setImage(image); + } + }; + + private Flash flash; + + private class Flash implements Runnable { + + private final Display display; + + public Flash(Display display) { + this.display = display; + } + + public void run() { + while (true) { + synchronized (this) { + try { + while (!flashing) + wait(); + } catch (InterruptedException e) { + break; + } + } + + if (display.isDisposed()) + break; + + display.syncExec(flipImage); + synchronized (this) { + try { + wait(FLASH_INTERVAL); + } catch (InterruptedException e) { + break; + } + } + } + } + }; + + public ChatWindow(LineChatClientView view, Composite parent, + ChatTreeViewer tree, String initText) { + super(null); + this.view = view; + this.tree = tree; + this.initText = initText; + addStatusLine(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + protected void configureShell(final Shell newShell) { + super.configureShell(newShell); + newShell.setText("Team Chat: " + view.name); + image = ImageDescriptor.createFromURL( + ClientPlugin.getDefault().find(new Path("icons/person.gif"))) + .createImage(); + newShell.setImage(image); + RGB[] colors = new RGB[2]; + colors[0] = new RGB(0, 0, 0); + colors[1] = new RGB(255, 255, 255); + ImageData data = new ImageData(16, 16, 1, new PaletteData(colors)); + data.transparentPixel = 0; + blank = new Image(newShell.getDisplay(), data); + + flash = new Flash(newShell.getDisplay()); + new Thread(flash).start(); + + newShell.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + flash(); + if (image != null) + image.dispose(); + + if (blank != null) + blank.dispose(); + } + }); + + newShell.addShellListener(new ShellAdapter() { + public void shellActivated(ShellEvent e) { + stopFlashing(); + if (!chat.isDisposed()) + chat.textinput.setFocus(); + } + }); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) + */ + protected Control createContents(Composite parent) { + chat = new ChatComposite(view, parent, tree, SWT.NORMAL, initText, this); + chat.setLayoutData(new GridData(GridData.FILL_BOTH)); + chat.setFont(parent.getFont()); + return chat; + } + + ChatComposite getChat() { + return chat; + } + + boolean hasFocus() { + if (getShell().isDisposed()) + return false; + else + return hasFocus(getShell()); + } + + private boolean hasFocus(Composite composite) { + if (composite.isFocusControl()) + return true; + else { + Control[] children = composite.getChildren(); + for (int i = 0; i < children.length; ++i) + if (children[i] instanceof Composite + && hasFocus((Composite) children[i])) + return true; + else if (children[i].isFocusControl()) + return true; + } + + return false; + } + + void flash() { + synchronized (flash) { + if (!flashing) { + flashing = true; + flash.notify(); + } + } + } + + private void stopFlashing() { + synchronized (flash) { + if (flashing) { + flashing = false; + if (!getShell().isDisposed() && image != null && !image.isDisposed()) + getShell().setImage(image); + } + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.window.Window#handleShellCloseEvent() + */ + protected void handleShellCloseEvent() { + if (!getShell().isDisposed()) + getShell().setVisible(false); + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/FileReceiverUI.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/FileReceiverUI.java new file mode 100644 index 000000000..4fd28c5c3 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/FileReceiverUI.java @@ -0,0 +1,24 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.io.File; + +import org.eclipse.ecf.core.identity.ID; + +public interface FileReceiverUI { + + public void receiveStart(ID from, File aFile, long length, float rate); + public void receiveData(ID from, File aFile, int dataLength); + public void receiveDone(ID from, File aFile, Exception e); + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/FileSenderUI.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/FileSenderUI.java new file mode 100644 index 000000000..a792fb108 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/FileSenderUI.java @@ -0,0 +1,22 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.io.File; + +public interface FileSenderUI { + + public void sendStart(File aFile, long length, float rate); + public void sendData(File aFile, long dataLength); + public void sendDone(File aFile, Exception e); + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java new file mode 100644 index 000000000..7fd6aa287 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizard.java @@ -0,0 +1,78 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.ecf.example.collab.actions.ClientConnectAction; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IWorkbench; + +public class JoinGroupWizard extends Wizard { + JoinGroupWizardPage mainPage; + private IProject project; + private IWorkbench workbench; + + public JoinGroupWizard(IProject project, IWorkbench workbench) { + super(); + this.project = project; + this.workbench = workbench; + } + + protected ISchedulingRule getSchedulingRule() { + return project; + } + public void addPages() { + super.addPages(); + mainPage = new JoinGroupWizardPage(); + addPage(mainPage); + } + + public boolean performFinish() { + try { + finishPage(new NullProgressMonitor()); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + protected void finishPage(final IProgressMonitor monitor) + throws InterruptedException, CoreException { + + ClientConnectAction client = null; + String groupName = mainPage.getJoinGroupText(); + String nickName = mainPage.getNicknameText(); + String containerType = mainPage.getContainerType(); + String password = mainPage.getPasswordText(); + try { + ID groupID = IDFactory.makeStringID(groupName); + client = new ClientConnectAction(); + client.setProject(project); + client.setUsername(nickName); + client.setTargetID(groupID); + client.setContainerType(containerType); + client.setData(password); + client.run(null); + } catch (Exception e) { + String id = ClientPlugin.PLUGIN_ID; + throw new CoreException(new Status(Status.ERROR, id, 100, "Could not connect to "+groupName, e)); + } + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizardAction.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizardAction.java new file mode 100644 index 000000000..ad5d97eeb --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizardAction.java @@ -0,0 +1,68 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.part.IShowInSource; +import org.eclipse.ui.part.ShowInContext; + +public class JoinGroupWizardAction extends ActionDelegate implements + IObjectActionDelegate { + + IProject project; + + public JoinGroupWizardAction() { + super(); + } + + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + project = null; + Object o = targetPart.getAdapter(IShowInSource.class); + if (o != null) { + IShowInSource sis = (IShowInSource) o; + ShowInContext sc = sis.getShowInContext(); + ISelection s = sc.getSelection(); + if (s instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) s; + Object obj = ss.getFirstElement(); + if (obj instanceof IJavaProject) { + IJavaProject ij = (IJavaProject) obj; + project = ij.getProject(); + } + if (obj instanceof IProject) { + project = (IProject) obj; + } + } + } + } + protected IWorkbench getWorkbench() { + return PlatformUI.getWorkbench(); + } + + public void run(IAction action) { + JoinGroupWizard wizard = new JoinGroupWizard(project,getWorkbench()); + // Create the wizard dialog + WizardDialog dialog = new WizardDialog + (getWorkbench().getActiveWorkbenchWindow().getShell(),wizard); + // Open the wizard dialog + dialog.open(); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizardPage.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizardPage.java new file mode 100644 index 000000000..d6ac7c7bb --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/JoinGroupWizardPage.java @@ -0,0 +1,128 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ +package org.eclipse.ecf.example.collab.ui; + +import java.util.Iterator; +import java.util.List; +import org.eclipse.ecf.core.SharedObjectContainerDescription; +import org.eclipse.ecf.core.SharedObjectContainerFactory; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class JoinGroupWizardPage extends WizardPage { + protected static final String PAGE_DESCRIPTION = "Join ECF Collaboration Group"; + private static final String JOINGROUP_FIELDNAME = "Group ID:"; + private static final String NICKNAME_FIELDNAME = "Nickname:"; + private static final String ECF_DEFAULT_URL = "ecftcp://localhost:3282/server"; + protected static final String ECF_TEMPLATE_URL = "ecftcp://<machinename>:<port>/<name>"; + protected static final String PAGE_TITLE = "Join ECF Group"; + + public JoinGroupWizardPage() { + super("wizardPage"); + setTitle(PAGE_TITLE); + setDescription(PAGE_DESCRIPTION); + } + + protected Text nickname_text; + protected Text joingroup_text; + protected Combo combo; + protected Text password_text; + protected List containerDescriptions; + + protected void fillCombo() { + combo.add("Default"); + containerDescriptions = SharedObjectContainerFactory.getDescriptions(); + for(Iterator i=containerDescriptions.iterator(); i.hasNext(); ) { + SharedObjectContainerDescription desc = (SharedObjectContainerDescription) i.next(); + String name = desc.getName(); + String description = desc.getDescription(); + if (description != null && !description.equals("")) { + name = name + " - " + description; + } + combo.add(name); + } + // Set to default + combo.select(0); + } + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + final GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + container.setLayout(gridLayout); + // + setControl(container); + + final Label label_4 = new Label(container, SWT.NONE); + label_4.setText("ECF Provider:"); + + combo = new Combo(container, SWT.NONE); + final GridData gridData_1 = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + combo.setLayoutData(gridData_1); + fillCombo(); + + final Label label_2 = new Label(container, SWT.NONE); + + final Label label_3 = new Label(container, SWT.NONE); + label_3.setText(ECF_TEMPLATE_URL); + + final Label label = new Label(container, SWT.NONE); + label.setText(JOINGROUP_FIELDNAME); + + joingroup_text = new Text(container, SWT.BORDER); + joingroup_text.setText(ECF_DEFAULT_URL); + final GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.widthHint = 140; + joingroup_text.setLayoutData(gridData); + + final Label label_1 = new Label(container, SWT.NONE); + label_1.setLayoutData(new GridData()); + label_1.setText(NICKNAME_FIELDNAME); + + nickname_text = new Text(container, SWT.BORDER); + final GridData nickname = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + nickname_text.setLayoutData(nickname); + nickname_text.setText(System.getProperty("user.name")); + + final Label label_5 = new Label(container, SWT.NONE); + label_5.setText("Password:"); + + password_text = new Text(container, SWT.BORDER); + password_text.setEchoChar('*'); + password_text.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + } + + public String getJoinGroupText() { + return joingroup_text.getText().trim(); + } + + public String getNicknameText() { + return nickname_text.getText().trim(); + } + + public String getPasswordText() { + return password_text.getText(); + } + + public String getContainerType() { + int index = combo.getSelectionIndex(); + if (index == 0) return null; + else { + SharedObjectContainerDescription desc = (SharedObjectContainerDescription) containerDescriptions.get(index-1); + return desc.getName(); + } + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatClientView.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatClientView.java new file mode 100644 index 000000000..1997c3301 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatClientView.java @@ -0,0 +1,499 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.share.EclipseMessage; +import org.eclipse.ecf.example.collab.share.TreeItem; +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.ecf.example.collab.share.url.ExecProg; +import org.eclipse.ecf.example.collab.share.url.ExecURL; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.part.ViewPart; + + +public class LineChatClientView implements FileSenderUI { + /* + public static final String[] APPSHAREARGTYPES = { ID.class.getName(), + VNCParams.class.getName() }; + public static final String APPSHARECLASSNAME = EclipseAppShareServer.class + .getName(); + */ + public static final String CLIENT_PREFIX = " says"; + protected static final String DEFAULT_ECLIPSE_COMPONENT_CLASS = org.eclipse.ecf.example.collab.share.TestEclipseSessionComponent.class + .getName(); + public static final String DEFAULT_UNIX_BROWSER = "mozilla"; + public static final String ENTER_STRING = "ARRIVED"; + public static final String EXECPROGARGTYPES[] = { ID.class.getName(), + "[Ljava.lang.String;", "[Ljava.lang.String;", + Boolean.class.getName(), Boolean.class.getName() }; + public static final String EXECPROGCLASSNAME = ExecProg.class.getName(); + public static final String HOST_PREFIX = "You say"; + public static final String LEFT_STRING = "LEFT"; + public static final String MESSAGECLASSNAME = EclipseMessage.class + .getName(); + public static final String REMOTEFILEPATH = null; + public static final String SHOWURLARGTYPES[] = { ID.class.getName(), + "java.lang.String" }; + public static final String SHOWURLCLASSNAME = ExecURL.class.getName(); + protected static final int TREE_EXPANSION_LEVELS = 1; + public static final String TREE_HEADER = "Participants"; + SimpleDateFormat df = new SimpleDateFormat("MM/dd hh:mm a"); + String downloaddir; + LineChatHandler lch; + Hashtable myNames = new Hashtable(); + String name; + Vector proxyObjects = new Vector(); + TeamChat teamChat; + User userdata; + LineChatView view; + protected ID appShareID = null; + protected ID getAppShareID() { + return appShareID; + } + protected void setAppShareID(ID val) { + appShareID = val; + } + public LineChatClientView(LineChatHandler lch, LineChatView view, + String name, String initText, String downloaddir) { + super(); + this.lch = lch; + this.view = view; + this.name = name; + this.teamChat = new TeamChat(this,view.tabFolder, SWT.NULL, initText); + this.userdata = lch.getUser(); + this.downloaddir = downloaddir; + if (userdata != null) + addUser(userdata); + } + public ViewPart getView() { + return view; + } + public Control getTextControl() { + return teamChat.getTextControl(); + } + public Control getTreeControl() { + return teamChat.getTreeControl(); + } + public boolean addUser(User ud) { + if (ud == null) + return false; + ID userID = ud.getUserID(); + String username = ud.getNickname(); + if (myNames.containsKey(userID)) { + String existingName = (String) myNames.get(userID); + if (!existingName.equals(username)) { + myNames.put(userID, username); + final String str = existingName + " changed name to " + + username; + showText(str); + } + return false; + } else { + myNames.put(userID, username); + final String str = dateTime() + " " + username + " " + ENTER_STRING; + addUserToTree(ud); + showText(str); + return true; + } + } + protected void addUserToTree(User ud) { + if (ud == null) + return; + TreeParent root = getPresenceRoot(); + if (root == null) + return; + TreeUser top = makeUserNode(ud); + if (top == null) + return; + root.addChild(top); + refreshTreeView(); + } + protected void appendAndScrollToBottom(final String str) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + if (teamChat != null) + teamChat.appendText(str + "\n"); + } + }); + } + public boolean changeUser(User user) { + return changeUserInTree(user); + } + protected boolean changeUserInTree(User userdata) { + if (userdata == null) + return false; + // First, find node for user + TreeParent top = getPresenceRoot(); + for (Iterator childs = top.children().iterator(); childs.hasNext();) { + TreeUser child = (TreeUser) childs.next(); + User ud = (User) child.getUser(); + if (ud.getUserID().equals(userdata.getUserID())) { + // We've found it...so remove existing data + top.removeChild(child); + addUserToTree(userdata); + return true; + } + } + return false; + } + protected void closeClient() { + if (lch != null) { + lch.chatGUIDestroy(); + } + } + protected String dateTime() { + StringBuffer sb = new StringBuffer("["); + sb.append(df.format(new Date())).append("]"); + return sb.toString(); + } + public void disposeClient() { + myNames.clear(); + view.disposeClient(this); + if (teamChat != null) { + if (teamChat.chatWindow != null) + teamChat.chatWindow.close(); + + teamChat = null; + } + if (lch != null) { + lch = null; + } + } + protected void expandAll() { + if (teamChat != null) { + teamChat.getTree().expandToLevel(TREE_EXPANSION_LEVELS); + } + } + protected String getPrefix(ID objID) { + String prefix = ""; + if (userdata.getUserID().equals(objID)) { + prefix += dateTime() + " " + HOST_PREFIX + ": "; + } else { + String tmp = getUserData(objID); + if (tmp == null) { + tmp = objID.toString(); + } + prefix += dateTime() + " " + tmp + CLIENT_PREFIX + ": "; + } + return prefix; + } + protected TreeParent getPresenceRoot() { + if (teamChat == null) + return null; + ViewContentProvider vcp = (ViewContentProvider) teamChat.getTree() + .getContentProvider(); + if (vcp == null) + return null; + else + return vcp.getPresenceRoot(); + } + protected String getPrivatePrefix(ID objID) { + String prefix = ""; + if (userdata.getUserID().equals(objID)) { + prefix += dateTime() + " " + HOST_PREFIX + " (private): "; + } else { + String tmp = getUserData(objID); + if (tmp == null) { + tmp = objID.toString(); + } + prefix += dateTime() + " " + tmp + CLIENT_PREFIX + " (private): "; + } + return prefix; + } + protected TeamChat getTeamChat() { + return teamChat; + } + protected String getUserData(ID id) { + return (String) myNames.get(id); + } + public User getUser(ID id) { + if (id == null) + return null; + TreeParent top = getPresenceRoot(); + for (Iterator e = top.children().iterator(); e.hasNext();) { + TreeUser tn = (TreeUser) e.next(); + User ud = (User) tn.getUser(); + if (id.equals(ud.getUserID())) { + return ud; + } + } + return null; + } + protected void handleTextInput(String text) { + String fullString = null; + if (lch == null) { + fullString = "<Unknown> " + CLIENT_PREFIX + text; + } else { + fullString = getPrefix(userdata.getUserID()) + text; + } + appendAndScrollToBottom(fullString); + teamChat.clearInput(); + if (lch != null) + lch.inputText(text); + } + protected void makeObject(ID target, String className, String[] args) { + makeObject(target, className, null, args); + } + protected void makeObject(ID target, final String className,String[] argTypes, Object[] args) { + if (lch != null) { + HashMap map = new HashMap(); + map.put("args",args); + map.put("types",argTypes); + try { + lch.makeObject(target, className, map); + } catch (final Exception e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, + "Make Object Exception", + "Exception creating instance of '" + className + + "'. \nException: " + e); + } + }); + e.printStackTrace(); + lch.chatException(e, "makeObject(" + className + ")"); + } + } + } + protected void makeProxyObject(ID target, final String className) { + if (lch != null) { + try { + // With this interface, we'll simply supply the class name + // as the instance name. Eventually, the user interface should + // allow the creation of some other instance name + lch.makeProxyObject(target, className, className); + proxyObjects.add(className); + teamChat.enableProxyMessage(true); + } catch (final Exception e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, + "Make Proxy Object Exception", + "Exception creating instance of '" + className + + "'. \nException: " + e); + } + }); + e.printStackTrace(); + lch.chatException(e, "makeProxyObject(" + className + ")"); + } + } + } + protected TreeParent makeUserNode(TreeParent node, Vector ht) { + if (node == null || ht == null) + return null; + for (Enumeration e = ht.elements(); e.hasMoreElements();) { + TreeItem ti = (TreeItem) e.nextElement(); + Object val = ti.getValue(); + final TreeParent tn = new TreeParent(this, ti); + if (val instanceof Vector) { + // Create new tree node + makeUserNode(tn, (Vector) val); + } + node.addChild(tn); + } + refreshTreeView(); + return node; + } + protected TreeUser makeUserNode(User ud) { + if (ud == null) + return null; + TreeUser tu = new TreeUser(this, ud); + return (TreeUser) makeUserNode(tu, ud.getUserFields()); + } + protected void messageProxyObject(ID target, String classname, String meth, + Object[] args) { + if (lch != null) { + lch.messageProxyObject(target, classname, meth, args); + } + } + protected void refreshTreeView() { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + if (teamChat != null) { + try { + //teamChat.getTree().refresh(getPresenceRoot(), true); + teamChat.getTree().refresh(); + expandAll(); + } catch (Exception e) { + } + } + } + }); + } + protected void removeProxyObject(ID target, final String className) { + if (lch != null) { + try { + // With this interface, we'll simply supply the class name + // as the instance name. Eventually, the user interface should + // allow the creation of some other instance name + lch.removeProxyObject(target, className); + proxyObjects.remove(className); + teamChat.enableProxyMessage(proxyObjects.size() > 0); + } catch (final Exception e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(null, + "Remove Proxy Object Exception", + "Exception creating instance of '" + className + + "'. \nException: " + e); + } + }); + e.printStackTrace(); + lch.chatException(e, "removeProxyObject(" + className + ")"); + } + } + } + public void removeUser(ID id) { + String name = getUserData(id); + if (name != null) { + final String str = dateTime() + " " + name + " " + LEFT_STRING; + showText(str); + } + myNames.remove(id); + removeUserFromTree(id); + } + protected void removeUserFromTree(ID id) { + if (id == null) + return; + TreeParent top = getPresenceRoot(); + if (top != null) { + for (Iterator e = top.children().iterator(); e.hasNext();) { + TreeUser tn = (TreeUser) e.next(); + User ud = (User) tn.getUser(); + if (id.equals(ud.getUserID())) { + top.removeChild(tn); + refreshTreeView(); + } + } + } + } + protected void runProgram(ID receiver, String program, String[] env) { + String[] cmds = { program }; + Object[] args = { receiver, cmds, env, new Boolean(receiver == null), + new Boolean(false) }; + // Do it + makeObject(null, EXECPROGCLASSNAME, EXECPROGARGTYPES, args); + } + public void sendData(File aFile, long dataLength) { + } + public void sendDone(File aFile, Exception e) { + if (e != null) { + showText("Exception '" + e.getMessage() + "' sending file '" + + aFile.getName()); + } else { + showText("\tSend of '" + aFile.getName() + "' completed"); + if (lch != null) + lch.refreshProject(); + } + } + public void sendStart(File aFile, long length, float rate) { + //present user with notification that file is being transferred + showText("\tSending '" + aFile.getName() + "'"); + } + public void setTitle(String title) { + // NOTHING HAPPENS + } + public void setVisible(boolean visible) { + // NOTHING HAPPENS + //teamChat.setVisible(visible); + } + public void showLine(ID user, String line) { + final String fullString = getPrefix(user) + line; + appendAndScrollToBottom(fullString); + } + public void showPrivate(ID user, String line) { + final String fullString = getPrivatePrefix(user) + line; + appendAndScrollToBottom(fullString); + } + public void showRawLine(ID sender, String str) { + if (getUserData(sender) != null) { + appendAndScrollToBottom(str); + } + } + public void startedTyping(final User user) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + if (teamChat != null) + teamChat.setStatus(user.getNickname() + " is typing..."); + } + }); + } + protected void showText(final String str) { + appendAndScrollToBottom(str); + } + public void toFront() { + view.setActiveTab(name); + } + protected TreeParent updateSubtree(TreeParent root, TreeItem item) { + root.removeAllChildren(); + TreeParent newRoot = new TreeParent(this, item); + Object val = item.getValue(); + if (val instanceof Vector) { + return makeUserNode(newRoot, (Vector) val); + } else + return newRoot; + } + public boolean updateTreeDisplay(ID user, TreeItem item) { + if (user == null || item == null) + return false; + TreeParent root = getPresenceRoot(); + boolean res = false; + for (Iterator childs = root.children().iterator(); childs.hasNext();) { + TreeUser ut = (TreeUser) childs.next(); + User a = ut.getUser(); + if (a != null && (user.equals(a.getUserID()))) { + // Found user...now find tree item + res = updateUserTree(ut, item); + refreshTreeView(); + return true; + } + } + return false; + } + protected boolean updateUserTree(TreeParent userNode, TreeItem item) { + if (userNode == null || item == null) + return false; + int i = 0; + for (Iterator e = userNode.children().iterator(); e.hasNext(); i++) { + TreeParent child = (TreeParent) e.next(); + TreeItem existing = child.getTreeItem(); + if (item.equals(existing)) { + TreeParent newChild = updateSubtree(child, item); + userNode.removeChild(child); + userNode.addChild(newChild); + return true; + } else { + Object val = existing.getValue(); + if (val instanceof Vector) { + Vector v = (Vector) val; + for (Enumeration ev = v.elements(); ev.hasMoreElements();) { + TreeItem ti = (TreeItem) ev.nextElement(); + updateUserTree(child, ti); + } + } + } + } + return false; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatHandler.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatHandler.java new file mode 100644 index 000000000..8c25d5c9d --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatHandler.java @@ -0,0 +1,58 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.util.Map; + +import org.eclipse.ecf.core.SharedObjectContainerJoinException; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.example.collab.share.User; + + +public interface LineChatHandler { + + public String getWindowTitle(); + public String getTreeTopLabel(); + public String getVersionString(); + + public ID getServerID(); + public User getUser(); + public void chatException(Exception e, String msg); + public void chatGUIDestroy(); + public void sendStartedTyping(); + public void inputText(String aString); + + public ID makeObject(ID target, String classname, Map map) + throws Exception; + + public Object getObject(ID target); + + public void joinGroup(ID remote, Object data) + throws SharedObjectContainerJoinException; + + public void leaveGroup(); + + public void refreshProject(); + + public void sendRingMessageToUser(User touser,String msg); + public void sendPrivateMessageToUser(User touser, String msg); + + public void makeProxyObject(ID target,String classname,String name); + public void messageProxyObject(ID target, String name, String meth, Object [] args); + public void removeProxyObject(ID target,String name); + + public void sendCVSProjectUpdateRequest(User touser, String msg); + public boolean isCVSShared(); + + public void sendShowViewWithID(User touser, String id, String secID, Integer mode); + public void sendShowView(User touser, String id); +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatView.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatView.java new file mode 100644 index 000000000..d5036127d --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/LineChatView.java @@ -0,0 +1,234 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.Hashtable; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.part.ViewPart; + + +public class LineChatView extends ViewPart { + // The single view + static protected LineChatView singleton = null; + + static protected Hashtable clientViews = new Hashtable(); + + TabFolder tabFolder = null; + + /* + protected static ID appShare = null; + protected static EclipseAppShareServer appShareServer = null; + + protected static void setAppShareID(ID newID, EclipseAppShareServer server) { + synchronized (clientViews) { + appShare = newID; + appShareServer = server; + stopAppShareAction.setServer(appShareServer); + if (newID == null) { + removeActionFromToolbar(stopAppShareAction); + } else { + addActionToToolbar(stopAppShareAction); + } + } + } + protected static ID getAppShareID() { + return appShare; + } + protected static boolean appShareActive() { + return (appShare != null); + } + */ + public static boolean isDisposed() { + return (singleton == null); + } + public LineChatView() { + } + protected Object addClientView(LineChatClientView cv, TabItem ti) { + synchronized (clientViews) { + return clientViews.put(cv,ti); + } + } + protected void removeClientView(LineChatClientView cv) { + final TabItem ti = (TabItem) clientViews.remove(cv); + // Clean up app share + /* + final ID appShareID = cv.getAppShareID(); + if (appShareID != null) { + if (appShareID.equals(appShare)) { + appShareServer.destroySelf(); + } + } + */ + Display.getDefault().syncExec(new Runnable() { + public void run() { + /* + if (appShareID != null) { + if (appShareID.equals(appShare)) { + setAppShareID(null,null); + } + } + */ + if (ti != null) ti.dispose(); + } + }); + //if (clientViews.size()==0) { + // this.hideView(); + //} + } + + protected void hideView() { + Display.getDefault().syncExec(new Runnable() { + public void run() { + try { + IWorkbenchPage wp = LineChatView.this.getSite().getPage(); + wp.hideView(LineChatView.this); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + public static LineChatClientView makeClientView(final LineChatHandler lch, final String name,final String initText,String downloaddir) + throws Exception { + LineChatClientView newView = null; + synchronized (clientViews) { + if (singleton == null) throw new InstantiationException("View not initialized"); + newView = new LineChatClientView(lch,singleton,name,initText,downloaddir); + TabItem ti = new TabItem(singleton.tabFolder,SWT.NULL); + ti.setControl(newView.getTeamChat()); + ti.setText(newView.name); + singleton.addClientView(newView,ti); + } + return newView; + } + + public void setFocus() { + synchronized (clientViews) { + singleton.tabFolder.setFocus(); + } + } + + static class StopAppShareAction extends Action { + String id = null; + /* + EclipseAppShareServer server; + */ + public StopAppShareAction() { + this("appshare.stop"); + } + public StopAppShareAction(String id) { + this.id = id; + activateAction(); + super.setId(this.id); + } + /* + protected void setServer(EclipseAppShareServer s) { + server = s; + } + */ + protected void activateAction() { + setText(ClientPlugin.getResourceString(id + ".text")); + setDescription(ClientPlugin.getResourceString(id + ".tooltip")); + setToolTipText(ClientPlugin.getResourceString(id + ".description")); + setEnabled(true); + try { + final URL installUrl = ClientPlugin.getPluginTopLocation(); + final URL imageUrl = new URL(installUrl, ClientPlugin.getResourceString(id + ".image")); + setImageDescriptor(ImageDescriptor.createFromURL(imageUrl)); + } catch (MalformedURLException e) { + ClientPlugin.log("Exception loading image for action: "+id, e); + } + } + + public void run() { + // Actually do something + /* + synchronized (clientViews) { + if (server != null) { + server.destroySelf(); + setAppShareID(null,null); + } + } + */ + } + } + + static IToolBarManager toolbarManager = null; + static IActionBars actionBars = null; + static StopAppShareAction stopAppShareAction = new StopAppShareAction(); + + protected static void addActionToToolbar(Action action) { + toolbarManager.add(action); + actionBars.updateActionBars(); + } + protected static void removeActionFromToolbar(Action action) { + if (action == null) return; + toolbarManager.remove(action.getId()); + actionBars.updateActionBars(); + } + public void createPartControl(Composite parent) { + singleton = this; + IViewSite viewSite = this.getViewSite(); + actionBars = viewSite.getActionBars(); + toolbarManager = actionBars.getToolBarManager(); + singleton.tabFolder = new TabFolder(parent,SWT.NORMAL); + } + protected void disposeClient(LineChatClientView lccv) { + if (singleton != null) singleton.removeClientView(lccv); + } + public void dispose() { + synchronized (clientViews) { + closeAllClients(); + } + singleton = null; + super.dispose(); + } + public void saveState(IMemento state) { + // We can save state here, associated with all UI config for collab views + // For now, we'll just use it to close the window + } + protected void closeAllClients() { + for (Enumeration e=clientViews.keys();e.hasMoreElements();) { + LineChatClientView vc = (LineChatClientView) e.nextElement(); + vc.closeClient(); + } + } + protected void setActiveTab(String name) { + if (name == null) return; + if (tabFolder != null) { + TabItem [] items = tabFolder.getItems(); + if (items == null) return; + for(int i=0; i < items.length; i++) { + String itemName = items[i].getText(); + if (name.equals(itemName)) { + tabFolder.setSelection(i); + } + } + } + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/MessageLoader.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/MessageLoader.java new file mode 100644 index 000000000..c1dbad4ec --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/MessageLoader.java @@ -0,0 +1,51 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + + +public class MessageLoader { + + private static final String RESOURCE_BUNDLE= MessageLoader.class.getName(); + private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); + + private MessageLoader() { + } + + public static String getString(String key) { + try { + return fgResourceBundle.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + + /** + * Gets a string from the resource bundle and formats it with the argument + * + * @param key the string used to get the bundle value, must not be null + */ + public static String getFormattedString(String key, Object arg) { + return MessageFormat.format(getString(key), new Object[] { arg }); + } + + /** + * Gets a string from the resource bundle and formats it with arguments + */ + public static String getFormattedString(String key, Object[] args) { + return MessageFormat.format(getString(key), args); + } + +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/MessageLoader.properties b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/MessageLoader.properties new file mode 100644 index 000000000..7b1f5df11 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/MessageLoader.properties @@ -0,0 +1,43 @@ +LineChatClientView.contextmenu.send=Send EclipseProjectComponent... +LineChatClientView.contextmenu.message=Message to EclipseProjectComponent... +LineChatClientView.contextmenu.remove=Remove EclipseProjectComponent... +LineChatClientView.contextmenu.sendmessage=Send Message to Group... + +LineChatClientView.contextmenu.appshare=Start Application Share... +LineChatClientView.contextmenu.appshare.confirmtitle=Confirm Start Application Share +LineChatClientView.contextmenu.appshare.confirmmessage=Choose 'OK' to start application sharing. Once you choose 'OK', the cursor will change to allow you to select an application. Move the mouse to select the application, and click the left mouse button to start sharing. To cancel window selection, hit Esc or click the right mouse button + +LineChatClientView.contextmenu.appshare.activetitle=Application Share Active +LineChatClientView.contextmenu.appshare.activemessage=Application Sharing Already Active. To stop, click on stop icon in upper right of view + +LineChatClientView.contextmenu.appshare.cancelledtitle=Application Share Cancelled +LineChatClientView.contextmenu.appshare.cancelledmessage=Application Sharing Cancelled by User + +LineChatClientView.contextmenu.sendfile=Send File... +LineChatClientView.contextmenu.sendfileandlaunch=Send File and Launch... + +LineChatClientView.contextmenu.cobrowse=Co-Browse URL... +LineChatClientView.contextmenu.selectall=Select All +LineChatClientView.contextmenu.selectall.tooltip=Select All Text +LineChatClientView.contextmenu.copy=Copy +LineChatClientView.contextmenu.copy.tooltip=Copy Selected Text +LineChatClientView.contextmenu.clear=Clear +LineChatClientView.contextmenu.clear.tooltip=Clear Output Window +LineChatClientView.contextmenu.paste=Paste +LineChatClientView.contextmenu.paste.tooltip=Paste Clipboard for Input +LineChatClientView.contextmenu.runprogram=Start Remote Program... +LineChatClientView.contextmenu.repobject=Send Replicated Object to Group... +LineChatClientView.contextmenu.repobjectserver=Send Replicated Object to Server... +LineChatClientView.contextmenu.leaveGroup=Leave Group +LineChatClientView.contextmenu.sendCVSUpdateRequest=Send CVS Update Request... +LineChatClientView.contextmenu.sendCVSUpdateRequestInitStr=Please allow update +LineChatClientView.contextmenu.sendCVSUpdateRequestTitle=Launch CVS Update on Remote Clients +LineChatClientView.contextmenu.sendCVSUpdateRequestMessage=Message to Remote Users: + +LineChatClientView.contextmenu.sendShowViewRequest=Send Show View Request... +LineChatClientView.contextmenu.sendShowViewRequest.dialog.title=Select View to Open for Group + +LineChatClientView.textinputinit=<input chat text here> + +LineChatClientView.contextmenu.closeMessageTitle="Confirm Close Collaboration for Project" +LineChatClientView.contextmenu.closeMessageMessage=Are you sure you want to close collaboration for '
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ShowViewsDialog.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ShowViewsDialog.java new file mode 100644 index 000000000..b535c6e80 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ShowViewsDialog.java @@ -0,0 +1,42 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.internal.WorkbenchPlugin; +import org.eclipse.ui.internal.dialogs.ShowViewDialog; +import org.eclipse.ui.internal.registry.IViewDescriptor; + +public class ShowViewsDialog extends ShowViewDialog { + + LineChatHandler lch; + + public ShowViewsDialog(Shell shell, LineChatHandler lch) { + super(shell,WorkbenchPlugin.getDefault().getViewRegistry()); + this.lch = lch; + } + + public void showViews(User touser) { + IViewDescriptor[] descs = getSelection(); + if (descs==null) return; + for (int i = 0; i < descs.length; ++i) { + lch.sendShowView(touser,descs[i].getID()); + } + } + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText(MessageLoader + .getString("LineChatClientView.contextmenu.sendShowViewRequest.dialog.title")); + //WorkbenchHelp.setHelp(shell, IHelpContextIds.SHOW_VIEW_DIALOG); + } +} diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TeamChat.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TeamChat.java new file mode 100644 index 000000000..4ab7d15f5 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TeamChat.java @@ -0,0 +1,124 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.ToolBar; + +class TeamChat extends Composite { + ChatComposite chat = null; + SashForm sash = null; + ChatTreeViewer treeView = null; + ViewContentProvider vc; + ToolBar bar; + LineChatClientView view; + ChatWindow chatWindow; + + static final int DEFAULT_TREE_WIDGET_PERCENT = 40; + + TeamChat(LineChatClientView view,Composite parent, int options, String initText) { + super(parent, options); + + this.view = view; + setLayout(new FillLayout()); + boolean useChatWindow = + ClientPlugin.getDefault().getPluginPreferences().getBoolean(ClientPlugin.USE_CHAT_WINDOW); + int[] w = null; + if (!useChatWindow) { + sash = new SashForm(this, SWT.NORMAL); + sash.setLayout(new FillLayout()); + sash.setOrientation(SWT.HORIZONTAL); + w = new int[2]; + w[0] = DEFAULT_TREE_WIDGET_PERCENT; + w[1] = 100 - w[0]; + } + + treeView = + new ChatTreeViewer( + useChatWindow ? (Composite) this : (Composite) sash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + treeView.setAutoExpandLevel(LineChatClientView.TREE_EXPANSION_LEVELS); + vc = new ViewContentProvider(view); + + treeView.setContentProvider(vc); + treeView.setLabelProvider(new ViewLabelProvider()); + treeView.setInput(ResourcesPlugin.getWorkspace()); + + + if (useChatWindow) { + chatWindow = new ChatWindow(view, this, treeView, initText); + chatWindow.create(); + chat = chatWindow.getChat(); + } else { + chat = new ChatComposite(view, sash, treeView, SWT.NORMAL, initText); + sash.setWeights(w); + } + } + + void appendText(String text) { + if (chatWindow != null + && chatWindow.getShell() != null + && !chatWindow.getShell().isDisposed() + && !chatWindow.hasFocus()) { + + if (chatWindow.getShell().isVisible()) + chatWindow.flash(); + else + chatWindow.open(); + } + + chat.appendText(text); + setStatus(null); + } + + void setStatus(String status) { + if (chatWindow != null) + chatWindow.setStatus(status); + } + + void clearInput() { + chat.clearInput(); + } + + void enableProxyMessage(boolean val) { + chat.enableProxyMessage(val); + } + + ChatTreeViewer getTree() { + return treeView; + } + + Control getTreeControl() { + return treeView.getControl(); + } + + Control getTextControl() { + return chat.getTextControl(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Widget#dispose() + */ + public void dispose() { + if (chatWindow != null) { + chatWindow.close(); + chatWindow = null; + } + + super.dispose(); + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeCategory.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeCategory.java new file mode 100644 index 000000000..7a9970a60 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeCategory.java @@ -0,0 +1,21 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +class TreeCategory extends TreeParent { + private LineChatClientView view; + + TreeCategory(LineChatClientView view, String name) { + super(view, name); + this.view = view; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeDropTarget.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeDropTarget.java new file mode 100644 index 000000000..7b019fc4c --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeDropTarget.java @@ -0,0 +1,102 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.ecf.example.collab.share.User; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Widget; + + + +class TreeDropTarget extends ChatDropTarget { + public TreeDropTarget(LineChatClientView view, Control control, ChatComposite comp) { + super(view,control, comp); + } + protected Object getData(DropTargetEvent event) { + Object item = event.item; + if (item != null && item instanceof Widget) { + Widget titem = (Widget) item; + Object obj = titem.getData(); + return obj; + } + return null; + } + private User findUserNode(Object to) { + if (to == null) + return null; + if (to instanceof TreeUser) { + TreeUser tu = (TreeUser) to; + return tu.getUser(); + } + if (to instanceof TreeParent) { + return findUserNode(((TreeParent) to).getParent()); + } + return null; + } + protected User isUserHit(Object item) { + return findUserNode(item); + } + public void dragEnter(DropTargetEvent event) { + if (event.detail == DND.DROP_DEFAULT) { + if ((event.operations & DND.DROP_COPY) != 0) { + event.detail = DND.DROP_COPY; + } else { + event.detail = DND.DROP_NONE; + } + } + Object item = getData(event); + if (item == null) { + event.detail = DND.DROP_NONE; + return; + } else { + User user = isUserHit(item); + if (user == null) { + event.detail = DND.DROP_NONE; + return; + } + selectedUser = user; + } + // will accept text but prefer to have files dropped + for (int i = 0; i < event.dataTypes.length; i++) { + if (fileTransfer.isSupportedType(event.dataTypes[i])) { + event.currentDataType = event.dataTypes[i]; + // files should only be copied + if (event.detail != DND.DROP_COPY) { + event.detail = DND.DROP_NONE; + selectedUser = null; + } + break; + } + } + } + public void dragOver(DropTargetEvent event) { + if ((event.operations & DND.DROP_COPY) != 0) { + event.detail = DND.DROP_COPY; + } else { + event.detail = DND.DROP_NONE; + } + Object item = getData(event); + if (item == null) { + event.detail = DND.DROP_NONE; + return; + } else { + User user = isUserHit(item); + if (user == null) { + event.detail = DND.DROP_NONE; + return; + } + selectedUser = user; + } + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeObject.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeObject.java new file mode 100644 index 000000000..558871b9a --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeObject.java @@ -0,0 +1,37 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.core.runtime.IAdaptable; + +class TreeObject implements IAdaptable { + protected String name; + private TreeParent parent; + public TreeObject(String name) { + this.name = name; + } + public Object getAdapter(Class key) { + return null; + } + public String getName() { + return name; + } + public TreeParent getParent() { + return parent; + } + public void setParent(TreeParent parent) { + this.parent = parent; + } + public String toString() { + return getName(); + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeParent.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeParent.java new file mode 100644 index 000000000..7f16666b3 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeParent.java @@ -0,0 +1,62 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.ecf.example.collab.share.TreeItem; + +class TreeParent extends TreeObject { + private LineChatClientView view; + private List children; + private TreeItem treeItem; + public TreeParent(LineChatClientView view, String name) { + super(name); + this.view = view; + children = Collections.synchronizedList(new ArrayList()); + } + public TreeParent(LineChatClientView view, TreeItem item) { + this(view, item.toString()); + treeItem = item; + } + public void addChild(TreeObject child) { + children.add(child); + child.setParent(this); + } + public List children() { + return children; + } + public TreeObject[] getChildren() { + return (TreeObject[]) children.toArray(new TreeObject[children + .size()]); + } + public TreeItem getTreeItem() { + return treeItem; + } + public boolean hasChildren() { + return children.size() > 0; + } + public void removeAllChildren() { + synchronized (children) { + for (int i = 0; i < children.size(); i++) { + TreeObject child = (TreeObject) children.remove(i); + child.setParent(null); + } + } + } + public void removeChild(TreeObject child) { + children.remove(child); + child.setParent(null); + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeUser.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeUser.java new file mode 100644 index 000000000..d0fa47001 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/TreeUser.java @@ -0,0 +1,27 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.ecf.example.collab.share.User; + +class TreeUser extends TreeParent { + private LineChatClientView view; + User ud; + TreeUser(LineChatClientView view, User ud) { + super(view, ud.getNickname()); + this.view = view; + this.ud = ud; + } + User getUser() { + return ud; + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ViewContentProvider.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ViewContentProvider.java new file mode 100644 index 000000000..9648a66a6 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ViewContentProvider.java @@ -0,0 +1,80 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +class ViewContentProvider implements IStructuredContentProvider, + ITreeContentProvider { + private TreeParent invisibleRoot; + private TreeParent memberRoot; + private TreeParent presenceRoot; + protected LineChatClientView view; + + public ViewContentProvider(LineChatClientView view) { + super(); + this.view = view; + } + public void dispose() { + } + + public Object[] getChildren(Object parent) { + if (parent instanceof TreeParent) { + return ((TreeParent) parent).getChildren(); + } + return new Object[0]; + } + + public Object[] getElements(Object parent) { + + if (parent.equals(ResourcesPlugin.getWorkspace())) { + if (presenceRoot == null) + initialize(); + return getChildren(presenceRoot); + } + return getChildren(parent); + + } + + public Object getParent(Object child) { + if (child instanceof TreeObject) { + return ((TreeObject) child).getParent(); + } + return null; + } + + public TreeParent getPresenceRoot() { + return presenceRoot; + } + + public TreeParent getRoot() { + return invisibleRoot; + } + + public boolean hasChildren(Object parent) { + if (parent instanceof TreeParent) + return ((TreeParent) parent).hasChildren(); + return false; + } + + private void initialize() { + presenceRoot = new TreeParent(view,LineChatClientView.TREE_HEADER); + invisibleRoot = new TreeParent(view, ""); + invisibleRoot.addChild(presenceRoot); + } + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } +}
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ViewLabelProvider.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ViewLabelProvider.java new file mode 100644 index 000000000..1f0b1540c --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ui/ViewLabelProvider.java @@ -0,0 +1,53 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. 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: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ + +package org.eclipse.ecf.example.collab.ui; + +import org.eclipse.ecf.example.collab.ClientPlugin; +import org.eclipse.ecf.example.collab.ClientPluginConstants; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + + +class ViewLabelProvider extends LabelProvider { + public Image getImage(Object obj) { + Image image = null; //By default, no image exists for obj, but if found to be a specific instance, load from plugin repository. + ImageRegistry registry = ClientPlugin.getDefault().getImageRegistry(); + + if (obj instanceof TreeUser) { + image = registry.get(ClientPluginConstants.DECORATION_USER); + } else if (obj instanceof TreeParent && (((TreeParent)obj).getTreeItem() != null)) { + + String childName = ((TreeParent)obj).getTreeItem().getLabel(); + //TODO: Come up with a better strategy of matching node type to entity decoration. + if (childName.equals("Project")) { + image = registry.get(ClientPluginConstants.DECORATION_PROJECT); + } else if (childName.equals("Join Time")) { + image = registry.get(ClientPluginConstants.DECORATION_TIME); + } else if (childName.equals("Container Type")) { + image = registry.get(ClientPluginConstants.DECORATION_TASK); + } + } + + return image; + /* + * String imageKey = ISharedImages.IMG_OBJ_ELEMENT; if (obj + * instanceof TreeParent) imageKey = ISharedImages.IMG_OBJ_PROJECT; + * return + * PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); + */ + } + + public String getText(Object obj) { + return obj.toString(); + } +}
\ No newline at end of file |
