Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 379217 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jubula.documentation/gefapi/javadoc/javadoc.xml (-1 / +1 lines)
Lines 20-26 Link Here
20
			noindex="false" 
20
			noindex="false" 
21
			nonavbar="false" 
21
			nonavbar="false" 
22
			notree="false" 
22
			notree="false" 
23
			packagenames="org.eclipse.jubula.rc.rcp.gef.identifier" 
23
			packagenames="org.eclipse.jubula.rc.rcp.e3.gef.identifier" 
24
			sourcepathref="rc.gef.extension.sourcepath"
24
			sourcepathref="rc.gef.extension.sourcepath"
25
			splitindex="true" 
25
			splitindex="true" 
26
			use="true" 
26
			use="true" 
(-)a/org.eclipse.jubula.feature.source/feature.xml (-1 / +1 lines)
Lines 194-200 BREDEX GmbH - initial API and implementation and/or initial documentation Link Here
194
         unpack="false"/>
194
         unpack="false"/>
195
195
196
   <plugin
196
   <plugin
197
         id="org.eclipse.jubula.rc.rcp.source"
197
         id="org.eclipse.jubula.rc.rcp.e3.source"
198
         download-size="0"
198
         download-size="0"
199
         install-size="0"
199
         install-size="0"
200
         version="0.0.0"
200
         version="0.0.0"
(-)a/org.eclipse.jubula.feature/feature.xml (-1 / +1 lines)
Lines 327-333 BREDEX GmbH - initial API and implementation and/or initial documentation Link Here
327
         unpack="false"/>
327
         unpack="false"/>
328
328
329
   <plugin
329
   <plugin
330
         id="org.eclipse.jubula.rc.rcp"
330
         id="org.eclipse.jubula.rc.rcp.e3"
331
         download-size="0"
331
         download-size="0"
332
         install-size="0"
332
         install-size="0"
333
         version="0.0.0"
