JBoss Tools SVN: r37650 - trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-01-04 20:37:04 -0500 (Wed, 04 Jan 2012)
New Revision: 37650
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java
Log:
https://issues.jboss.org/browse/JBIDE-10585 Deadlock when building JSF project
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java 2012-01-05 00:17:16 UTC (rev 37649)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ELReference.java 2012-01-05 01:37:04 UTC (rev 37650)
@@ -266,7 +266,7 @@
if(markers.isEmpty()) {
markerArray = EMPTY_MARKER_ARRAY;
} else {
- markerArray = markers.toArray(new IMarker[0]);
+ markerArray = markers.toArray(new IMarker[markers.size()]);
}
}
return markerArray;
@@ -293,17 +293,22 @@
/**
* Removes all markers from this EL.
*/
- public synchronized void deleteMarkers() {
- initMarkers();
- for (IMarker marker : markers) {
+ public void deleteMarkers() {
+ IMarker[] aMarkers = null;
+ synchronized (this) {
+ initMarkers();
+ aMarkers = getMarkers();
+ markers.clear();
+ markerArray = null;
+ }
+
+ for (IMarker marker : aMarkers) {
try {
marker.delete();
} catch (CoreException e) {
ELCorePlugin.getDefault().logError(e);
}
}
- markers.clear();
- markerArray = null;
}
/**
12 years, 11 months
JBoss Tools SVN: r37649 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-01-04 19:17:16 -0500 (Wed, 04 Jan 2012)
New Revision: 37649
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
cleaned up the code
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2012-01-04 21:39:38 UTC (rev 37648)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2012-01-05 00:17:16 UTC (rev 37649)
@@ -362,7 +362,6 @@
IProject pr = file.getProject();
if(!validationHelper.getValidationContextManager().projectHasBeenValidated(this, pr)) {
filesToValidate.add(file);
-// removeAllMessagesFromResource(file);
}
}
}
@@ -2536,5 +2535,4 @@
protected String getPreferencePageId() {
return PREFERENCE_PAGE_ID;
}
-
}
\ No newline at end of file
12 years, 11 months
JBoss Tools SVN: r37648 - in trunk: jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-01-04 16:39:38 -0500 (Wed, 04 Jan 2012)
New Revision: 37648
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationContextManager.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidatorManager.java
trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/validation/KBValidationTest.java
Log:
https://issues.jboss.org/browse/JBIDE-10582 ConcurrentModificationException during building CDI project
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationContextManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationContextManager.java 2012-01-04 16:43:47 UTC (rev 37647)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationContextManager.java 2012-01-04 21:39:38 UTC (rev 37648)
@@ -25,11 +25,9 @@
void addProject(IProject project);
- void clearAll();
-
void clearRegisteredFiles();
- void clearAllResourceLinks();
+ void clearAllResourceLinks(Set<IProject> rootProjects);
Set<IFile> getRemovedFiles();
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java 2012-01-04 16:43:47 UTC (rev 37647)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java 2012-01-04 21:39:38 UTC (rev 37648)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.validation;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -42,10 +43,7 @@
init(project);
}
- public void init(IProject project) {
- projectTree.clear();
- validators.clear();
- validationResourceRegister = null;
+ private synchronized void inintConfigurationElements() {
if(ALL_VALIDATORS == null) {
// Load all the validators
ALL_VALIDATORS = new ArrayList<IConfigurationElement>();
@@ -62,7 +60,15 @@
}
}
}
+ }
+ public void init(IProject project) {
+ projectTree.clear();
+ validators.clear();
+ validationResourceRegister = null;
+
+ inintConfigurationElements();
+
List<IValidator> dependentValidators = new ArrayList<IValidator>();
List<IValidator> allValidators = new ArrayList<IValidator>();
for (IConfigurationElement element : ALL_VALIDATORS) {
@@ -150,18 +156,6 @@
return validators;
}
- /* (non-Javadoc)
- * @see org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAll()
- */
- public void clearAll() {
- clearRegisteredFiles();
- for (IValidatingProjectTree tree : projectTree.values()) {
- for (IValidatingProjectSet brunch : tree.getBrunches().values()) {
- brunch.getRootContext().clearAll();
- }
- }
- }
-
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.validation.IValidationContext#clearRegisteredFiles()
@@ -241,10 +235,14 @@
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.validation.IValidationContextManager#clearAllResourceLinks()
*/
- public void clearAllResourceLinks() {
- for (IValidatingProjectTree tree : projectTree.values()) {
- for (IValidatingProjectSet brunch : tree.getBrunches().values()) {
- brunch.getRootContext().clearAll();
+ public void clearAllResourceLinks(Set<IProject> rootProjects) {
+ Collection<IValidatingProjectTree> trees = projectTree.values();
+ for (IProject rootProject : rootProjects) {
+ for (IValidatingProjectTree tree : trees) {
+ IValidatingProjectSet brunch = tree.getBrunches().get(rootProject);
+ if(brunch!=null) {
+ brunch.getRootContext().clearAll();
+ }
}
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidatorManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidatorManager.java 2012-01-04 16:43:47 UTC (rev 37647)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidatorManager.java 2012-01-04 21:39:38 UTC (rev 37648)
@@ -80,7 +80,7 @@
if(!changedFiles.isEmpty() || validationHelper.getURIs().length > 0) {
status = validate(changedFiles, validationHelper, reporter, rootProjects);
} else if(!validationContextManager.getRegisteredFiles().isEmpty()) {
- validationContextManager.clearAllResourceLinks();
+ validationContextManager.clearAllResourceLinks(rootProjects);
status = validateAll(validationHelper, reporter, rootProjects);
}
} finally {
Modified: trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/validation/KBValidationTest.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/validation/KBValidationTest.java 2012-01-04 16:43:47 UTC (rev 37647)
+++ trunk/jst/tests/org.jboss.tools.jst.web.kb.test/src/org/jboss/tools/jst/web/kb/test/validation/KBValidationTest.java 2012-01-04 21:39:38 UTC (rev 37648)
@@ -73,11 +73,9 @@
}
public void addProject(IProject project) {
}
- public void clearAll() {
- }
public void clearRegisteredFiles() {
}
- public void clearAllResourceLinks() {
+ public void clearAllResourceLinks(Set<IProject> projects) {
}
public Set<IFile> getRemovedFiles() {
return null;
12 years, 11 months
JBoss Tools SVN: r37647 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-01-04 11:43:47 -0500 (Wed, 04 Jan 2012)
New Revision: 37647
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build-dependencies-pom.xml
Log:
aggregation pom for the portlet dependencies
Added: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build-dependencies-pom.xml
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build-dependencies-pom.xml (rev 0)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/build-dependencies-pom.xml 2012-01-04 16:43:47 UTC (rev 37647)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>portlet.dependencies.build</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Build portlet dependencies</name>
+ <packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
+
+ <properties>
+ <skipTests>true</skipTests>
+ <swtbot.test.skip>true</swtbot.test.skip>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+
+ <modules>
+ <module>../../../archives/features/org.jboss.ide.eclipse.archives.feature</module>
+ <module>../../../archives/features/org.jboss.ide.eclipse.archives.source.feature</module>
+ <module>../../../archives/plugins</module>
+ <module>../../../as/features/org.jboss.ide.eclipse.as.archives.integration.feature</module>
+ <module>../../../as/features/org.jboss.ide.eclipse.as.feature</module>
+ <module>../../../as/features/org.jboss.ide.eclipse.as.jmx.integration.feature</module>
+ <module>../../../as/features/org.jboss.ide.eclipse.as.server.rse.integration.feature</module>
+ <module>../../../as/features/org.jboss.ide.eclipse.as.serverAdapter.wtp.feature</module>
+ <module>../../../as/features/org.jboss.ide.eclipse.as.source.feature</module>
+ <module>../../../as/plugins</module>
+ <module>../../../build/parent</module>
+ <module>../../../common/features/org.jboss.tools.common.all.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.all.source.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.core.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.jdt.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.jdt.source.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.mylyn.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.mylyn.source.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.text.ext.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.ui.feature</module>
+ <module>../../../common/features/org.jboss.tools.common.verification.feature</module>
+ <module>../../../common/plugins</module>
+ <module>../../../hibernatetools/features/org.hibernate.eclipse.feature</module>
+ <module>../../../hibernatetools/plugins</module>
+ <module>../../../jmx/features/org.jboss.tools.jmx.feature</module>
+ <module>../../../jmx/plugins</module>
+ <module>../../../jsf/features/org.jboss.tools.jsf.feature</module>
+ <module>../../../jsf/features/org.jboss.tools.richfaces.feature</module>
+ <module>../../../jsf/plugins</module>
+ <module>../../../jsf/tests/org.jboss.tools.jsf.ui.bot.test</module>
+ <module>../../../jst/features/org.jboss.tools.jst.feature</module>
+ <module>../../../jst/features/org.jboss.tools.jst.web.tiles.feature</module>
+ <module>../../../jst/plugins</module>
+ <module>../../../jst/tests/org.jboss.tools.jst.ui.bot.test</module>
+ <module>../../../jst/tests/org.jboss.tools.jst.ui.firstrun.bot.test</module>
+ <module>../../../seam/features/org.jboss.tools.seam.feature</module>
+ <module>../../../seam/plugins</module>
+ <module>../../../tests</module>
+ <module>../../../vpe/features/org.jboss.tools.vpe.browsersim.feature</module>
+ <module>../../../vpe/features/org.jboss.tools.vpe.feature</module>
+ <module>../../../vpe/features/org.jboss.tools.xulrunner.feature</module>
+ <module>../../../vpe/plugins</module>
+ <module>../../../vpe/tests/org.jboss.tools.vpe.ui.bot.test</module>
+ </modules>
+</project>
12 years, 11 months
JBoss Tools SVN: r37646 - in trunk/vpe/plugins: org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-01-04 10:47:31 -0500 (Wed, 04 Jan 2012)
New Revision: 37646
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/BrowserSimBrowser.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/IBrowserSimBrowserFactory.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/back-selected.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/back.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/forward-selected.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/forward.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/iPhone3.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/refresh-selected.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/refresh.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/stop-selected.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/stop.png
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/native_skin/
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/ControlHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/AppleIPhone3Skin.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/BrowserSimSkin.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/NativeSkin.java
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/icons/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/AbstractWebKitBrowser.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/WebKitBrowserFactory.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/DevicesListStorage.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/util/ResourcesUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-10431 : browsersim should be sexy
- created interfaces for skins
- created native skin
- created iPhone3 skin
- refactored code
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/DevicesListStorage.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/DevicesListStorage.java 2012-01-04 15:23:01 UTC (rev 37645)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/DevicesListStorage.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -30,7 +30,7 @@
*/
public class DevicesListStorage {
- private static final String DEFAULT_PREFERENCES_RESOURCE = "/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg";
+ private static final String DEFAULT_PREFERENCES_RESOURCE = "config/devices.cfg";
private static final String USER_PREFERENCES_FOLDER = "org.jboss.tools.vpe.browsersim";
private static final String USER_PREFERENCES_FILE = "devices.cfg";
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/back-selected.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/back-selected.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/back.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/back.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/forward-selected.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/forward-selected.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/forward.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/forward.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/iPhone3.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/iPhone3.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/refresh-selected.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/refresh-selected.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/refresh.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/refresh.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/stop-selected.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/stop-selected.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/stop.png
===================================================================
(Binary files differ)
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/iphone_skin/stop.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2012-01-04 15:23:01 UTC (rev 37645)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/BrowserSim.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -17,6 +17,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
+import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.browser.LocationListener;
import org.eclipse.swt.browser.ProgressEvent;
@@ -27,47 +28,35 @@
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.jboss.tools.vpe.browsersim.browser.AbstractWebKitBrowser;
+import org.jboss.tools.vpe.browsersim.browser.BrowserSimBrowser;
import org.jboss.tools.vpe.browsersim.browser.WebKitBrowserFactory;
import org.jboss.tools.vpe.browsersim.model.Device;
import org.jboss.tools.vpe.browsersim.model.DeviceOrientation;
import org.jboss.tools.vpe.browsersim.model.DevicesList;
import org.jboss.tools.vpe.browsersim.model.DevicesListHolder;
import org.jboss.tools.vpe.browsersim.model.DevicesListStorage;
-import org.jboss.tools.vpe.browsersim.util.ResourcesUtil;
+import org.jboss.tools.vpe.browsersim.ui.skin.BrowserSimSkin;
+import org.jboss.tools.vpe.browsersim.ui.skin.NativeSkin;
/**
* @author Yahor Radtsevich (yradtsevich)
*/
public class BrowserSim implements Runnable {
private static final String DEFAULT_URL = "about:blank"; //"http://www.w3schools.com/js/tryit_view.asp?filename=try_nav_useragent"; //$NON-NLS-1$
- private AbstractWebKitBrowser browser;
+ private BrowserSimBrowser browser;
private Display display;
private Shell shell;
- private Text locationText;
- private Label statusLabel;
- private ProgressBar progressBar;
private String initialUrl;
private Menu devicesMenu;
private DevicesListHolder devicesListHolder;
private DeviceOrientation deviceOrientation;
+ private BrowserSimSkin skin;
public static void main(String[] args) {
String initialUrl;
@@ -93,46 +82,15 @@
@Override
public void run() {
- shell = new Shell(display);
- shell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (devicesListHolder != null) {
- DevicesListStorage.saveUserDefinedDevicesList(devicesListHolder.getDevicesList());
- }
- }
- });
- shell.setText(Messages.BrowserSim_BROWSER_SIM);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- shell.setLayout(gridLayout);
- Menu appMenuBar = display.getMenuBar();
- if (appMenuBar == null) {
- appMenuBar = new Menu(shell, SWT.BAR);
- shell.setMenuBar(appMenuBar);
- }
+ skin = new NativeSkin();//new AppleIPhone3Skin();
+ skin.setBrowserFactory(new WebKitBrowserFactory());
- ToolBar toolbar = createControlBar();
- GridData data = new GridData();
- data.horizontalSpan = 3;
- toolbar.setLayoutData(data);
-
- Label labelAddress = new Label(shell, SWT.NONE);
- labelAddress.setText(Messages.BrowserSim_ADDRESS);
-
- locationText = new Text(shell, SWT.BORDER);
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = 2;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = 0;
- locationText.setLayoutData(data);
-
try {
- browser = WebKitBrowserFactory.createWebKitBrowser(shell, SWT.NONE);
+ skin.createControls(display);
} catch (SWTError e) {
System.out.println(Messages.BrowserSim_COULD_NOT_INSTANTIATE_WEBKIT_BROWSER + e.getMessage());
- MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+ MessageBox messageBox = new MessageBox(new Shell(display), SWT.OK | SWT.ICON_ERROR);
messageBox.setText("Error");
messageBox.setMessage(Messages.BrowserSim_COULD_NOT_INSTANTIATE_WEBKIT_BROWSER + e.getMessage());
messageBox.open();
@@ -140,165 +98,90 @@
display.dispose();
return;
}
-
- data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.horizontalSpan = 3;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- browser.setLayoutData(data);
-
- statusLabel = new Label(shell, SWT.NONE);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
- data.widthHint = 0;
- statusLabel.setLayoutData(data);
-
- progressBar = new ProgressBar(shell, SWT.NONE);
- data = new GridData();
- data.horizontalAlignment = GridData.END;
- progressBar.setLayoutData(data);
-
+
+ shell = skin.getShell();
+ shell.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (devicesListHolder != null) {
+ DevicesListStorage.saveUserDefinedDevicesList(devicesListHolder.getDevicesList());
+ }
+ }
+ });
+ shell.setText(Messages.BrowserSim_BROWSER_SIM);
+
+ browser = skin.getBrowser();
+
browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {
- if (event.total == 0) return;
- int ratio = event.current * 100 / event.total;
- progressBar.setSelection(ratio);
+ if (event.total == 0) return;
+ int ratio = event.current * 100 / event.total;
+ skin.progressChanged(ratio);
}
public void completed(ProgressEvent event) {
- progressBar.setSelection(0);
+ skin.progressChanged(-1);
}
});
browser.addStatusTextListener(new StatusTextListener() {
public void changed(StatusTextEvent event) {
- statusLabel.setText(event.text);
+ skin.statusTextChanged(event.text);
}
});
browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
if (event.top) {
- locationText.setText(event.location);
+ skin.locationChanged(event.location);
}
+ }
+ public void changing(LocationEvent event) {
+ }
+ });
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalSpan = 3;
+ data.grabExcessHorizontalSpace = true;
+ data.grabExcessVerticalSpace = true;
+ browser.setLayoutData(data);
+
+ browser.addLocationListener(new LocationListener() {
+ public void changed(LocationEvent event) {
initOrientation(deviceOrientation.getOrientationAngle());
}
public void changing(LocationEvent event) {
}
});
+ skin.setControlHandler(new ControlHandlerImpl(browser));
+
devicesListHolder = new DevicesListHolder();
- fillMenuBar(appMenuBar);
+ Menu appMenuBar = skin.getMenuBar();
+ if (appMenuBar != null) {
+ fillMenuBar(appMenuBar);
+ }
- locationText.addListener(SWT.DefaultSelection, new Listener() {
- public void handleEvent(Event e) {
- browser.setUrl(locationText.getText());
- }
- });
+ DevicesList devicesList = DevicesListStorage.loadUserDefinedDevicesList();
+ if (devicesList == null) {
+ devicesList = DevicesListStorage.loadDefaultDevicesList();
+ }
- DevicesList devicesList = devicesListHolder.getDevicesList();
+ devicesListHolder.setDevicesList(devicesList);
+ devicesListHolder.notifyObservers();
+
if (devicesList != null && devicesList.getDevices() != null
&& devicesList.getSelectedDeviceIndex() < devicesList.getDevices().size()) {
setDevice(devicesList.getDevices().get(devicesList.getSelectedDeviceIndex()));
}
- shell.open();
+
browser.setUrl(initialUrl);
- while (!shell.isDisposed()) {
+ while (!this.shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
- public ToolBar createControlBar() {
- ToolBar toolbar = new ToolBar(shell, SWT.NONE);
- ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
-// itemBack.setText("Back");
- itemBack.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- browser.back();
- }
- });
-
- ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
-// itemForward.setText("Forward");
- itemForward.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- browser.forward();
- }
- });
-
- ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
-// itemStop.setText("Stop");
- itemStop.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- browser.stop();
- }
- });
-
- ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
-// itemRefresh.setText("Refresh");
- itemRefresh.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- browser.refresh();
- }
- });
-
- ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
-// itemGo.setText("Go");
- itemGo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- browser.setUrl(locationText.getText());
- }
- });
-
- ToolItem itemRotateCounterclockwise = new ToolItem(toolbar, SWT.PUSH);
-// itemGo.setText("Rotate Counterclockwise");
- itemRotateCounterclockwise.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- rotateDevice(true);
- }
- });
-
- ToolItem itemRotateClockwise = new ToolItem(toolbar, SWT.PUSH);
-// itemGo.setText("Rotate Clockwise");
- itemRotateClockwise.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- rotateDevice(false);
- }
- });
-
- final Image imageBack = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/nav_backward.gif")); //$NON-NLS-1$
- final Image imageForward = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/nav_forward.gif")); //$NON-NLS-1$
- final Image imageStop = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/nav_stop.gif")); //$NON-NLS-1$
- final Image imageRefresh = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/nav_refresh.gif")); //$NON-NLS-1$
- final Image imageGo = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/nav_go.gif")); //$NON-NLS-1$
- final Image imageRotateClockwise = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/rotate_clockwise.png")); //$NON-NLS-1$
- final Image imageRotateCounterclockwise = new Image(display, ResourcesUtil.getResourceAsStream("/org/jboss/tools/vpe/browsersim/resources/icons/rotate_counterclockwise.png")); //$NON-NLS-1$
-
- itemBack.setImage(imageBack);
- itemForward.setImage(imageForward);
- itemStop.setImage(imageStop);
- itemRefresh.setImage(imageRefresh);
- itemGo.setImage(imageGo);
- itemRotateClockwise.setImage(imageRotateClockwise);
- itemRotateCounterclockwise.setImage(imageRotateCounterclockwise);
-
- shell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- imageBack.dispose();
- imageForward.dispose();
- imageStop.dispose();
- imageRefresh.dispose();
- imageGo.dispose();
- imageRotateClockwise.dispose();
- imageRotateCounterclockwise.dispose();
- }
- });
-
- return toolbar;
- }
-
public void fillMenuBar(Menu appMenuBar) {
Menu file = createDropDownMenu(appMenuBar, Messages.BrowserSim_FILE);
MenuItem exit = new MenuItem(file, SWT.PUSH);
@@ -325,15 +208,7 @@
});
}
});
-
- DevicesList devicesList = DevicesListStorage.loadUserDefinedDevicesList();
- if (devicesList == null) {
- devicesList = DevicesListStorage.loadDefaultDevicesList();
- }
-
- devicesListHolder.setDevicesList(devicesList);
- devicesListHolder.notifyObservers();
-
+
new MenuItem(devicesMenu, SWT.BAR);
MenuItem manageDevicesMenuItem = new MenuItem(devicesMenu, SWT.PUSH);
manageDevicesMenuItem.setText(Messages.BrowserSim_MORE);
@@ -389,13 +264,15 @@
}
public void setDevice(final Device device) {
- for (MenuItem menuItem : devicesMenu.getItems()) {
- if (menuItem.getData() instanceof Device) {
- menuItem.setSelection(menuItem.getData() == device);
+ if (devicesMenu != null) {
+ for (MenuItem menuItem : devicesMenu.getItems()) {
+ if (menuItem.getData() instanceof Device) {
+ menuItem.setSelection(menuItem.getData() == device);
+ }
}
}
- setBrowserSize(device.getWidth(), device.getHeight());
+ skin.setBrowserSize(device.getWidth(), device.getHeight());
deviceOrientation = new DeviceOrientation(device.getWidth() < device.getHeight()
? DeviceOrientation.PORTRAIT
: DeviceOrientation.LANDSCAPE);
@@ -408,9 +285,9 @@
if (orientationAngle == DeviceOrientation.LANDSCAPE
|| orientationAngle == DeviceOrientation.LANDSCAPE_INVERTED) {
- setBrowserSize(maxSize, minSize);
+ skin.setBrowserSize(maxSize, minSize);
} else {
- setBrowserSize(minSize, maxSize);
+ skin.setBrowserSize(minSize, maxSize);
}
fireOrientationChangeEvent(orientationAngle);
@@ -420,62 +297,6 @@
browser.setDefaultUserAgent(device.getUserAgent());
browser.refresh();
}
-
- private void setBrowserSize(int width, int height) {
- GridData data = (GridData) browser.getLayoutData();
-
- Rectangle clientArea = getMonitorClientArea();
- int shellWidthHint = SWT.DEFAULT;
- if (width != Device.DEFAULT_SIZE) {
- data.widthHint = width;
- } else if (data.widthHint == SWT.DEFAULT) {
- shellWidthHint = clientArea.width;
- }
- int shellHeightHint = SWT.DEFAULT;
- if (height != Device.DEFAULT_SIZE) {
- data.heightHint = height;
- } else if (data.heightHint == SWT.DEFAULT) {
- shellHeightHint = clientArea.height;
- }
- Point shellSize = shell.computeSize(shellWidthHint, shellHeightHint);
- shellSize.x = Math.min(shellSize.x, clientArea.width);
- shellSize.y = Math.min(shellSize.y, clientArea.height);
- shell.setSize(shellSize);
-
- Rectangle shellBounds = shell.getBounds();
- int bottomOverlap = shellBounds.y + shellBounds.height - (clientArea.y + clientArea.height);
- if (bottomOverlap > 0) {
- if (shellBounds.y > bottomOverlap) {
- shellBounds.y -= bottomOverlap;
- } else {
- shellBounds.y = 0;
- }
- }
-
- int rightOverlap = shellBounds.x + shellBounds.width - (clientArea.x + clientArea.width);
- if (rightOverlap > 0) {
- if (shellBounds.x > rightOverlap) {
- shellBounds.x -= rightOverlap;
- } else {
- shellBounds.x = 0;
- }
- }
-
- shell.setBounds(shellBounds);
- }
-
- private Rectangle getMonitorClientArea() {
- Rectangle clientArea = shell.getMonitor().getClientArea();
-
- /* on Linux returned monitor client area may be bigger
- * than the monitor bounds when multiple monitors are used.
- * The following code fixes this */
- Rectangle bounds = shell.getMonitor().getBounds();
- clientArea.width = Math.min(clientArea.width, bounds.width);
- clientArea.height = Math.min(clientArea.height, bounds.height);
-
- return clientArea;
- }
private void initOrientation(int orientation) {
browser.execute("window.onorientationchange = null;"
@@ -499,4 +320,52 @@
deviceOrientation.turnDevice(counterclockwise);
deviceOrientation.notifyObservers();
}
+
+ class ControlHandlerImpl implements ControlHandler {
+ private Browser browser;
+
+ public ControlHandlerImpl(Browser browser) {
+ this.browser = browser;
+ }
+
+ @Override
+ public void goBack() {
+ browser.back();
+ }
+
+ @Override
+ public void goForward() {
+ browser.forward();
+ }
+
+ @Override
+ public void goHome() {
+ browser.setUrl("about:blank");//XXX
+ }
+
+ @Override
+ public void goToAddress(String address) {
+ browser.setUrl(address);
+ }
+
+ @Override
+ public void showContextMenu() {
+ // TODO Auto-generated method stub//XXX
+ }
+
+ @Override
+ public void rotate(boolean counterclockwise) {
+ BrowserSim.this.rotateDevice(counterclockwise);
+ }
+
+ @Override
+ public void stop() {
+ browser.stop();
+ }
+
+ @Override
+ public void refresh() {
+ browser.refresh();
+ }
+ }
}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/ControlHandler.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/ControlHandler.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/ControlHandler.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.browsersim.ui;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface ControlHandler {
+ void goBack();
+ void goForward();
+ void goHome();
+ void goToAddress(String address);
+ void showContextMenu();
+ void rotate(boolean counterclockwise);
+ void stop();
+ void refresh();
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java 2012-01-04 15:23:01 UTC (rev 37645)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.vpe.browsersim.ui;
import org.eclipse.swt.SWT;
@@ -19,6 +29,9 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.tools.vpe.browsersim.model.Device;
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
public class EditDeviceDialog extends Dialog {
protected Device resultDevice;
protected Device initialDevice;
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/AppleIPhone3Skin.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/AppleIPhone3Skin.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/AppleIPhone3Skin.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.browsersim.ui.skin;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.vpe.browsersim.browser.BrowserSimBrowser;
+import org.jboss.tools.vpe.browsersim.browser.IBrowserSimBrowserFactory;
+import org.jboss.tools.vpe.browsersim.ui.ControlHandler;
+import org.jboss.tools.vpe.browsersim.util.ResourcesUtil;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class AppleIPhone3Skin implements BrowserSimSkin {
+ private static final Point FORWARD_LOCATION = new Point(115, 571);
+ private static final Rectangle BROWSER_RECTANGLE = new Rectangle(33, 206, 320, 355);
+ private static final Rectangle URL_RECTANGLE = new Rectangle(45, 178, 245, 17);
+ private static final int URL_BACKGROUND_COLOR = SWT.COLOR_WHITE;
+ private static final Rectangle PROGRESS_BAR_RECTANGLE = new Rectangle(40, 200, 277, 5);
+ private static final Point STOP_LOCATION = new Point(294, 178);
+ private static final Point REFRESH_LOCATION = new Point(323, 173);
+ private static final Point BACK_LOCATION = new Point(52, 571);
+
+ private static final int[] VISIBLE_REGION = {
+ 62, 3, 257, 3, 258, 2, 258, 0, 320, 0, 320, 2, 321, 3, 330, 3, 331, 4, 334, 4, 335, 5, 338, 5, 339, 6, 341, 6,
+ 342, 7, 344, 7, 345, 8, 347, 8, 348, 9, 349, 9, 350, 10, 351, 10, 353, 12, 354, 12, 355, 13, 356, 13, 359, 16,
+ 360, 16, 368, 24, 368, 25, 371, 28, 371, 29, 373, 31, 373, 32, 374, 33, 374, 34, 375, 35, 375, 36, 376, 37,
+ 376, 38, 377, 39, 377, 41, 378, 42, 378, 43, 379, 44, 379, 46, 380, 47, 380, 50, 381, 51, 381, 54, 382, 55, 382,
+ 60, 383, 61, 383, 668, 382, 669, 382, 673, 381, 674, 381, 678, 380, 679, 380, 682, 379, 683, 379, 685, 378, 686, 378,
+ 687, 377, 688, 377, 690, 376, 691, 376, 692, 375, 693, 375, 694, 374, 695, 374, 696, 373, 697, 373, 698, 371, 700, 371,
+ 701, 368, 704, 368, 705, 360, 713, 359, 713, 356, 716, 355, 716, 354, 717, 353, 717, 351, 719, 350, 719, 349, 720, 348,
+ 720, 347, 721, 345, 721, 344, 722, 341, 722, 340, 723, 337, 723, 336, 724, 334, 724, 333, 725, 329, 725, 328, 726, 59,
+ 726, 58, 725, 54, 725, 53, 724, 47, 724, 46, 723, 44, 723, 43, 722, 41, 722, 40, 721, 39, 721, 38, 720, 37, 720, 36, 719,
+ 35, 719, 34, 718, 33, 718, 31, 716, 30, 716, 28, 714, 27, 714, 17, 704, 17, 703, 14, 700, 14, 699, 13, 698, 13, 697, 12,
+ 696, 12, 695, 11, 694, 11, 693, 10, 692, 10, 691, 9, 690, 9, 689, 8, 688, 8, 686, 7, 685, 7, 683, 6, 682, 6, 680, 5, 679,
+ 5, 676, 4, 675, 4, 670, 3, 669, 3, 660, 2, 659, 2, 258, 1, 257, 1, 256, 0, 255, 0, 220, 1, 219, 1, 212, 2, 211, 2, 177, 1,
+ 176, 1, 169, 0, 168, 0, 132, 2, 130, 2, 108, 3, 107, 2, 106, 1, 106, 1, 74, 2, 73, 2, 67, 3, 66, 3, 59, 4, 58, 4, 54, 5, 53,
+ 5, 50, 6, 49, 6, 47, 7, 46, 7, 44, 8, 43, 8, 41, 9, 40, 9, 39, 10, 38, 10, 37, 11, 36, 11, 35, 12, 34, 12, 33, 13, 32, 13, 31,
+ 14, 30, 14, 29, 17, 26, 17, 25, 26, 16, 27, 16, 30, 13, 31, 13, 33, 11, 34, 11, 35, 10, 36, 10, 37, 9, 38, 9, 39, 8, 41, 8,
+ 42, 7, 43, 7, 44, 6, 47, 6, 48, 5, 50, 5, 51, 4, 61, 4
+ };
+
+ private IBrowserSimBrowserFactory browserFactory;
+ private Shell shell;
+ private BrowserSimBrowser browser;
+ private Display display;
+ private ControlHandler controlHandler;
+ private Text locationText;
+ private ProgressBar progressBar;
+
+ @Override
+ public void setBrowserFactory(IBrowserSimBrowserFactory browserFactory) {
+ this.browserFactory = browserFactory;
+ }
+
+ @Override
+ public void createControls(Display display) {
+ this.display = display;
+ shell = new Shell(display, SWT.NO_TRIM | SWT.NO_BACKGROUND);
+ Region region = new Region();
+ region.add(VISIBLE_REGION);
+ shell.setRegion(region);
+ final Image shellImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/iPhone3.png"));
+ final Image backImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/back.png"));
+ final Image backSelectedImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/back-selected.png"));
+ final Image forwardImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/forward.png"));
+ final Image forwardSelectedImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/forward-selected.png"));
+ final Image refreshImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/refresh.png"));
+ final Image refreshSelectedImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/refresh-selected.png"));
+ final Image stopImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/stop.png"));
+ final Image stopSelectedImage = new Image(display, ResourcesUtil.getResourceAsStream("iphone_skin/stop-selected.png"));
+ shell.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ shellImage.dispose();
+ backImage.dispose();
+ backSelectedImage.dispose();
+ forwardImage.dispose();
+ forwardSelectedImage.dispose();
+ refreshImage.dispose();
+ refreshSelectedImage.dispose();
+ stopImage.dispose();
+ stopSelectedImage.dispose();
+ }
+ });
+
+ PhoneButton backButton = new PhoneButton(shell, backImage, backSelectedImage);
+ backButton.setLocation(BACK_LOCATION);
+ backButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ controlHandler.goBack();
+ };
+ });
+
+ PhoneButton forwardButton = new PhoneButton(shell, forwardImage, forwardSelectedImage);
+ forwardButton.setLocation(FORWARD_LOCATION);
+ forwardButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ controlHandler.goForward();
+ }
+ });
+
+ PhoneButton refreshButton = new PhoneButton(shell, refreshImage, refreshSelectedImage);
+ refreshButton.setLocation(REFRESH_LOCATION);
+ refreshButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ controlHandler.refresh();
+ }
+ });
+ PhoneButton stopButton = new PhoneButton(shell, stopImage, stopSelectedImage);
+ stopButton.setLocation(STOP_LOCATION);
+ stopButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ controlHandler.stop();
+ }
+ });
+
+ Listener l = new Listener() {
+ Point origin;
+
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case SWT.MouseDown:
+ origin = new Point(e.x, e.y);
+ break;
+ case SWT.MouseUp:
+ origin = null;
+ break;
+ case SWT.MouseMove:
+ if (origin != null) {
+ Point p = AppleIPhone3Skin.this.display.map(shell, null, e.x, e.y);
+ shell.setLocation(p.x - origin.x, p.y - origin.y);
+ }
+ break;
+ }
+ }
+ };
+
+ shell.addListener(SWT.MouseDown, l);
+ shell.addListener(SWT.MouseUp, l);
+ shell.addListener(SWT.MouseMove, l);
+ // define a region
+ Rectangle imageSize = shellImage.getBounds();
+ // shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
+ shell.setSize(imageSize.width, imageSize.height);
+ // shell.setBackgroundImage(image);
+ shell.addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ Rectangle bounds = shellImage.getBounds();
+ Point size = shell.getSize();
+ e.gc.drawImage(shellImage, 0, 0, bounds.width, bounds.height, 0, 0,
+ size.x, size.y);
+ }
+ });
+
+ locationText = new Text(shell, SWT.NONE);
+ locationText.setBackground(display.getSystemColor(URL_BACKGROUND_COLOR));
+ locationText.setBounds(URL_RECTANGLE);
+
+ progressBar = new ProgressBar(shell, SWT.NONE);
+ progressBar.setBounds(PROGRESS_BAR_RECTANGLE);
+
+ browser = browserFactory.createBrowser(shell, SWT.NONE);
+ browser.setBounds(BROWSER_RECTANGLE);
+
+ locationText.addListener(SWT.DefaultSelection, new Listener() {
+ public void handleEvent(Event e) {
+ controlHandler.goToAddress(locationText.getText());
+ }
+ });
+
+ shell.open();
+ }
+
+ @Override
+ public BrowserSimBrowser getBrowser() {
+ return browser;
+ }
+
+ @Override
+ public Shell getShell() {
+ return shell;
+ }
+
+ @Override
+ public Menu getMenuBar() {
+ return display.getMenuBar();
+ }
+
+ @Override
+ public void setControlHandler(ControlHandler controlHandler) {
+ this.controlHandler = controlHandler;
+ }
+
+ @Override
+ public void setBrowserSize(int width, int height) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void locationChanged(String location) {
+ locationText.setText(location);
+ }
+
+ @Override
+ public void progressChanged(int percents) {
+ if (percents > 0) {
+ progressBar.setVisible(true);
+ progressBar.setSelection(percents);
+ } else {
+ progressBar.setVisible(false);
+ }
+ }
+
+ @Override
+ public void statusTextChanged(String newStatusText) {
+ // TODO Auto-generated method stub
+ }
+}
+
+class PhoneButton extends Button {
+ private Image enabledImage;
+ private Image selectedImage;
+
+ public PhoneButton(Composite parent, Image enabledImage, Image selectedImage) {
+ super(parent, SWT.FLAT);
+ this.enabledImage = enabledImage;
+ this.selectedImage = selectedImage;
+
+ Rectangle imageBounds = enabledImage.getBounds();
+ setSize(imageBounds.width, imageBounds.height);
+ setImage(enabledImage);
+
+ this.addMouseTrackListener(new MouseTrackListener() {
+ @Override
+ public void mouseHover(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseExit(MouseEvent e) {
+ setImage(PhoneButton.this.enabledImage);
+ }
+
+ @Override
+ public void mouseEnter(MouseEvent e) {
+ if (PhoneButton.this.selectedImage != null) {
+ setImage(PhoneButton.this.selectedImage);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ setVisible(enabled);
+ }
+
+ @Override
+ protected void checkSubclass() {
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/BrowserSimSkin.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/BrowserSimSkin.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/BrowserSimSkin.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.browsersim.ui.skin;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.vpe.browsersim.browser.BrowserSimBrowser;
+import org.jboss.tools.vpe.browsersim.browser.IBrowserSimBrowserFactory;
+import org.jboss.tools.vpe.browsersim.ui.ControlHandler;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public interface BrowserSimSkin {
+ void setBrowserFactory(IBrowserSimBrowserFactory browserFactory);
+ void createControls(Display display);
+ BrowserSimBrowser getBrowser();
+ Shell getShell();
+ Menu getMenuBar();
+ void setControlHandler(ControlHandler controlHandler);
+ void setBrowserSize(int width, int height);
+
+ void locationChanged(String newLocation);
+ void progressChanged(int percents); // -1 for completed
+ void statusTextChanged(String newStatusText);
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/NativeSkin.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/NativeSkin.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/ui/skin/NativeSkin.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.browsersim.ui.skin;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.jboss.tools.vpe.browsersim.browser.BrowserSimBrowser;
+import org.jboss.tools.vpe.browsersim.browser.IBrowserSimBrowserFactory;
+import org.jboss.tools.vpe.browsersim.model.Device;
+import org.jboss.tools.vpe.browsersim.ui.ControlHandler;
+import org.jboss.tools.vpe.browsersim.ui.Messages;
+import org.jboss.tools.vpe.browsersim.util.ResourcesUtil;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class NativeSkin implements BrowserSimSkin {
+ private ProgressBar progressBar;
+ private Label statusLabel;
+ private Text locationText;
+ private Shell shell;
+ private BrowserSimBrowser browser;
+ private Menu menuBar;
+ private ControlHandler controlHandler;
+ private ToolItem itemBack;
+ private ToolItem itemForward;
+ private ToolItem itemStop;
+ private ToolItem itemRefresh;
+ private ToolItem itemGo;
+ private ToolItem itemRotateCounterclockwise;
+ private ToolItem itemRotateClockwise;
+ private Composite skinComposite;
+ private IBrowserSimBrowserFactory browserFactory;
+
+ public NativeSkin() {
+ }
+
+ @Override
+ public void setBrowserFactory(IBrowserSimBrowserFactory browserFactory) {
+ this.browserFactory = browserFactory;
+ };
+
+ @Override
+ public void createControls(Display display) {
+ shell = new Shell(display);
+ shell.setLayout(new FillLayout(SWT.VERTICAL | SWT.HORIZONTAL));
+
+ menuBar = display.getMenuBar();
+ if (menuBar == null) {
+ menuBar = new Menu(shell, SWT.BAR);
+ shell.setMenuBar(menuBar);
+ }
+
+ skinComposite = new Composite(shell, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ skinComposite.setLayout(gridLayout);
+
+ ToolBar toolbar = createControlBar();
+ GridData toolbarData = new GridData();
+ toolbarData.horizontalSpan = 3;
+ toolbar.setLayoutData(toolbarData);
+
+ Label labelAddress = new Label(skinComposite, SWT.NONE);
+ labelAddress.setText(Messages.BrowserSim_ADDRESS);
+
+ locationText = new Text(skinComposite, SWT.BORDER);
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.horizontalSpan = 2;
+ data.grabExcessHorizontalSpace = true;
+ data.widthHint = 0;
+ locationText.setLayoutData(data);
+
+ browser = browserFactory.createBrowser(skinComposite, SWT.NONE);
+
+ statusLabel = new Label(skinComposite, SWT.NONE);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ data.widthHint = 0;
+ statusLabel.setLayoutData(data);
+
+ progressBar = new ProgressBar(skinComposite, SWT.NONE);
+ data = new GridData();
+ data.horizontalAlignment = GridData.END;
+ progressBar.setLayoutData(data);
+
+ addControlListeners();
+
+ shell.open();
+ }
+
+ private void addControlListeners() {
+ locationText.addListener(SWT.DefaultSelection, new Listener() {
+ public void handleEvent(Event e) {
+ controlHandler.goToAddress(locationText.getText());
+ }
+ });
+
+ itemBack.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.goBack();
+ }
+ });
+
+ itemForward.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.goForward();
+ }
+ });
+
+ itemStop.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.stop();
+ }
+ });
+
+ itemRefresh.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.refresh();
+ }
+ });
+
+ itemRotateCounterclockwise.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.rotate(true);
+ }
+ });
+
+ itemRotateClockwise.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.rotate(false);
+ }
+ });
+
+ itemGo.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ controlHandler.goToAddress(locationText.getText());
+ }
+ });
+ }
+
+ @Override
+ public void setControlHandler(ControlHandler controlHandler) {
+ this.controlHandler = controlHandler;
+ }
+
+ private ToolBar createControlBar() {
+ ToolBar toolbar = new ToolBar(skinComposite, SWT.NONE);
+
+ itemBack = new ToolItem(toolbar, SWT.PUSH);
+// itemBack.setText("Back");
+ itemForward = new ToolItem(toolbar, SWT.PUSH);
+// itemForward.setText("Forward");
+ itemStop = new ToolItem(toolbar, SWT.PUSH);
+// itemStop.setText("Stop");
+ itemRefresh = new ToolItem(toolbar, SWT.PUSH);
+// itemRefresh.setText("Refresh");
+ itemGo = new ToolItem(toolbar, SWT.PUSH);
+// itemGo.setText("Go");
+ itemRotateCounterclockwise = new ToolItem(toolbar, SWT.PUSH);
+// itemGo.setText("Rotate Counterclockwise");
+ itemRotateClockwise = new ToolItem(toolbar, SWT.PUSH);
+// itemGo.setText("Rotate Clockwise");
+
+ Display display = skinComposite.getDisplay();
+ final Image imageBack = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/nav_backward.gif")); //$NON-NLS-1$
+ final Image imageForward = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/nav_forward.gif")); //$NON-NLS-1$
+ final Image imageStop = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/nav_stop.gif")); //$NON-NLS-1$
+ final Image imageRefresh = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/nav_refresh.gif")); //$NON-NLS-1$
+ final Image imageGo = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/nav_go.gif")); //$NON-NLS-1$
+ final Image imageRotateClockwise = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/rotate_clockwise.png")); //$NON-NLS-1$
+ final Image imageRotateCounterclockwise = new Image(display, ResourcesUtil.getResourceAsStream("native_skin/rotate_counterclockwise.png")); //$NON-NLS-1$
+
+ itemBack.setImage(imageBack);
+ itemForward.setImage(imageForward);
+ itemStop.setImage(imageStop);
+ itemRefresh.setImage(imageRefresh);
+ itemGo.setImage(imageGo);
+ itemRotateClockwise.setImage(imageRotateClockwise);
+ itemRotateCounterclockwise.setImage(imageRotateCounterclockwise);
+
+ skinComposite.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ imageBack.dispose();
+ imageForward.dispose();
+ imageStop.dispose();
+ imageRefresh.dispose();
+ imageGo.dispose();
+ imageRotateClockwise.dispose();
+ imageRotateCounterclockwise.dispose();
+ }
+ });
+
+ return toolbar;
+ }
+
+ public void setBrowserSize(int width, int height) {
+ GridData data = (GridData) browser.getLayoutData();
+
+ Rectangle clientArea = getMonitorClientArea();
+ int shellWidthHint = SWT.DEFAULT;
+ if (width != Device.DEFAULT_SIZE) {
+ data.widthHint = width;
+ } else if (data.widthHint == SWT.DEFAULT) {
+ shellWidthHint = clientArea.width;
+ }
+ int shellHeightHint = SWT.DEFAULT;
+ if (height != Device.DEFAULT_SIZE) {
+ data.heightHint = height;
+ } else if (data.heightHint == SWT.DEFAULT) {
+ shellHeightHint = clientArea.height;
+ }
+ Point shellSize = shell.computeSize(shellWidthHint, shellHeightHint);
+ shellSize.x = Math.min(shellSize.x, clientArea.width);
+ shellSize.y = Math.min(shellSize.y, clientArea.height);
+ shell.setSize(shellSize);
+
+ Rectangle shellBounds = shell.getBounds();
+ int bottomOverlap = shellBounds.y + shellBounds.height - (clientArea.y + clientArea.height);
+ if (bottomOverlap > 0) {
+ if (shellBounds.y > bottomOverlap) {
+ shellBounds.y -= bottomOverlap;
+ } else {
+ shellBounds.y = 0;
+ }
+ }
+
+ int rightOverlap = shellBounds.x + shellBounds.width - (clientArea.x + clientArea.width);
+ if (rightOverlap > 0) {
+ if (shellBounds.x > rightOverlap) {
+ shellBounds.x -= rightOverlap;
+ } else {
+ shellBounds.x = 0;
+ }
+ }
+
+ shell.setBounds(shellBounds);
+ }
+
+ private Rectangle getMonitorClientArea() {
+ Rectangle clientArea = skinComposite.getMonitor().getClientArea();
+
+ /* on Linux returned monitor client area may be bigger
+ * than the monitor bounds when multiple monitors are used.
+ * The following code fixes this */
+ Rectangle bounds = skinComposite.getMonitor().getBounds();
+ clientArea.width = Math.min(clientArea.width, bounds.width);
+ clientArea.height = Math.min(clientArea.height, bounds.height);
+
+ return clientArea;
+ }
+
+ @Override
+ public BrowserSimBrowser getBrowser() {
+ return browser;
+ }
+
+ @Override
+ public Shell getShell() {
+ return shell;
+ }
+
+ @Override
+ public Menu getMenuBar() {
+ return menuBar;
+ }
+
+ @Override
+ public void locationChanged(String location) {
+ locationText.setText(location);
+ }
+
+ @Override
+ public void progressChanged(int percents) {
+ if (percents > 0) {
+ progressBar.setEnabled(true);
+ progressBar.setSelection(percents);
+ } else {
+ progressBar.setSelection(0);
+ progressBar.setEnabled(false);
+ }
+
+ }
+
+ @Override
+ public void statusTextChanged(String statusText) {
+ statusLabel.setText(statusText);
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/util/ResourcesUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/util/ResourcesUtil.java 2012-01-04 15:23:01 UTC (rev 37645)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/util/ResourcesUtil.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -19,7 +19,13 @@
*/
public class ResourcesUtil {
+ private static final String RESOURCES_ROOT_FOLDER = "/org/jboss/tools/vpe/browsersim/resources/"; //$NON-NLS-1$
+
public static InputStream getResourceAsStream(String name) {
- return BrowserSim.class.getResourceAsStream(name);
+ if (name.startsWith("/")) {
+ return BrowserSim.class.getResourceAsStream(name);
+ } else {
+ return BrowserSim.class.getResourceAsStream(RESOURCES_ROOT_FOLDER + name);
+ }
}
}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/AbstractWebKitBrowser.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/AbstractWebKitBrowser.java 2012-01-04 15:23:01 UTC (rev 37645)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/AbstractWebKitBrowser.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -11,13 +11,12 @@
package org.jboss.tools.vpe.browsersim.browser;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
/**
* @author Yahor Radtsevich (yradtsevich)
*/
-public abstract class AbstractWebKitBrowser extends Browser {
+public abstract class AbstractWebKitBrowser extends BrowserSimBrowser {
private String defaultUserAgent;
@@ -26,10 +25,6 @@
}
@Override
- protected void checkSubclass() {
- }
-
- @Override
public boolean setUrl(String url, String postData, String[] headers) {
setCustomUserAgent(defaultUserAgent);
boolean result = super.setUrl(url, postData, headers);
@@ -37,6 +32,7 @@
return result;
}
+ @Override
public void setDefaultUserAgent(String defaultUserAgent) {
this.defaultUserAgent = defaultUserAgent;
setCustomUserAgent(defaultUserAgent);
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/BrowserSimBrowser.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/BrowserSimBrowser.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/BrowserSimBrowser.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -0,0 +1,17 @@
+package org.jboss.tools.vpe.browsersim.browser;
+
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.Composite;
+
+public abstract class BrowserSimBrowser extends Browser {
+
+ public BrowserSimBrowser(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ public abstract void setDefaultUserAgent(String defaultUserAgent);
+
+ @Override
+ protected void checkSubclass() {
+ }
+}
Added: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/IBrowserSimBrowserFactory.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/IBrowserSimBrowserFactory.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/IBrowserSimBrowserFactory.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -0,0 +1,7 @@
+package org.jboss.tools.vpe.browsersim.browser;
+
+import org.eclipse.swt.widgets.Composite;
+
+public interface IBrowserSimBrowserFactory {
+ BrowserSimBrowser createBrowser(Composite parent, int style);
+}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/WebKitBrowserFactory.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/WebKitBrowserFactory.java 2012-01-04 15:23:01 UTC (rev 37645)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim.browser/src/org/jboss/tools/vpe/browsersim/browser/WebKitBrowserFactory.java 2012-01-04 15:47:31 UTC (rev 37646)
@@ -20,8 +20,9 @@
/**
* @author "Yahor Radtsevich (yradtsevich)"
*/
-public class WebKitBrowserFactory {
- public static AbstractWebKitBrowser createWebKitBrowser(Composite parent, int style) {
+public class WebKitBrowserFactory implements IBrowserSimBrowserFactory {
+ @Override
+ public AbstractWebKitBrowser createBrowser(Composite parent, int style) {
if (PlatformUtil.CURRENT_PLATFORM.equals("gtk.linux.x86")) {
return new WebKitBrowser_gtk_linux_x86(parent, style);
} else if (PlatformUtil.CURRENT_PLATFORM.equals("gtk.linux.x86_64")) {
12 years, 11 months
JBoss Tools SVN: r37645 - in trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test: rest and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2012-01-04 10:23:01 -0500 (Wed, 04 Jan 2012)
New Revision: 37645
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java
Log:
RESTfulValidationTest template created + moving tests to proper location
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2012-01-04 15:00:39 UTC (rev 37644)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -11,8 +11,9 @@
package org.jboss.tools.ws.ui.bot.test;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.test.RESTfulExplorerSupportTest;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.test.RESTfulServicesExplorerTest;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulExplorerSupportTest;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulServicesExplorerTest;
+import org.jboss.tools.ws.ui.bot.test.rest.validation.RESTfulValidationTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SampleRESTWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SampleSoapWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SimpleRESTWebServiceTest;
@@ -52,7 +53,8 @@
SimpleSoapWebServiceTest.class,
SimpleRESTWebServiceTest.class,
RESTfulExplorerSupportTest.class,
- RESTfulServicesExplorerTest.class,
+ RESTfulServicesExplorerTest.class,
+ RESTfulValidationTest.class,
BottomUpWSTest.class,
TopDownWSTest.class,
WsClientTest.class,
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -0,0 +1,25 @@
+package org.jboss.tools.ws.ui.bot.test.rest;
+
+public enum RESTFulAnnotations {
+
+ CONFIGURE_MENU_LABEL("Configure"),
+ REST_SUPPORT_MENU_LABEL_ADD("Add JAX-RS 1.1 support..."),
+ REST_SUPPORT_MENU_LABEL_REMOVE("Remove JAX-RS 1.1 support..."),
+ REST_EXPLORER_LABEL("JAX-RS REST Web Services"),
+ REST_EXPLORER_LABEL_BUILD("Building RESTful Web Services..."),
+ GET("GET"),
+ POST("POST"),
+ PUT("PUT"),
+ DELETE("DELETE");
+
+ private String label;
+
+ private RESTFulAnnotations(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.utils.NodeContextUtil;
+
+/**
+ * Test base for bot tests using RESTFul support
+ * @author jjankovi
+ *
+ */
+public class RESTfulTestBase extends WSTestBase {
+
+ protected final String CONFIGURE_MENU_LABEL = "Configure";
+ protected final String REST_SUPPORT_MENU_LABEL_ADD = "Add JAX-RS 1.1 support...";
+ protected final String REST_SUPPORT_MENU_LABEL_REMOVE = "Remove JAX-RS 1.1 support...";
+ protected final String REST_EXPLORER_LABEL = "JAX-RS REST Web Services";
+ protected final String REST_EXPLORER_LABEL_BUILD = "Building RESTful Web Services...";
+ private enum ConfigureOption {
+ ADD, REMOVE;
+ }
+
+ /**
+ *
+ * @param wsProjectName
+ */
+ protected void addRestSupport(String wsProjectName) {
+ configureRestSupport(wsProjectName, ConfigureOption.ADD);
+ }
+
+ protected void removeRestSupport(String wsProjectName) {
+ configureRestSupport(wsProjectName, ConfigureOption.REMOVE);
+ }
+
+ private void configureRestSupport(String wsProjectName, ConfigureOption option) {
+ projectExplorer.selectProject(wsProjectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, RESTFulAnnotations.CONFIGURE_MENU_LABEL.getLabel(),
+ option==ConfigureOption.ADD?
+ RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_ADD.getLabel():
+ RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_REMOVE.getLabel()).click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ /**
+ *
+ * @param wsProjectName
+ * @return
+ */
+ protected boolean isRestSupportEnabled(String wsProjectName) {
+ return (projectExplorer.isFilePresent(wsProjectName,
+ RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel()) ||
+ projectExplorer.isFilePresent(wsProjectName,
+ RESTFulAnnotations.REST_EXPLORER_LABEL_BUILD.getLabel()));
+ }
+
+}
Deleted: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java 2012-01-04 15:00:39 UTC (rev 37644)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -1,25 +0,0 @@
-package org.jboss.tools.ws.ui.bot.test.rest.explorer;
-
-public enum RESTFulAnnotations {
-
- CONFIGURE_MENU_LABEL("Configure"),
- REST_SUPPORT_MENU_LABEL_ADD("Add JAX-RS 1.1 support..."),
- REST_SUPPORT_MENU_LABEL_REMOVE("Remove JAX-RS 1.1 support..."),
- REST_EXPLORER_LABEL("JAX-RS REST Web Services"),
- REST_EXPLORER_LABEL_BUILD("Building RESTful Web Services..."),
- GET("GET"),
- POST("POST"),
- PUT("PUT"),
- DELETE("DELETE");
-
- private String label;
-
- private RESTFulAnnotations(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
-}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer;
+
+import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test checks if context menu 'Add RESTful 1.1 Support' works properly
+ * @author jjankovi
+ *
+ */
+public class RESTfulExplorerSupportTest extends RESTfulTestBase {
+
+ protected String getWsProjectName() {
+ return "RestExplorerTest";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.validation.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Before
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ }
+
+
+ @Test
+ public void testSupportJAX_RS1_1_Explorer() {
+
+ addRestSupport(getWsProjectName());
+ assertTrue(isRestSupportEnabled(getWsProjectName()));
+
+ }
+
+}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.utils.NodeContextUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class RESTfulExplorerValidationTest extends WSTestBase {
+
+ private static final String CONFIGURE_MENU_LABEL = "Configure";
+ private static final String REST_SUPPORT_MENU_LABEL_ADD = "Add JAX-RS 1.1 support...";
+ private static final String REST_SUPPORT_MENU_LABEL_REMOVE = "Remove JAX-RS 1.1 support...";
+ private static final String REST_EXPLORER_LABEL = "JAX-RS REST Web Services";
+
+ protected String getWsProjectName() {
+ return "RestExplorerTest";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.validation.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Before
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ }
+
+
+ @Test
+ public void testSupportJAX_RS1_1_Explorer() {
+
+ addRestSupport(getWsProjectName());
+
+ projectExplorer.selectProject(getWsProjectName());
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(getWsProjectName());
+ assertTrue(NodeContextUtil.nodeContextMenu(tree, item, CONFIGURE_MENU_LABEL,
+ REST_SUPPORT_MENU_LABEL_REMOVE).isVisible());
+ assertTrue(projectExplorer.isFilePresent(getWsProjectName(), REST_EXPLORER_LABEL));
+
+ }
+
+ private void addRestSupport(String wsProjectName) {
+ projectExplorer.selectProject(wsProjectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, CONFIGURE_MENU_LABEL,
+ REST_SUPPORT_MENU_LABEL_ADD).click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.rest.RESTFulAnnotations;
+import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
+import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
+import org.junit.Test;
+
+/**
+ * Test operates on exploring RESTFul services in RESTful explorer
+ *
+ * TO DO: I have to add rest libraries for EAP 5.1
+ * @author jjankovi
+ *
+ */
+public class RESTfulServicesExplorerTest extends RESTfulTestBase {
+
+ private RESTFullExplorerWizard restfulWizard = null;
+
+ protected String getWsProjectName() {
+ return "RestServicesExplorer";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.services.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Override
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ if (!isRestSupportEnabled(getWsProjectName())) {
+ addRestSupport(getWsProjectName());
+ }
+ }
+
+ @Override
+ public void cleanup() {
+ if (projectExists(getWsProjectName())) {
+ removeRestSupport(getWsProjectName());
+ }
+ }
+
+ @Test
+ public void testAddingSimpleRESTMethods() {
+
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
+ @Test
+ public void testAddingAdvancedRESTMethods() {
+
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/AdvancedRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.GET.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.PUT.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/put/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("text/plain"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.POST.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/post/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("text/plain"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
+ }
+
+ @Test
+ public void testEditingSimpleRESTMethods() {
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE", "@GET");
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ assertFalse(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ fail("There should not be DELETE RESTful services");
+ }
+ }
+
+ }
+
+ @Test
+ public void testEditingAdvancedRESTMethods() {
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/AdvancedRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/{id}"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "/delete/{id}", "delete/edited/{id}");
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE",
+ "@DELETE" + LINE_SEPARATOR + "@Produces(\"text/plain\")");
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/edited/{id}"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ }
+ }
+
+ @Test
+ public void testDeletingRESTMethods() {
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/EmptyRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 0);
+
+ }
+
+ private boolean areAllRestServicesPresent(SWTBotTreeItem[] restServices) {
+
+ String[] restMethods = {RESTFulAnnotations.GET.getLabel(), RESTFulAnnotations.POST.getLabel(),
+ RESTFulAnnotations.POST.getLabel(), RESTFulAnnotations.DELETE.getLabel()};
+ for (String restMethod : restMethods) {
+ boolean serviceFound = false;
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(restMethod)) {
+ serviceFound = true;
+ break;
+ }
+ }
+ if (!serviceFound) return false;
+ }
+ return true;
+ }
+
+}
Deleted: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java 2012-01-04 15:00:39 UTC (rev 37644)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.bot.test.rest.explorer;
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ws.ui.bot.test.WSTestBase;
-import org.jboss.tools.ws.ui.bot.test.utils.NodeContextUtil;
-
-/**
- * Test base for bot tests using RESTFul support
- * @author jjankovi
- *
- */
-public class RESTfulTestBase extends WSTestBase {
-
- private enum ConfigureOption {
- ADD, REMOVE;
- }
-
- /**
- *
- * @param wsProjectName
- */
- protected void addRestSupport(String wsProjectName) {
- configureRestSupport(wsProjectName, ConfigureOption.ADD);
- }
-
- protected void removeRestSupport(String wsProjectName) {
- configureRestSupport(wsProjectName, ConfigureOption.REMOVE);
- }
-
- private void configureRestSupport(String wsProjectName, ConfigureOption option) {
- projectExplorer.selectProject(wsProjectName);
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
- item.expand();
- NodeContextUtil.nodeContextMenu(tree, item, RESTFulAnnotations.CONFIGURE_MENU_LABEL.getLabel(),
- option==ConfigureOption.ADD?
- RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_ADD.getLabel():
- RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_REMOVE.getLabel()).click();
- bot.sleep(Timing.time2S());
- util.waitForNonIgnoredJobs();
- }
-
- /**
- *
- * @param wsProjectName
- * @return
- */
- protected boolean isRestSupportEnabled(String wsProjectName) {
- return (projectExplorer.isFilePresent(wsProjectName,
- RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel()) ||
- projectExplorer.isFilePresent(wsProjectName,
- RESTFulAnnotations.REST_EXPLORER_LABEL_BUILD.getLabel()));
- }
-
-}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -0,0 +1,55 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.validation;
+
+import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
+
+/**
+ * Test operates on JAX-RS validation
+ * @author jjankovi
+ *
+ */
+public class RESTfulValidationTest extends RESTfulTestBase {
+
+ protected String getWsProjectName() {
+ return "RestServicesValidation";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.validation.services.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ public void testCorrectValueValidation() {
+ //not implemented yet
+ }
+
+ public void testBadValueValidation() {
+ //not implemented yet
+ }
+
+ public void testCorrectToBadValueValidation() {
+ //not implemented yet
+ }
+
+ public void testValidatorDisabling() {
+ //not implemented yet
+ }
+
+ public void testValidatorReenabling() {
+ //not implemented yet
+ }
+
+}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java 2012-01-04 15:00:39 UTC (rev 37644)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java 2012-01-04 15:23:01 UTC (rev 37645)
@@ -13,7 +13,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTFulAnnotations;
+import org.jboss.tools.ws.ui.bot.test.rest.RESTFulAnnotations;
public class RESTFullExplorerWizard extends SWTTestExt {
12 years, 11 months
JBoss Tools SVN: r37644 - in trunk/ws/tests/org.jboss.tools.ws.ui.bot.test: src/org/jboss/tools/ws/ui/bot/test and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2012-01-04 10:00:39 -0500 (Wed, 04 Jan 2012)
New Revision: 37644
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java
Log:
RESTFulServicesExplorerTest completion
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2012-01-04 15:00:39 UTC (rev 37644)
@@ -19,7 +19,6 @@
org.junit4;bundle-version="4.5.0",
org.jboss.tools.ws.ui;bundle-version="1.1.0",
org.eclipse.core.resources,
- org.jboss.tools.tests,
org.eclipse.wst.common.project.facet.core,
org.hamcrest;bundle-version="1.1.0"
Bundle-ActivationPolicy: lazy
Deleted: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -1,106 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.ui.bot.test;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWSDL;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-
-public class JBossWSProjectFacetBotTest extends WSWizardTest {
-
- public void testNewWizard() throws IOException, CoreException {
- bot.menu("File").menu("New").menu("Project...").click();
- bot.shell("New Project").activate();
- SWTBotTree tree = bot.tree();
- tree.expandNode("Web").expandNode("Dynamic Web Project").select();
- assertTrue(bot.button("Next >").isEnabled());
- bot.button("Next >").click();
- bot.shell("New Dynamic Web Project").activate();
- assertFalse(bot.button("Finish").isEnabled());
-
- bot.textWithLabel("Project name:").setText("B");
- assertTrue(bot.button("Finish").isEnabled());
- bot.comboBoxInGroup("Dynamic web module version").setSelection("2.5");
- bot.comboBoxInGroup("Configuration").setSelection(
- "JBossWS Web Service Project v3.0");
- assertFalse(bot.button("Finish").isEnabled());
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.radio(0).click();
- bot.sleep(2000);
- assertTrue(bot.button("Finish").isEnabled());
- open.finish(bot);
- project = ResourcesPlugin.getWorkspace().getRoot().getProject("B");
- assertNotNull(project);
- IFacetedProject fproj = ProjectFacetsManager.create(project);
- assertNotNull(fproj
- .getProjectFacetVersion((IProjectFacet) ProjectFacetsManager
- .getProjectFacet("jbossws.core")));
- tryJBIDE6250();
- }
-
- private void tryJBIDE6250() {
- setDefaultWSRuntime();
-
- SWTBot wiz = open.newObject(WebServicesWSDL.LABEL);
- wiz.textWithLabel(WebServicesWSDL.TEXT_FILE_NAME).setText(
- "ClassB" + ".wsdl");
- wiz.textWithLabel(
- WebServicesWSDL.TEXT_ENTER_OR_SELECT_THE_PARENT_FOLDER)
- .setText("B");
- wiz.button(IDELabel.Button.NEXT).click();
- open.finish(wiz);
- eclipse.setClassContentFromResource(bot.editorByTitle("ClassB"
- + ".wsdl"), true,
- org.jboss.tools.ws.ui.bot.test.Activator.PLUGIN_ID,
- "jbossws", "ClassB" + ".wsdl");
-
- bot.sleep(1000);
- bot.menu("File").menu("New").menu("Other...").click();
- bot.shell("New").activate();
-
- SWTBotTree tree = bot.tree();
- SWTBotTreeItem item = tree.getTreeItem("Web Services");
- tree.select(item);
- item.expand();
- try {
- item.getNode("Web Service").select();
- } catch (Exception e) {
- item.collapse();
- item.expand();
- item.getNode("Web Service").select();
- }
- bot.sleep(1000);
- assertTrue(bot.button("Next >").isEnabled());
- bot.button("Next >").click();
- bot.shell("Web Service").activate();
- bot.comboBoxWithLabel("Web service type:").setSelection(1);
- bot.comboBoxWithLabel("Service definition:").setText(
- "/B/ClassB.wsdl");
- while (!bot.button("Next >").isEnabled()) {
- bot.sleep(1000);
- }
- selectProject();
- bot.button("Next >").click();
- bot.sleep(1000);
- assertTrue(bot.checkBox(0).isChecked());
- }
-}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -49,6 +49,8 @@
protected static final Logger LOGGER = Logger
.getLogger(WSTestBase.class.getName());
+ protected final String LINE_SEPARATOR = System.getProperty("line.separator");
+
protected static final ResourceHelper resourceHelper = new ResourceHelper();
protected static final ProjectHelper projectHelper = new ProjectHelper();
protected static final DeploymentHelper deploymentHelper = new DeploymentHelper();
Deleted: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.bot.test;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.jboss.tools.test.util.TestProjectProvider;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.SWTOpenExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.parts.SWTBotHyperlinkExt;
-
-public class WSWizardTest extends TestCase{
- protected static SWTBotExt bot = new SWTBotExt();
- public static final SWTOpenExt open = new SWTOpenExt(bot);
- public static final SWTEclipseExt eclipse = new SWTEclipseExt(bot);
- public static final String JBOSSWS_HOME_DEFAULT = "D:/softinstall/jboss-5.1.0.GA";
- public static final String JBOSSWS_42_HOME = "jbosstools.test.jboss.home.5.1";
- public static final String JBOSS_AS_42_HOME = System.getProperty(
- JBOSSWS_42_HOME, JBOSSWS_HOME_DEFAULT);
- IProject project;
-
- protected void setUp() throws Exception {
- bot.viewByTitle("Welcome").close();
- bot.perspectiveByLabel("Java EE").activate();
- createServerRuntime();
- }
- protected void tearDown() throws Exception {
- bot = null;
- }
-
- public void createServerRuntime() {
- if (!isServerRuntimeDefined(bot, "AS4.2Runtime")) {
- bot.menu("File").menu("New").menu("Other...").click();
- bot.shell("New").activate();
- SWTBotTree tree = bot.tree();
- bot.sleep(Timing.time1S());
- tree.expandNode("Server").select("Server");
- bot.button("Next >").click();
- SWTBotTree tree2 = bot.tree();
- tree2.expandNode("JBoss Community").select("JBoss AS 5.1");
- bot.textWithLabel("Server name:").setText("AS4.2Server");
- bot.button("Next >").click();
- bot.textWithLabel("Name").setText("AS4.2Runtime");
- bot.textWithLabel("Home Directory").setText(JBOSS_AS_42_HOME);
- bot.button("Finish").click();
- bot.sleep(Timing.time2S());
- }
- }
-
- public static boolean isServerRuntimeDefined(SWTWorkbenchBot bot,
- String runtimeName) {
-
- boolean serverRuntimeNotDefined = true;
-
- bot.menu("Window").menu("Preferences").click();
- bot.shell("Preferences").activate();
- bot.tree().expandNode("Server").select("Runtime Environments");
-
- SWTBotTable tbRuntimeEnvironments = bot.table();
- int numRows = tbRuntimeEnvironments.rowCount();
- if (numRows > 0) {
- int currentRow = 0;
- while (serverRuntimeNotDefined && currentRow < numRows) {
- if (tbRuntimeEnvironments.cell(currentRow, 0).equalsIgnoreCase(
- runtimeName)) {
- serverRuntimeNotDefined = false;
- } else {
- currentRow++;
- }
- }
- }
-
- bot.button("OK").click();
-
- return !serverRuntimeNotDefined;
-
- }
-
-
- public IProject importProject() throws CoreException, IOException, InvocationTargetException, InterruptedException {
- TestProjectProvider provider = new TestProjectProvider("org.jboss.tools.ws.ui.bot.test", "/projects/" + "A",
- "A", true);
- IProject prj = provider.getProject();
- return prj;
- }
-
- public void selectProject() {
- SWTBotHyperlinkExt link = bot.hyperlink(2);
- if(!"Service project: B".equals(link.getText())){
- link.click();
-
- SWTBot dBot = bot.activeShell().bot();
- dBot.comboBoxWithLabel("Service project:").setText("B");
- dBot.button("OK").click();
- dBot.sleep(Timing.time1S());
- }
- }
- public void setDefaultWSRuntime(){
- bot.menu("Window").menu("Preferences").click();
- bot.shell("Preferences").activate();
- SWTBotTree tree = bot.tree();
- tree.expandNode("Web Services").expandNode("Server and Runtime").select();
- bot.comboBoxWithLabel("Web service runtime:").setSelection("JBossWS");
- bot.button("OK").click();
- bot.sleep(Timing.time2S());
- }
-}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.utils.NodeContextUtil;
+
+/**
+ * Test base for bot tests using RESTFul support
+ * @author jjankovi
+ *
+ */
+public class RESTfulTestBase extends WSTestBase {
+
+ private enum ConfigureOption {
+ ADD, REMOVE;
+ }
+
+ /**
+ *
+ * @param wsProjectName
+ */
+ protected void addRestSupport(String wsProjectName) {
+ configureRestSupport(wsProjectName, ConfigureOption.ADD);
+ }
+
+ protected void removeRestSupport(String wsProjectName) {
+ configureRestSupport(wsProjectName, ConfigureOption.REMOVE);
+ }
+
+ private void configureRestSupport(String wsProjectName, ConfigureOption option) {
+ projectExplorer.selectProject(wsProjectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, RESTFulAnnotations.CONFIGURE_MENU_LABEL.getLabel(),
+ option==ConfigureOption.ADD?
+ RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_ADD.getLabel():
+ RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_REMOVE.getLabel()).click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ /**
+ *
+ * @param wsProjectName
+ * @return
+ */
+ protected boolean isRestSupportEnabled(String wsProjectName) {
+ return (projectExplorer.isFilePresent(wsProjectName,
+ RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel()) ||
+ projectExplorer.isFilePresent(wsProjectName,
+ RESTFulAnnotations.REST_EXPLORER_LABEL_BUILD.getLabel()));
+ }
+
+}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -11,6 +11,7 @@
package org.jboss.tools.ws.ui.bot.test.rest.explorer.test;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulTestBase;
import org.junit.Before;
import org.junit.Test;
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -11,17 +11,24 @@
package org.jboss.tools.ws.ui.bot.test.rest.explorer.test;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTFulAnnotations;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulTestBase;
+import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
import org.junit.Test;
-
-
/**
* Test operates on exploring RESTFul services in RESTful explorer
+ *
+ * TO DO: I have to add rest libraries for EAP 5.1
* @author jjankovi
*
*/
public class RESTfulServicesExplorerTest extends RESTfulTestBase {
+ private RESTFullExplorerWizard restfulWizard = null;
+
protected String getWsProjectName() {
return "RestServicesExplorer";
}
@@ -37,42 +44,244 @@
@Override
public void setup() {
if (!projectExists(getWsProjectName())) {
- projectHelper.createProject(getWsProjectName());
+ projectHelper.createProject(getWsProjectName());
+ }
+ if (!isRestSupportEnabled(getWsProjectName())) {
addRestSupport(getWsProjectName());
}
}
@Override
public void cleanup() {
- if (projectExists(getWsProjectName())) {
- removeRestSupport(getWsProjectName());
- projectExplorer.deleteAllProjects();
+ if (projectExists(getWsProjectName())) {
+ removeRestSupport(getWsProjectName());
}
}
@Test
public void testAddingSimpleRESTMethods() {
- //only get, post, put, delete
+
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
}
@Test
public void testAddingAdvancedRESTMethods() {
- //with additional path param
+
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/AdvancedRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.GET.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.PUT.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/put/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("text/plain"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.POST.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/post/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("text/plain"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
}
@Test
public void testEditingSimpleRESTMethods() {
- //only get, post, put, delete
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE", "@GET");
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ assertFalse(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ fail("There should not be DELETE RESTful services");
+ }
+ }
+
}
@Test
public void testEditingAdvancedRESTMethods() {
- ////with additional path param
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/AdvancedRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/{id}"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "/delete/{id}", "delete/edited/{id}");
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE",
+ "@DELETE" + LINE_SEPARATOR + "@Produces(\"text/plain\")");
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel())) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/edited/{id}"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ }
}
@Test
public void testDeletingRESTMethods() {
- //deleting all rest methods
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources", "src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/EmptyRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 0);
+
}
+ private boolean areAllRestServicesPresent(SWTBotTreeItem[] restServices) {
+
+ String[] restMethods = {RESTFulAnnotations.GET.getLabel(), RESTFulAnnotations.POST.getLabel(),
+ RESTFulAnnotations.POST.getLabel(), RESTFulAnnotations.DELETE.getLabel()};
+ for (String restMethod : restMethods) {
+ boolean serviceFound = false;
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(restMethod)) {
+ serviceFound = true;
+ break;
+ }
+ }
+ if (!serviceFound) return false;
+ }
+ return true;
+ }
+
}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java 2012-01-04 14:57:09 UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java 2012-01-04 15:00:39 UTC (rev 37644)
@@ -13,6 +13,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.text.MessageFormat;
import java.util.Scanner;
import org.eclipse.core.resources.IFile;
@@ -60,6 +61,18 @@
}
/**
+ * Method replaces string "target" by string "replacement.
+ * @param target
+ * @param replacement
+ */
+ public void replaceInEditor(SWTBotEclipseEditor ed, String target, String replacement) {
+ ed.selectRange(0, 0, ed.getText().length());
+ ed.setText(ed.getText().replace(target,replacement));
+ ed.save();
+ }
+
+
+ /**
* Method copies resource to class opened in SWTBotEditor
* @param classEdit
* @param resource
@@ -75,5 +88,21 @@
if (closeEdit) classEdit.close();
}
+ /**
+ * Method copies resource to class opened in SWTBotEditor with entered parameters
+ * @param classEdit
+ * @param resource
+ * @param closeEdit
+ * @param param
+ */
+ public void copyResourceToClass(SWTBotEditor classEdit,
+ InputStream resource, boolean closeEdit, Object... param) {
+ String s = readStream(resource);
+ String code = MessageFormat.format(s, param);
+ classEdit.toTextEditor().selectRange(0, 0, classEdit.toTextEditor().getText().length());
+ classEdit.toTextEditor().setText(code);
+ classEdit.save();
+ if (closeEdit) classEdit.close();
+ }
}
12 years, 11 months
JBoss Tools SVN: r37643 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-01-04 09:57:09 -0500 (Wed, 04 Jan 2012)
New Revision: 37643
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
Log:
Added dependant plugins (for bot tests)
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2012-01-04 14:46:56 UTC (rev 37642)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2012-01-04 14:57:09 UTC (rev 37643)
@@ -14,7 +14,8 @@
org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
org.apache.log4j;bundle-version="1.2.13",
org.junit4;bundle-version="4.8.1",
- org.eclipse.datatools.connectivity;bundle-version="1.1.2",
org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
org.hamcrest;bundle-version="1.1.0",
- org.eclipse.ui.forms;bundle-version="3.5.0"
+ org.eclipse.ui.forms;bundle-version="3.5.0",
+ org.jboss.ide.eclipse.as.ui;bundle-version="2.3.0",
+ org.jboss.tools.portlet.ui;bundle-version="1.2.0"
12 years, 11 months
JBoss Tools SVN: r37642 - trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/restful.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2012-01-04 09:46:56 -0500 (Wed, 04 Jan 2012)
New Revision: 37642
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/restful/EmptyRestfulWS.java.ws
Log:
new resource file for RESTful tests added
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/restful/EmptyRestfulWS.java.ws
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/restful/EmptyRestfulWS.java.ws (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/restful/EmptyRestfulWS.java.ws 2012-01-04 14:46:56 UTC (rev 37642)
@@ -0,0 +1,9 @@
+package {0};
+
+import javax.ws.rs.Path;
+
+
+@Path("/rest")
+public class {1} '{'
+
+'}'
12 years, 11 months