333
         version="0.0.0"
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/.checkstyle (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4
  <fileset name="all" enabled="true" check-config-name="Jubula" local="false">
5
    <file-match-pattern match-pattern="." include-pattern="true"/>
6
  </fileset>
7
</fileset-config>
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/.classpath (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/.gitignore (+2 lines)
Added Link Here
1
/bin
2
/target
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/.project (+41 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.eclipse.jubula.rc.rcp.e3.specific</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
33
	</natures>
34
	<linkedResources>
35
		<link>
36
			<name>.settings</name>
37
			<type>2</type>
38
			<locationURI>WORKSPACE_LOC/jubula/org.eclipse.jubula.project.configuration/settings/1.4</locationURI>
39
		</link>
40
	</linkedResources>
41
</projectDescription>
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/META-INF/MANIFEST.MF (+12 lines)
Added Link Here
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Jubula Remote Control - RCP e3 specific
4
Bundle-SymbolicName: org.eclipse.jubula.rc.rcp.e3.specific;singleton:=true
5
Bundle-Version: 2.0.0.qualifier
6
Bundle-ClassPath: .
7
Bundle-Vendor: Eclipse Jubula
8
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
9
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
10
Bundle-ActivationPolicy: lazy
11
Bundle-RequiredExecutionEnvironment: J2SE-1.4
12
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/about.html (+28 lines)
Added Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6
<title>About</title>
7
</head>
8
<body lang="EN-US">
9
<h2>About This Content</h2>
10
 
11
<p>June 22,  2011</p>	
12
<h3>License</h3>
13
14
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
15
indicated below, the Content is provided to you under the terms and conditions of the
16
Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
17
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
18
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19
20
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
21
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22
apply to your use of any object code in the Content.  Check the Redistributor's license that was 
23
provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
24
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
26
27
</body>
28
</html>
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/build.properties (+17 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2004, 2011 BREDEX GmbH.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
###############################################################################
8
bin.includes = about.html,\
9
               META-INF/,\
10
               plugin.xml,\
11
               .
12
jars.compile.order = .
13
source.. = src/
14
output.. = bin/
15
javacSource = 1.4
16
javacTarget = 1.4
17
javacErrors.. = -assertIdentifier
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/plugin.xml (+11 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.2"?><!--
3
    Copyright (c) 2004, 2010 BREDEX GmbH.
4
    All rights reserved. This program and the accompanying materials
5
    are made available under the terms of the Eclipse Public License v1.0
6
    which accompanies this distribution, and is available at
7
    http://www.eclipse.org/legal/epl-v10.html
8
 -->
9
10
<plugin>
11
</plugin>
(-)a/org.eclipse.jubula.rc.rcp.e3.specific/pom.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- Copyright (c) 2004, 2011 BREDEX GmbH. All rights reserved. This program 
3
	and the accompanying materials are made available under the terms of the 
4
	Eclipse Public License v1.0 which accompanies this distribution, and is available 
5
	at http://www.eclipse.org/legal/epl-v10.html -->
6
<project
7
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
8
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
9
	<modelVersion>4.0.0</modelVersion>
10
    <parent>
11
      <artifactId>org.eclipse.jubula.releng.client</artifactId>
12
      <groupId>org.eclipse.jubula</groupId>
13
      <version>2.0.0-SNAPSHOT</version>
14
      <relativePath>../org.eclipse.jubula.releng.client</relativePath>
15
    </parent>
16
	<groupId>org.eclipse.jubula</groupId>
17
	<artifactId>org.eclipse.jubula.rc.rcp.e3.specific</artifactId>
18
	<version>2.0.0-SNAPSHOT</version>
19
    <packaging>eclipse-plugin</packaging>
20
</project>
(-)a/org.eclipse.jubula.rc.rcp.e3/.checkstyle (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4
  <fileset name="all" enabled="true" check-config-name="Jubula" local="false">
5
    <file-match-pattern match-pattern="." include-pattern="true"/>
6
  </fileset>
7
</fileset-config>
(-)a/org.eclipse.jubula.rc.rcp.e3/.classpath (+24 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="lib" path="lib/ch.qos.logback.classic.jar"/>
7
	<classpathentry kind="lib" path="lib/ch.qos.logback.core.jar"/>
8
	<classpathentry kind="lib" path="lib/ch.qos.logback.slf4j.jar"/>
9
	<classpathentry kind="lib" path="lib/org.apache.commons.beanutils.jar"/>
10
	<classpathentry kind="lib" path="lib/org.apache.commons.lang.jar"/>
11
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.communication"/>
12
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.communication.jar"/>
13
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.rc.common"/>
14
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.rc.common.jar"/>
15
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.rc.swt"/>
16
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.rc.swt.jar"/>
17
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.tools"/>
18
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.tools.jar"/>
19
	<classpathentry kind="lib" path="lib/org.slf4j.api.jar"/>
20
	<classpathentry kind="lib" path="lib/org.slf4j.jcl.jar"/>
21
	<classpathentry kind="lib" path="lib/xpp3_min-1.1.3.4.O.jar"/>
22
	<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
23
	<classpathentry kind="output" path="bin"/>
24
</classpath>
(-)a/org.eclipse.jubula.rc.rcp.e3/.gitignore (+3 lines)
Added Link Here
1
/bin
2
/target
3
/lib
(-)a/org.eclipse.jubula.rc.rcp.e3/.project (+41 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.eclipse.jubula.rc.rcp.e3</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
33
	</natures>
34
	<linkedResources>
35
		<link>
36
			<name>.settings</name>
37
			<type>2</type>
38
			<locationURI>WORKSPACE_LOC/jubula/org.eclipse.jubula.project.configuration/settings/1.4</locationURI>
39
		</link>
40
	</linkedResources>
41
</projectDescription>
(-)a/org.eclipse.jubula.rc.rcp.e3/META-INF/MANIFEST.MF (+30 lines)
Added Link Here
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Jubula Remote Control - RCP e3
4
Bundle-SymbolicName: org.eclipse.jubula.rc.rcp.e3; singleton:=true
5
Bundle-Version: 2.0.0.qualifier
6
Bundle-ClassPath: .,
7
 lib/org.eclipse.jubula.tools.jar,
8
 lib/org.apache.commons.lang.jar,
9
 lib/org.apache.oro.jar,
10
 lib/org.apache.commons.beanutils.jar,
11
 lib/org.eclipse.jubula.rc.common.jar,
12
 lib/org.eclipse.jubula.rc.swt.jar,
13
 lib/org.eclipse.jubula.communication.jar,
14
 lib/org.slf4j.api.jar,
15
 lib/org.slf4j.jcl.jar,
16
 lib/ch.qos.logback.slf4j.jar,
17
 lib/ch.qos.logback.core.jar,
18
 lib/ch.qos.logback.classic.jar,
19
 lib/xpp3_min-1.1.3.4.O.jar,
20
 lib/xstream-1.3.1.jar,
21
 resources/
22
Bundle-Vendor: Eclipse Jubula
23
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
24
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
25
 org.eclipse.draw2d;bundle-version="[3.0.0,4.0.0)";resolution:=optional,
26
 org.eclipse.gef;bundle-version="[3.0.0,4.0.0)";resolution:=optional
27
Bundle-ActivationPolicy: lazy
28
Bundle-RequiredExecutionEnvironment: J2SE-1.4
29
Export-Package: org.eclipse.jubula.rc.rcp.e3.gef.factory,
30
 org.eclipse.jubula.rc.rcp.e3.gef.identifier
(-)a/org.eclipse.jubula.rc.rcp.e3/about.html (+28 lines)
Added Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6
<title>About</title>
7
</head>
8
<body lang="EN-US">
9
<h2>About This Content</h2>
10
 
11
<p>June 22,  2011</p>	
12
<h3>License</h3>
13
14
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
15
indicated below, the Content is provided to you under the terms and conditions of the
16
Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
17
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
18
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19
20
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
21
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22
apply to your use of any object code in the Content.  Check the Redistributor's license that was 
23
provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
24
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
26
27
</body>
28
</html>
(-)a/org.eclipse.jubula.rc.rcp.e3/build.properties (+32 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2004, 2011 BREDEX GmbH.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
###############################################################################
8
bin.includes = about.html,\
9
               resources/,\
10
               META-INF/,\
11
               plugin.xml,\
12
               .,\
13
               lib/org.eclipse.jubula.tools.jar,\
14
               lib/org.apache.commons.lang.jar,\
15
               lib/org.apache.commons.beanutils.jar,\
16
               lib/org.apache.oro.jar,\
17
               lib/org.eclipse.jubula.rc.common.jar,\
18
               lib/org.eclipse.jubula.rc.swt.jar,\
19
               lib/org.eclipse.jubula.communication.jar,\
20
               lib/org.slf4j.api.jar,\
21
               lib/org.slf4j.jcl.jar,\
22
               lib/ch.qos.logback.slf4j.jar,\
23
               lib/ch.qos.logback.core.jar,\
24
               lib/ch.qos.logback.classic.jar,\
25
               lib/xpp3_min-1.1.3.4.O.jar,\
26
               lib/xstream-1.3.1.jar
27
jars.compile.order = .
28
source.. = src/
29
output.. = bin/
30
javacSource = 1.4
31
javacTarget = 1.4
32
javacErrors.. = -assertIdentifier
(-)a/org.eclipse.jubula.rc.rcp.e3/genLib.xml (+111 lines)
Added Link Here
1
<!--
2
    Copyright (c) 2004, 2011 BREDEX GmbH.
3
    All rights reserved. This program and the accompanying materials
4
    are made available under the terms of the Eclipse Public License v1.0
5
    which accompanies this distribution, and is available at
6
    http://www.eclipse.org/legal/epl-v10.html
7
 -->
8
<project name="org.eclipse.jubula.rc.rcp.e3" default="gen-lib" basedir=".">
9
  
10
  <property name="OrbitStorage" value="../org.eclipse.jubula.rc.common.orbit" />
11
  <property name="SiteStorage" value="../org.eclipse.jubula.site/target/site/plugins" />
12
13
  <target name="gen-lib">
14
  
15
    <mkdir dir="lib" />
16
    <delete>
17
      <fileset dir="lib" includes="**/*"/>
18
    </delete>
19
20
    <copy todir="lib">
21
      <fileset dir="${OrbitStorage}">
22
        <include name="ch.qos.logback.classic*.jar" />
23
      </fileset>
24
      <mergemapper to="ch.qos.logback.classic.jar"/>
25
    </copy>
26
    <copy todir="lib">
27
      <fileset dir="${OrbitStorage}">
28
        <include name="ch.qos.logback.core*.jar" />
29
      </fileset>
30
      <mergemapper to="ch.qos.logback.core.jar"/>
31
    </copy>
32
    <copy todir="lib">
33
      <fileset dir="${OrbitStorage}">
34
        <include name="ch.qos.logback.slf4j*.jar" />
35
      </fileset>
36
      <mergemapper to="ch.qos.logback.slf4j.jar"/>
37
    </copy>
38
39
    <copy todir="lib">
40
      <fileset dir="${OrbitStorage}">
41
        <include name="org.apache.commons.beanutils*.jar" />
42
      </fileset>
43
      <mergemapper to="org.apache.commons.beanutils.jar"/>
44
    </copy>
45
    <copy todir="lib">
46
      <fileset dir="${OrbitStorage}">
47
        <include name="org.apache.commons.lang*.jar" />
48
      </fileset>
49
      <mergemapper to="org.apache.commons.lang.jar"/>
50
    </copy>
51
    <copy todir="lib">
52
      <fileset dir="${OrbitStorage}">
53
        <include name="org.apache.oro*.jar" />
54
      </fileset>
55
      <mergemapper to="org.apache.oro.jar"/>
56
    </copy>
57
58
    <copy todir="lib">
59
      <fileset dir="${OrbitStorage}">
60
        <include name="org.slf4j.api*.jar" />
61
      </fileset>
62
      <mergemapper to="org.slf4j.api.jar"/>
63
    </copy>
64
    <copy todir="lib">
65
      <fileset dir="${OrbitStorage}">
66
        <include name="org.slf4j.jcl*.jar" />
67
      </fileset>
68
      <mergemapper to="org.slf4j.jcl.jar"/>
69
    </copy>
70
71
  	<!-- 
72
  	The "SNAPSHOT" in the include selector ensures that only the non-source 
73
  	JAR is used. Without it, the corresponding source JAR was being used,
74
  	and it was either being used exclusively or was *overwriting* the content
75
  	provided by the non-source JAR. This caused compilation to fail when also
76
  	building source bundles. 
77
  	-->
78
    <copy todir="lib">
79
      <fileset dir="../org.eclipse.jubula.rc.common/target">
80
        <include name="org.eclipse.jubula.rc.common*SNAPSHOT.jar" />
81
      </fileset>
82
      <mergemapper to="org.eclipse.jubula.rc.common.jar"/>
83
    </copy>
84
    <copy todir="lib">
85
      <fileset dir="../org.eclipse.jubula.rc.swt/target">
86
        <include name="org.eclipse.jubula.rc.swt*SNAPSHOT.jar" />
87
      </fileset>
88
      <mergemapper to="org.eclipse.jubula.rc.swt.jar"/>
89
    </copy>
90
    <copy todir="lib">
91
      <fileset dir="../org.eclipse.jubula.tools/target">
92
        <include name="org.eclipse.jubula.tools*SNAPSHOT.jar" />
93
      </fileset>
94
      <mergemapper to="org.eclipse.jubula.tools.jar"/>
95
    </copy>
96
    <copy todir="lib">
97
      <fileset dir="../org.eclipse.jubula.communication/target">
98
        <include name="org.eclipse.jubula.communication*SNAPSHOT.jar" />
99
      </fileset>
100
      <mergemapper to="org.eclipse.jubula.communication.jar"/>
101
    </copy>
102
103
	<copy todir="lib">
104
          <fileset dir="../org.eclipse.jubula.tools/lib">
105
            <include name="xpp3*.jar" />
106
            <include name="xstream*.jar" />
107
          </fileset>
108
	</copy>
109
  </target>
110
  
111
</project>
(-)a/org.eclipse.jubula.rc.rcp.e3/plugin.xml (+14 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.2"?><!--
3
    Copyright (c) 2004, 2010 BREDEX GmbH.
4
    All rights reserved. This program and the accompanying materials
5
    are made available under the terms of the Eclipse Public License v1.0
6
    which accompanies this distribution, and is available at
7
    http://www.eclipse.org/legal/epl-v10.html
8
 -->
9
10
<plugin>
11
   	 <extension point="org.eclipse.ui.startup">
12
   		<startup class="org.eclipse.jubula.rc.rcp.e3.accessor.Startup"/>
13
   </extension>
14
</plugin>
(-)a/org.eclipse.jubula.rc.rcp.e3/pom.xml (+77 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
  <modelVersion>4.0.0</modelVersion>
5
  <parent>
6
    <artifactId>org.eclipse.jubula.releng.client</artifactId>
7
    <groupId>org.eclipse.jubula</groupId>
8
    <version>2.0.0-SNAPSHOT</version>
9
    <relativePath>../org.eclipse.jubula.releng.client</relativePath>
10
  </parent>
11
  <groupId>org.eclipse.jubula</groupId>
12
  <artifactId>org.eclipse.jubula.rc.rcp.e3</artifactId>
13
  <version>2.0.0-SNAPSHOT</version>
14
  <packaging>eclipse-plugin</packaging>
15
16
  <dependencies>
17
    <dependency>
18
      <groupId>org.eclipse.jubula</groupId>
19
      <artifactId>org.eclipse.jubula.tools</artifactId>
20
      <version>2.0.0-SNAPSHOT</version>
21
    </dependency>
22
    <dependency>
23
      <groupId>org.eclipse.jubula</groupId>
24
      <artifactId>org.eclipse.jubula.communication</artifactId>
25
      <version>2.0.0-SNAPSHOT</version>
26
    </dependency>
27
    <dependency>
28
      <groupId>org.eclipse.jubula</groupId>
29
      <artifactId>org.eclipse.jubula.rc.common</artifactId>
30
      <version>2.0.0-SNAPSHOT</version>
31
    </dependency>
32
    <dependency>
33
      <groupId>org.eclipse.jubula</groupId>
34
      <artifactId>org.eclipse.jubula.rc.swt</artifactId>
35
      <version>2.0.0-SNAPSHOT</version>
36
    </dependency>
37
  </dependencies>
38
39
  <build>
40
    <plugins>
41
      <plugin>
42
        <artifactId>maven-antrun-plugin</artifactId>
43
        <version>1.6</version>
44
        <executions>
45
          <execution>
46
            <id>gen-lib</id>
47
            <phase>generate-resources</phase>
48
            <configuration>
49
              <target>
50
                <ant antfile="genLib.xml" />
51
              </target>
52
            </configuration>
53
            <goals>
54
              <goal>run</goal>
55
            </goals>
56
          </execution>
57
        </executions>
58
      </plugin>
59
      <plugin>
60
        <artifactId>maven-clean-plugin</artifactId>
61
        <version>2.4.1</version>
62
        <configuration>
63
          <filesets>
64
            <fileset>
65
              <directory>lib</directory>
66
              <includes>
67
                <include>*.jar</include>
68
              </includes>
69
              <followSymlinks>false</followSymlinks>
70
            </fileset>
71
          </filesets>
72
        </configuration>
73
      </plugin>
74
    </plugins>
75
  </build>
76
77
</project>
(-)a/org.eclipse.jubula.rc.rcp.e3/resources/logback.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<configuration scan="true">
3
	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4
		<!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
5
		<encoder>
6
			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
7
			</pattern>
8
		</encoder>
9
	</appender>
10
	<appender name="FILE" class="ch.qos.logback.core.FileAppender">
11
		<file>${user.home}/.jubula/logs/rc_rcp.log</file>
12
		<encoder>
13
			<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
14
			</pattern>
15
		</encoder>
16
	</appender>
17
	<root level="warn">
18
		<appender-ref ref="FILE" />
19
	</root>
20
</configuration>
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/accessor/Startup.java (+694 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.accessor;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.lang.reflect.Method;
15
import java.util.ArrayList;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Properties;
21
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.jface.action.IContributionItem;
24
import org.eclipse.jface.dialogs.Dialog;
25
import org.eclipse.jface.dialogs.IDialogConstants;
26
import org.eclipse.jface.dialogs.IPageChangedListener;
27
import org.eclipse.jface.dialogs.PageChangedEvent;
28
import org.eclipse.jface.preference.IPreferenceNode;
29
import org.eclipse.jface.preference.PreferenceDialog;
30
import org.eclipse.jface.preference.PreferenceManager;
31
import org.eclipse.jubula.rc.common.AUTServer;
32
import org.eclipse.jubula.rc.rcp.e3.gef.inspector.GefInspectorListenerAppender;
33
import org.eclipse.jubula.rc.rcp.e3.gef.listener.GefPartListener;
34
import org.eclipse.jubula.rc.swt.SwtAUTServer;
35
import org.eclipse.jubula.rc.swt.listener.ComponentHandler;
36
import org.eclipse.jubula.tools.constants.AutConfigConstants;
37
import org.eclipse.jubula.tools.constants.AutEnvironmentConstants;
38
import org.eclipse.jubula.tools.constants.CommandConstants;
39
import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants;
40
import org.eclipse.jubula.tools.utils.EnvironmentUtils;
41
import org.eclipse.swt.SWT;
42
import org.eclipse.swt.widgets.Button;
43
import org.eclipse.swt.widgets.Composite;
44
import org.eclipse.swt.widgets.Control;
45
import org.eclipse.swt.widgets.CoolBar;
46
import org.eclipse.swt.widgets.CoolItem;
47
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Event;
49
import org.eclipse.swt.widgets.Item;
50
import org.eclipse.swt.widgets.Listener;
51
import org.eclipse.swt.widgets.Shell;
52
import org.eclipse.swt.widgets.ToolBar;
53
import org.eclipse.swt.widgets.Widget;
54
import org.eclipse.ui.IEditorReference;
55
import org.eclipse.ui.IPartListener2;
56
import org.eclipse.ui.IStartup;
57
import org.eclipse.ui.IViewReference;
58
import org.eclipse.ui.IWindowListener;
59
import org.eclipse.ui.IWorkbench;
60
import org.eclipse.ui.IWorkbenchPage;
61
import org.eclipse.ui.IWorkbenchPartReference;
62
import org.eclipse.ui.IWorkbenchWindow;
63
import org.eclipse.ui.PlatformUI;
64
import org.eclipse.ui.internal.WorkbenchPartReference;
65
66
67
/**
68
 * Initializes an AUT Server in a plug-in context.
69
 * 
70
 * It is very important to avoid referencing GEF (org.eclipse.gef.*) classes 
71
 * directly from this class, as this will cause Class Not Found errors if the 
72
 * AUT does not contain the GEF plug-in.
73
 *
74
 * @author BREDEX GmbH
75
 * @created Oct 5, 2007
76
 */
77
public class Startup implements IStartup {
78
    /** Key for GEF Viewer in component data */
79
    public static final String TEST_GEF_VIEWER_DATA_KEY = "TEST_GEF_VIEWER"; //$NON-NLS-1$
80
81
    /** bundle ID for Eclipse Graphical Editing Framework (GEF) */
82
    public static final String GEF_BUNDLE_ID = "org.eclipse.gef"; //$NON-NLS-1$
83
    
84
    /** Key for RCP partId in component data */
85
    private static final String TEST_RCP_DATA_KEY = 
86
        SwtAUTHierarchyConstants.RCP_NAME;
87
    
88
    /** ID suffix for toolbars belonging to a part (view/editor) */
89
    private static final String TOOLBAR_ID_SUFFIX = ".toolbar"; //$NON-NLS-1$
90
        
91
    /** Single listener instance */
92
    private static IPartListener2 partNamingListener = 
93
        new PartNamingListener();
94
    
95
    /** 
96
     * This listener 
97
     */
98
    private IPartListener2 m_gefListener = null;
99
100
    /**
101
     * This listener assigns names to components as they become visible. The
102
     * assigned name is determined by supporting data of the component and its
103
     * surroundings.
104
     *
105
     * @author BREDEX GmbH
106
     * @created Oct 19, 2007
107
     */
108
    private static class ComponentNamer implements Listener {
109
110
        /** map for naming dialog buttons */
111
        private static Map componentNAMES = new HashMap();
112
        
113
        /** is name generation enabled */
114
        private static boolean generateNames = false;
115
        
116
        static {
117
            generateNames = Boolean.valueOf(
118
                    EnvironmentUtils.getProcessEnvironment()
119
                        .getProperty(
120
                                AutEnvironmentConstants
121
                                    .GENERATE_COMPONENT_NAMES))
122
                            .booleanValue();
123
            
124
            addCompName(IDialogConstants.ABORT_ID, "abort"); //$NON-NLS-1$
125
            addCompName(IDialogConstants.BACK_ID, "back"); //$NON-NLS-1$
126
            addCompName(IDialogConstants.CANCEL_ID, "cancel"); //$NON-NLS-1$
127
            addCompName(IDialogConstants.CLIENT_ID, "client"); //$NON-NLS-1$
128
            addCompName(IDialogConstants.CLOSE_ID, "close"); //$NON-NLS-1$
129
            addCompName(IDialogConstants.DESELECT_ALL_ID, "deselectAll"); //$NON-NLS-1$
130
            addCompName(IDialogConstants.DETAILS_ID, "details"); //$NON-NLS-1$
131
            addCompName(IDialogConstants.FINISH_ID, "finish"); //$NON-NLS-1$
132
            addCompName(IDialogConstants.HELP_ID, "help"); //$NON-NLS-1$
133
            addCompName(IDialogConstants.IGNORE_ID, "ignore"); //$NON-NLS-1$
134
            addCompName(IDialogConstants.INTERNAL_ID, "internal"); //$NON-NLS-1$
135
            addCompName(IDialogConstants.NEXT_ID, "next"); //$NON-NLS-1$
136
            addCompName(IDialogConstants.NO_ID, "no"); //$NON-NLS-1$
137
            addCompName(IDialogConstants.NO_TO_ALL_ID, "noToAll"); //$NON-NLS-1$
138
            addCompName(IDialogConstants.OK_ID, "ok"); //$NON-NLS-1$
139
            addCompName(IDialogConstants.OPEN_ID, "open"); //$NON-NLS-1$
140
            addCompName(IDialogConstants.PROCEED_ID, "proceed"); //$NON-NLS-1$
141
            addCompName(IDialogConstants.RETRY_ID, "retry"); //$NON-NLS-1$
142
            addCompName(IDialogConstants.SELECT_ALL_ID, "selectAll"); //$NON-NLS-1$
143
            addCompName(IDialogConstants.SELECT_TYPES_ID, "selectTypes"); //$NON-NLS-1$
144
            addCompName(IDialogConstants.SKIP_ID, "skip"); //$NON-NLS-1$
145
            addCompName(IDialogConstants.STOP_ID, "stop"); //$NON-NLS-1$
146
            addCompName(IDialogConstants.YES_ID, "yes"); //$NON-NLS-1$
147
            addCompName(IDialogConstants.YES_TO_ALL_ID, "yesToAll"); //$NON-NLS-1$
148
        }
149
        
150
        /**
151
         * add component id <-> name mapping
152
         * @param compID the component identifier
153
         * @param compName the component name
154
         */
155
        private static void addCompName(int compID, String compName) {
156
            String staticNamePreafix = "dialog.button."; //$NON-NLS-1$
157
            componentNAMES.put(new Integer(compID), 
158
                    staticNamePreafix + compName);
159
        }
160
        
161
        /**
162
         * {@inheritDoc}
163
         */
164
        public void handleEvent(Event event) {
165
            addNameData(event.widget);
166
            Item [] items = new Item [] {};
167
            if (event.widget instanceof ToolBar) {
168
                items = ((ToolBar)event.widget).getItems();
169
            } else if (event.widget instanceof CoolBar) {
170
                items = ((CoolBar)event.widget).getItems();
171
            }
172
            for (int i = 0; i < items.length; i++) {
173
                addNameData(items[i]);
174
            }
175
        }
176
177
        /**
178
         * Adds name information to the given widget, if necessary.
179
         * 
180
         * @param widget The widget to name.
181
         */
182
        private void addNameData(Widget widget) {
183
            // Assign name
184
            if (widget != null && !widget.isDisposed()) {
185
                if (widget.getData(Startup.TEST_RCP_DATA_KEY) != null) {
186
                    // Component already has a name, so we don't need to
187
                    // assign a new one.
188
                    return;
189
                }
190
                Object data = getWidgetData(widget);
191
192
                if (data instanceof IContributionItem) {
193
                    // Name buttons and toolitems according to the action that
194
                    // they represent, if possible.
195
                    String actionId = ((IContributionItem)data).getId();
196
                    if (actionId != null && actionId.trim().length() > 0) {
197
198
                        widget.setData(Startup.TEST_RCP_DATA_KEY, actionId);
199
                        ComponentHandler.getAutHierarchy()
200
                            .refreshComponentName(widget);
201
202
                    }
203
                } else if (data instanceof PreferenceDialog) {
204
                    PreferenceDialog prefDialog = (PreferenceDialog)data;
205
             
206
                    // Add a listener to add name data as pages are 
207
                    // selected/created.
208
                    prefDialog.addPageChangedListener(
209
                        new IPageChangedListener() {
210
211
                            public void pageChanged(PageChangedEvent event) {
212
                                addNameDataToPrefPage(event.getSelectedPage());
213
                            }
214
                        
215
                        });
216
217
                    // The listener won't notice the initally selected page,
218
                    // so we have to add that name data here.
219
                    addNameDataToPrefPage(prefDialog.getSelectedPage());
220
                }
221
                if (generateNames && data instanceof Dialog) {
222
                    Dialog dialog = (Dialog)data;
223
                    setNameForDialogButtonBarButtons(dialog);
224
                }
225
            }
226
        }
227
228
        /**
229
         * 
230
         * @param widget The widget for which to get the data.
231
         * @return the data object corresponding to the given widget.
232
         */
233
        private Object getWidgetData(Widget widget) {
234
            Object data = widget.getData();
235
236
            // Handle the case of CoolBar containing CoolItem containing ToolBar.
237
            // The CoolItem is the widget that represents the toolbar 
238
            // contribution, but it (the CoolItem) is not in our AUT 
239
            // component hierarchy, due to the fact that the ToolBar's 
240
            // getParent() returns the CoolBar rather than the CoolItem.
241
            // To resolve this discrepancy, we use the data from the 
242
            // coresponding CoolItem to generate a name for the ToolBar.
243
            try {
244
                if (widget instanceof ToolBar) {
245
                    Composite toolbarParent = ((ToolBar)widget).getParent();
246
                    if (toolbarParent instanceof CoolBar) {
247
                        CoolItem [] coolItems = 
248
                            ((CoolBar)toolbarParent).getItems();
249
                        for (int i = 0; i < coolItems.length; i++) {
250
                            CoolItem item = coolItems[i];
251
                            if (item != null 
252
                                    && item.getControl() == widget) {
253
                                data = item.getData();
254
                            }
255
                        }
256
                    }
257
                }
258
            } catch (NoClassDefFoundError e) {
259
                // we may be running in eRCP which doesn't know
260
                // about
261
                // toolbars, so we just ignore this
262
            }
263
264
            return data;
265
        }
266
        
267
        /**
268
         * @param dialog the dialog
269
         */
270
        private void setNameForDialogButtonBarButtons(Dialog dialog) {
271
            try {
272
                Method getButtonMethod = Dialog.class.getDeclaredMethod(
273
                        "getButton", new Class[] { int.class }); //$NON-NLS-1$
274
                getButtonMethod.setAccessible(true);
275
276
                Iterator components = componentNAMES.keySet().iterator();
277
                while (components.hasNext()) {
278
                    Integer componentID = (Integer)components.next();
279
                    invokeNameSetting(dialog, getButtonMethod, componentID,
280
                            componentNAMES.get(componentID));
281
                }
282
            } catch (SecurityException e) {
283
                // ignore exceptions
284
            } catch (NoSuchMethodException e) {
285
                // ignore exceptions
286
            }
287
        }
288
289
        /**
290
         * use this method to set a name on the given object
291
         * @param useObject the object
292
         * @param methodToInvoke the method to invoke
293
         * @param buttonID the button id
294
         * @param buttonName the button name
295
         */
296
        private void invokeNameSetting(Object useObject, Method methodToInvoke,
297
                Integer buttonID, Object buttonName) {
298
            Object ret = null;
299
            try {
300
                ret = methodToInvoke.invoke(useObject,
301
                        new Object[] { buttonID });
302
            } catch (IllegalArgumentException e) {
303
                // ignore exceptions
304
            } catch (IllegalAccessException e) {
305
                // ignore exceptions
306
            } catch (InvocationTargetException e) {
307
                // ignore exceptions
308
            }
309
            if (ret instanceof Button) {
310
                Button button = (Button)ret;
311
                if (button.getData(TEST_RCP_DATA_KEY) == null) {
312
                    button.setData(TEST_RCP_DATA_KEY, buttonName);
313
                }
314
            }
315
        }
316
317
        /**
318
         * Attaches name data to the given page appropriate.
319
         * 
320
         * @param selectedPage The page to which we will try to attach the 
321
         *                     name data.
322
         */
323
        private void addNameDataToPrefPage(Object selectedPage) {
324
            if (selectedPage == null) {
325
                return;
326
            }
327
            PreferenceManager prefMan = 
328
                PlatformUI.getWorkbench().getPreferenceManager();
329
330
            Iterator iter = 
331
                prefMan.getElements(PreferenceManager.PRE_ORDER).iterator();
332
            while (iter.hasNext()) {
333
                IPreferenceNode prefNode = 
334
                    (IPreferenceNode)iter.next();
335
                if (selectedPage.equals(prefNode.getPage())) {
336
                    Control pageControl = 
337
                        prefNode.getPage().getControl();
338
                    String prefNodeId = prefNode.getId();
339
                    
340
                    // Assign id to page composite only if the composite exists
341
                    // and if the id is usable
342
                    if (pageControl != null 
343
                        && !pageControl.isDisposed()
344
                        && pageControl.getData(
345
                            Startup.TEST_RCP_DATA_KEY) == null
346
                        && prefNodeId != null
347
                        && prefNodeId.trim().length() > 0) {
348
                       
349
                        pageControl.setData(
350
                            Startup.TEST_RCP_DATA_KEY, prefNodeId);
351
                       
352
                        Shell prefShell = 
353
                            pageControl.getDisplay().getActiveShell();
354
                        Event activateEvent = new Event();
355
                        activateEvent.time = (int)System.currentTimeMillis();
356
                        activateEvent.type = SWT.Activate;
357
                        activateEvent.widget = prefShell;
358
                        prefShell.notifyListeners(SWT.Activate, activateEvent);
359
360
                    }
361
362
                    // We found the page we were looking for, so we can stop 
363
                    // searching.
364
                    break;
365
                }
366
            }
367
        }
368
    }
369
370
    /**
371
     * Assigns the controls (Composites) of Parts unique names based on 
372
     * their partId.
373
     *
374
     * @author BREDEX GmbH
375
     * @created Oct 5, 2007
376
     */
377
    static class PartNamingListener implements IPartListener2 {
378
379
        /**
380
         * 
381
         * {@inheritDoc}
382
         */
383
        public void partActivated(IWorkbenchPartReference partRef) {
384
            // Do nothing
385
        }
386
387
        /**
388
         * 
389
         * {@inheritDoc}
390
         */
391
        public void partBroughtToTop(IWorkbenchPartReference partRef) {
392
            // Do nothing
393
        }
394
395
        /**
396
         * 
397
         * {@inheritDoc}
398
         */
399
        public void partClosed(IWorkbenchPartReference partRef) {
400
            // Do nothing
401
        }
402
403
        /**
404
         * 
405
         * {@inheritDoc}
406
         */
407
        public void partDeactivated(IWorkbenchPartReference partRef) {
408
            // Do nothing
409
        }
410
411
        /**
412
         * 
413
         * {@inheritDoc}
414
         */
415
        public void partHidden(IWorkbenchPartReference partRef) {
416
            // Do nothing
417
        }
418
419
        /**
420
         * 
421
         * {@inheritDoc}
422
         */
423
        public void partInputChanged(IWorkbenchPartReference partRef) {
424
            // Do nothing
425
        }
426
427
        /**
428
         * 
429
         * {@inheritDoc}
430
         */
431
        public void partOpened(IWorkbenchPartReference partRef) {
432
            if (partRef instanceof WorkbenchPartReference) {
433
                WorkbenchPartReference workbenchPartRef = 
434
                    (WorkbenchPartReference)partRef;
435
                // Get pane contents and part id
436
                Control partContent = 
437
                    workbenchPartRef.getPane().getControl();
438
439
                if (partContent != null 
440
                    && !partContent.isDisposed()
441
                    && partContent.getData(TEST_RCP_DATA_KEY) == null) {
442
                    
443
                    // Name pane control based on part
444
                    String partId = workbenchPartRef.getId();
445
446
                    // Append secondary id, if necessary
447
                    if (partRef instanceof IViewReference) {
448
                        String secondaryId = 
449
                            ((IViewReference)partRef).getSecondaryId();
450
                        if (secondaryId != null) {
451
                            partId += "_" + secondaryId; //$NON-NLS-1$
452
                        }
453
                    }
454
455
                    if (partId == null || partId.trim().length() == 0) {
456
                        // Don't assign a name if the id is unusable
457
                        return;
458
                    }
459
                    partContent.setData(TEST_RCP_DATA_KEY, partId);
460
461
                    // Assign a corresponding id to the part's toolbar, if
462
                    // possible/usable.
463
                    Control partToolbar = 
464
                        workbenchPartRef.getPane().getToolBar();
465
                    if (partToolbar != null) {
466
                        partToolbar.setData(TEST_RCP_DATA_KEY, 
467
                                partId + TOOLBAR_ID_SUFFIX);
468
                    }
469
                    
470
                    // A repaint is required in order for the aut component 
471
                    // hierarchy to notice the change.
472
                    Shell shell = PlatformUI.getWorkbench()
473
                        .getActiveWorkbenchWindow().getShell();
474
                    repaintToolbars(shell);
475
                }
476
            }
477
478
        }
479
480
        /**
481
         * 
482
         * {@inheritDoc}
483
         */
484
        public void partVisible(IWorkbenchPartReference partRef) {
485
            partOpened(partRef);
486
        }
487
        
488
    }
489
490
    
491
    /**
492
     * {@inheritDoc}
493
     */
494
    public void earlyStartup() {
495
        final Properties envVars = 
496
            EnvironmentUtils.getProcessEnvironment();
497
        
498
        if (getValue(AutConfigConstants.AUT_AGENT_HOST, envVars) != null) {
499
            final IWorkbench workbench = PlatformUI.getWorkbench();
500
            final Display display = workbench.getDisplay();
501
            initAutServer(display, envVars);
502
503
            display.syncExec(new Runnable() {
504
                public void run() {
505
                    // add GEF listeners (and listener appenders) for GEF, if available
506
                    if (Platform.getBundle(Startup.GEF_BUNDLE_ID) != null) {
507
                        m_gefListener = new GefPartListener();
508
                        AUTServer.getInstance().addInspectorListenerAppender(
509
                                new GefInspectorListenerAppender());
510
                    }
511
                    
512
                    // add naming listener
513
                    ComponentNamer namer = new ComponentNamer();
514
                    display.addFilter(SWT.Paint, namer);
515
                    display.addFilter(SWT.Activate, namer);
516
517
                    // Add window listener
518
                    addWindowListener(workbench);
519
                    
520
                    IWorkbenchWindow window = 
521
                        workbench.getActiveWorkbenchWindow();
522
                    if (window != null) {
523
                        // Add part listeners
524
                        addPartListeners(window);
525
                        
526
                        // Handle existing parts
527
                        IWorkbenchPage [] pages = window.getPages();
528
                        for (int i = 0; i < pages.length; i++) {
529
                            IEditorReference[] editorRefs = 
530
                                pages[i].getEditorReferences();
531
                            IViewReference[] viewRefs = 
532
                                pages[i].getViewReferences();
533
                            for (int j = 0; j < editorRefs.length; j++) {
534
                                partNamingListener.partOpened(editorRefs[j]);
535
                                if (m_gefListener != null) {
536
                                    m_gefListener.partOpened(editorRefs[j]);
537
                                }
538
                            }
539
                            for (int k = 0; k < viewRefs.length; k++) {
540
                                partNamingListener.partOpened(viewRefs[k]);
541
                                if (m_gefListener != null) {
542
                                    m_gefListener.partOpened(viewRefs[k]);
543
                                }
544
                            }
545
                        }
546
547
                        // If a shell already exists, make sure that we get another
548
                        // chance to immediately add/use our naming listeners.
549
                        Shell mainShell = window.getShell();
550
                        if (mainShell != null && !mainShell.isDisposed()) {
551
                            repaintToolbars(mainShell);
552
                        }
553
                    }
554
                }
555
556
            });
557
558
            // add listener to AUT
559
            AUTServer.getInstance().addToolKitEventListenerToAUT();
560
561
        }
562
563
    }
564
565
    /**
566
     * Initializes the AUT Server for the host application.
567
     * 
568
     * @param display The Display to use for the AUT Server.
569
     * @param envVars Environment variables to consult in configuring the 
570
     *                AUT Server.
571
     */
572
    private void initAutServer(Display display, Properties envVars) {
573
        ((SwtAUTServer)AUTServer.getInstance(CommandConstants
574
                .AUT_SWT_SERVER)).setDisplay(display);
575
        AUTServer.getInstance().setAutAgentHost(getValue(
576
                AutConfigConstants.AUT_AGENT_HOST, envVars));
577
        AUTServer.getInstance().setAutAgentPort(getValue(
578
                AutConfigConstants.AUT_AGENT_PORT, envVars));
579
        AUTServer.getInstance().setAutID(getValue(
580
                AutConfigConstants.AUT_NAME, envVars));
581
582
        AUTServer.getInstance().start(true);
583
    }
584
585
    /**
586
     * Adds a window listener to the given workbench. This listener adds a 
587
     * part naming listener to opening windows.
588
     * 
589
     * @param workbench The workbench to which the listener will be added.
590
     */
591
    private void addWindowListener(IWorkbench workbench) {
592
        workbench.addWindowListener(new IWindowListener() {
593
594
            public void windowActivated(IWorkbenchWindow window) {
595
                addPartListeners(window);
596
            }
597
598
            public void windowClosed(IWorkbenchWindow window) {
599
                // Do nothing
600
            }
601
602
            public void windowDeactivated(IWorkbenchWindow window) {
603
                // Do nothing
604
            }
605
606
            public void windowOpened(IWorkbenchWindow window) {
607
                addPartListeners(window);
608
            }
609
610
        });
611
    }
612
613
    /**
614
     * Fires a paint event on all Toolbars and Coolbars within the given shell.
615
     * 
616
     * @param mainShell The shell to search for Coolbars and Toolbars.
617
     */
618
    public static void repaintToolbars(Shell mainShell) {
619
        List toolbarList = new ArrayList();
620
        getToolbars(mainShell, toolbarList);
621
        Iterator iter = toolbarList.iterator();
622
        while (iter.hasNext()) {
623
            Control toolbar = (Control)iter.next();
624
            toolbar.update();
625
            toolbar.redraw();
626
            toolbar.update();
627
        }
628
    }
629
630
    /**
631
     * Adds all Coolbars and Toolbars within the given composite to the given
632
     * list. The search is is also performed recursively on children of the 
633
     * given composite.
634
     * 
635
     * @param composite The composite to search.
636
     * @param toolbarList The list to which found Toolbars and Coolbars will 
637
     * be added.
638
     */
639
    public static void getToolbars(Composite composite, 
640
        List toolbarList) {
641
        
642
        if (composite != null && !composite.isDisposed()) {
643
            Control [] children = composite.getChildren();
644
            for (int i = 0; i < children.length; i++) {
645
                if (children[i] instanceof Composite) {
646
                    getToolbars((Composite)children[i], toolbarList);
647
                }
648
                try {
649
                    if (children[i] instanceof ToolBar
650
                            || children[i] instanceof CoolBar) {
651
652
                        toolbarList.add(children[i]);
653
                    }
654
                } catch (NoClassDefFoundError e) {
655
                    // we may be running in eRCP which doesn't know about
656
                    // toolbars, so we just ignore this
657
                }
658
            }
659
        }
660
    }
661
662
    /**
663
     * Add part listeners to the given window.
664
     * 
665
     * @param window The window to which the listeners will be added.
666
     */
667
    private void addPartListeners(IWorkbenchWindow window) {
668
        window.getPartService().addPartListener(partNamingListener);
669
        if (m_gefListener != null) {
670
            window.getPartService().addPartListener(m_gefListener);
671
        }
672
    }
673
674
    /**
675
     * Returns the value for a given property. First, <code>envVars</code> 
676
     * is checked for the given property. If this
677
     * property cannot be found there, the 
678
     * Java System Properties will be checked. If the property is not 
679
     * found there, <code>null</code> will be returned.
680
     * 
681
     * @param envVars The first source to check for the given property.
682
     * @param propName The name of the property for which to find the value.
683
     * @return The value for the given property name, or <code>null</code> if
684
     *         given property name cannot be found.
685
     */
686
    private String getValue(String propName, Properties envVars) {
687
        String value = 
688
            envVars.getProperty(propName);
689
        if (value == null) {
690
            value = System.getProperty(propName);
691
        }
692
        return value;
693
    }
694
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/factory/DefaultEditPartAdapterFactory.java (+85 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.factory;
12
13
import org.eclipse.core.runtime.IAdapterFactory;
14
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.gef.EditPart;
16
import org.eclipse.jubula.rc.rcp.e3.gef.identifier.ClassCountEditPartIdentifier;
17
import org.eclipse.jubula.rc.rcp.e3.gef.identifier.IEditPartIdentifier;
18
19
20
/**
21
 * The default adapter factory for getting adapters from EditPart to 
22
 * IEditPartIdentifier. 
23
 *
24
 * @author BREDEX GmbH
25
 * @created May 13, 2009
26
 */
27
public class DefaultEditPartAdapterFactory implements IAdapterFactory {
28
29
    /** the types managed by this factory */
30
    private static final Class [] ADAPTABLE_TYPES = 
31
        new Class [] {EditPart.class};
32
    
33
    /**
34
     * {@inheritDoc}
35
     */
36
    public Object getAdapter(Object adaptableObject, Class adapterType) {
37
        if (adaptableObject instanceof EditPart) {
38
            if (adapterType == IEditPartIdentifier.class) {
39
                return new ClassCountEditPartIdentifier(
40
                        (EditPart)adaptableObject);
41
            }
42
        }
43
        return null;
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public Class[] getAdapterList() {
50
        return ADAPTABLE_TYPES;
51
    }
52
53
    /**
54
     * 
55
     * @param editPart The EditPart for which to find the IEditPartIdentifier.
56
     * @return the IEditPartIdentifier for the given EditPart. First, an attempt
57
     *         is made to load this from a registered adapter factory. If this
58
     *         does not provide an adapter, then this adapter factory is 
59
     *         queried, providing a default implementation.
60
     */
61
    public static IEditPartIdentifier loadFigureIdentifier(EditPart editPart) {
62
        if (editPart == null) {
63
            // null-safe
64
            return null;
65
        }
66
        IEditPartIdentifier editPartIdentifier = 
67
            (IEditPartIdentifier)Platform.getAdapterManager().loadAdapter(
68
                    editPart, IEditPartIdentifier.class.getName());
69
//        if (editPartIdentifier == null) {
70
//            AccessibleEditPart accessible = 
71
//                (AccessibleEditPart)Platform.getAdapterManager().loadAdapter(
72
//                    editPart, AccessibleEditPart.class.getName());
73
//            AccessibleEvent e = new AccessibleEvent(IEditPartIdentifier.class);
74
//            accessible.getName(e);
75
//            if (e.result != null) {
76
//                editPartIdentifier = new StaticEditPartIdentifier(e.result);
77
//            }
78
//        }
79
        if (editPartIdentifier == null) {
80
            editPartIdentifier = new ClassCountEditPartIdentifier(editPart);
81
        }
82
        
83
        return editPartIdentifier;
84
    }
85
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/identifier/ClassCountEditPartIdentifier.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.identifier;
12
13
import java.util.HashMap;
14
import java.util.Iterator;
15
import java.util.Map;
16
17
import org.eclipse.gef.EditPart;
18
19
/**
20
 * Default implementation of {@link IEditPartIdentifier}. The identifier is 
21
 * the name of the class of the {@link EditPart} plus a sequential number.
22
 *
23
 * @author BREDEX GmbH
24
 * @created May 13, 2009
25
 */
26
public class ClassCountEditPartIdentifier implements IEditPartIdentifier {
27
28
    /** the EditPart for which identifiers can be generated */
29
    private EditPart m_editPart;
30
    
31
    /**
32
     * Constructor
33
     * 
34
     * @param editPart The EditPart for which identifiers can be generated.
35
     */
36
    public ClassCountEditPartIdentifier(EditPart editPart) {
37
        m_editPart = editPart;
38
    }
39
    
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public String getIdentifier() {
44
        EditPart parent = m_editPart.getParent();
45
        String className = m_editPart.getClass().getName();
46
        String id = className;
47
        if (parent != null) {
48
            id += "_"; //$NON-NLS-1$
49
            Iterator siblingIterator = parent.getChildren().iterator();
50
            boolean isFound = false;
51
            int count = 0;
52
            while (siblingIterator.hasNext() && !isFound) {
53
                EditPart sibling = (EditPart)siblingIterator.next();
54
                if (sibling == m_editPart) {
55
                    isFound = true;
56
                }
57
                if (sibling.getClass().getName().equals(className)) {
58
                    count++;
59
                }
60
            }
61
            id += count;
62
        }
63
        return id;
64
    }
65
66
    /**
67
     * {@inheritDoc}
68
     */
69
    public Map getConnectionAnchors() {
70
        return new HashMap();
71
    }
72
73
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/identifier/IEditPartIdentifier.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.identifier;
12
13
import java.util.Map;
14
15
16
17
/**
18
 * Encapsulates the ability to generate unique IDs for a given 
19
 * {@link org.eclipse.gef.EditPart}.
20
 *
21
 * @author BREDEX GmbH
22
 * @created May 13, 2009
23
 */
24
public interface IEditPartIdentifier {
25
26
    /**
27
     * 
28
     * @return a String uniquely identifying the EditPart.
29
     */
30
    public String getIdentifier();
31
32
    /**
33
     * 
34
     * @return a map that correlates identifiers (<code>String</code>s) with 
35
     *         <code>ConnectionAnchor</code>s.
36
     */
37
    public Map getConnectionAnchors();
38
    
39
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/identifier/StaticEditPartIdentifier.java (+53 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.identifier;
12
13
import java.util.Collections;
14
import java.util.Map;
15
16
17
/**
18
 * Provides a static String as an identifier. This class does not take the 
19
 * state of the {@link org.eclipse.gef.EditPart} into account, so it is useful
20
 * for stateless {@link org.eclipse.gef.EditPart}s (ex. containers).
21
 *
22
 * @author BREDEX GmbH
23
 * @created May 19, 2009
24
 */
25
public class StaticEditPartIdentifier implements IEditPartIdentifier {
26
27
    /** the identifier that will always be returned */
28
    private String m_id;
29
    
30
    /**
31
     * Constructor
32
     * 
33
     * @param id The static identifier String that will always be returned.
34
     */
35
    public StaticEditPartIdentifier(String id) {
36
        m_id = id;
37
    }
38
    
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public String getIdentifier() {
43
        return m_id;
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public Map getConnectionAnchors() {
50
        return Collections.EMPTY_MAP;
51
    }
52
53
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/implclasses/FigureCanvasImplClass.java (+763 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.implclasses;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.Iterator;
15
import java.util.List;
16
import java.util.Map;
17
18
import org.apache.commons.beanutils.PropertyUtils;
19
import org.apache.commons.lang.Validate;
20
import org.eclipse.draw2d.Connection;
21
import org.eclipse.draw2d.ConnectionAnchor;
22
import org.eclipse.draw2d.FigureCanvas;
23
import org.eclipse.draw2d.IFigure;
24
import org.eclipse.draw2d.geometry.Point;
25
import org.eclipse.gef.ConnectionEditPart;
26
import org.eclipse.gef.EditDomain;
27
import org.eclipse.gef.EditPart;
28
import org.eclipse.gef.GraphicalEditPart;
29
import org.eclipse.gef.GraphicalViewer;
30
import org.eclipse.gef.RootEditPart;
31
import org.eclipse.gef.palette.PaletteEntry;
32
import org.eclipse.gef.ui.palette.PaletteViewer;
33
import org.eclipse.jubula.rc.common.driver.ClickOptions;
34
import org.eclipse.jubula.rc.common.driver.IRobot;
35
import org.eclipse.jubula.rc.common.driver.IRunnable;
36
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
37
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
38
import org.eclipse.jubula.rc.common.implclasses.Verifier;
39
import org.eclipse.jubula.rc.rcp.e3.accessor.Startup;
40
import org.eclipse.jubula.rc.rcp.e3.gef.factory.DefaultEditPartAdapterFactory;
41
import org.eclipse.jubula.rc.rcp.e3.gef.identifier.IEditPartIdentifier;
42
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
43
import org.eclipse.jubula.rc.swt.implclasses.AbstractControlImplClass;
44
import org.eclipse.jubula.rc.swt.implclasses.MenuUtil;
45
import org.eclipse.jubula.tools.objects.event.EventFactory;
46
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
47
import org.eclipse.swt.graphics.Rectangle;
48
import org.eclipse.swt.widgets.Composite;
49
import org.eclipse.swt.widgets.Control;
50
51
52
/**
53
 * Implementation class for Figure Canvas (Eclipse GEF).
54
 *
55
 * @author BREDEX GmbH
56
 * @created May 13, 2009
57
 */
58
public class FigureCanvasImplClass extends AbstractControlImplClass {
59
60
    /** 
61
     * the viewer that contains the EditParts corresponding to the FigureCanvas 
62
     */
63
    private GraphicalViewer m_viewer = null;
64
    
65
    /** the composite in which the IFigures are displayed */
66
    private Composite m_composite = null;
67
    
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public Control getComponent() {
72
        return m_composite;
73
    }
74
75
    /**
76
     * 
77
     * @return the viewer associated with the canvas to test.
78
     */
79
    private GraphicalViewer getViewer() {
80
        return m_viewer;
81
    }
82
83
    /**
84
     * 
85
     * @return the control for the canvas to test.
86
     */
87
    private Control getViewerControl() {
88
        return getViewer().getControl();
89
    }
90
91
    /**
92
     * 
93
     * @return the root edit part of the viewer.
94
     */
95
    private RootEditPart getRootEditPart() {
96
        return getViewer().getRootEditPart();
97
    }
98
99
    /**
100
     * 
101
     * @return the root of the palette viewer (tool palette).
102
     */
103
    private RootEditPart getPaletteRoot() {
104
        return getViewer().getEditDomain().getPaletteViewer().getRootEditPart();
105
    }
106
107
    /**
108
     * 
109
     * @param textPath The path to the tool.
110
     * @param operator The operator used for matching.
111
     * @return the EditPart found at the end of the given path. Returns 
112
     *         <code>null</code> if no EditPart can be found for the given path
113
     *         or if the EditPart found is not a GraphicalEditPart.
114
     */
115
    private GraphicalEditPart findPaletteEditPart(
116
            String textPath, String operator) {
117
118
        final String[] pathItems = MenuUtil.splitPath(textPath);
119
        boolean isExisting = true;
120
        
121
        EditPart currentEditPart = getPaletteRoot().getContents();
122
        
123
        for (int i = 0; i < pathItems.length && currentEditPart != null; i++) {
124
            List effectiveChildren = currentEditPart.getChildren();
125
            
126
            EditPart [] children = 
127
                (EditPart [])effectiveChildren.toArray(
128
                        new EditPart[effectiveChildren.size()]);
129
            boolean itemFound = false;
130
            for (int j = 0; j < children.length && !itemFound; j++) {
131
                Object model = children[j].getModel();
132
                if (model instanceof PaletteEntry) {
133
                    String entryLabel = ((PaletteEntry)model).getLabel();
134
                    if (entryLabel != null 
135
                        && MatchUtil.getInstance().match(
136
                            entryLabel, pathItems[i], operator)) {
137
                        itemFound = true;
138
                        currentEditPart = children[j];
139
                    }
140
                }
141
            }
142
            if (!itemFound) {
143
                isExisting = false;
144
                break;
145
            }
146
            
147
        }
148
        
149
        return isExisting && currentEditPart instanceof GraphicalEditPart 
150
            ? (GraphicalEditPart)currentEditPart : null;
151
        
152
    }
153
    
154
    /**
155
     * {@inheritDoc}
156
     */
157
    public String[] getTextArrayFromComponent() {
158
        return null;
159
    }
160
161
    /**
162
     * {@inheritDoc}
163
     */
164
    public void setComponent(final Object graphicsComponent) {
165
        getEventThreadQueuer().invokeAndWait(getClass().getName() + ".setComponent", new IRunnable() { //$NON-NLS-1$
166
167
            public Object run() throws StepExecutionException {
168
                FigureCanvas figureCanvas = (FigureCanvas)graphicsComponent;
169
                Composite parent = figureCanvas;
170
                while (parent != null
171
                        && !(parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY) 
172
                                instanceof GraphicalViewer)) {
173
                    parent = parent.getParent();
174
                }
175
                
176
                if (parent != null) {
177
                    m_composite = parent;
178
                    m_viewer = 
179
                        (GraphicalViewer)parent.getData(
180
                                Startup.TEST_GEF_VIEWER_DATA_KEY);
181
                }
182
                return null;
183
            }
184
            
185
        });
186
    }
187
188
    /**
189
     * Checks whether the figure for the EditPart for the given path exists and
190
     * is visible.
191
     * 
192
     * @param textPath The path to the figure.
193
     * @param operator The operator used for matching.
194
     * @param exists   Whether the figure is expected to exist.
195
     */
196
    public void gdCheckFigureExists(
197
            String textPath, String operator, boolean exists) {
198
199
        boolean isExisting = 
200
            findFigure(findEditPart(textPath, operator)) != null; 
201
        if (!isExisting) {
202
            // See if there's a connection anchor at the given path
203
            isExisting = findConnectionAnchor(textPath, operator) != null;
204
        }
205
        
206
        Verifier.equals(exists, isExisting);
207
208
    }
209
210
    /**
211
     * Checks the given property of the figure at the given path.
212
     * 
213
     * @param textPath The path to the figure.
214
     * @param textPathOperator The operator used for matching the text path.
215
     * @param propertyName The name of the property
216
     * @param expectedPropValue The value of the property as a string
217
     * @param valueOperator The operator used to verify
218
     */
219
    public void gdVerifyFigureProperty(String textPath, 
220
            String textPathOperator, final String propertyName, 
221
            String expectedPropValue, String valueOperator) {
222
223
        final IFigure figure = 
224
            findFigure(findEditPart(textPath, textPathOperator));
225
        if (figure == null) {
226
            throw new StepExecutionException(
227
                    "No figure could be found for the given text path.", //$NON-NLS-1$
228
                    EventFactory.createActionError(
229
                            TestErrorEvent.NOT_FOUND));
230
        }
231
        Object prop = getEventThreadQueuer().invokeAndWait("getProperty",  //$NON-NLS-1$
232
            new IRunnable() {
233
234
                public Object run() throws StepExecutionException {
235
                    try {
236
                        return PropertyUtils.getProperty(figure, propertyName);
237
                    } catch (IllegalAccessException e) {
238
                        throw new StepExecutionException(
239
                            e.getMessage(), 
240
                            EventFactory.createActionError(
241
                                TestErrorEvent.PROPERTY_NOT_ACCESSABLE));
242
                    } catch (InvocationTargetException e) {
243
                        throw new StepExecutionException(
244
                            e.getMessage(), 
245
                            EventFactory.createActionError(
246
                                TestErrorEvent.PROPERTY_NOT_ACCESSABLE));
247
                    } catch (NoSuchMethodException e) {
248
                        throw new StepExecutionException(
249
                            e.getMessage(), 
250
                            EventFactory.createActionError(
251
                                TestErrorEvent.PROPERTY_NOT_ACCESSABLE));
252
                    }
253
                }
254
                
255
            });
256
        final String propToStr = String.valueOf(prop);
257
        Verifier.match(propToStr, expectedPropValue, valueOperator);
258
        
259
    }
260
    
261
    /**
262
     * Checks whether the tool for the given path exists and
263
     * is visible.
264
     * 
265
     * @param textPath The path to the figure.
266
     * @param operator The operator used for matching.
267
     * @param exists   Whether the figure is expected to exist.
268
     */
269
    public void gdCheckToolExists(
270
            String textPath, String operator, boolean exists) {
271
272
        boolean isExisting = findPaletteFigure(textPath, operator) != null; 
273
        
274
        Verifier.equals(exists, isExisting);
275
276
    }
277
278
    /**
279
     * Finds and clicks the figure for the given path.
280
     * 
281
     * @param textPath The path to the figure.
282
     * @param operator The operator used for matching.
283
     * @param count The number of times to click.
284
     * @param button The mouse button to use for the click.
285
     */
286
    public void gdClickFigure(String textPath, String operator, 
287
            int count, int button) {
288
289
        getRobot().click(getViewerControl(), 
290
                getFigureBoundsChecked(textPath, operator), 
291
                ClickOptions.create().setScrollToVisible(false)
292
                    .setClickCount(count).setMouseButton(button));
293
    }
294
295
    /**
296
     * Finds and clicks on a connection between a source figure and a 
297
     * target figure.
298
     * 
299
     * @param sourceTextPath The path to the source figure.
300
     * @param sourceOperator The operator to use for matching the source 
301
     *                       figure path.
302
     * @param targetTextPath The path to the target figure.
303
     * @param targetOperator The operator to use for matching the target
304
     *                       figure path.
305
     * @param count The number of times to click.
306
     * @param button The mouse button to use for the click.
307
     */
308
    public void gdClickConnection(String sourceTextPath, String sourceOperator,
309
            String targetTextPath, String targetOperator, 
310
            int count, int button) {
311
312
        GraphicalEditPart sourceEditPart = 
313
            findEditPart(sourceTextPath, sourceOperator);
314
        GraphicalEditPart targetEditPart = 
315
            findEditPart(targetTextPath, targetOperator);
316
317
        ConnectionEditPart connectionEditPart = null;
318
        
319
        if (sourceEditPart != null) {
320
            List sourceConnectionList = sourceEditPart.getSourceConnections();
321
            ConnectionEditPart [] sourceConnections = 
322
                (ConnectionEditPart [])sourceConnectionList.toArray(
323
                        new ConnectionEditPart[sourceConnectionList.size()]); 
324
            for (int i = 0; i < sourceConnections.length 
325
                    && connectionEditPart == null; i++) {
326
                if (sourceConnections[i].getTarget() == targetEditPart) {
327
                    connectionEditPart = sourceConnections[i];
328
                }
329
            }
330
        } else if (targetEditPart != null) {
331
            List targetConnectionList = targetEditPart.getTargetConnections();
332
            ConnectionEditPart [] targetConnections = 
333
                (ConnectionEditPart [])targetConnectionList.toArray(
334
                        new ConnectionEditPart[targetConnectionList.size()]); 
335
            for (int i = 0; i < targetConnections.length 
336
                    && connectionEditPart == null; i++) {
337
                if (targetConnections[i].getSource() == targetEditPart) {
338
                    connectionEditPart = targetConnections[i];
339
                }
340
            }
341
        } else {
342
            throw new StepExecutionException(
343
                    "No figures could be found for the given text paths.", //$NON-NLS-1$
344
                    EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
345
        }
346
347
        IFigure connectionFigure = findFigure(connectionEditPart);
348
        if (connectionFigure == null) {
349
            String missingEnd = sourceEditPart == null ? "source" : "target"; //$NON-NLS-1$ //$NON-NLS-2$
350
            throw new StepExecutionException(
351
                    "No connection could be found for the given " + missingEnd + " figure.", //$NON-NLS-1$ //$NON-NLS-2$
352
                    EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
353
        }
354
        
355
        // Scrolling
356
        revealEditPart(connectionEditPart);
357
358
        if (connectionFigure instanceof Connection) {
359
            Point midpoint = 
360
                ((Connection)connectionFigure).getPoints().getMidpoint();
361
            connectionFigure.translateToAbsolute(midpoint);
362
            getRobot().click(getViewerControl(), null, 
363
                    ClickOptions.create().setScrollToVisible(false)
364
                        .setClickCount(count).setMouseButton(button), 
365
                    midpoint.x, true, midpoint.y, true);
366
        } else {
367
            getRobot().click(getViewerControl(), 
368
                    getBounds(connectionFigure), 
369
                    ClickOptions.create().setScrollToVisible(false)
370
                        .setClickCount(count).setMouseButton(button));
371
        }
372
        
373
    }
374
375
    /**
376
     * Clicks the specified position within the given figure.
377
     *  
378
     * @param textPath The path to the figure.
379
     * @param operator The operator used for matching.
380
     * @param count amount of clicks
381
     * @param button what button should be clicked
382
     * @param xPos what x position
383
     * @param xUnits should x position be pixel or percent values
384
     * @param yPos what y position
385
     * @param yUnits should y position be pixel or percent values
386
     * @throws StepExecutionException if step execution fails.
387
     */
388
    public void gdClickInFigure(String textPath, String operator, 
389
        int count, int button, int xPos, String xUnits, 
390
        int yPos, String yUnits) throws StepExecutionException {
391
        
392
        getRobot().click(getViewerControl(), 
393
                getFigureBoundsChecked(textPath, operator), 
394
                ClickOptions.create().setScrollToVisible(false)
395
                    .setClickCount(count).setMouseButton(button), 
396
                xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL), 
397
                yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL));
398
    }
399
400
    /**
401
     * Simulates the beginning of a Drag. Moves to the specified position 
402
     * within the given figure and stores information related to the drag to 
403
     * be used later by a Drop operation.
404
     * 
405
     * @param textPath The path to the figure.
406
     * @param operator The operator used for matching.
407
     * @param mouseButton the mouse button.
408
     * @param modifier the modifier, e.g. shift, ctrl, etc.
409
     * @param xPos what x position
410
     * @param xUnits should x position be pixel or percent values
411
     * @param yPos what y position
412
     * @param yUnits should y position be pixel or percent values
413
     */
414
    public void gdDragFigure(String textPath, String operator, 
415
            int mouseButton, String modifier, int xPos,
416
            String xUnits, int yPos, String yUnits) {
417
        // Only store the Drag-Information. Otherwise the GUI-Eventqueue
418
        // blocks after performed Drag!
419
        final DragAndDropHelperSwt dndHelper = DragAndDropHelperSwt
420
            .getInstance();
421
        dndHelper.setMouseButton(mouseButton);
422
        dndHelper.setModifier(modifier);
423
        dndHelper.setDragComponent(null);
424
        gdClickInFigure(textPath, operator, 0, mouseButton, 
425
                xPos, xUnits, yPos, yUnits);
426
    }
427
428
    /**
429
     * Performs a Drop. Moves to the specified location within the given figure
430
     * and releases the modifier and mouse button pressed by the previous drag
431
     * operation.
432
     * 
433
     * @param textPath The path to the figure.
434
     * @param operator The operator used for matching.
435
     * @param xPos what x position
436
     * @param xUnits should x position be pixel or percent values
437
     * @param yPos what y position
438
     * @param yUnits should y position be pixel or percent values
439
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
440
     *                        between moving the mouse to the drop point and
441
     *                        releasing the mouse button
442
     */
443
    public void gdDropOnFigure(final String textPath, final String operator, 
444
            final int xPos, final String xUnits, final int yPos, 
445
            final String yUnits, int delayBeforeDrop) {
446
447
        final DragAndDropHelperSwt dndHelper = 
448
            DragAndDropHelperSwt.getInstance();
449
        final IRobot robot = getRobot();
450
        final String modifier = dndHelper.getModifier();
451
        final int mouseButton = dndHelper.getMouseButton();
452
        // Note: This method performs the drag AND drop action in one runnable
453
        // in the GUI-Eventqueue because after the mousePress, the eventqueue
454
        // blocks!
455
        try {
456
            pressOrReleaseModifiers(modifier, true);
457
458
            getEventThreadQueuer().invokeAndWait("gdStartDragFigure", new IRunnable() { //$NON-NLS-1$
459
                public Object run() throws StepExecutionException {
460
                    // drag
461
                    robot.mousePress(dndHelper.getDragComponent(), null, 
462
                            mouseButton);
463
                    
464
                    shakeMouse();
465
466
                    // drop
467
                    gdClickInFigure(textPath, operator, 0, 
468
                            mouseButton, xPos, xUnits, yPos, yUnits);
469
                    
470
                    return null;
471
                }            
472
            });
473
474
            waitBeforeDrop(delayBeforeDrop);
475
        } finally {
476
            getRobot().mouseRelease(null, null, mouseButton);
477
            pressOrReleaseModifiers(modifier, false);
478
        }
479
    }
480
481
    /**
482
     * Returns the bounds for the figure for the given path. If no such 
483
     * figure can be found, a {@link StepExecutionException} will be thrown.
484
     * 
485
     * @param textPath The path to the figure.
486
     * @param operator The operator used for matching.
487
     * @return the bounds of the figure for the given path. 
488
     */
489
    private Rectangle getFigureBoundsChecked(String textPath, String operator) {
490
        GraphicalEditPart editPart = 
491
            findEditPart(textPath, operator);
492
        IFigure figure = findFigure(editPart);
493
        ConnectionAnchor anchor = null;
494
        
495
        if (figure == null) {
496
            // Try to find a connection anchor instead
497
            anchor = findConnectionAnchor(textPath, operator);
498
            if (anchor != null) {
499
                final String[] pathItems = MenuUtil.splitPath(textPath);
500
                final String[] editPartPathItems = 
501
                    new String[pathItems.length - 1];
502
                System.arraycopy(
503
                        pathItems, 0, editPartPathItems, 0, 
504
                        editPartPathItems.length);
505
                editPart = findEditPart(operator, editPartPathItems);
506
            }
507
            if (anchor == null || findFigure(editPart) == null) {
508
                throw new StepExecutionException(
509
                        "No figure could be found for the given text path.", //$NON-NLS-1$
510
                        EventFactory.createActionError(
511
                                TestErrorEvent.NOT_FOUND));
512
            }
513
            
514
        }
515
516
        // Scrolling
517
        revealEditPart(editPart);
518
        
519
        return figure != null ? getBounds(figure) : getBounds(anchor);
520
    }
521
522
    /**
523
     * Clicks the tool found at the given path.
524
     * 
525
     * @param textPath The path to the tool.
526
     * @param operator The operator used for matching.
527
     * @param count The number of times to click.
528
     */
529
    public void gdSelectTool(String textPath, String operator, int count) {
530
        Control paletteControl = getPaletteControl();
531
        IFigure figure = 
532
            findPaletteFigureChecked(textPath, operator);
533
        getRobot().click(paletteControl, getBounds(figure), 
534
                ClickOptions.create().setScrollToVisible(false)
535
                    .setClickCount(count));
536
    }
537
    
538
    /**
539
     * @return the control associated with the palette viewer.
540
     */
541
    private Control getPaletteControl() {
542
        EditDomain editDomain = getViewer().getEditDomain();
543
        if (editDomain == null) {
544
            return null;
545
        }
546
        
547
        PaletteViewer paletteViewer = editDomain.getPaletteViewer();
548
        if (paletteViewer == null) {
549
            return null;
550
        }
551
        
552
        return paletteViewer.getControl();
553
    }
554
555
    /**
556
     * 
557
     * @param figure The figure for which to find the bounds.
558
     * @return the bounds of the given figure.
559
     */
560
    private Rectangle getBounds(IFigure figure) {
561
        org.eclipse.draw2d.geometry.Rectangle figureBounds = 
562
            new org.eclipse.draw2d.geometry.Rectangle(figure.getBounds());
563
        
564
        // Take scrolling and zooming into account
565
        figure.translateToAbsolute(figureBounds);
566
567
        return new Rectangle(
568
                figureBounds.x, figureBounds.y, 
569
                figureBounds.width, figureBounds.height);
570
    }
571
572
    /**
573
     * 
574
     * @param anchor The anchor for which to find the bounds.
575
     * @return the "bounds" of the given anchor. Since the location of an 
576
     *         anchor is defined as a single point, the bounds are a small
577
     *         rectangle with that point at the center.
578
     */
579
    private Rectangle getBounds(ConnectionAnchor anchor) {
580
        Validate.notNull(anchor);
581
        Point refPoint = anchor.getReferencePoint();
582
583
        return new Rectangle(
584
                refPoint.x - 1, refPoint.y - 1, 3, 3);
585
    }
586
587
    /**
588
     * 
589
     * @param textPath The path to the GraphicalEditPart.
590
     * @param operator The operator used for matching.
591
     * @return the GraphicalEditPart for the given path. Returns 
592
     *         <code>null</code> if no EditPart exists for the given path or if
593
     *         the found EditPart is not a GraphicalEditPart.
594
     */
595
    private GraphicalEditPart findEditPart(String textPath, String operator) {
596
        final String[] pathItems = MenuUtil.splitPath(textPath);
597
        return findEditPart(operator, pathItems);
598
    }
599
600
    /**
601
     * @param operator The operator used for matching.
602
     * @param pathItems The path to the GraphicalEditPart. Each element in the
603
     *                  array represents a single segment of the path.
604
     * @return the GraphicalEditPart for the given path. Returns 
605
     *         <code>null</code> if no EditPart exists for the given path or if
606
     *         the found EditPart is not a GraphicalEditPart.
607
     */
608
    private GraphicalEditPart findEditPart(String operator,
609
            final String[] pathItems) {
610
        boolean isExisting = true;
611
        EditPart currentEditPart = getRootEditPart().getContents();
612
        
613
        for (int i = 0; i < pathItems.length && currentEditPart != null; i++) {
614
            List effectiveChildren = currentEditPart.getChildren();
615
            EditPart [] children = 
616
                (EditPart [])effectiveChildren.toArray(
617
                        new EditPart[effectiveChildren.size()]);
618
            boolean itemFound = false;
619
            for (int j = 0; j < children.length && !itemFound; j++) {
620
                IEditPartIdentifier childFigureIdentifier = 
621
                    DefaultEditPartAdapterFactory.loadFigureIdentifier(
622
                            children[j]);
623
                if (childFigureIdentifier != null) {
624
                    String figureId = childFigureIdentifier.getIdentifier();
625
                    if (figureId != null 
626
                        && MatchUtil.getInstance().match(
627
                            figureId, pathItems[i], operator)) {
628
                        itemFound = true;
629
                        currentEditPart = children[j];
630
                    }
631
                }
632
            }
633
            if (!itemFound) {
634
                isExisting = false;
635
                break;
636
            }
637
            
638
        }
639
        
640
        return isExisting && currentEditPart instanceof GraphicalEditPart 
641
            ? (GraphicalEditPart)currentEditPart : null;
642
    }
643
644
    /**
645
     * 
646
     * @param textPath The path to the figure.
647
     * @param operator The operator used for matching.
648
     * @return the figure for the GraphicalEditPart for the given path within 
649
     *         the palette. Returns <code>null</code> if no EditPart exists 
650
     *         for the given path or if the found EditPart does not have a 
651
     *         figure.
652
     */
653
    private IFigure findPaletteFigure(String textPath, String operator) {
654
        GraphicalEditPart editPart = findPaletteEditPart(textPath, operator);
655
        
656
        // Scrolling
657
        revealEditPart(editPart);
658
659
        return findFigure(editPart);
660
    }
661
662
    /**
663
     * Finds and returns the palette figure for the given path. If no such 
664
     * figure can be found, a {@link StepExecutionException} will be thrown.
665
     * 
666
     * @param textPath The path to the figure.
667
     * @param operator The operator used for matching.
668
     * @return the figure for the GraphicalEditPart for the given path within 
669
     *         the palette.
670
     */
671
    private IFigure findPaletteFigureChecked(String textPath, String operator) {
672
        IFigure figure = findPaletteFigure(textPath, operator);
673
        if (figure == null) {
674
            throw new StepExecutionException(
675
                    "No palette figure could be found for the given text path.", //$NON-NLS-1$
676
                    EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
677
        }
678
        return figure;
679
680
    }
681
    
682
    /**
683
     * 
684
     * @param editPart The EditPart for which to find the corresponding figure.
685
     * @return the (visible) figure corresponding to the given EditPart, or 
686
     *         <code>null</code> if no visible figure corresponds to the given 
687
     *         EditPart.
688
     */
689
    private IFigure findFigure(GraphicalEditPart editPart) {
690
        if (editPart != null) {
691
            IFigure figure = editPart.getFigure();
692
            if (figure.isShowing()) {
693
                return figure;
694
            }
695
        }
696
697
        return null;
698
    }
699
700
    /**
701
     * Attempts to find a connection anchor at the given textpath.
702
     * 
703
     * @param textPath The path to the anchor.
704
     * @param operator The operator used for matching.
705
     * @return the anchor found at the given text path, or <code>null</code>
706
     *         if no such anchor exists.
707
     */
708
    private ConnectionAnchor findConnectionAnchor(
709
            String textPath, String operator) {
710
711
        final String[] pathItems = MenuUtil.splitPath(textPath);
712
        final String[] editPartPathItems = new String[pathItems.length - 1];
713
        System.arraycopy(
714
                pathItems, 0, editPartPathItems, 0, editPartPathItems.length);
715
        GraphicalEditPart editPart = findEditPart(operator, editPartPathItems);
716
        if (editPart != null) {
717
            String anchorPathItem = pathItems[pathItems.length - 1];
718
            IEditPartIdentifier editPartIdentifier =
719
                DefaultEditPartAdapterFactory.loadFigureIdentifier(editPart);
720
            if (editPartIdentifier != null) {
721
                Map anchorMap = 
722
                    editPartIdentifier.getConnectionAnchors();
723
                if (anchorMap != null) {
724
                    Iterator anchorMapIter = 
725
                        anchorMap.keySet().iterator();
726
                    while (anchorMapIter.hasNext()) {
727
                        Object anchorMapKey = anchorMapIter.next();
728
                        Object anchorMapValue = 
729
                            anchorMap.get(anchorMapKey);
730
                        if (anchorMapKey instanceof String
731
                                && anchorMapValue instanceof ConnectionAnchor
732
                                && MatchUtil.getInstance().match(
733
                                    (String)anchorMapKey, anchorPathItem, 
734
                                    operator)) {
735
736
                            return (ConnectionAnchor)anchorMapValue;
737
                        }
738
                    }
739
                }
740
            }
741
        }
742
743
        return null;
744
    }
745
    
746
    /**
747
     * Reveals the given {@link EditPart} within its viewer.
748
     * 
749
     * @param editPart the {@link EditPart} to reveal.
750
     */
751
    private void revealEditPart(final EditPart editPart) {
752
        if (editPart != null) {
753
            getEventThreadQueuer().invokeAndWait(getClass().getName() + ".revealEditPart", new IRunnable() { //$NON-NLS-1$
754
                
755
                public Object run() throws StepExecutionException {
756
                    editPart.getViewer().reveal(editPart);
757
                    return null;
758
                }
759
                
760
            });
761
        }
762
    }
763
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/inspector/FigureHighlighter.java (+196 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.inspector;
12
13
import java.util.Iterator;
14
import java.util.Map;
15
16
import org.eclipse.draw2d.ConnectionAnchor;
17
import org.eclipse.draw2d.IFigure;
18
import org.eclipse.draw2d.geometry.Point;
19
import org.eclipse.gef.ConnectionEditPart;
20
import org.eclipse.gef.EditPart;
21
import org.eclipse.gef.GraphicalEditPart;
22
import org.eclipse.gef.GraphicalViewer;
23
import org.eclipse.jubula.rc.rcp.e3.gef.factory.DefaultEditPartAdapterFactory;
24
import org.eclipse.jubula.rc.rcp.e3.gef.identifier.IEditPartIdentifier;
25
import org.eclipse.jubula.rc.rcp.e3.gef.util.FigureCanvasUtil;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.MouseEvent;
28
import org.eclipse.swt.events.MouseMoveListener;
29
import org.eclipse.swt.events.PaintEvent;
30
import org.eclipse.swt.events.PaintListener;
31
import org.eclipse.swt.graphics.Color;
32
import org.eclipse.swt.graphics.Rectangle;
33
import org.eclipse.swt.widgets.Control;
34
35
36
/**
37
 * Highlights figures as the mouse moves over them.
38
 *
39
 * @author BREDEX GmbH
40
 * @created Jun 26, 2009
41
 */
42
public class FigureHighlighter implements MouseMoveListener {
43
44
    /** the viewer containing figures that can be highlighted */
45
    private GraphicalViewer m_viewer;
46
    
47
    /** the color to use for highlighting */
48
    private Color m_highlightColor;
49
50
    /** transparency for highlighting */
51
    private int m_highlightAlpha;
52
    
53
    /** the current highlighted bounds */
54
    private Rectangle m_currentBounds;
55
    
56
    /** the pain listener that performs the actual highlighting */
57
    private PaintListener m_paintListener;
58
    
59
    /**
60
     * Constructor
61
     * 
62
     * @param viewer The viewer containing figures to highlight.
63
     */
64
    public FigureHighlighter(GraphicalViewer viewer) {
65
        m_viewer = viewer;
66
        m_highlightColor = 
67
            viewer.getControl().getDisplay().getSystemColor(SWT.COLOR_BLUE);
68
        m_highlightAlpha = 100;
69
        m_currentBounds = null;
70
        m_paintListener = new PaintListener() {
71
72
            public void paintControl(PaintEvent e) {
73
                if (m_currentBounds != null) {
74
                    Color bgColor = e.gc.getBackground();
75
                    int alpha = e.gc.getAlpha();
76
                    e.gc.setAlpha(m_highlightAlpha);
77
                    e.gc.setBackground(m_highlightColor);
78
                    e.gc.fillRectangle(m_currentBounds);
79
                    e.gc.setAlpha(alpha);
80
                    e.gc.setBackground(bgColor);
81
                }
82
            }
83
            
84
        };
85
        viewer.getControl().addPaintListener(m_paintListener);
86
    }
87
88
    /**
89
     * {@inheritDoc}
90
     */
91
    public void mouseMove(MouseEvent e) {
92
        Point cursorLocation = 
93
            new Point(e.x, e.y);
94
        EditPart editPart = 
95
            FigureCanvasUtil.findAtCurrentMousePosition(e.display, m_viewer);
96
        if (editPart == m_viewer.getContents().getRoot()
97
                || editPart == null) {
98
            if (m_currentBounds != null) {
99
                m_currentBounds = null;
100
                m_viewer.getControl().redraw();
101
            }
102
            
103
            return;
104
        }
105
106
        // Check for connection anchor
107
        Rectangle anchorBounds = 
108
            getConnectionAnchorBounds(
109
                DefaultEditPartAdapterFactory.loadFigureIdentifier(
110
                        editPart), cursorLocation);
111
        
112
        if (anchorBounds == null 
113
                && editPart instanceof ConnectionEditPart) {
114
115
            ConnectionEditPart connEditPart = 
116
                (ConnectionEditPart)editPart;
117
            EditPart srcEditPart = connEditPart.getSource();
118
            EditPart targetEditPart = connEditPart.getTarget();
119
            anchorBounds = getConnectionAnchorBounds(
120
                DefaultEditPartAdapterFactory.loadFigureIdentifier(srcEditPart),
121
                cursorLocation);
122
            if (anchorBounds == null) {
123
                anchorBounds = getConnectionAnchorBounds(
124
                        DefaultEditPartAdapterFactory
125
                        .loadFigureIdentifier(targetEditPart), 
126
                        cursorLocation);
127
            }
128
        }
129
130
        Rectangle bounds = anchorBounds;
131
        if (bounds == null
132
                && editPart != m_viewer.getContents().getRoot()
133
                && !(editPart instanceof ConnectionEditPart)
134
                && editPart instanceof GraphicalEditPart) {
135
            IFigure figure = ((GraphicalEditPart)editPart).getFigure();
136
            org.eclipse.draw2d.geometry.Rectangle figureBounds = 
137
                new org.eclipse.draw2d.geometry.Rectangle(figure.getBounds());
138
            figure.translateToAbsolute(figureBounds);
139
            bounds = new Rectangle(figureBounds.x, figureBounds.y, 
140
                    figureBounds.width, figureBounds.height);
141
        }
142
        m_currentBounds = bounds;
143
        m_viewer.getControl().redraw();
144
        
145
    }
146
147
    /**
148
     * 
149
     * @param editPartIdentifier Provides a list of possible anchors.
150
     * @param cursorLocation The location at which to look for the anchor.
151
     * @return the bounds for the connection anchor at the given location, or
152
     *         <code>null</code> if no such anchor can be found.
153
     */
154
    private Rectangle getConnectionAnchorBounds(
155
            IEditPartIdentifier editPartIdentifier, Point cursorLocation) {
156
157
        if (editPartIdentifier != null) {
158
            Map anchorMap = 
159
                editPartIdentifier.getConnectionAnchors();
160
            if (anchorMap != null) {
161
                Iterator iter = anchorMap.keySet().iterator();
162
                while (iter.hasNext()) {
163
                    Object key = iter.next();
164
                    Object value = anchorMap.get(key);
165
                    if (key instanceof String 
166
                            && value instanceof ConnectionAnchor) {
167
                        Point refPoint = 
168
                            ((ConnectionAnchor)value).getReferencePoint();
169
170
                        // The "bounds" of an anchor is considered to be 
171
                        // 3 pixels in all directions.
172
                        Rectangle refBounds = new Rectangle(
173
                                refPoint.x - 3, refPoint.y - 3, 7, 7);
174
                        if (refBounds.contains(cursorLocation.getSWTPoint())) {
175
                            return refBounds;
176
                        }
177
                    }
178
                }
179
            }
180
        }
181
        
182
        return null;
183
    }
184
185
    /**
186
     * Removes all listeners added by this highlighter.
187
     */
188
    public void removeAddedListeners() {
189
        Control control = m_viewer.getControl();
190
        if (!control.isDisposed()) {
191
            control.removePaintListener(m_paintListener);
192
            control.redraw();
193
        }
194
    }
195
    
196
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/inspector/GefInspectorListenerAppender.java (+440 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.inspector;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Map;
19
20
import org.eclipse.draw2d.ConnectionAnchor;
21
import org.eclipse.draw2d.FigureCanvas;
22
import org.eclipse.draw2d.geometry.Point;
23
import org.eclipse.draw2d.geometry.Rectangle;
24
import org.eclipse.gef.ConnectionEditPart;
25
import org.eclipse.gef.EditDomain;
26
import org.eclipse.gef.EditPart;
27
import org.eclipse.gef.EditPartViewer;
28
import org.eclipse.gef.GraphicalEditPart;
29
import org.eclipse.gef.GraphicalViewer;
30
import org.eclipse.gef.RootEditPart;
31
import org.eclipse.gef.palette.PaletteEntry;
32
import org.eclipse.gef.ui.palette.PaletteViewer;
33
import org.eclipse.jubula.communication.message.InspectorComponentSelectedMessage;
34
import org.eclipse.jubula.rc.common.AUTServer;
35
import org.eclipse.jubula.rc.common.listener.IAutListenerAppender;
36
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
37
import org.eclipse.jubula.rc.rcp.e3.accessor.Startup;
38
import org.eclipse.jubula.rc.rcp.e3.gef.factory.DefaultEditPartAdapterFactory;
39
import org.eclipse.jubula.rc.rcp.e3.gef.identifier.IEditPartIdentifier;
40
import org.eclipse.jubula.rc.rcp.e3.gef.util.FigureCanvasUtil;
41
import org.eclipse.jubula.tools.exception.CommunicationException;
42
import org.eclipse.jubula.tools.objects.ComponentIdentifier;
43
import org.eclipse.jubula.tools.objects.IComponentIdentifier;
44
import org.eclipse.swt.SWT;
45
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Control;
47
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Event;
49
import org.eclipse.swt.widgets.Listener;
50
import org.eclipse.swt.widgets.Widget;
51
import org.eclipse.ui.PlatformUI;
52
53
54
/**
55
 * Adds listeners for the Inspector function. These listeners will only 
56
 * interact with GEF components.
57
 *
58
 * @author BREDEX GmbH
59
 * @created Jun 11, 2009
60
 */
61
public class GefInspectorListenerAppender implements IAutListenerAppender {
62
63
    /** the logger */
64
    private static final AutServerLogger LOG = 
65
        new AutServerLogger(GefInspectorListenerAppender.class);
66
    
67
    /**
68
     * Responsible for adding highlighters to controls and managing those
69
     * highlighters.
70
     *
71
     * @author BREDEX GmbH
72
     * @created Jun 29, 2009
73
     */
74
    private static class FigureHighlightAppender implements Listener {
75
76
        /** mapping from control to figure highlighter */
77
        private Map m_canvasToListener = new HashMap();
78
        
79
        /**
80
         * {@inheritDoc}
81
         */
82
        public void handleEvent(Event event) {
83
            if (event.widget instanceof FigureCanvas) {
84
                FigureCanvas canvas = (FigureCanvas)event.widget;
85
                if (event.type == SWT.MouseEnter) {
86
                    handleMouseEnter(canvas);
87
                }
88
            }
89
        }
90
91
        /**
92
         * Removes all listeners added by this appender.
93
         */
94
        public void removeAddedListeners() {
95
            Iterator iter = m_canvasToListener.keySet().iterator();
96
            while (iter.hasNext()) {
97
                Control control = (Control)iter.next();
98
                if (!control.isDisposed()) {
99
                    FigureHighlighter highlighter =
100
                        (FigureHighlighter)m_canvasToListener.get(control);
101
                    highlighter.removeAddedListeners();
102
                    control.removeMouseMoveListener(highlighter);
103
                }
104
            }
105
            m_canvasToListener.clear();
106
        }
107
        
108
        /**
109
         * Adds a figure highlighter to the given canvas.
110
         * 
111
         * @param canvas The figure canvas entered by the mouse.
112
         */
113
        private void handleMouseEnter(final FigureCanvas canvas) {
114
            if (m_canvasToListener.containsKey(canvas)) {
115
                // Highlighter already registered.
116
                return;
117
            }
118
119
            GraphicalViewer viewer = FigureCanvasUtil.getViewer(canvas);
120
            if (viewer != null) {
121
                if (viewer.getContents() instanceof GraphicalEditPart) {
122
                    FigureHighlighter highlighter = 
123
                        new FigureHighlighter(viewer);
124
                    m_canvasToListener.put(canvas, highlighter);
125
                    canvas.addMouseMoveListener(highlighter);
126
                }
127
            }
128
        }
129
        
130
    }
131
    
132
    /**
133
     * Listens for a mouse click and:
134
     *  1. deregisters itself and any other provider listeners, and 
135
     *  2. sends a "component selected" message
136
     *  
137
     * if that mouse click was over a GEF component.
138
     *
139
     * @author BREDEX GmbH
140
     * @created Jun 11, 2009
141
     */
142
    private static class GefInspectorComponentSelectedListener 
143
            implements Listener {
144
145
        /** the appender */
146
        private FigureHighlightAppender m_highlightAppender;
147
148
        /**
149
         * Constructor
150
         * 
151
         * @param highlightAppender The appender to use.
152
         */
153
        public GefInspectorComponentSelectedListener(
154
                FigureHighlightAppender highlightAppender) {
155
            m_highlightAppender = highlightAppender;
156
        }
157
        
158
        /**
159
         * 
160
         * @param editPartIdentifier Provides connection anchor IDs and 
161
         *                           locations.
162
         * @param cursorLocation The location at which to search for an
163
         *                       anchor point.
164
         * @return the ID of the connection anchor at the given location, or
165
         *         <code>null</code> if there is no connection anchor at the
166
         *         given location.
167
         */
168
        private String getConnectionAnchorId(
169
                IEditPartIdentifier editPartIdentifier, Point cursorLocation) {
170
171
            if (editPartIdentifier != null) {
172
                Map anchorMap = 
173
                    editPartIdentifier.getConnectionAnchors();
174
                if (anchorMap != null) {
175
                    Iterator iter = anchorMap.keySet().iterator();
176
                    while (iter.hasNext()) {
177
                        Object key = iter.next();
178
                        Object value = anchorMap.get(key);
179
                        if (key instanceof String 
180
                                && value instanceof ConnectionAnchor) {
181
                            Point refPoint = 
182
                                ((ConnectionAnchor)value).getReferencePoint();
183
184
                            // A click is recognized as being "within the 
185
                            // bounds" of an anchor if it is within 3 pixels
186
                            // in any direction.
187
                            Rectangle refBounds = new Rectangle(
188
                                    refPoint.x - 3, refPoint.y - 3, 7, 7);
189
                            if (refBounds.contains(cursorLocation)) {
190
                                return (String)key;
191
                            }
192
                        }
193
                    }
194
                }
195
            }
196
            
197
            return null;
198
        }
199
        
200
        /**
201
         * 
202
         * {@inheritDoc}
203
         */
204
        public void handleEvent(Event event) {
205
            Display display = event.display;
206
            display.removeFilter(SWT.MouseDown, this);
207
            display.removeFilter(SWT.MouseEnter, m_highlightAppender);
208
            m_highlightAppender.removeAddedListeners();
209
            event.doit = false;
210
            event.type = SWT.None;
211
            Widget selectedWidget = event.widget;
212
            IComponentIdentifier compId = null;
213
            
214
            if (!(selectedWidget instanceof FigureCanvas)) {
215
                sendIdInfo(compId);
216
                return;
217
            }
218
219
            FigureCanvas figureCanvas = 
220
                (FigureCanvas)selectedWidget;
221
            Composite parent = figureCanvas;
222
            while (parent != null
223
                    && !(parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY) 
224
                            instanceof GraphicalViewer)) {
225
                parent = parent.getParent();
226
            }
227
            
228
            if (parent == null) {
229
                sendIdInfo(compId);
230
                return;
231
            }
232
233
            Object gefData = 
234
                parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY);
235
            
236
            if (gefData instanceof EditPartViewer) {
237
                EditPartViewer viewer = (EditPartViewer)gefData;
238
                Point cursorLocation = new Point(display.map(null, 
239
                        viewer.getControl(), 
240
                        display.getCursorLocation()));
241
                EditPart editPart = viewer.findObjectAt(cursorLocation);
242
                EditPart primaryEditPart = FigureCanvasUtil.getPrimaryEditPart(
243
                        editPart, viewer.getRootEditPart());
244
                List idStringList = Collections.EMPTY_LIST;
245
                
246
                if (primaryEditPart != null) {
247
                    idStringList = getPathToRoot(viewer.getRootEditPart(), 
248
                            cursorLocation, primaryEditPart);
249
                    
250
                } else {
251
                    // No primary figure found. 
252
                    // Check whether a tool was selected.
253
                    EditDomain editDomain = viewer.getEditDomain();
254
                    if (editDomain != null) {
255
                        PaletteViewer paletteViewer = 
256
                            editDomain.getPaletteViewer();
257
                        if (paletteViewer != null) {
258
                            EditPart paletteEditPart = 
259
                                paletteViewer.findObjectAt(new Point(
260
                                        display.map(viewer.getControl(), 
261
                                                paletteViewer.getControl(), 
262
                                                cursorLocation.getSWTPoint())));
263
                            if (paletteEditPart != null) {
264
                                idStringList = getToolPathToRoot(
265
                                        paletteViewer.getRootEditPart(), 
266
                                        paletteEditPart);
267
                            }
268
                        }
269
                    }
270
                }
271
                
272
                compId = createCompId(idStringList);
273
            }
274
            sendIdInfo(compId);
275
        }
276
277
        /**
278
         * 
279
         * @param editPart The edit part for which to find the path.
280
         * @param root The root for <code>editPart</code>. This is used to 
281
         *             avoid adding the root identifier to the returned list.
282
         * @param cursorLocation The location to check for nearby connection
283
         *                       anchors.
284
         * @return a list containing the identifier of each edit part between
285
         *         <code>editPart</code> and its root. The first element in the
286
         *         list will be the identifier for a connection anchor if 
287
         *         <code>cursorLocation</code> is near such an anchor.
288
         */
289
        private List getPathToRoot(RootEditPart root, Point cursorLocation,
290
                EditPart editPart) {
291
            
292
            List idStringList = new ArrayList();
293
            EditPart currentEditPart = editPart;
294
            
295
            // Check for connection anchor
296
            String connectionId = 
297
                getConnectionAnchorId(
298
                    DefaultEditPartAdapterFactory.loadFigureIdentifier(
299
                            currentEditPart), 
300
                    cursorLocation);
301
            
302
            if (connectionId == null 
303
                    && currentEditPart instanceof ConnectionEditPart) {
304
305
                ConnectionEditPart connEditPart = 
306
                    (ConnectionEditPart)editPart;
307
                EditPart srcEditPart = connEditPart.getSource();
308
                EditPart targetEditPart = connEditPart.getTarget();
309
                connectionId = getConnectionAnchorId(
310
                        DefaultEditPartAdapterFactory
311
                        .loadFigureIdentifier(srcEditPart), 
312
                        cursorLocation);
313
                if (connectionId != null) {
314
                    currentEditPart = srcEditPart;
315
                } else {
316
                    connectionId = getConnectionAnchorId(
317
                            DefaultEditPartAdapterFactory
318
                            .loadFigureIdentifier(targetEditPart), 
319
                            cursorLocation);
320
                    if (connectionId != null) {
321
                        currentEditPart = targetEditPart;
322
                    }
323
                }
324
            }
325
326
            if (connectionId != null) {
327
                idStringList.add(connectionId);
328
            }
329
330
            while (currentEditPart != root.getContents() 
331
                    && currentEditPart != null) {
332
                IEditPartIdentifier identifier = 
333
                    DefaultEditPartAdapterFactory.loadFigureIdentifier(
334
                            currentEditPart);
335
                if (identifier != null) {
336
                    idStringList.add(identifier.getIdentifier());
337
                }
338
                currentEditPart = currentEditPart.getParent();
339
            }
340
            
341
            return idStringList;
342
343
        }
344
345
        /**
346
         * 
347
         * @param editPart The edit part for which to find the path.
348
         * @param root The root for <code>editPart</code>. This is used to 
349
         *             avoid adding the root identifier to the returned list.
350
         * @return a list containing the identifier of each edit part between
351
         *         <code>editPart</code> and its root.
352
         */
353
        private List getToolPathToRoot(RootEditPart root, EditPart editPart) {
354
355
            List idStringList = new ArrayList();
356
            EditPart currentEditPart = editPart;
357
            
358
            if (currentEditPart != null) {
359
                Object model = currentEditPart.getModel();
360
                while (model instanceof PaletteEntry
361
                        && currentEditPart != root.getContents()) {
362
                    idStringList.add(((PaletteEntry)model).getLabel());
363
                    currentEditPart = 
364
                        currentEditPart.getParent();
365
                    model = currentEditPart.getModel();
366
                }
367
            }
368
369
            return idStringList;
370
        }
371
372
        /**
373
         * Sends the given ID information to the client.
374
         * 
375
         * @param compId The component identifier to send. May be 
376
         *               <code>null</code>.
377
         */
378
        private void sendIdInfo(IComponentIdentifier compId) {
379
            InspectorComponentSelectedMessage message = 
380
                new InspectorComponentSelectedMessage();
381
            message.setComponentIdentifier(compId);
382
            try {
383
                AUTServer.getInstance().getCommunicator().send(message);
384
            } catch (CommunicationException e) {
385
                LOG.error("Error occurred while trying to send message to Client.", e); //$NON-NLS-1$
386
            }
387
        }
388
        
389
        /**
390
         * 
391
         * @param idStringList The path to root for a specific edit part or
392
         *                     connection anchor.
393
         * @return a component identifier for the given path, or 
394
         *         <code>null</code> if no valid component identifier can be
395
         *         generated.
396
         */
397
        private IComponentIdentifier createCompId(List idStringList) {
398
            IComponentIdentifier compId = null;
399
            if (!idStringList.isEmpty()) {
400
                Collections.reverse(idStringList);
401
                compId = new ComponentIdentifier();
402
                compId.setHierarchyNames(idStringList);
403
            }
404
            
405
            return compId;
406
        }
407
    }
408
    
409
    /** the listener responsible for appending highlight listeners */
410
    private FigureHighlightAppender m_highlightAppender;
411
    
412
    /** the listener responsible for handling mouse clicks */
413
    private GefInspectorComponentSelectedListener m_componentSelectedListener;
414
    
415
    /**
416
     * Constructor
417
     */
418
    public GefInspectorListenerAppender() {
419
        m_highlightAppender = new FigureHighlightAppender();
420
        m_componentSelectedListener = 
421
            new GefInspectorComponentSelectedListener(m_highlightAppender);
422
    }
423
    
424
    /**
425
     * {@inheritDoc}
426
     */
427
    public void addAutListener() {
428
        final Display display = PlatformUI.getWorkbench().getDisplay();
429
        
430
        display.syncExec(new Runnable() {
431
432
            public void run() {
433
                display.addFilter(SWT.MouseEnter, m_highlightAppender);
434
                display.addFilter(SWT.MouseDown, m_componentSelectedListener);
435
            }
436
            
437
        });
438
    }
439
440
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/listener/GefPartListener.java (+141 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.listener;
12
13
import org.eclipse.gef.GraphicalViewer;
14
import org.eclipse.jface.viewers.ISelectionChangedListener;
15
import org.eclipse.jface.viewers.SelectionChangedEvent;
16
import org.eclipse.jubula.rc.rcp.e3.accessor.Startup;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.ui.IPartListener2;
19
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.IWorkbenchPartReference;
21
import org.eclipse.ui.internal.WorkbenchPartReference;
22
import org.eclipse.ui.part.MultiPageEditorPart;
23
24
25
/**
26
 * @author BREDEX GmbH
27
 * @created Dec 17, 2009
28
 */
29
public class GefPartListener implements IPartListener2 {
30
31
    /**
32
     * 
33
     * {@inheritDoc}
34
     */
35
    public void partActivated(IWorkbenchPartReference partRef) {
36
        // Do nothing
37
    }
38
39
    /**
40
     * 
41
     * {@inheritDoc}
42
     */
43
    public void partBroughtToTop(IWorkbenchPartReference partRef) {
44
        // Do nothing
45
    }
46
47
    /**
48
     * 
49
     * {@inheritDoc}
50
     */
51
    public void partClosed(IWorkbenchPartReference partRef) {
52
        // Do nothing
53
    }
54
55
    /**
56
     * 
57
     * {@inheritDoc}
58
     */
59
    public void partDeactivated(IWorkbenchPartReference partRef) {
60
        // Do nothing
61
    }
62
63
    /**
64
     * 
65
     * {@inheritDoc}
66
     */
67
    public void partHidden(IWorkbenchPartReference partRef) {
68
        // Do nothing
69
    }
70
71
    /**
72
     * 
73
     * {@inheritDoc}
74
     */
75
    public void partInputChanged(IWorkbenchPartReference partRef) {
76
        // Do nothing
77
    }
78
79
    /**
80
     * 
81
     * {@inheritDoc}
82
     */
83
    public void partOpened(final IWorkbenchPartReference partRef) {
84
        IWorkbenchPart part = partRef.getPart(false);
85
        
86
        if (part instanceof MultiPageEditorPart) {
87
            ((MultiPageEditorPart)part).getSite().getSelectionProvider()
88
                .addSelectionChangedListener(new ISelectionChangedListener() {
89
                    
90
                    public void selectionChanged(SelectionChangedEvent event) {
91
                        if (event.getSource() instanceof GraphicalViewer) {
92
                            registerGraphicalViewer(
93
                                (GraphicalViewer)event.getSource(), partRef);
94
                        }
95
                    }
96
                });
97
        }
98
        
99
        if (part != null 
100
                && partRef instanceof WorkbenchPartReference) {
101
            GraphicalViewer viewer = 
102
                (GraphicalViewer)part.getAdapter(
103
                        GraphicalViewer.class);
104
            registerGraphicalViewer(viewer, partRef);
105
        }
106
    }
107
108
    /**
109
     * 
110
     * {@inheritDoc}
111
     */
112
    public void partVisible(IWorkbenchPartReference partRef) {
113
        partOpened(partRef);
114
    }
115
116
    /**
117
     * Registers a {@link GraphicalViewer} with the given 
118
     * {@link IWorkbenchPartReference}.
119
     * 
120
     * @param viewer The viewer to register.
121
     * @param partRef The reference to the part that (indirectly) contains the
122
     *                viewer.
123
     */
124
    private void registerGraphicalViewer(GraphicalViewer viewer, 
125
            IWorkbenchPartReference partRef) {
126
127
        IWorkbenchPart part = partRef.getPart(false);
128
        if (part != null && partRef instanceof WorkbenchPartReference) {
129
            if (viewer != null) {
130
                // Note the viewer on the component
131
                Control partContent = 
132
                    ((WorkbenchPartReference)partRef).getPane().getControl();
133
134
                if (partContent != null && !partContent.isDisposed()) {
135
                    partContent.setData(Startup.TEST_GEF_VIEWER_DATA_KEY,
136
                            viewer);
137
                }
138
            }
139
        }
140
    }
141
}
(-)a/org.eclipse.jubula.rc.rcp.e3/src/org/eclipse/jubula/rc/rcp/e3/gef/util/FigureCanvasUtil.java (+114 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.e3.gef.util;
12
13
import org.eclipse.draw2d.FigureCanvas;
14
import org.eclipse.draw2d.geometry.Point;
15
import org.eclipse.gef.EditPart;
16
import org.eclipse.gef.EditPartViewer;
17
import org.eclipse.gef.GraphicalViewer;
18
import org.eclipse.gef.RootEditPart;
19
import org.eclipse.jubula.rc.rcp.e3.accessor.Startup;
20
import org.eclipse.jubula.rc.rcp.e3.gef.factory.DefaultEditPartAdapterFactory;
21
import org.eclipse.jubula.rc.rcp.e3.gef.identifier.IEditPartIdentifier;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Display;
24
25
26
/**
27
 * Utility class for interacting with a FigureCanvas.
28
 * 
29
 * @author BREDEX GmbH
30
 * @created Jun 26, 2009
31
 */
32
public class FigureCanvasUtil {
33
34
    /**
35
     * Private constructor
36
     */
37
    private FigureCanvasUtil() {
38
    // Nothing to initialize
39
    }
40
41
    /**
42
     * 
43
     * @param figureCanvas
44
     *            The canvas for which to find the viewer.
45
     * @return the graphical viewer associated with the given canvas, or
46
     *         <code>null</code> if no such viewer could be found.
47
     */
48
    public static GraphicalViewer getViewer(FigureCanvas figureCanvas) {
49
        Composite parent = figureCanvas;
50
        while (parent != null
51
                && !(parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY) 
52
                        instanceof GraphicalViewer)) {
53
            parent = parent.getParent();
54
        }
55
56
        if (parent != null) {
57
58
            return (GraphicalViewer)parent
59
                    .getData(Startup.TEST_GEF_VIEWER_DATA_KEY);
60
        }
61
62
        return null;
63
    }
64
65
    /**
66
     * 
67
     * @param display The display containing the edit part to find.
68
     * @param viewer The viewer containing the edit part to find.
69
     * @return the edit part for the viewer at the current mouse pointer
70
     *         coordinates, or <code>null</code> if no such edit part can be
71
     *         found.
72
     */
73
    public static EditPart findAtCurrentMousePosition(
74
            Display display, EditPartViewer viewer) {
75
        Point cursorLocation = new Point(display.map(null, viewer.getControl(),
76
                display.getCursorLocation()));
77
        EditPart editPart = viewer.findObjectAt(cursorLocation);
78
        EditPart primaryEditPart = getPrimaryEditPart(editPart, viewer
79
                .getRootEditPart());
80
81
        return primaryEditPart;
82
    }
83
84
    /**
85
     * Searches the path to root for the first element considered to be testable
86
     * by Jubula. Testable in this case means that an ID can be acquired for
87
     * the edit part.
88
     * 
89
     * @param editPart
90
     *            The starting edit part.
91
     * @param root
92
     *            The root for <code>editPart</code>. This is used to avoid
93
     *            identifying the root edit part as the primary edit part.
94
     * @return the first edit part on the path to root that has an ID.
95
     */
96
    public static EditPart getPrimaryEditPart(final EditPart editPart,
97
            RootEditPart root) {
98
99
        EditPart currentEditPart = editPart;
100
101
        while (currentEditPart != root.getContents() 
102
                && currentEditPart != null) {
103
            IEditPartIdentifier identifier = DefaultEditPartAdapterFactory
104
                    .loadFigureIdentifier(currentEditPart);
105
            if (identifier != null) {
106
                return currentEditPart;
107
            }
108
            currentEditPart = currentEditPart.getParent();
109
        }
110
111
        return null;
112
    }
113
114
}
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/.checkstyle (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4
  <fileset name="all" enabled="true" check-config-name="Jubula" local="false">
5
    <file-match-pattern match-pattern="." include-pattern="true"/>
6
  </fileset>
7
</fileset-config>
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/.classpath (+7 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/.gitignore (+2 lines)
Added Link Here
1
/bin
2
/target
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/.project (+41 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.eclipse.jubula.rc.rcp.e4.compat</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
33
	</natures>
34
	<linkedResources>
35
		<link>
36
			<name>.settings</name>
37
			<type>2</type>
38
			<locationURI>WORKSPACE_LOC/jubula/org.eclipse.jubula.project.configuration/settings/1.4</locationURI>
39
		</link>
40
	</linkedResources>
41
</projectDescription>
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/META-INF/MANIFEST.MF (+12 lines)
Added Link Here
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Jubula Remote Control - RCP e4 compat
4
Bundle-SymbolicName: org.eclipse.jubula.rc.rcp.e4.compat; singleton:=true
5
Bundle-Version: 2.0.0.qualifier
6
Bundle-ClassPath: .
7
Bundle-Vendor: Eclipse Jubula
8
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
9
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
10
Bundle-ActivationPolicy: lazy
11
Bundle-RequiredExecutionEnvironment: J2SE-1.4
12
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/about.html (+28 lines)
Added Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6
<title>About</title>
7
</head>
8
<body lang="EN-US">
9
<h2>About This Content</h2>
10
 
11
<p>June 22,  2011</p>	
12
<h3>License</h3>
13
14
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
15
indicated below, the Content is provided to you under the terms and conditions of the
16
Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
17
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
18
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19
20
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
21
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22
apply to your use of any object code in the Content.  Check the Redistributor's license that was 
23
provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
24
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
26
27
</body>
28
</html>
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/build.properties (+17 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2004, 2011 BREDEX GmbH.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
###############################################################################
8
bin.includes = about.html,\
9
               META-INF/,\
10
               plugin.xml,\
11
               .
12
jars.compile.order = .
13
source.. = src/
14
output.. = bin/
15
javacSource = 1.4
16
javacTarget = 1.4
17
javacErrors.. = -assertIdentifier
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/plugin.xml (+11 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.2"?><!--
3
    Copyright (c) 2004, 2010 BREDEX GmbH.
4
    All rights reserved. This program and the accompanying materials
5
    are made available under the terms of the Eclipse Public License v1.0
6
    which accompanies this distribution, and is available at
7
    http://www.eclipse.org/legal/epl-v10.html
8
 -->
9
10
<plugin>
11
</plugin>
(-)a/org.eclipse.jubula.rc.rcp.e4.compat/pom.xml (+20 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- Copyright (c) 2004, 2011 BREDEX GmbH. All rights reserved. This program 
3
	and the accompanying materials are made available under the terms of the 
4
	Eclipse Public License v1.0 which accompanies this distribution, and is available 
5
	at http://www.eclipse.org/legal/epl-v10.html -->
6
<project
7
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
8
	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
9
	<modelVersion>4.0.0</modelVersion>
10
    <parent>
11
      <artifactId>org.eclipse.jubula.releng.client</artifactId>
12
      <groupId>org.eclipse.jubula</groupId>
13
      <version>2.0.0-SNAPSHOT</version>
14
      <relativePath>../org.eclipse.jubula.releng.client</relativePath>
15
    </parent>
16
	<groupId>org.eclipse.jubula</groupId>
17
	<artifactId>org.eclipse.jubula.rc.rcp.e4.compat</artifactId>
18
	<version>2.0.0-SNAPSHOT</version>
19
    <packaging>eclipse-plugin</packaging>
20
</project>
(-)a/org.eclipse.jubula.rc.rcp/.checkstyle (-7 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
3
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4
  <fileset name="all" enabled="true" check-config-name="Jubula" local="false">
5
    <file-match-pattern match-pattern="." include-pattern="true"/>
6
  </fileset>
7
</fileset-config>
(-)a/org.eclipse.jubula.rc.rcp/.classpath (-24 lines)
Lines 1-24 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="lib" path="lib/ch.qos.logback.classic.jar"/>
7
	<classpathentry kind="lib" path="lib/ch.qos.logback.core.jar"/>
8
	<classpathentry kind="lib" path="lib/ch.qos.logback.slf4j.jar"/>
9
	<classpathentry kind="lib" path="lib/org.apache.commons.beanutils.jar"/>
10
	<classpathentry kind="lib" path="lib/org.apache.commons.lang.jar"/>
11
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.communication"/>
12
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.communication.jar"/>
13
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.rc.common"/>
14
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.rc.common.jar"/>
15
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.rc.swt"/>
16
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.rc.swt.jar"/>
17
	<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.jubula.tools"/>
18
	<classpathentry kind="lib" path="lib/org.eclipse.jubula.tools.jar"/>
19
	<classpathentry kind="lib" path="lib/org.slf4j.api.jar"/>
20
	<classpathentry kind="lib" path="lib/org.slf4j.jcl.jar"/>
21
	<classpathentry kind="lib" path="lib/xpp3_min-1.1.3.4.O.jar"/>
22
	<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
23
	<classpathentry kind="output" path="bin"/>
24
</classpath>
(-)a/org.eclipse.jubula.rc.rcp/.gitignore (-3 lines)
Lines 1-3 Link Here
1
/bin
2
/target
3
/lib
(-)a/org.eclipse.jubula.rc.rcp/.project (-41 lines)
Lines 1-41 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.eclipse.jubula.rc.rcp</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
33
	</natures>
34
	<linkedResources>
35
		<link>
36
			<name>.settings</name>
37
			<type>2</type>
38
			<locationURI>WORKSPACE_LOC/jubula/org.eclipse.jubula.project.configuration/settings/1.4</locationURI>
39
		</link>
40
	</linkedResources>
41
</projectDescription>
(-)a/org.eclipse.jubula.rc.rcp/META-INF/MANIFEST.MF (-30 lines)
Lines 1-30 Link Here
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Jubula Remote Control - RCP
4
Bundle-SymbolicName: org.eclipse.jubula.rc.rcp; singleton:=true
5
Bundle-Version: 2.0.0.qualifier
6
Bundle-ClassPath: .,
7
 lib/org.eclipse.jubula.tools.jar,
8
 lib/org.apache.commons.lang.jar,
9
 lib/org.apache.oro.jar,
10
 lib/org.apache.commons.beanutils.jar,
11
 lib/org.eclipse.jubula.rc.common.jar,
12
 lib/org.eclipse.jubula.rc.swt.jar,
13
 lib/org.eclipse.jubula.communication.jar,
14
 lib/org.slf4j.api.jar,
15
 lib/org.slf4j.jcl.jar,
16
 lib/ch.qos.logback.slf4j.jar,
17
 lib/ch.qos.logback.core.jar,
18
 lib/ch.qos.logback.classic.jar,
19
 lib/xpp3_min-1.1.3.4.O.jar,
20
 lib/xstream-1.3.1.jar,
21
 resources/
22
Bundle-Vendor: Eclipse Jubula
23
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
24
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
25
 org.eclipse.draw2d;bundle-version="[3.0.0,4.0.0)";resolution:=optional,
26
 org.eclipse.gef;bundle-version="[3.0.0,4.0.0)";resolution:=optional
27
Bundle-ActivationPolicy: lazy
28
Bundle-RequiredExecutionEnvironment: J2SE-1.4
29
Export-Package: org.eclipse.jubula.rc.rcp.gef.factory,
30
 org.eclipse.jubula.rc.rcp.gef.identifier
(-)a/org.eclipse.jubula.rc.rcp/about.html (-28 lines)
Lines 1-28 Link Here
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6
<title>About</title>
7
</head>
8
<body lang="EN-US">
9
<h2>About This Content</h2>
10
 
11
<p>June 22,  2011</p>	
12
<h3>License</h3>
13
14
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
15
indicated below, the Content is provided to you under the terms and conditions of the
16
Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
17
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
18
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19
20
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
21
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22
apply to your use of any object code in the Content.  Check the Redistributor's license that was 
23
provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
24
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25
and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
26
27
</body>
28
</html>
(-)a/org.eclipse.jubula.rc.rcp/build.properties (-32 lines)
Lines 1-32 Link Here
1
###############################################################################
2
# Copyright (c) 2004, 2011 BREDEX GmbH.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
###############################################################################
8
bin.includes = about.html,\
9
               resources/,\
10
               META-INF/,\
11
               plugin.xml,\
12
               .,\
13
               lib/org.eclipse.jubula.tools.jar,\
14
               lib/org.apache.commons.lang.jar,\
15
               lib/org.apache.commons.beanutils.jar,\
16
               lib/org.apache.oro.jar,\
17
               lib/org.eclipse.jubula.rc.common.jar,\
18
               lib/org.eclipse.jubula.rc.swt.jar,\
19
               lib/org.eclipse.jubula.communication.jar,\
20
               lib/org.slf4j.api.jar,\
21
               lib/org.slf4j.jcl.jar,\
22
               lib/ch.qos.logback.slf4j.jar,\
23
               lib/ch.qos.logback.core.jar,\
24
               lib/ch.qos.logback.classic.jar,\
25
               lib/xpp3_min-1.1.3.4.O.jar,\
26
               lib/xstream-1.3.1.jar
27
jars.compile.order = .
28
source.. = src/
29
output.. = bin/
30
javacSource = 1.4
31
javacTarget = 1.4
32
javacErrors.. = -assertIdentifier
(-)a/org.eclipse.jubula.rc.rcp/genLib.xml (-111 lines)
Lines 1-111 Link Here
1
<!--
2
    Copyright (c) 2004, 2011 BREDEX GmbH.
3
    All rights reserved. This program and the accompanying materials
4
    are made available under the terms of the Eclipse Public License v1.0
5
    which accompanies this distribution, and is available at
6
    http://www.eclipse.org/legal/epl-v10.html
7
 -->
8
<project name="org.eclipse.jubula.rc.rcp" default="gen-lib" basedir=".">
9
  
10
  <property name="OrbitStorage" value="../org.eclipse.jubula.rc.common.orbit" />
11
  <property name="SiteStorage" value="../org.eclipse.jubula.site/target/site/plugins" />
12
13
  <target name="gen-lib">
14
  
15
    <mkdir dir="lib" />
16
    <delete>
17
      <fileset dir="lib" includes="**/*"/>
18
    </delete>
19
20
    <copy todir="lib">
21
      <fileset dir="${OrbitStorage}">
22
        <include name="ch.qos.logback.classic*.jar" />
23
      </fileset>
24
      <mergemapper to="ch.qos.logback.classic.jar"/>
25
    </copy>
26
    <copy todir="lib">
27
      <fileset dir="${OrbitStorage}">
28
        <include name="ch.qos.logback.core*.jar" />
29
      </fileset>
30
      <mergemapper to="ch.qos.logback.core.jar"/>
31
    </copy>
32
    <copy todir="lib">
33
      <fileset dir="${OrbitStorage}">
34
        <include name="ch.qos.logback.slf4j*.jar" />
35
      </fileset>
36
      <mergemapper to="ch.qos.logback.slf4j.jar"/>
37
    </copy>
38
39
    <copy todir="lib">
40
      <fileset dir="${OrbitStorage}">
41
        <include name="org.apache.commons.beanutils*.jar" />
42
      </fileset>
43
      <mergemapper to="org.apache.commons.beanutils.jar"/>
44
    </copy>
45
    <copy todir="lib">
46
      <fileset dir="${OrbitStorage}">
47
        <include name="org.apache.commons.lang*.jar" />
48
      </fileset>
49
      <mergemapper to="org.apache.commons.lang.jar"/>
50
    </copy>
51
    <copy todir="lib">
52
      <fileset dir="${OrbitStorage}">
53
        <include name="org.apache.oro*.jar" />
54
      </fileset>
55
      <mergemapper to="org.apache.oro.jar"/>
56
    </copy>
57
58
    <copy todir="lib">
59
      <fileset dir="${OrbitStorage}">
60
        <include name="org.slf4j.api*.jar" />
61
      </fileset>
62
      <mergemapper to="org.slf4j.api.jar"/>
63
    </copy>
64
    <copy todir="lib">
65
      <fileset dir="${OrbitStorage}">
66
        <include name="org.slf4j.jcl*.jar" />
67
      </fileset>
68
      <mergemapper to="org.slf4j.jcl.jar"/>
69
    </copy>
70
71
  	<!-- 
72
  	The "SNAPSHOT" in the include selector ensures that only the non-source 
73
  	JAR is used. Without it, the corresponding source JAR was being used,
74
  	and it was either being used exclusively or was *overwriting* the content
75
  	provided by the non-source JAR. This caused compilation to fail when also
76
  	building source bundles. 
77
  	-->
78
    <copy todir="lib">
79
      <fileset dir="../org.eclipse.jubula.rc.common/target">
80
        <include name="org.eclipse.jubula.rc.common*SNAPSHOT.jar" />
81
      </fileset>
82
      <mergemapper to="org.eclipse.jubula.rc.common.jar"/>
83
    </copy>
84
    <copy todir="lib">
85
      <fileset dir="../org.eclipse.jubula.rc.swt/target">
86
        <include name="org.eclipse.jubula.rc.swt*SNAPSHOT.jar" />
87
      </fileset>
88
      <mergemapper to="org.eclipse.jubula.rc.swt.jar"/>
89
    </copy>
90
    <copy todir="lib">
91
      <fileset dir="../org.eclipse.jubula.tools/target">
92
        <include name="org.eclipse.jubula.tools*SNAPSHOT.jar" />
93
      </fileset>
94
      <mergemapper to="org.eclipse.jubula.tools.jar"/>
95
    </copy>
96
    <copy todir="lib">
97
      <fileset dir="../org.eclipse.jubula.communication/target">
98
        <include name="org.eclipse.jubula.communication*SNAPSHOT.jar" />
99
      </fileset>
100
      <mergemapper to="org.eclipse.jubula.communication.jar"/>
101
    </copy>
102
103
	<copy todir="lib">
104
          <fileset dir="../org.eclipse.jubula.tools/lib">
105
            <include name="xpp3*.jar" />
106
            <include name="xstream*.jar" />
107
          </fileset>
108
	</copy>
109
  </target>
110
  
111
</project>
(-)a/org.eclipse.jubula.rc.rcp/plugin.xml (-14 lines)
Lines 1-14 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.2"?><!--
3
    Copyright (c) 2004, 2010 BREDEX GmbH.
4
    All rights reserved. This program and the accompanying materials
5
    are made available under the terms of the Eclipse Public License v1.0
6
    which accompanies this distribution, and is available at
7
    http://www.eclipse.org/legal/epl-v10.html
8
 -->
9
10
<plugin>
11
   	 <extension point="org.eclipse.ui.startup">
12
   		<startup class="org.eclipse.jubula.rc.rcp.accessor.Startup"/>
13
   </extension>
14
</plugin>
(-)a/org.eclipse.jubula.rc.rcp/pom.xml (-77 lines)
Lines 1-77 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4
  <modelVersion>4.0.0</modelVersion>
5
  <parent>
6
    <artifactId>org.eclipse.jubula.releng.client</artifactId>
7
    <groupId>org.eclipse.jubula</groupId>
8
    <version>2.0.0-SNAPSHOT</version>
9
    <relativePath>../org.eclipse.jubula.releng.client</relativePath>
10
  </parent>
11
  <groupId>org.eclipse.jubula</groupId>
12
  <artifactId>org.eclipse.jubula.rc.rcp</artifactId>
13
  <version>2.0.0-SNAPSHOT</version>
14
  <packaging>eclipse-plugin</packaging>
15
16
  <dependencies>
17
    <dependency>
18
      <groupId>org.eclipse.jubula</groupId>
19
      <artifactId>org.eclipse.jubula.tools</artifactId>
20
      <version>2.0.0-SNAPSHOT</version>
21
    </dependency>
22
    <dependency>
23
      <groupId>org.eclipse.jubula</groupId>
24
      <artifactId>org.eclipse.jubula.communication</artifactId>
25
      <version>2.0.0-SNAPSHOT</version>
26
    </dependency>
27
    <dependency>
28
      <groupId>org.eclipse.jubula</groupId>
29
      <artifactId>org.eclipse.jubula.rc.common</artifactId>
30
      <version>2.0.0-SNAPSHOT</version>
31
    </dependency>
32
    <dependency>
33
      <groupId>org.eclipse.jubula</groupId>
34
      <artifactId>org.eclipse.jubula.rc.swt</artifactId>
35
      <version>2.0.0-SNAPSHOT</version>
36
    </dependency>
37
  </dependencies>
38
39
  <build>
40
    <plugins>
41
      <plugin>
42
        <artifactId>maven-antrun-plugin</artifactId>
43
        <version>1.6</version>
44
        <executions>
45
          <execution>
46
            <id>gen-lib</id>
47
            <phase>generate-resources</phase>
48
            <configuration>
49
              <target>
50
                <ant antfile="genLib.xml" />
51
              </target>
52
            </configuration>
53
            <goals>
54
              <goal>run</goal>
55
            </goals>
56
          </execution>
57
        </executions>
58
      </plugin>
59
      <plugin>
60
        <artifactId>maven-clean-plugin</artifactId>
61
        <version>2.4.1</version>
62
        <configuration>
63
          <filesets>
64
            <fileset>
65
              <directory>lib</directory>
66
              <includes>
67
                <include>*.jar</include>
68
              </includes>
69
              <followSymlinks>false</followSymlinks>
70
            </fileset>
71
          </filesets>
72
        </configuration>
73
      </plugin>
74
    </plugins>
75
  </build>
76
77
</project>
(-)a/org.eclipse.jubula.rc.rcp/resources/logback.xml (-20 lines)
Lines 1-20 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<configuration scan="true">
3
	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4
		<!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
5
		<encoder>
6
			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
7
			</pattern>
8
		</encoder>
9
	</appender>
10
	<appender name="FILE" class="ch.qos.logback.core.FileAppender">
11
		<file>${user.home}/.jubula/logs/rc_rcp.log</file>
12
		<encoder>
13
			<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
14
			</pattern>
15
		</encoder>
16
	</appender>
17
	<root level="warn">
18
		<appender-ref ref="FILE" />
19
	</root>
20
</configuration>
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/accessor/Startup.java (-694 lines)
Lines 1-694 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.accessor;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.lang.reflect.Method;
15
import java.util.ArrayList;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Properties;
21
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.jface.action.IContributionItem;
24
import org.eclipse.jface.dialogs.Dialog;
25
import org.eclipse.jface.dialogs.IDialogConstants;
26
import org.eclipse.jface.dialogs.IPageChangedListener;
27
import org.eclipse.jface.dialogs.PageChangedEvent;
28
import org.eclipse.jface.preference.IPreferenceNode;
29
import org.eclipse.jface.preference.PreferenceDialog;
30
import org.eclipse.jface.preference.PreferenceManager;
31
import org.eclipse.jubula.rc.common.AUTServer;
32
import org.eclipse.jubula.rc.rcp.gef.inspector.GefInspectorListenerAppender;
33
import org.eclipse.jubula.rc.rcp.gef.listener.GefPartListener;
34
import org.eclipse.jubula.rc.swt.SwtAUTServer;
35
import org.eclipse.jubula.rc.swt.listener.ComponentHandler;
36
import org.eclipse.jubula.tools.constants.AutConfigConstants;
37
import org.eclipse.jubula.tools.constants.AutEnvironmentConstants;
38
import org.eclipse.jubula.tools.constants.CommandConstants;
39
import org.eclipse.jubula.tools.constants.SwtAUTHierarchyConstants;
40
import org.eclipse.jubula.tools.utils.EnvironmentUtils;
41
import org.eclipse.swt.SWT;
42
import org.eclipse.swt.widgets.Button;
43
import org.eclipse.swt.widgets.Composite;
44
import org.eclipse.swt.widgets.Control;
45
import org.eclipse.swt.widgets.CoolBar;
46
import org.eclipse.swt.widgets.CoolItem;
47
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Event;
49
import org.eclipse.swt.widgets.Item;
50
import org.eclipse.swt.widgets.Listener;
51
import org.eclipse.swt.widgets.Shell;
52
import org.eclipse.swt.widgets.ToolBar;
53
import org.eclipse.swt.widgets.Widget;
54
import org.eclipse.ui.IEditorReference;
55
import org.eclipse.ui.IPartListener2;
56
import org.eclipse.ui.IStartup;
57
import org.eclipse.ui.IViewReference;
58
import org.eclipse.ui.IWindowListener;
59
import org.eclipse.ui.IWorkbench;
60
import org.eclipse.ui.IWorkbenchPage;
61
import org.eclipse.ui.IWorkbenchPartReference;
62
import org.eclipse.ui.IWorkbenchWindow;
63
import org.eclipse.ui.PlatformUI;
64
import org.eclipse.ui.internal.WorkbenchPartReference;
65
66
67
/**
68
 * Initializes an AUT Server in a plug-in context.
69
 * 
70
 * It is very important to avoid referencing GEF (org.eclipse.gef.*) classes 
71
 * directly from this class, as this will cause Class Not Found errors if the 
72
 * AUT does not contain the GEF plug-in.
73
 *
74
 * @author BREDEX GmbH
75
 * @created Oct 5, 2007
76
 */
77
public class Startup implements IStartup {
78
    /** Key for GEF Viewer in component data */
79
    public static final String TEST_GEF_VIEWER_DATA_KEY = "TEST_GEF_VIEWER"; //$NON-NLS-1$
80
81
    /** bundle ID for Eclipse Graphical Editing Framework (GEF) */
82
    public static final String GEF_BUNDLE_ID = "org.eclipse.gef"; //$NON-NLS-1$
83
    
84
    /** Key for RCP partId in component data */
85
    private static final String TEST_RCP_DATA_KEY = 
86
        SwtAUTHierarchyConstants.RCP_NAME;
87
    
88
    /** ID suffix for toolbars belonging to a part (view/editor) */
89
    private static final String TOOLBAR_ID_SUFFIX = ".toolbar"; //$NON-NLS-1$
90
        
91
    /** Single listener instance */
92
    private static IPartListener2 partNamingListener = 
93
        new PartNamingListener();
94
    
95
    /** 
96
     * This listener 
97
     */
98
    private IPartListener2 m_gefListener = null;
99
100
    /**
101
     * This listener assigns names to components as they become visible. The
102
     * assigned name is determined by supporting data of the component and its
103
     * surroundings.
104
     *
105
     * @author BREDEX GmbH
106
     * @created Oct 19, 2007
107
     */
108
    private static class ComponentNamer implements Listener {
109
110
        /** map for naming dialog buttons */
111
        private static Map componentNAMES = new HashMap();
112
        
113
        /** is name generation enabled */
114
        private static boolean generateNames = false;
115
        
116
        static {
117
            generateNames = Boolean.valueOf(
118
                    EnvironmentUtils.getProcessEnvironment()
119
                        .getProperty(
120
                                AutEnvironmentConstants
121
                                    .GENERATE_COMPONENT_NAMES))
122
                            .booleanValue();
123
            
124
            addCompName(IDialogConstants.ABORT_ID, "abort"); //$NON-NLS-1$
125
            addCompName(IDialogConstants.BACK_ID, "back"); //$NON-NLS-1$
126
            addCompName(IDialogConstants.CANCEL_ID, "cancel"); //$NON-NLS-1$
127
            addCompName(IDialogConstants.CLIENT_ID, "client"); //$NON-NLS-1$
128
            addCompName(IDialogConstants.CLOSE_ID, "close"); //$NON-NLS-1$
129
            addCompName(IDialogConstants.DESELECT_ALL_ID, "deselectAll"); //$NON-NLS-1$
130
            addCompName(IDialogConstants.DETAILS_ID, "details"); //$NON-NLS-1$
131
            addCompName(IDialogConstants.FINISH_ID, "finish"); //$NON-NLS-1$
132
            addCompName(IDialogConstants.HELP_ID, "help"); //$NON-NLS-1$
133
            addCompName(IDialogConstants.IGNORE_ID, "ignore"); //$NON-NLS-1$
134
            addCompName(IDialogConstants.INTERNAL_ID, "internal"); //$NON-NLS-1$
135
            addCompName(IDialogConstants.NEXT_ID, "next"); //$NON-NLS-1$
136
            addCompName(IDialogConstants.NO_ID, "no"); //$NON-NLS-1$
137
            addCompName(IDialogConstants.NO_TO_ALL_ID, "noToAll"); //$NON-NLS-1$
138
            addCompName(IDialogConstants.OK_ID, "ok"); //$NON-NLS-1$
139
            addCompName(IDialogConstants.OPEN_ID, "open"); //$NON-NLS-1$
140
            addCompName(IDialogConstants.PROCEED_ID, "proceed"); //$NON-NLS-1$
141
            addCompName(IDialogConstants.RETRY_ID, "retry"); //$NON-NLS-1$
142
            addCompName(IDialogConstants.SELECT_ALL_ID, "selectAll"); //$NON-NLS-1$
143
            addCompName(IDialogConstants.SELECT_TYPES_ID, "selectTypes"); //$NON-NLS-1$
144
            addCompName(IDialogConstants.SKIP_ID, "skip"); //$NON-NLS-1$
145
            addCompName(IDialogConstants.STOP_ID, "stop"); //$NON-NLS-1$
146
            addCompName(IDialogConstants.YES_ID, "yes"); //$NON-NLS-1$
147
            addCompName(IDialogConstants.YES_TO_ALL_ID, "yesToAll"); //$NON-NLS-1$
148
        }
149
        
150
        /**
151
         * add component id <-> name mapping
152
         * @param compID the component identifier
153
         * @param compName the component name
154
         */
155
        private static void addCompName(int compID, String compName) {
156
            String staticNamePreafix = "dialog.button."; //$NON-NLS-1$
157
            componentNAMES.put(new Integer(compID), 
158
                    staticNamePreafix + compName);
159
        }
160
        
161
        /**
162
         * {@inheritDoc}
163
         */
164
        public void handleEvent(Event event) {
165
            addNameData(event.widget);
166
            Item [] items = new Item [] {};
167
            if (event.widget instanceof ToolBar) {
168
                items = ((ToolBar)event.widget).getItems();
169
            } else if (event.widget instanceof CoolBar) {
170
                items = ((CoolBar)event.widget).getItems();
171
            }
172
            for (int i = 0; i < items.length; i++) {
173
                addNameData(items[i]);
174
            }
175
        }
176
177
        /**
178
         * Adds name information to the given widget, if necessary.
179
         * 
180
         * @param widget The widget to name.
181
         */
182
        private void addNameData(Widget widget) {
183
            // Assign name
184
            if (widget != null && !widget.isDisposed()) {
185
                if (widget.getData(Startup.TEST_RCP_DATA_KEY) != null) {
186
                    // Component already has a name, so we don't need to
187
                    // assign a new one.
188
                    return;
189
                }
190
                Object data = getWidgetData(widget);
191
192
                if (data instanceof IContributionItem) {
193
                    // Name buttons and toolitems according to the action that
194
                    // they represent, if possible.
195
                    String actionId = ((IContributionItem)data).getId();
196
                    if (actionId != null && actionId.trim().length() > 0) {
197
198
                        widget.setData(Startup.TEST_RCP_DATA_KEY, actionId);
199
                        ComponentHandler.getAutHierarchy()
200
                            .refreshComponentName(widget);
201
202
                    }
203
                } else if (data instanceof PreferenceDialog) {
204
                    PreferenceDialog prefDialog = (PreferenceDialog)data;
205
             
206
                    // Add a listener to add name data as pages are 
207
                    // selected/created.
208
                    prefDialog.addPageChangedListener(
209
                        new IPageChangedListener() {
210
211
                            public void pageChanged(PageChangedEvent event) {
212
                                addNameDataToPrefPage(event.getSelectedPage());
213
                            }
214
                        
215
                        });
216
217
                    // The listener won't notice the initally selected page,
218
                    // so we have to add that name data here.
219
                    addNameDataToPrefPage(prefDialog.getSelectedPage());
220
                }
221
                if (generateNames && data instanceof Dialog) {
222
                    Dialog dialog = (Dialog)data;
223
                    setNameForDialogButtonBarButtons(dialog);
224
                }
225
            }
226
        }
227
228
        /**
229
         * 
230
         * @param widget The widget for which to get the data.
231
         * @return the data object corresponding to the given widget.
232
         */
233
        private Object getWidgetData(Widget widget) {
234
            Object data = widget.getData();
235
236
            // Handle the case of CoolBar containing CoolItem containing ToolBar.
237
            // The CoolItem is the widget that represents the toolbar 
238
            // contribution, but it (the CoolItem) is not in our AUT 
239
            // component hierarchy, due to the fact that the ToolBar's 
240
            // getParent() returns the CoolBar rather than the CoolItem.
241
            // To resolve this discrepancy, we use the data from the 
242
            // coresponding CoolItem to generate a name for the ToolBar.
243
            try {
244
                if (widget instanceof ToolBar) {
245
                    Composite toolbarParent = ((ToolBar)widget).getParent();
246
                    if (toolbarParent instanceof CoolBar) {
247
                        CoolItem [] coolItems = 
248
                            ((CoolBar)toolbarParent).getItems();
249
                        for (int i = 0; i < coolItems.length; i++) {
250
                            CoolItem item = coolItems[i];
251
                            if (item != null 
252
                                    && item.getControl() == widget) {
253
                                data = item.getData();
254
                            }
255
                        }
256
                    }
257
                }
258
            } catch (NoClassDefFoundError e) {
259
                // we may be running in eRCP which doesn't know
260
                // about
261
                // toolbars, so we just ignore this
262
            }
263
264
            return data;
265
        }
266
        
267
        /**
268
         * @param dialog the dialog
269
         */
270
        private void setNameForDialogButtonBarButtons(Dialog dialog) {
271
            try {
272
                Method getButtonMethod = Dialog.class.getDeclaredMethod(
273
                        "getButton", new Class[] { int.class }); //$NON-NLS-1$
274
                getButtonMethod.setAccessible(true);
275
276
                Iterator components = componentNAMES.keySet().iterator();
277
                while (components.hasNext()) {
278
                    Integer componentID = (Integer)components.next();
279
                    invokeNameSetting(dialog, getButtonMethod, componentID,
280
                            componentNAMES.get(componentID));
281
                }
282
            } catch (SecurityException e) {
283
                // ignore exceptions
284
            } catch (NoSuchMethodException e) {
285
                // ignore exceptions
286
            }
287
        }
288
289
        /**
290
         * use this method to set a name on the given object
291
         * @param useObject the object
292
         * @param methodToInvoke the method to invoke
293
         * @param buttonID the button id
294
         * @param buttonName the button name
295
         */
296
        private void invokeNameSetting(Object useObject, Method methodToInvoke,
297
                Integer buttonID, Object buttonName) {
298
            Object ret = null;
299
            try {
300
                ret = methodToInvoke.invoke(useObject,
301
                        new Object[] { buttonID });
302
            } catch (IllegalArgumentException e) {
303
                // ignore exceptions
304
            } catch (IllegalAccessException e) {
305
                // ignore exceptions
306
            } catch (InvocationTargetException e) {
307
                // ignore exceptions
308
            }
309
            if (ret instanceof Button) {
310
                Button button = (Button)ret;
311
                if (button.getData(TEST_RCP_DATA_KEY) == null) {
312
                    button.setData(TEST_RCP_DATA_KEY, buttonName);
313
                }
314
            }
315
        }
316
317
        /**
318
         * Attaches name data to the given page appropriate.
319
         * 
320
         * @param selectedPage The page to which we will try to attach the 
321
         *                     name data.
322
         */
323
        private void addNameDataToPrefPage(Object selectedPage) {
324
            if (selectedPage == null) {
325
                return;
326
            }
327
            PreferenceManager prefMan = 
328
                PlatformUI.getWorkbench().getPreferenceManager();
329
330
            Iterator iter = 
331
                prefMan.getElements(PreferenceManager.PRE_ORDER).iterator();
332
            while (iter.hasNext()) {
333
                IPreferenceNode prefNode = 
334
                    (IPreferenceNode)iter.next();
335
                if (selectedPage.equals(prefNode.getPage())) {
336
                    Control pageControl = 
337
                        prefNode.getPage().getControl();
338
                    String prefNodeId = prefNode.getId();
339
                    
340
                    // Assign id to page composite only if the composite exists
341
                    // and if the id is usable
342
                    if (pageControl != null 
343
                        && !pageControl.isDisposed()
344
                        && pageControl.getData(
345
                            Startup.TEST_RCP_DATA_KEY) == null
346
                        && prefNodeId != null
347
                        && prefNodeId.trim().length() > 0) {
348
                       
349
                        pageControl.setData(
350
                            Startup.TEST_RCP_DATA_KEY, prefNodeId);
351
                       
352
                        Shell prefShell = 
353
                            pageControl.getDisplay().getActiveShell();
354
                        Event activateEvent = new Event();
355
                        activateEvent.time = (int)System.currentTimeMillis();
356
                        activateEvent.type = SWT.Activate;
357
                        activateEvent.widget = prefShell;
358
                        prefShell.notifyListeners(SWT.Activate, activateEvent);
359
360
                    }
361
362
                    // We found the page we were looking for, so we can stop 
363
                    // searching.
364
                    break;
365
                }
366
            }
367
        }
368
    }
369
370
    /**
371
     * Assigns the controls (Composites) of Parts unique names based on 
372
     * their partId.
373
     *
374
     * @author BREDEX GmbH
375
     * @created Oct 5, 2007
376
     */
377
    static class PartNamingListener implements IPartListener2 {
378
379
        /**
380
         * 
381
         * {@inheritDoc}
382
         */
383
        public void partActivated(IWorkbenchPartReference partRef) {
384
            // Do nothing
385
        }
386
387
        /**
388
         * 
389
         * {@inheritDoc}
390
         */
391
        public void partBroughtToTop(IWorkbenchPartReference partRef) {
392
            // Do nothing
393
        }
394
395
        /**
396
         * 
397
         * {@inheritDoc}
398
         */
399
        public void partClosed(IWorkbenchPartReference partRef) {
400
            // Do nothing
401
        }
402
403
        /**
404
         * 
405
         * {@inheritDoc}
406
         */
407
        public void partDeactivated(IWorkbenchPartReference partRef) {
408
            // Do nothing
409
        }
410
411
        /**
412
         * 
413
         * {@inheritDoc}
414
         */
415
        public void partHidden(IWorkbenchPartReference partRef) {
416
            // Do nothing
417
        }
418
419
        /**
420
         * 
421
         * {@inheritDoc}
422
         */
423
        public void partInputChanged(IWorkbenchPartReference partRef) {
424
            // Do nothing
425
        }
426
427
        /**
428
         * 
429
         * {@inheritDoc}
430
         */
431
        public void partOpened(IWorkbenchPartReference partRef) {
432
            if (partRef instanceof WorkbenchPartReference) {
433
                WorkbenchPartReference workbenchPartRef = 
434
                    (WorkbenchPartReference)partRef;
435
                // Get pane contents and part id
436
                Control partContent = 
437
                    workbenchPartRef.getPane().getControl();
438
439
                if (partContent != null 
440
                    && !partContent.isDisposed()
441
                    && partContent.getData(TEST_RCP_DATA_KEY) == null) {
442
                    
443
                    // Name pane control based on part
444
                    String partId = workbenchPartRef.getId();
445
446
                    // Append secondary id, if necessary
447
                    if (partRef instanceof IViewReference) {
448
                        String secondaryId = 
449
                            ((IViewReference)partRef).getSecondaryId();
450
                        if (secondaryId != null) {
451
                            partId += "_" + secondaryId; //$NON-NLS-1$
452
                        }
453
                    }
454
455
                    if (partId == null || partId.trim().length() == 0) {
456
                        // Don't assign a name if the id is unusable
457
                        return;
458
                    }
459
                    partContent.setData(TEST_RCP_DATA_KEY, partId);
460
461
                    // Assign a corresponding id to the part's toolbar, if
462
                    // possible/usable.
463
                    Control partToolbar = 
464
                        workbenchPartRef.getPane().getToolBar();
465
                    if (partToolbar != null) {
466
                        partToolbar.setData(TEST_RCP_DATA_KEY, 
467
                                partId + TOOLBAR_ID_SUFFIX);
468
                    }
469
                    
470
                    // A repaint is required in order for the aut component 
471
                    // hierarchy to notice the change.
472
                    Shell shell = PlatformUI.getWorkbench()
473
                        .getActiveWorkbenchWindow().getShell();
474
                    repaintToolbars(shell);
475
                }
476
            }
477
478
        }
479
480
        /**
481
         * 
482
         * {@inheritDoc}
483
         */
484
        public void partVisible(IWorkbenchPartReference partRef) {
485
            partOpened(partRef);
486
        }
487
        
488
    }
489
490
    
491
    /**
492
     * {@inheritDoc}
493
     */
494
    public void earlyStartup() {
495
        final Properties envVars = 
496
            EnvironmentUtils.getProcessEnvironment();
497
        
498
        if (getValue(AutConfigConstants.AUT_AGENT_HOST, envVars) != null) {
499
            final IWorkbench workbench = PlatformUI.getWorkbench();
500
            final Display display = workbench.getDisplay();
501
            initAutServer(display, envVars);
502
503
            display.syncExec(new Runnable() {
504
                public void run() {
505
                    // add GEF listeners (and listener appenders) for GEF, if available
506
                    if (Platform.getBundle(Startup.GEF_BUNDLE_ID) != null) {
507
                        m_gefListener = new GefPartListener();
508
                        AUTServer.getInstance().addInspectorListenerAppender(
509
                                new GefInspectorListenerAppender());
510
                    }
511
                    
512
                    // add naming listener
513
                    ComponentNamer namer = new ComponentNamer();
514
                    display.addFilter(SWT.Paint, namer);
515
                    display.addFilter(SWT.Activate, namer);
516
517
                    // Add window listener
518
                    addWindowListener(workbench);
519
                    
520
                    IWorkbenchWindow window = 
521
                        workbench.getActiveWorkbenchWindow();
522
                    if (window != null) {
523
                        // Add part listeners
524
                        addPartListeners(window);
525
                        
526
                        // Handle existing parts
527
                        IWorkbenchPage [] pages = window.getPages();
528
                        for (int i = 0; i < pages.length; i++) {
529
                            IEditorReference[] editorRefs = 
530
                                pages[i].getEditorReferences();
531
                            IViewReference[] viewRefs = 
532
                                pages[i].getViewReferences();
533
                            for (int j = 0; j < editorRefs.length; j++) {
534
                                partNamingListener.partOpened(editorRefs[j]);
535
                                if (m_gefListener != null) {
536
                                    m_gefListener.partOpened(editorRefs[j]);
537
                                }
538
                            }
539
                            for (int k = 0; k < viewRefs.length; k++) {
540
                                partNamingListener.partOpened(viewRefs[k]);
541
                                if (m_gefListener != null) {
542
                                    m_gefListener.partOpened(viewRefs[k]);
543
                                }
544
                            }
545
                        }
546
547
                        // If a shell already exists, make sure that we get another
548
                        // chance to immediately add/use our naming listeners.
549
                        Shell mainShell = window.getShell();
550
                        if (mainShell != null && !mainShell.isDisposed()) {
551
                            repaintToolbars(mainShell);
552
                        }
553
                    }
554
                }
555
556
            });
557
558
            // add listener to AUT
559
            AUTServer.getInstance().addToolKitEventListenerToAUT();
560
561
        }
562
563
    }
564
565
    /**
566
     * Initializes the AUT Server for the host application.
567
     * 
568
     * @param display The Display to use for the AUT Server.
569
     * @param envVars Environment variables to consult in configuring the 
570
     *                AUT Server.
571
     */
572
    private void initAutServer(Display display, Properties envVars) {
573
        ((SwtAUTServer)AUTServer.getInstance(CommandConstants
574
                .AUT_SWT_SERVER)).setDisplay(display);
575
        AUTServer.getInstance().setAutAgentHost(getValue(
576
                AutConfigConstants.AUT_AGENT_HOST, envVars));
577
        AUTServer.getInstance().setAutAgentPort(getValue(
578
                AutConfigConstants.AUT_AGENT_PORT, envVars));
579
        AUTServer.getInstance().setAutID(getValue(
580
                AutConfigConstants.AUT_NAME, envVars));
581
582
        AUTServer.getInstance().start(true);
583
    }
584
585
    /**
586
     * Adds a window listener to the given workbench. This listener adds a 
587
     * part naming listener to opening windows.
588
     * 
589
     * @param workbench The workbench to which the listener will be added.
590
     */
591
    private void addWindowListener(IWorkbench workbench) {
592
        workbench.addWindowListener(new IWindowListener() {
593
594
            public void windowActivated(IWorkbenchWindow window) {
595
                addPartListeners(window);
596
            }
597
598
            public void windowClosed(IWorkbenchWindow window) {
599
                // Do nothing
600
            }
601
602
            public void windowDeactivated(IWorkbenchWindow window) {
603
                // Do nothing
604
            }
605
606
            public void windowOpened(IWorkbenchWindow window) {
607
                addPartListeners(window);
608
            }
609
610
        });
611
    }
612
613
    /**
614
     * Fires a paint event on all Toolbars and Coolbars within the given shell.
615
     * 
616
     * @param mainShell The shell to search for Coolbars and Toolbars.
617
     */
618
    public static void repaintToolbars(Shell mainShell) {
619
        List toolbarList = new ArrayList();
620
        getToolbars(mainShell, toolbarList);
621
        Iterator iter = toolbarList.iterator();
622
        while (iter.hasNext()) {
623
            Control toolbar = (Control)iter.next();
624
            toolbar.update();
625
            toolbar.redraw();
626
            toolbar.update();
627
        }
628
    }
629
630
    /**
631
     * Adds all Coolbars and Toolbars within the given composite to the given
632
     * list. The search is is also performed recursively on children of the 
633
     * given composite.
634
     * 
635
     * @param composite The composite to search.
636
     * @param toolbarList The list to which found Toolbars and Coolbars will 
637
     * be added.
638
     */
639
    public static void getToolbars(Composite composite, 
640
        List toolbarList) {
641
        
642
        if (composite != null && !composite.isDisposed()) {
643
            Control [] children = composite.getChildren();
644
            for (int i = 0; i < children.length; i++) {
645
                if (children[i] instanceof Composite) {
646
                    getToolbars((Composite)children[i], toolbarList);
647
                }
648
                try {
649
                    if (children[i] instanceof ToolBar
650
                            || children[i] instanceof CoolBar) {
651
652
                        toolbarList.add(children[i]);
653
                    }
654
                } catch (NoClassDefFoundError e) {
655
                    // we may be running in eRCP which doesn't know about
656
                    // toolbars, so we just ignore this
657
                }
658
            }
659
        }
660
    }
661
662
    /**
663
     * Add part listeners to the given window.
664
     * 
665
     * @param window The window to which the listeners will be added.
666
     */
667
    private void addPartListeners(IWorkbenchWindow window) {
668
        window.getPartService().addPartListener(partNamingListener);
669
        if (m_gefListener != null) {
670
            window.getPartService().addPartListener(m_gefListener);
671
        }
672
    }
673
674
    /**
675
     * Returns the value for a given property. First, <code>envVars</code> 
676
     * is checked for the given property. If this
677
     * property cannot be found there, the 
678
     * Java System Properties will be checked. If the property is not 
679
     * found there, <code>null</code> will be returned.
680
     * 
681
     * @param envVars The first source to check for the given property.
682
     * @param propName The name of the property for which to find the value.
683
     * @return The value for the given property name, or <code>null</code> if
684
     *         given property name cannot be found.
685
     */
686
    private String getValue(String propName, Properties envVars) {
687
        String value = 
688
            envVars.getProperty(propName);
689
        if (value == null) {
690
            value = System.getProperty(propName);
691
        }
692
        return value;
693
    }
694
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/factory/DefaultEditPartAdapterFactory.java (-85 lines)
Lines 1-85 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.factory;
12
13
import org.eclipse.core.runtime.IAdapterFactory;
14
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.gef.EditPart;
16
import org.eclipse.jubula.rc.rcp.gef.identifier.ClassCountEditPartIdentifier;
17
import org.eclipse.jubula.rc.rcp.gef.identifier.IEditPartIdentifier;
18
19
20
/**
21
 * The default adapter factory for getting adapters from EditPart to 
22
 * IEditPartIdentifier. 
23
 *
24
 * @author BREDEX GmbH
25
 * @created May 13, 2009
26
 */
27
public class DefaultEditPartAdapterFactory implements IAdapterFactory {
28
29
    /** the types managed by this factory */
30
    private static final Class [] ADAPTABLE_TYPES = 
31
        new Class [] {EditPart.class};
32
    
33
    /**
34
     * {@inheritDoc}
35
     */
36
    public Object getAdapter(Object adaptableObject, Class adapterType) {
37
        if (adaptableObject instanceof EditPart) {
38
            if (adapterType == IEditPartIdentifier.class) {
39
                return new ClassCountEditPartIdentifier(
40
                        (EditPart)adaptableObject);
41
            }
42
        }
43
        return null;
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public Class[] getAdapterList() {
50
        return ADAPTABLE_TYPES;
51
    }
52
53
    /**
54
     * 
55
     * @param editPart The EditPart for which to find the IEditPartIdentifier.
56
     * @return the IEditPartIdentifier for the given EditPart. First, an attempt
57
     *         is made to load this from a registered adapter factory. If this
58
     *         does not provide an adapter, then this adapter factory is 
59
     *         queried, providing a default implementation.
60
     */
61
    public static IEditPartIdentifier loadFigureIdentifier(EditPart editPart) {
62
        if (editPart == null) {
63
            // null-safe
64
            return null;
65
        }
66
        IEditPartIdentifier editPartIdentifier = 
67
            (IEditPartIdentifier)Platform.getAdapterManager().loadAdapter(
68
                    editPart, IEditPartIdentifier.class.getName());
69
//        if (editPartIdentifier == null) {
70
//            AccessibleEditPart accessible = 
71
//                (AccessibleEditPart)Platform.getAdapterManager().loadAdapter(
72
//                    editPart, AccessibleEditPart.class.getName());
73
//            AccessibleEvent e = new AccessibleEvent(IEditPartIdentifier.class);
74
//            accessible.getName(e);
75
//            if (e.result != null) {
76
//                editPartIdentifier = new StaticEditPartIdentifier(e.result);
77
//            }
78
//        }
79
        if (editPartIdentifier == null) {
80
            editPartIdentifier = new ClassCountEditPartIdentifier(editPart);
81
        }
82
        
83
        return editPartIdentifier;
84
    }
85
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/identifier/ClassCountEditPartIdentifier.java (-73 lines)
Lines 1-73 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.identifier;
12
13
import java.util.HashMap;
14
import java.util.Iterator;
15
import java.util.Map;
16
17
import org.eclipse.gef.EditPart;
18
19
/**
20
 * Default implementation of {@link IEditPartIdentifier}. The identifier is 
21
 * the name of the class of the {@link EditPart} plus a sequential number.
22
 *
23
 * @author BREDEX GmbH
24
 * @created May 13, 2009
25
 */
26
public class ClassCountEditPartIdentifier implements IEditPartIdentifier {
27
28
    /** the EditPart for which identifiers can be generated */
29
    private EditPart m_editPart;
30
    
31
    /**
32
     * Constructor
33
     * 
34
     * @param editPart The EditPart for which identifiers can be generated.
35
     */
36
    public ClassCountEditPartIdentifier(EditPart editPart) {
37
        m_editPart = editPart;
38
    }
39
    
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public String getIdentifier() {
44
        EditPart parent = m_editPart.getParent();
45
        String className = m_editPart.getClass().getName();
46
        String id = className;
47
        if (parent != null) {
48
            id += "_"; //$NON-NLS-1$
49
            Iterator siblingIterator = parent.getChildren().iterator();
50
            boolean isFound = false;
51
            int count = 0;
52
            while (siblingIterator.hasNext() && !isFound) {
53
                EditPart sibling = (EditPart)siblingIterator.next();
54
                if (sibling == m_editPart) {
55
                    isFound = true;
56
                }
57
                if (sibling.getClass().getName().equals(className)) {
58
                    count++;
59
                }
60
            }
61
            id += count;
62
        }
63
        return id;
64
    }
65
66
    /**
67
     * {@inheritDoc}
68
     */
69
    public Map getConnectionAnchors() {
70
        return new HashMap();
71
    }
72
73
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/identifier/IEditPartIdentifier.java (-39 lines)
Lines 1-39 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.identifier;
12
13
import java.util.Map;
14
15
16
17
/**
18
 * Encapsulates the ability to generate unique IDs for a given 
19
 * {@link org.eclipse.gef.EditPart}.
20
 *
21
 * @author BREDEX GmbH
22
 * @created May 13, 2009
23
 */
24
public interface IEditPartIdentifier {
25
26
    /**
27
     * 
28
     * @return a String uniquely identifying the EditPart.
29
     */
30
    public String getIdentifier();
31
32
    /**
33
     * 
34
     * @return a map that correlates identifiers (<code>String</code>s) with 
35
     *         <code>ConnectionAnchor</code>s.
36
     */
37
    public Map getConnectionAnchors();
38
    
39
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/identifier/StaticEditPartIdentifier.java (-53 lines)
Lines 1-53 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.identifier;
12
13
import java.util.Collections;
14
import java.util.Map;
15
16
17
/**
18
 * Provides a static String as an identifier. This class does not take the 
19
 * state of the {@link org.eclipse.gef.EditPart} into account, so it is useful
20
 * for stateless {@link org.eclipse.gef.EditPart}s (ex. containers).
21
 *
22
 * @author BREDEX GmbH
23
 * @created May 19, 2009
24
 */
25
public class StaticEditPartIdentifier implements IEditPartIdentifier {
26
27
    /** the identifier that will always be returned */
28
    private String m_id;
29
    
30
    /**
31
     * Constructor
32
     * 
33
     * @param id The static identifier String that will always be returned.
34
     */
35
    public StaticEditPartIdentifier(String id) {
36
        m_id = id;
37
    }
38
    
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public String getIdentifier() {
43
        return m_id;
44
    }
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public Map getConnectionAnchors() {
50
        return Collections.EMPTY_MAP;
51
    }
52
53
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/implclasses/FigureCanvasImplClass.java (-763 lines)
Lines 1-763 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.implclasses;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.Iterator;
15
import java.util.List;
16
import java.util.Map;
17
18
import org.apache.commons.beanutils.PropertyUtils;
19
import org.apache.commons.lang.Validate;
20
import org.eclipse.draw2d.Connection;
21
import org.eclipse.draw2d.ConnectionAnchor;
22
import org.eclipse.draw2d.FigureCanvas;
23
import org.eclipse.draw2d.IFigure;
24
import org.eclipse.draw2d.geometry.Point;
25
import org.eclipse.gef.ConnectionEditPart;
26
import org.eclipse.gef.EditDomain;
27
import org.eclipse.gef.EditPart;
28
import org.eclipse.gef.GraphicalEditPart;
29
import org.eclipse.gef.GraphicalViewer;
30
import org.eclipse.gef.RootEditPart;
31
import org.eclipse.gef.palette.PaletteEntry;
32
import org.eclipse.gef.ui.palette.PaletteViewer;
33
import org.eclipse.jubula.rc.common.driver.ClickOptions;
34
import org.eclipse.jubula.rc.common.driver.IRobot;
35
import org.eclipse.jubula.rc.common.driver.IRunnable;
36
import org.eclipse.jubula.rc.common.exception.StepExecutionException;
37
import org.eclipse.jubula.rc.common.implclasses.MatchUtil;
38
import org.eclipse.jubula.rc.common.implclasses.Verifier;
39
import org.eclipse.jubula.rc.rcp.accessor.Startup;
40
import org.eclipse.jubula.rc.rcp.gef.factory.DefaultEditPartAdapterFactory;
41
import org.eclipse.jubula.rc.rcp.gef.identifier.IEditPartIdentifier;
42
import org.eclipse.jubula.rc.swt.driver.DragAndDropHelperSwt;
43
import org.eclipse.jubula.rc.swt.implclasses.AbstractControlImplClass;
44
import org.eclipse.jubula.rc.swt.implclasses.MenuUtil;
45
import org.eclipse.jubula.tools.objects.event.EventFactory;
46
import org.eclipse.jubula.tools.objects.event.TestErrorEvent;
47
import org.eclipse.swt.graphics.Rectangle;
48
import org.eclipse.swt.widgets.Composite;
49
import org.eclipse.swt.widgets.Control;
50
51
52
/**
53
 * Implementation class for Figure Canvas (Eclipse GEF).
54
 *
55
 * @author BREDEX GmbH
56
 * @created May 13, 2009
57
 */
58
public class FigureCanvasImplClass extends AbstractControlImplClass {
59
60
    /** 
61
     * the viewer that contains the EditParts corresponding to the FigureCanvas 
62
     */
63
    private GraphicalViewer m_viewer = null;
64
    
65
    /** the composite in which the IFigures are displayed */
66
    private Composite m_composite = null;
67
    
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public Control getComponent() {
72
        return m_composite;
73
    }
74
75
    /**
76
     * 
77
     * @return the viewer associated with the canvas to test.
78
     */
79
    private GraphicalViewer getViewer() {
80
        return m_viewer;
81
    }
82
83
    /**
84
     * 
85
     * @return the control for the canvas to test.
86
     */
87
    private Control getViewerControl() {
88
        return getViewer().getControl();
89
    }
90
91
    /**
92
     * 
93
     * @return the root edit part of the viewer.
94
     */
95
    private RootEditPart getRootEditPart() {
96
        return getViewer().getRootEditPart();
97
    }
98
99
    /**
100
     * 
101
     * @return the root of the palette viewer (tool palette).
102
     */
103
    private RootEditPart getPaletteRoot() {
104
        return getViewer().getEditDomain().getPaletteViewer().getRootEditPart();
105
    }
106
107
    /**
108
     * 
109
     * @param textPath The path to the tool.
110
     * @param operator The operator used for matching.
111
     * @return the EditPart found at the end of the given path. Returns 
112
     *         <code>null</code> if no EditPart can be found for the given path
113
     *         or if the EditPart found is not a GraphicalEditPart.
114
     */
115
    private GraphicalEditPart findPaletteEditPart(
116
            String textPath, String operator) {
117
118
        final String[] pathItems = MenuUtil.splitPath(textPath);
119
        boolean isExisting = true;
120
        
121
        EditPart currentEditPart = getPaletteRoot().getContents();
122
        
123
        for (int i = 0; i < pathItems.length && currentEditPart != null; i++) {
124
            List effectiveChildren = currentEditPart.getChildren();
125
            
126
            EditPart [] children = 
127
                (EditPart [])effectiveChildren.toArray(
128
                        new EditPart[effectiveChildren.size()]);
129
            boolean itemFound = false;
130
            for (int j = 0; j < children.length && !itemFound; j++) {
131
                Object model = children[j].getModel();
132
                if (model instanceof PaletteEntry) {
133
                    String entryLabel = ((PaletteEntry)model).getLabel();
134
                    if (entryLabel != null 
135
                        && MatchUtil.getInstance().match(
136
                            entryLabel, pathItems[i], operator)) {
137
                        itemFound = true;
138
                        currentEditPart = children[j];
139
                    }
140
                }
141
            }
142
            if (!itemFound) {
143
                isExisting = false;
144
                break;
145
            }
146
            
147
        }
148
        
149
        return isExisting && currentEditPart instanceof GraphicalEditPart 
150
            ? (GraphicalEditPart)currentEditPart : null;
151
        
152
    }
153
    
154
    /**
155
     * {@inheritDoc}
156
     */
157
    public String[] getTextArrayFromComponent() {
158
        return null;
159
    }
160
161
    /**
162
     * {@inheritDoc}
163
     */
164
    public void setComponent(final Object graphicsComponent) {
165
        getEventThreadQueuer().invokeAndWait(getClass().getName() + ".setComponent", new IRunnable() { //$NON-NLS-1$
166
167
            public Object run() throws StepExecutionException {
168
                FigureCanvas figureCanvas = (FigureCanvas)graphicsComponent;
169
                Composite parent = figureCanvas;
170
                while (parent != null
171
                        && !(parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY) 
172
                                instanceof GraphicalViewer)) {
173
                    parent = parent.getParent();
174
                }
175
                
176
                if (parent != null) {
177
                    m_composite = parent;
178
                    m_viewer = 
179
                        (GraphicalViewer)parent.getData(
180
                                Startup.TEST_GEF_VIEWER_DATA_KEY);
181
                }
182
                return null;
183
            }
184
            
185
        });
186
    }
187
188
    /**
189
     * Checks whether the figure for the EditPart for the given path exists and
190
     * is visible.
191
     * 
192
     * @param textPath The path to the figure.
193
     * @param operator The operator used for matching.
194
     * @param exists   Whether the figure is expected to exist.
195
     */
196
    public void gdCheckFigureExists(
197
            String textPath, String operator, boolean exists) {
198
199
        boolean isExisting = 
200
            findFigure(findEditPart(textPath, operator)) != null; 
201
        if (!isExisting) {
202
            // See if there's a connection anchor at the given path
203
            isExisting = findConnectionAnchor(textPath, operator) != null;
204
        }
205
        
206
        Verifier.equals(exists, isExisting);
207
208
    }
209
210
    /**
211
     * Checks the given property of the figure at the given path.
212
     * 
213
     * @param textPath The path to the figure.
214
     * @param textPathOperator The operator used for matching the text path.
215
     * @param propertyName The name of the property
216
     * @param expectedPropValue The value of the property as a string
217
     * @param valueOperator The operator used to verify
218
     */
219
    public void gdVerifyFigureProperty(String textPath, 
220
            String textPathOperator, final String propertyName, 
221
            String expectedPropValue, String valueOperator) {
222
223
        final IFigure figure = 
224
            findFigure(findEditPart(textPath, textPathOperator));
225
        if (figure == null) {
226
            throw new StepExecutionException(
227
                    "No figure could be found for the given text path.", //$NON-NLS-1$
228
                    EventFactory.createActionError(
229
                            TestErrorEvent.NOT_FOUND));
230
        }
231
        Object prop = getEventThreadQueuer().invokeAndWait("getProperty",  //$NON-NLS-1$
232
            new IRunnable() {
233
234
                public Object run() throws StepExecutionException {
235
                    try {
236
                        return PropertyUtils.getProperty(figure, propertyName);
237
                    } catch (IllegalAccessException e) {
238
                        throw new StepExecutionException(
239
                            e.getMessage(), 
240
                            EventFactory.createActionError(
241
                                TestErrorEvent.PROPERTY_NOT_ACCESSABLE));
242
                    } catch (InvocationTargetException e) {
243
                        throw new StepExecutionException(
244
                            e.getMessage(), 
245
                            EventFactory.createActionError(
246
                                TestErrorEvent.PROPERTY_NOT_ACCESSABLE));
247
                    } catch (NoSuchMethodException e) {
248
                        throw new StepExecutionException(
249
                            e.getMessage(), 
250
                            EventFactory.createActionError(
251
                                TestErrorEvent.PROPERTY_NOT_ACCESSABLE));
252
                    }
253
                }
254
                
255
            });
256
        final String propToStr = String.valueOf(prop);
257
        Verifier.match(propToStr, expectedPropValue, valueOperator);
258
        
259
    }
260
    
261
    /**
262
     * Checks whether the tool for the given path exists and
263
     * is visible.
264
     * 
265
     * @param textPath The path to the figure.
266
     * @param operator The operator used for matching.
267
     * @param exists   Whether the figure is expected to exist.
268
     */
269
    public void gdCheckToolExists(
270
            String textPath, String operator, boolean exists) {
271
272
        boolean isExisting = findPaletteFigure(textPath, operator) != null; 
273
        
274
        Verifier.equals(exists, isExisting);
275
276
    }
277
278
    /**
279
     * Finds and clicks the figure for the given path.
280
     * 
281
     * @param textPath The path to the figure.
282
     * @param operator The operator used for matching.
283
     * @param count The number of times to click.
284
     * @param button The mouse button to use for the click.
285
     */
286
    public void gdClickFigure(String textPath, String operator, 
287
            int count, int button) {
288
289
        getRobot().click(getViewerControl(), 
290
                getFigureBoundsChecked(textPath, operator), 
291
                ClickOptions.create().setScrollToVisible(false)
292
                    .setClickCount(count).setMouseButton(button));
293
    }
294
295
    /**
296
     * Finds and clicks on a connection between a source figure and a 
297
     * target figure.
298
     * 
299
     * @param sourceTextPath The path to the source figure.
300
     * @param sourceOperator The operator to use for matching the source 
301
     *                       figure path.
302
     * @param targetTextPath The path to the target figure.
303
     * @param targetOperator The operator to use for matching the target
304
     *                       figure path.
305
     * @param count The number of times to click.
306
     * @param button The mouse button to use for the click.
307
     */
308
    public void gdClickConnection(String sourceTextPath, String sourceOperator,
309
            String targetTextPath, String targetOperator, 
310
            int count, int button) {
311
312
        GraphicalEditPart sourceEditPart = 
313
            findEditPart(sourceTextPath, sourceOperator);
314
        GraphicalEditPart targetEditPart = 
315
            findEditPart(targetTextPath, targetOperator);
316
317
        ConnectionEditPart connectionEditPart = null;
318
        
319
        if (sourceEditPart != null) {
320
            List sourceConnectionList = sourceEditPart.getSourceConnections();
321
            ConnectionEditPart [] sourceConnections = 
322
                (ConnectionEditPart [])sourceConnectionList.toArray(
323
                        new ConnectionEditPart[sourceConnectionList.size()]); 
324
            for (int i = 0; i < sourceConnections.length 
325
                    && connectionEditPart == null; i++) {
326
                if (sourceConnections[i].getTarget() == targetEditPart) {
327
                    connectionEditPart = sourceConnections[i];
328
                }
329
            }
330
        } else if (targetEditPart != null) {
331
            List targetConnectionList = targetEditPart.getTargetConnections();
332
            ConnectionEditPart [] targetConnections = 
333
                (ConnectionEditPart [])targetConnectionList.toArray(
334
                        new ConnectionEditPart[targetConnectionList.size()]); 
335
            for (int i = 0; i < targetConnections.length 
336
                    && connectionEditPart == null; i++) {
337
                if (targetConnections[i].getSource() == targetEditPart) {
338
                    connectionEditPart = targetConnections[i];
339
                }
340
            }
341
        } else {
342
            throw new StepExecutionException(
343
                    "No figures could be found for the given text paths.", //$NON-NLS-1$
344
                    EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
345
        }
346
347
        IFigure connectionFigure = findFigure(connectionEditPart);
348
        if (connectionFigure == null) {
349
            String missingEnd = sourceEditPart == null ? "source" : "target"; //$NON-NLS-1$ //$NON-NLS-2$
350
            throw new StepExecutionException(
351
                    "No connection could be found for the given " + missingEnd + " figure.", //$NON-NLS-1$ //$NON-NLS-2$
352
                    EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
353
        }
354
        
355
        // Scrolling
356
        revealEditPart(connectionEditPart);
357
358
        if (connectionFigure instanceof Connection) {
359
            Point midpoint = 
360
                ((Connection)connectionFigure).getPoints().getMidpoint();
361
            connectionFigure.translateToAbsolute(midpoint);
362
            getRobot().click(getViewerControl(), null, 
363
                    ClickOptions.create().setScrollToVisible(false)
364
                        .setClickCount(count).setMouseButton(button), 
365
                    midpoint.x, true, midpoint.y, true);
366
        } else {
367
            getRobot().click(getViewerControl(), 
368
                    getBounds(connectionFigure), 
369
                    ClickOptions.create().setScrollToVisible(false)
370
                        .setClickCount(count).setMouseButton(button));
371
        }
372
        
373
    }
374
375
    /**
376
     * Clicks the specified position within the given figure.
377
     *  
378
     * @param textPath The path to the figure.
379
     * @param operator The operator used for matching.
380
     * @param count amount of clicks
381
     * @param button what button should be clicked
382
     * @param xPos what x position
383
     * @param xUnits should x position be pixel or percent values
384
     * @param yPos what y position
385
     * @param yUnits should y position be pixel or percent values
386
     * @throws StepExecutionException if step execution fails.
387
     */
388
    public void gdClickInFigure(String textPath, String operator, 
389
        int count, int button, int xPos, String xUnits, 
390
        int yPos, String yUnits) throws StepExecutionException {
391
        
392
        getRobot().click(getViewerControl(), 
393
                getFigureBoundsChecked(textPath, operator), 
394
                ClickOptions.create().setScrollToVisible(false)
395
                    .setClickCount(count).setMouseButton(button), 
396
                xPos, xUnits.equalsIgnoreCase(POS_UNIT_PIXEL), 
397
                yPos, yUnits.equalsIgnoreCase(POS_UNIT_PIXEL));
398
    }
399
400
    /**
401
     * Simulates the beginning of a Drag. Moves to the specified position 
402
     * within the given figure and stores information related to the drag to 
403
     * be used later by a Drop operation.
404
     * 
405
     * @param textPath The path to the figure.
406
     * @param operator The operator used for matching.
407
     * @param mouseButton the mouse button.
408
     * @param modifier the modifier, e.g. shift, ctrl, etc.
409
     * @param xPos what x position
410
     * @param xUnits should x position be pixel or percent values
411
     * @param yPos what y position
412
     * @param yUnits should y position be pixel or percent values
413
     */
414
    public void gdDragFigure(String textPath, String operator, 
415
            int mouseButton, String modifier, int xPos,
416
            String xUnits, int yPos, String yUnits) {
417
        // Only store the Drag-Information. Otherwise the GUI-Eventqueue
418
        // blocks after performed Drag!
419
        final DragAndDropHelperSwt dndHelper = DragAndDropHelperSwt
420
            .getInstance();
421
        dndHelper.setMouseButton(mouseButton);
422
        dndHelper.setModifier(modifier);
423
        dndHelper.setDragComponent(null);
424
        gdClickInFigure(textPath, operator, 0, mouseButton, 
425
                xPos, xUnits, yPos, yUnits);
426
    }
427
428
    /**
429
     * Performs a Drop. Moves to the specified location within the given figure
430
     * and releases the modifier and mouse button pressed by the previous drag
431
     * operation.
432
     * 
433
     * @param textPath The path to the figure.
434
     * @param operator The operator used for matching.
435
     * @param xPos what x position
436
     * @param xUnits should x position be pixel or percent values
437
     * @param yPos what y position
438
     * @param yUnits should y position be pixel or percent values
439
     * @param delayBeforeDrop the amount of time (in milliseconds) to wait
440
     *                        between moving the mouse to the drop point and
441
     *                        releasing the mouse button
442
     */
443
    public void gdDropOnFigure(final String textPath, final String operator, 
444
            final int xPos, final String xUnits, final int yPos, 
445
            final String yUnits, int delayBeforeDrop) {
446
447
        final DragAndDropHelperSwt dndHelper = 
448
            DragAndDropHelperSwt.getInstance();
449
        final IRobot robot = getRobot();
450
        final String modifier = dndHelper.getModifier();
451
        final int mouseButton = dndHelper.getMouseButton();
452
        // Note: This method performs the drag AND drop action in one runnable
453
        // in the GUI-Eventqueue because after the mousePress, the eventqueue
454
        // blocks!
455
        try {
456
            pressOrReleaseModifiers(modifier, true);
457
458
            getEventThreadQueuer().invokeAndWait("gdStartDragFigure", new IRunnable() { //$NON-NLS-1$
459
                public Object run() throws StepExecutionException {
460
                    // drag
461
                    robot.mousePress(dndHelper.getDragComponent(), null, 
462
                            mouseButton);
463
                    
464
                    shakeMouse();
465
466
                    // drop
467
                    gdClickInFigure(textPath, operator, 0, 
468
                            mouseButton, xPos, xUnits, yPos, yUnits);
469
                    
470
                    return null;
471
                }            
472
            });
473
474
            waitBeforeDrop(delayBeforeDrop);
475
        } finally {
476
            getRobot().mouseRelease(null, null, mouseButton);
477
            pressOrReleaseModifiers(modifier, false);
478
        }
479
    }
480
481
    /**
482
     * Returns the bounds for the figure for the given path. If no such 
483
     * figure can be found, a {@link StepExecutionException} will be thrown.
484
     * 
485
     * @param textPath The path to the figure.
486
     * @param operator The operator used for matching.
487
     * @return the bounds of the figure for the given path. 
488
     */
489
    private Rectangle getFigureBoundsChecked(String textPath, String operator) {
490
        GraphicalEditPart editPart = 
491
            findEditPart(textPath, operator);
492
        IFigure figure = findFigure(editPart);
493
        ConnectionAnchor anchor = null;
494
        
495
        if (figure == null) {
496
            // Try to find a connection anchor instead
497
            anchor = findConnectionAnchor(textPath, operator);
498
            if (anchor != null) {
499
                final String[] pathItems = MenuUtil.splitPath(textPath);
500
                final String[] editPartPathItems = 
501
                    new String[pathItems.length - 1];
502
                System.arraycopy(
503
                        pathItems, 0, editPartPathItems, 0, 
504
                        editPartPathItems.length);
505
                editPart = findEditPart(operator, editPartPathItems);
506
            }
507
            if (anchor == null || findFigure(editPart) == null) {
508
                throw new StepExecutionException(
509
                        "No figure could be found for the given text path.", //$NON-NLS-1$
510
                        EventFactory.createActionError(
511
                                TestErrorEvent.NOT_FOUND));
512
            }
513
            
514
        }
515
516
        // Scrolling
517
        revealEditPart(editPart);
518
        
519
        return figure != null ? getBounds(figure) : getBounds(anchor);
520
    }
521
522
    /**
523
     * Clicks the tool found at the given path.
524
     * 
525
     * @param textPath The path to the tool.
526
     * @param operator The operator used for matching.
527
     * @param count The number of times to click.
528
     */
529
    public void gdSelectTool(String textPath, String operator, int count) {
530
        Control paletteControl = getPaletteControl();
531
        IFigure figure = 
532
            findPaletteFigureChecked(textPath, operator);
533
        getRobot().click(paletteControl, getBounds(figure), 
534
                ClickOptions.create().setScrollToVisible(false)
535
                    .setClickCount(count));
536
    }
537
    
538
    /**
539
     * @return the control associated with the palette viewer.
540
     */
541
    private Control getPaletteControl() {
542
        EditDomain editDomain = getViewer().getEditDomain();
543
        if (editDomain == null) {
544
            return null;
545
        }
546
        
547
        PaletteViewer paletteViewer = editDomain.getPaletteViewer();
548
        if (paletteViewer == null) {
549
            return null;
550
        }
551
        
552
        return paletteViewer.getControl();
553
    }
554
555
    /**
556
     * 
557
     * @param figure The figure for which to find the bounds.
558
     * @return the bounds of the given figure.
559
     */
560
    private Rectangle getBounds(IFigure figure) {
561
        org.eclipse.draw2d.geometry.Rectangle figureBounds = 
562
            new org.eclipse.draw2d.geometry.Rectangle(figure.getBounds());
563
        
564
        // Take scrolling and zooming into account
565
        figure.translateToAbsolute(figureBounds);
566
567
        return new Rectangle(
568
                figureBounds.x, figureBounds.y, 
569
                figureBounds.width, figureBounds.height);
570
    }
571
572
    /**
573
     * 
574
     * @param anchor The anchor for which to find the bounds.
575
     * @return the "bounds" of the given anchor. Since the location of an 
576
     *         anchor is defined as a single point, the bounds are a small
577
     *         rectangle with that point at the center.
578
     */
579
    private Rectangle getBounds(ConnectionAnchor anchor) {
580
        Validate.notNull(anchor);
581
        Point refPoint = anchor.getReferencePoint();
582
583
        return new Rectangle(
584
                refPoint.x - 1, refPoint.y - 1, 3, 3);
585
    }
586
587
    /**
588
     * 
589
     * @param textPath The path to the GraphicalEditPart.
590
     * @param operator The operator used for matching.
591
     * @return the GraphicalEditPart for the given path. Returns 
592
     *         <code>null</code> if no EditPart exists for the given path or if
593
     *         the found EditPart is not a GraphicalEditPart.
594
     */
595
    private GraphicalEditPart findEditPart(String textPath, String operator) {
596
        final String[] pathItems = MenuUtil.splitPath(textPath);
597
        return findEditPart(operator, pathItems);
598
    }
599
600
    /**
601
     * @param operator The operator used for matching.
602
     * @param pathItems The path to the GraphicalEditPart. Each element in the
603
     *                  array represents a single segment of the path.
604
     * @return the GraphicalEditPart for the given path. Returns 
605
     *         <code>null</code> if no EditPart exists for the given path or if
606
     *         the found EditPart is not a GraphicalEditPart.
607
     */
608
    private GraphicalEditPart findEditPart(String operator,
609
            final String[] pathItems) {
610
        boolean isExisting = true;
611
        EditPart currentEditPart = getRootEditPart().getContents();
612
        
613
        for (int i = 0; i < pathItems.length && currentEditPart != null; i++) {
614
            List effectiveChildren = currentEditPart.getChildren();
615
            EditPart [] children = 
616
                (EditPart [])effectiveChildren.toArray(
617
                        new EditPart[effectiveChildren.size()]);
618
            boolean itemFound = false;
619
            for (int j = 0; j < children.length && !itemFound; j++) {
620
                IEditPartIdentifier childFigureIdentifier = 
621
                    DefaultEditPartAdapterFactory.loadFigureIdentifier(
622
                            children[j]);
623
                if (childFigureIdentifier != null) {
624
                    String figureId = childFigureIdentifier.getIdentifier();
625
                    if (figureId != null 
626
                        && MatchUtil.getInstance().match(
627
                            figureId, pathItems[i], operator)) {
628
                        itemFound = true;
629
                        currentEditPart = children[j];
630
                    }
631
                }
632
            }
633
            if (!itemFound) {
634
                isExisting = false;
635
                break;
636
            }
637
            
638
        }
639
        
640
        return isExisting && currentEditPart instanceof GraphicalEditPart 
641
            ? (GraphicalEditPart)currentEditPart : null;
642
    }
643
644
    /**
645
     * 
646
     * @param textPath The path to the figure.
647
     * @param operator The operator used for matching.
648
     * @return the figure for the GraphicalEditPart for the given path within 
649
     *         the palette. Returns <code>null</code> if no EditPart exists 
650
     *         for the given path or if the found EditPart does not have a 
651
     *         figure.
652
     */
653
    private IFigure findPaletteFigure(String textPath, String operator) {
654
        GraphicalEditPart editPart = findPaletteEditPart(textPath, operator);
655
        
656
        // Scrolling
657
        revealEditPart(editPart);
658
659
        return findFigure(editPart);
660
    }
661
662
    /**
663
     * Finds and returns the palette figure for the given path. If no such 
664
     * figure can be found, a {@link StepExecutionException} will be thrown.
665
     * 
666
     * @param textPath The path to the figure.
667
     * @param operator The operator used for matching.
668
     * @return the figure for the GraphicalEditPart for the given path within 
669
     *         the palette.
670
     */
671
    private IFigure findPaletteFigureChecked(String textPath, String operator) {
672
        IFigure figure = findPaletteFigure(textPath, operator);
673
        if (figure == null) {
674
            throw new StepExecutionException(
675
                    "No palette figure could be found for the given text path.", //$NON-NLS-1$
676
                    EventFactory.createActionError(TestErrorEvent.NOT_FOUND));
677
        }
678
        return figure;
679
680
    }
681
    
682
    /**
683
     * 
684
     * @param editPart The EditPart for which to find the corresponding figure.
685
     * @return the (visible) figure corresponding to the given EditPart, or 
686
     *         <code>null</code> if no visible figure corresponds to the given 
687
     *         EditPart.
688
     */
689
    private IFigure findFigure(GraphicalEditPart editPart) {
690
        if (editPart != null) {
691
            IFigure figure = editPart.getFigure();
692
            if (figure.isShowing()) {
693
                return figure;
694
            }
695
        }
696
697
        return null;
698
    }
699
700
    /**
701
     * Attempts to find a connection anchor at the given textpath.
702
     * 
703
     * @param textPath The path to the anchor.
704
     * @param operator The operator used for matching.
705
     * @return the anchor found at the given text path, or <code>null</code>
706
     *         if no such anchor exists.
707
     */
708
    private ConnectionAnchor findConnectionAnchor(
709
            String textPath, String operator) {
710
711
        final String[] pathItems = MenuUtil.splitPath(textPath);
712
        final String[] editPartPathItems = new String[pathItems.length - 1];
713
        System.arraycopy(
714
                pathItems, 0, editPartPathItems, 0, editPartPathItems.length);
715
        GraphicalEditPart editPart = findEditPart(operator, editPartPathItems);
716
        if (editPart != null) {
717
            String anchorPathItem = pathItems[pathItems.length - 1];
718
            IEditPartIdentifier editPartIdentifier =
719
                DefaultEditPartAdapterFactory.loadFigureIdentifier(editPart);
720
            if (editPartIdentifier != null) {
721
                Map anchorMap = 
722
                    editPartIdentifier.getConnectionAnchors();
723
                if (anchorMap != null) {
724
                    Iterator anchorMapIter = 
725
                        anchorMap.keySet().iterator();
726
                    while (anchorMapIter.hasNext()) {
727
                        Object anchorMapKey = anchorMapIter.next();
728
                        Object anchorMapValue = 
729
                            anchorMap.get(anchorMapKey);
730
                        if (anchorMapKey instanceof String
731
                                && anchorMapValue instanceof ConnectionAnchor
732
                                && MatchUtil.getInstance().match(
733
                                    (String)anchorMapKey, anchorPathItem, 
734
                                    operator)) {
735
736
                            return (ConnectionAnchor)anchorMapValue;
737
                        }
738
                    }
739
                }
740
            }
741
        }
742
743
        return null;
744
    }
745
    
746
    /**
747
     * Reveals the given {@link EditPart} within its viewer.
748
     * 
749
     * @param editPart the {@link EditPart} to reveal.
750
     */
751
    private void revealEditPart(final EditPart editPart) {
752
        if (editPart != null) {
753
            getEventThreadQueuer().invokeAndWait(getClass().getName() + ".revealEditPart", new IRunnable() { //$NON-NLS-1$
754
                
755
                public Object run() throws StepExecutionException {
756
                    editPart.getViewer().reveal(editPart);
757
                    return null;
758
                }
759
                
760
            });
761
        }
762
    }
763
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/inspector/FigureHighlighter.java (-196 lines)
Lines 1-196 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.inspector;
12
13
import java.util.Iterator;
14
import java.util.Map;
15
16
import org.eclipse.draw2d.ConnectionAnchor;
17
import org.eclipse.draw2d.IFigure;
18
import org.eclipse.draw2d.geometry.Point;
19
import org.eclipse.gef.ConnectionEditPart;
20
import org.eclipse.gef.EditPart;
21
import org.eclipse.gef.GraphicalEditPart;
22
import org.eclipse.gef.GraphicalViewer;
23
import org.eclipse.jubula.rc.rcp.gef.factory.DefaultEditPartAdapterFactory;
24
import org.eclipse.jubula.rc.rcp.gef.identifier.IEditPartIdentifier;
25
import org.eclipse.jubula.rc.rcp.gef.util.FigureCanvasUtil;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.MouseEvent;
28
import org.eclipse.swt.events.MouseMoveListener;
29
import org.eclipse.swt.events.PaintEvent;
30
import org.eclipse.swt.events.PaintListener;
31
import org.eclipse.swt.graphics.Color;
32
import org.eclipse.swt.graphics.Rectangle;
33
import org.eclipse.swt.widgets.Control;
34
35
36
/**
37
 * Highlights figures as the mouse moves over them.
38
 *
39
 * @author BREDEX GmbH
40
 * @created Jun 26, 2009
41
 */
42
public class FigureHighlighter implements MouseMoveListener {
43
44
    /** the viewer containing figures that can be highlighted */
45
    private GraphicalViewer m_viewer;
46
    
47
    /** the color to use for highlighting */
48
    private Color m_highlightColor;
49
50
    /** transparency for highlighting */
51
    private int m_highlightAlpha;
52
    
53
    /** the current highlighted bounds */
54
    private Rectangle m_currentBounds;
55
    
56
    /** the pain listener that performs the actual highlighting */
57
    private PaintListener m_paintListener;
58
    
59
    /**
60
     * Constructor
61
     * 
62
     * @param viewer The viewer containing figures to highlight.
63
     */
64
    public FigureHighlighter(GraphicalViewer viewer) {
65
        m_viewer = viewer;
66
        m_highlightColor = 
67
            viewer.getControl().getDisplay().getSystemColor(SWT.COLOR_BLUE);
68
        m_highlightAlpha = 100;
69
        m_currentBounds = null;
70
        m_paintListener = new PaintListener() {
71
72
            public void paintControl(PaintEvent e) {
73
                if (m_currentBounds != null) {
74
                    Color bgColor = e.gc.getBackground();
75
                    int alpha = e.gc.getAlpha();
76
                    e.gc.setAlpha(m_highlightAlpha);
77
                    e.gc.setBackground(m_highlightColor);
78
                    e.gc.fillRectangle(m_currentBounds);
79
                    e.gc.setAlpha(alpha);
80
                    e.gc.setBackground(bgColor);
81
                }
82
            }
83
            
84
        };
85
        viewer.getControl().addPaintListener(m_paintListener);
86
    }
87
88
    /**
89
     * {@inheritDoc}
90
     */
91
    public void mouseMove(MouseEvent e) {
92
        Point cursorLocation = 
93
            new Point(e.x, e.y);
94
        EditPart editPart = 
95
            FigureCanvasUtil.findAtCurrentMousePosition(e.display, m_viewer);
96
        if (editPart == m_viewer.getContents().getRoot()
97
                || editPart == null) {
98
            if (m_currentBounds != null) {
99
                m_currentBounds = null;
100
                m_viewer.getControl().redraw();
101
            }
102
            
103
            return;
104
        }
105
106
        // Check for connection anchor
107
        Rectangle anchorBounds = 
108
            getConnectionAnchorBounds(
109
                DefaultEditPartAdapterFactory.loadFigureIdentifier(
110
                        editPart), cursorLocation);
111
        
112
        if (anchorBounds == null 
113
                && editPart instanceof ConnectionEditPart) {
114
115
            ConnectionEditPart connEditPart = 
116
                (ConnectionEditPart)editPart;
117
            EditPart srcEditPart = connEditPart.getSource();
118
            EditPart targetEditPart = connEditPart.getTarget();
119
            anchorBounds = getConnectionAnchorBounds(
120
                DefaultEditPartAdapterFactory.loadFigureIdentifier(srcEditPart),
121
                cursorLocation);
122
            if (anchorBounds == null) {
123
                anchorBounds = getConnectionAnchorBounds(
124
                        DefaultEditPartAdapterFactory
125
                        .loadFigureIdentifier(targetEditPart), 
126
                        cursorLocation);
127
            }
128
        }
129
130
        Rectangle bounds = anchorBounds;
131
        if (bounds == null
132
                && editPart != m_viewer.getContents().getRoot()
133
                && !(editPart instanceof ConnectionEditPart)
134
                && editPart instanceof GraphicalEditPart) {
135
            IFigure figure = ((GraphicalEditPart)editPart).getFigure();
136
            org.eclipse.draw2d.geometry.Rectangle figureBounds = 
137
                new org.eclipse.draw2d.geometry.Rectangle(figure.getBounds());
138
            figure.translateToAbsolute(figureBounds);
139
            bounds = new Rectangle(figureBounds.x, figureBounds.y, 
140
                    figureBounds.width, figureBounds.height);
141
        }
142
        m_currentBounds = bounds;
143
        m_viewer.getControl().redraw();
144
        
145
    }
146
147
    /**
148
     * 
149
     * @param editPartIdentifier Provides a list of possible anchors.
150
     * @param cursorLocation The location at which to look for the anchor.
151
     * @return the bounds for the connection anchor at the given location, or
152
     *         <code>null</code> if no such anchor can be found.
153
     */
154
    private Rectangle getConnectionAnchorBounds(
155
            IEditPartIdentifier editPartIdentifier, Point cursorLocation) {
156
157
        if (editPartIdentifier != null) {
158
            Map anchorMap = 
159
                editPartIdentifier.getConnectionAnchors();
160
            if (anchorMap != null) {
161
                Iterator iter = anchorMap.keySet().iterator();
162
                while (iter.hasNext()) {
163
                    Object key = iter.next();
164
                    Object value = anchorMap.get(key);
165
                    if (key instanceof String 
166
                            && value instanceof ConnectionAnchor) {
167
                        Point refPoint = 
168
                            ((ConnectionAnchor)value).getReferencePoint();
169
170
                        // The "bounds" of an anchor is considered to be 
171
                        // 3 pixels in all directions.
172
                        Rectangle refBounds = new Rectangle(
173
                                refPoint.x - 3, refPoint.y - 3, 7, 7);
174
                        if (refBounds.contains(cursorLocation.getSWTPoint())) {
175
                            return refBounds;
176
                        }
177
                    }
178
                }
179
            }
180
        }
181
        
182
        return null;
183
    }
184
185
    /**
186
     * Removes all listeners added by this highlighter.
187
     */
188
    public void removeAddedListeners() {
189
        Control control = m_viewer.getControl();
190
        if (!control.isDisposed()) {
191
            control.removePaintListener(m_paintListener);
192
            control.redraw();
193
        }
194
    }
195
    
196
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/inspector/GefInspectorListenerAppender.java (-440 lines)
Lines 1-440 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.inspector;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Map;
19
20
import org.eclipse.draw2d.ConnectionAnchor;
21
import org.eclipse.draw2d.FigureCanvas;
22
import org.eclipse.draw2d.geometry.Point;
23
import org.eclipse.draw2d.geometry.Rectangle;
24
import org.eclipse.gef.ConnectionEditPart;
25
import org.eclipse.gef.EditDomain;
26
import org.eclipse.gef.EditPart;
27
import org.eclipse.gef.EditPartViewer;
28
import org.eclipse.gef.GraphicalEditPart;
29
import org.eclipse.gef.GraphicalViewer;
30
import org.eclipse.gef.RootEditPart;
31
import org.eclipse.gef.palette.PaletteEntry;
32
import org.eclipse.gef.ui.palette.PaletteViewer;
33
import org.eclipse.jubula.communication.message.InspectorComponentSelectedMessage;
34
import org.eclipse.jubula.rc.common.AUTServer;
35
import org.eclipse.jubula.rc.common.listener.IAutListenerAppender;
36
import org.eclipse.jubula.rc.common.logger.AutServerLogger;
37
import org.eclipse.jubula.rc.rcp.accessor.Startup;
38
import org.eclipse.jubula.rc.rcp.gef.factory.DefaultEditPartAdapterFactory;
39
import org.eclipse.jubula.rc.rcp.gef.identifier.IEditPartIdentifier;
40
import org.eclipse.jubula.rc.rcp.gef.util.FigureCanvasUtil;
41
import org.eclipse.jubula.tools.exception.CommunicationException;
42
import org.eclipse.jubula.tools.objects.ComponentIdentifier;
43
import org.eclipse.jubula.tools.objects.IComponentIdentifier;
44
import org.eclipse.swt.SWT;
45
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Control;
47
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Event;
49
import org.eclipse.swt.widgets.Listener;
50
import org.eclipse.swt.widgets.Widget;
51
import org.eclipse.ui.PlatformUI;
52
53
54
/**
55
 * Adds listeners for the Inspector function. These listeners will only 
56
 * interact with GEF components.
57
 *
58
 * @author BREDEX GmbH
59
 * @created Jun 11, 2009
60
 */
61
public class GefInspectorListenerAppender implements IAutListenerAppender {
62
63
    /** the logger */
64
    private static final AutServerLogger LOG = 
65
        new AutServerLogger(GefInspectorListenerAppender.class);
66
    
67
    /**
68
     * Responsible for adding highlighters to controls and managing those
69
     * highlighters.
70
     *
71
     * @author BREDEX GmbH
72
     * @created Jun 29, 2009
73
     */
74
    private static class FigureHighlightAppender implements Listener {
75
76
        /** mapping from control to figure highlighter */
77
        private Map m_canvasToListener = new HashMap();
78
        
79
        /**
80
         * {@inheritDoc}
81
         */
82
        public void handleEvent(Event event) {
83
            if (event.widget instanceof FigureCanvas) {
84
                FigureCanvas canvas = (FigureCanvas)event.widget;
85
                if (event.type == SWT.MouseEnter) {
86
                    handleMouseEnter(canvas);
87
                }
88
            }
89
        }
90
91
        /**
92
         * Removes all listeners added by this appender.
93
         */
94
        public void removeAddedListeners() {
95
            Iterator iter = m_canvasToListener.keySet().iterator();
96
            while (iter.hasNext()) {
97
                Control control = (Control)iter.next();
98
                if (!control.isDisposed()) {
99
                    FigureHighlighter highlighter =
100
                        (FigureHighlighter)m_canvasToListener.get(control);
101
                    highlighter.removeAddedListeners();
102
                    control.removeMouseMoveListener(highlighter);
103
                }
104
            }
105
            m_canvasToListener.clear();
106
        }
107
        
108
        /**
109
         * Adds a figure highlighter to the given canvas.
110
         * 
111
         * @param canvas The figure canvas entered by the mouse.
112
         */
113
        private void handleMouseEnter(final FigureCanvas canvas) {
114
            if (m_canvasToListener.containsKey(canvas)) {
115
                // Highlighter already registered.
116
                return;
117
            }
118
119
            GraphicalViewer viewer = FigureCanvasUtil.getViewer(canvas);
120
            if (viewer != null) {
121
                if (viewer.getContents() instanceof GraphicalEditPart) {
122
                    FigureHighlighter highlighter = 
123
                        new FigureHighlighter(viewer);
124
                    m_canvasToListener.put(canvas, highlighter);
125
                    canvas.addMouseMoveListener(highlighter);
126
                }
127
            }
128
        }
129
        
130
    }
131
    
132
    /**
133
     * Listens for a mouse click and:
134
     *  1. deregisters itself and any other provider listeners, and 
135
     *  2. sends a "component selected" message
136
     *  
137
     * if that mouse click was over a GEF component.
138
     *
139
     * @author BREDEX GmbH
140
     * @created Jun 11, 2009
141
     */
142
    private static class GefInspectorComponentSelectedListener 
143
            implements Listener {
144
145
        /** the appender */
146
        private FigureHighlightAppender m_highlightAppender;
147
148
        /**
149
         * Constructor
150
         * 
151
         * @param highlightAppender The appender to use.
152
         */
153
        public GefInspectorComponentSelectedListener(
154
                FigureHighlightAppender highlightAppender) {
155
            m_highlightAppender = highlightAppender;
156
        }
157
        
158
        /**
159
         * 
160
         * @param editPartIdentifier Provides connection anchor IDs and 
161
         *                           locations.
162
         * @param cursorLocation The location at which to search for an
163
         *                       anchor point.
164
         * @return the ID of the connection anchor at the given location, or
165
         *         <code>null</code> if there is no connection anchor at the
166
         *         given location.
167
         */
168
        private String getConnectionAnchorId(
169
                IEditPartIdentifier editPartIdentifier, Point cursorLocation) {
170
171
            if (editPartIdentifier != null) {
172
                Map anchorMap = 
173
                    editPartIdentifier.getConnectionAnchors();
174
                if (anchorMap != null) {
175
                    Iterator iter = anchorMap.keySet().iterator();
176
                    while (iter.hasNext()) {
177
                        Object key = iter.next();
178
                        Object value = anchorMap.get(key);
179
                        if (key instanceof String 
180
                                && value instanceof ConnectionAnchor) {
181
                            Point refPoint = 
182
                                ((ConnectionAnchor)value).getReferencePoint();
183
184
                            // A click is recognized as being "within the 
185
                            // bounds" of an anchor if it is within 3 pixels
186
                            // in any direction.
187
                            Rectangle refBounds = new Rectangle(
188
                                    refPoint.x - 3, refPoint.y - 3, 7, 7);
189
                            if (refBounds.contains(cursorLocation)) {
190
                                return (String)key;
191
                            }
192
                        }
193
                    }
194
                }
195
            }
196
            
197
            return null;
198
        }
199
        
200
        /**
201
         * 
202
         * {@inheritDoc}
203
         */
204
        public void handleEvent(Event event) {
205
            Display display = event.display;
206
            display.removeFilter(SWT.MouseDown, this);
207
            display.removeFilter(SWT.MouseEnter, m_highlightAppender);
208
            m_highlightAppender.removeAddedListeners();
209
            event.doit = false;
210
            event.type = SWT.None;
211
            Widget selectedWidget = event.widget;
212
            IComponentIdentifier compId = null;
213
            
214
            if (!(selectedWidget instanceof FigureCanvas)) {
215
                sendIdInfo(compId);
216
                return;
217
            }
218
219
            FigureCanvas figureCanvas = 
220
                (FigureCanvas)selectedWidget;
221
            Composite parent = figureCanvas;
222
            while (parent != null
223
                    && !(parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY) 
224
                            instanceof GraphicalViewer)) {
225
                parent = parent.getParent();
226
            }
227
            
228
            if (parent == null) {
229
                sendIdInfo(compId);
230
                return;
231
            }
232
233
            Object gefData = 
234
                parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY);
235
            
236
            if (gefData instanceof EditPartViewer) {
237
                EditPartViewer viewer = (EditPartViewer)gefData;
238
                Point cursorLocation = new Point(display.map(null, 
239
                        viewer.getControl(), 
240
                        display.getCursorLocation()));
241
                EditPart editPart = viewer.findObjectAt(cursorLocation);
242
                EditPart primaryEditPart = FigureCanvasUtil.getPrimaryEditPart(
243
                        editPart, viewer.getRootEditPart());
244
                List idStringList = Collections.EMPTY_LIST;
245
                
246
                if (primaryEditPart != null) {
247
                    idStringList = getPathToRoot(viewer.getRootEditPart(), 
248
                            cursorLocation, primaryEditPart);
249
                    
250
                } else {
251
                    // No primary figure found. 
252
                    // Check whether a tool was selected.
253
                    EditDomain editDomain = viewer.getEditDomain();
254
                    if (editDomain != null) {
255
                        PaletteViewer paletteViewer = 
256
                            editDomain.getPaletteViewer();
257
                        if (paletteViewer != null) {
258
                            EditPart paletteEditPart = 
259
                                paletteViewer.findObjectAt(new Point(
260
                                        display.map(viewer.getControl(), 
261
                                                paletteViewer.getControl(), 
262
                                                cursorLocation.getSWTPoint())));
263
                            if (paletteEditPart != null) {
264
                                idStringList = getToolPathToRoot(
265
                                        paletteViewer.getRootEditPart(), 
266
                                        paletteEditPart);
267
                            }
268
                        }
269
                    }
270
                }
271
                
272
                compId = createCompId(idStringList);
273
            }
274
            sendIdInfo(compId);
275
        }
276
277
        /**
278
         * 
279
         * @param editPart The edit part for which to find the path.
280
         * @param root The root for <code>editPart</code>. This is used to 
281
         *             avoid adding the root identifier to the returned list.
282
         * @param cursorLocation The location to check for nearby connection
283
         *                       anchors.
284
         * @return a list containing the identifier of each edit part between
285
         *         <code>editPart</code> and its root. The first element in the
286
         *         list will be the identifier for a connection anchor if 
287
         *         <code>cursorLocation</code> is near such an anchor.
288
         */
289
        private List getPathToRoot(RootEditPart root, Point cursorLocation,
290
                EditPart editPart) {
291
            
292
            List idStringList = new ArrayList();
293
            EditPart currentEditPart = editPart;
294
            
295
            // Check for connection anchor
296
            String connectionId = 
297
                getConnectionAnchorId(
298
                    DefaultEditPartAdapterFactory.loadFigureIdentifier(
299
                            currentEditPart), 
300
                    cursorLocation);
301
            
302
            if (connectionId == null 
303
                    && currentEditPart instanceof ConnectionEditPart) {
304
305
                ConnectionEditPart connEditPart = 
306
                    (ConnectionEditPart)editPart;
307
                EditPart srcEditPart = connEditPart.getSource();
308
                EditPart targetEditPart = connEditPart.getTarget();
309
                connectionId = getConnectionAnchorId(
310
                        DefaultEditPartAdapterFactory
311
                        .loadFigureIdentifier(srcEditPart), 
312
                        cursorLocation);
313
                if (connectionId != null) {
314
                    currentEditPart = srcEditPart;
315
                } else {
316
                    connectionId = getConnectionAnchorId(
317
                            DefaultEditPartAdapterFactory
318
                            .loadFigureIdentifier(targetEditPart), 
319
                            cursorLocation);
320
                    if (connectionId != null) {
321
                        currentEditPart = targetEditPart;
322
                    }
323
                }
324
            }
325
326
            if (connectionId != null) {
327
                idStringList.add(connectionId);
328
            }
329
330
            while (currentEditPart != root.getContents() 
331
                    && currentEditPart != null) {
332
                IEditPartIdentifier identifier = 
333
                    DefaultEditPartAdapterFactory.loadFigureIdentifier(
334
                            currentEditPart);
335
                if (identifier != null) {
336
                    idStringList.add(identifier.getIdentifier());
337
                }
338
                currentEditPart = currentEditPart.getParent();
339
            }
340
            
341
            return idStringList;
342
343
        }
344
345
        /**
346
         * 
347
         * @param editPart The edit part for which to find the path.
348
         * @param root The root for <code>editPart</code>. This is used to 
349
         *             avoid adding the root identifier to the returned list.
350
         * @return a list containing the identifier of each edit part between
351
         *         <code>editPart</code> and its root.
352
         */
353
        private List getToolPathToRoot(RootEditPart root, EditPart editPart) {
354
355
            List idStringList = new ArrayList();
356
            EditPart currentEditPart = editPart;
357
            
358
            if (currentEditPart != null) {
359
                Object model = currentEditPart.getModel();
360
                while (model instanceof PaletteEntry
361
                        && currentEditPart != root.getContents()) {
362
                    idStringList.add(((PaletteEntry)model).getLabel());
363
                    currentEditPart = 
364
                        currentEditPart.getParent();
365
                    model = currentEditPart.getModel();
366
                }
367
            }
368
369
            return idStringList;
370
        }
371
372
        /**
373
         * Sends the given ID information to the client.
374
         * 
375
         * @param compId The component identifier to send. May be 
376
         *               <code>null</code>.
377
         */
378
        private void sendIdInfo(IComponentIdentifier compId) {
379
            InspectorComponentSelectedMessage message = 
380
                new InspectorComponentSelectedMessage();
381
            message.setComponentIdentifier(compId);
382
            try {
383
                AUTServer.getInstance().getCommunicator().send(message);
384
            } catch (CommunicationException e) {
385
                LOG.error("Error occurred while trying to send message to Client.", e); //$NON-NLS-1$
386
            }
387
        }
388
        
389
        /**
390
         * 
391
         * @param idStringList The path to root for a specific edit part or
392
         *                     connection anchor.
393
         * @return a component identifier for the given path, or 
394
         *         <code>null</code> if no valid component identifier can be
395
         *         generated.
396
         */
397
        private IComponentIdentifier createCompId(List idStringList) {
398
            IComponentIdentifier compId = null;
399
            if (!idStringList.isEmpty()) {
400
                Collections.reverse(idStringList);
401
                compId = new ComponentIdentifier();
402
                compId.setHierarchyNames(idStringList);
403
            }
404
            
405
            return compId;
406
        }
407
    }
408
    
409
    /** the listener responsible for appending highlight listeners */
410
    private FigureHighlightAppender m_highlightAppender;
411
    
412
    /** the listener responsible for handling mouse clicks */
413
    private GefInspectorComponentSelectedListener m_componentSelectedListener;
414
    
415
    /**
416
     * Constructor
417
     */
418
    public GefInspectorListenerAppender() {
419
        m_highlightAppender = new FigureHighlightAppender();
420
        m_componentSelectedListener = 
421
            new GefInspectorComponentSelectedListener(m_highlightAppender);
422
    }
423
    
424
    /**
425
     * {@inheritDoc}
426
     */
427
    public void addAutListener() {
428
        final Display display = PlatformUI.getWorkbench().getDisplay();
429
        
430
        display.syncExec(new Runnable() {
431
432
            public void run() {
433
                display.addFilter(SWT.MouseEnter, m_highlightAppender);
434
                display.addFilter(SWT.MouseDown, m_componentSelectedListener);
435
            }
436
            
437
        });
438
    }
439
440
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/listener/GefPartListener.java (-141 lines)
Lines 1-141 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.listener;
12
13
import org.eclipse.gef.GraphicalViewer;
14
import org.eclipse.jface.viewers.ISelectionChangedListener;
15
import org.eclipse.jface.viewers.SelectionChangedEvent;
16
import org.eclipse.jubula.rc.rcp.accessor.Startup;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.ui.IPartListener2;
19
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.IWorkbenchPartReference;
21
import org.eclipse.ui.internal.WorkbenchPartReference;
22
import org.eclipse.ui.part.MultiPageEditorPart;
23
24
25
/**
26
 * @author BREDEX GmbH
27
 * @created Dec 17, 2009
28
 */
29
public class GefPartListener implements IPartListener2 {
30
31
    /**
32
     * 
33
     * {@inheritDoc}
34
     */
35
    public void partActivated(IWorkbenchPartReference partRef) {
36
        // Do nothing
37
    }
38
39
    /**
40
     * 
41
     * {@inheritDoc}
42
     */
43
    public void partBroughtToTop(IWorkbenchPartReference partRef) {
44
        // Do nothing
45
    }
46
47
    /**
48
     * 
49
     * {@inheritDoc}
50
     */
51
    public void partClosed(IWorkbenchPartReference partRef) {
52
        // Do nothing
53
    }
54
55
    /**
56
     * 
57
     * {@inheritDoc}
58
     */
59
    public void partDeactivated(IWorkbenchPartReference partRef) {
60
        // Do nothing
61
    }
62
63
    /**
64
     * 
65
     * {@inheritDoc}
66
     */
67
    public void partHidden(IWorkbenchPartReference partRef) {
68
        // Do nothing
69
    }
70
71
    /**
72
     * 
73
     * {@inheritDoc}
74
     */
75
    public void partInputChanged(IWorkbenchPartReference partRef) {
76
        // Do nothing
77
    }
78
79
    /**
80
     * 
81
     * {@inheritDoc}
82
     */
83
    public void partOpened(final IWorkbenchPartReference partRef) {
84
        IWorkbenchPart part = partRef.getPart(false);
85
        
86
        if (part instanceof MultiPageEditorPart) {
87
            ((MultiPageEditorPart)part).getSite().getSelectionProvider()
88
                .addSelectionChangedListener(new ISelectionChangedListener() {
89
                    
90
                    public void selectionChanged(SelectionChangedEvent event) {
91
                        if (event.getSource() instanceof GraphicalViewer) {
92
                            registerGraphicalViewer(
93
                                (GraphicalViewer)event.getSource(), partRef);
94
                        }
95
                    }
96
                });
97
        }
98
        
99
        if (part != null 
100
                && partRef instanceof WorkbenchPartReference) {
101
            GraphicalViewer viewer = 
102
                (GraphicalViewer)part.getAdapter(
103
                        GraphicalViewer.class);
104
            registerGraphicalViewer(viewer, partRef);
105
        }
106
    }
107
108
    /**
109
     * 
110
     * {@inheritDoc}
111
     */
112
    public void partVisible(IWorkbenchPartReference partRef) {
113
        partOpened(partRef);
114
    }
115
116
    /**
117
     * Registers a {@link GraphicalViewer} with the given 
118
     * {@link IWorkbenchPartReference}.
119
     * 
120
     * @param viewer The viewer to register.
121
     * @param partRef The reference to the part that (indirectly) contains the
122
     *                viewer.
123
     */
124
    private void registerGraphicalViewer(GraphicalViewer viewer, 
125
            IWorkbenchPartReference partRef) {
126
127
        IWorkbenchPart part = partRef.getPart(false);
128
        if (part != null && partRef instanceof WorkbenchPartReference) {
129
            if (viewer != null) {
130
                // Note the viewer on the component
131
                Control partContent = 
132
                    ((WorkbenchPartReference)partRef).getPane().getControl();
133
134
                if (partContent != null && !partContent.isDisposed()) {
135
                    partContent.setData(Startup.TEST_GEF_VIEWER_DATA_KEY,
136
                            viewer);
137
                }
138
            }
139
        }
140
    }
141
}
(-)a/org.eclipse.jubula.rc.rcp/src/org/eclipse/jubula/rc/rcp/gef/util/FigureCanvasUtil.java (-114 lines)
Lines 1-114 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2010 BREDEX GmbH.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     BREDEX GmbH - initial API and implementation and/or initial documentation
10
 *******************************************************************************/
11
package org.eclipse.jubula.rc.rcp.gef.util;
12
13
import org.eclipse.draw2d.FigureCanvas;
14
import org.eclipse.draw2d.geometry.Point;
15
import org.eclipse.gef.EditPart;
16
import org.eclipse.gef.EditPartViewer;
17
import org.eclipse.gef.GraphicalViewer;
18
import org.eclipse.gef.RootEditPart;
19
import org.eclipse.jubula.rc.rcp.accessor.Startup;
20
import org.eclipse.jubula.rc.rcp.gef.factory.DefaultEditPartAdapterFactory;
21
import org.eclipse.jubula.rc.rcp.gef.identifier.IEditPartIdentifier;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Display;
24
25
26
/**
27
 * Utility class for interacting with a FigureCanvas.
28
 * 
29
 * @author BREDEX GmbH
30
 * @created Jun 26, 2009
31
 */
32
public class FigureCanvasUtil {
33
34
    /**
35
     * Private constructor
36
     */
37
    private FigureCanvasUtil() {
38
    // Nothing to initialize
39
    }
40
41
    /**
42
     * 
43
     * @param figureCanvas
44
     *            The canvas for which to find the viewer.
45
     * @return the graphical viewer associated with the given canvas, or
46
     *         <code>null</code> if no such viewer could be found.
47
     */
48
    public static GraphicalViewer getViewer(FigureCanvas figureCanvas) {
49
        Composite parent = figureCanvas;
50
        while (parent != null
51
                && !(parent.getData(Startup.TEST_GEF_VIEWER_DATA_KEY) 
52
                        instanceof GraphicalViewer)) {
53
            parent = parent.getParent();
54
        }
55
56
        if (parent != null) {
57
58
            return (GraphicalViewer)parent
59
                    .getData(Startup.TEST_GEF_VIEWER_DATA_KEY);
60
        }
61
62
        return null;
63
    }
64
65
    /**
66
     * 
67
     * @param display The display containing the edit part to find.
68
     * @param viewer The viewer containing the edit part to find.
69
     * @return the edit part for the viewer at the current mouse pointer
70
     *         coordinates, or <code>null</code> if no such edit part can be
71
     *         found.
72
     */
73
    public static EditPart findAtCurrentMousePosition(
74
            Display display, EditPartViewer viewer) {
75
        Point cursorLocation = new Point(display.map(null, viewer.getControl(),
76
                display.getCursorLocation()));
77
        EditPart editPart = viewer.findObjectAt(cursorLocation);
78
        EditPart primaryEditPart = getPrimaryEditPart(editPart, viewer
79
                .getRootEditPart());
80
81
        return primaryEditPart;
82
    }
83
84
    /**
85
     * Searches the path to root for the first element considered to be testable
86
     * by Jubula. Testable in this case means that an ID can be acquired for
87
     * the edit part.
88
     * 
89
     * @param editPart
90
     *            The starting edit part.
91
     * @param root
92
     *            The root for <code>editPart</code>. This is used to avoid
93
     *            identifying the root edit part as the primary edit part.
94
     * @return the first edit part on the path to root that has an ID.
95
     */
96
    public static EditPart getPrimaryEditPart(final EditPart editPart,
97
            RootEditPart root) {
98
99
        EditPart currentEditPart = editPart;
100
101
        while (currentEditPart != root.getContents() 
102
                && currentEditPart != null) {
103
            IEditPartIdentifier identifier = DefaultEditPartAdapterFactory
104
                    .loadFigureIdentifier(currentEditPart);
105
            if (identifier != null) {
106
                return currentEditPart;
107
            }
108
            currentEditPart = currentEditPart.getParent();
109
        }
110
111
        return null;
112
    }
113
114
}
(-)a/org.eclipse.jubula.releng.server/pom.xml (-2 / +3 lines)
Lines 23-29 Link Here
23
        <module>../org.eclipse.jubula.rc.common.agent</module>
23
        <module>../org.eclipse.jubula.rc.common.agent</module>
24
        <module>../org.eclipse.jubula.rc.swing</module>
24
        <module>../org.eclipse.jubula.rc.swing</module>
25
        <module>../org.eclipse.jubula.rc.swt</module>
25
        <module>../org.eclipse.jubula.rc.swt</module>
26
        <module>../org.eclipse.jubula.rc.rcp</module>
26
        <module>../org.eclipse.jubula.rc.rcp.e3</module>
27
        <module>../org.eclipse.jubula.rc.rcp.e3.specific</module>
28
        <module>../org.eclipse.jubula.rc.rcp.e4.compat</module>
27
        <module>../org.eclipse.jubula.app.autrun</module>
29
        <module>../org.eclipse.jubula.app.autrun</module>
28
        <module>../org.eclipse.jubula.app.autagent</module>
30
        <module>../org.eclipse.jubula.app.autagent</module>
29
        <module>../org.eclipse.jubula.product.autagent.start</module>
31
        <module>../org.eclipse.jubula.product.autagent.start</module>
30
- 

Return to bug 379217