Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeb Ford-Reitz2011-06-30 09:50:57 +0000
committerZeb Ford-Reitz2011-06-30 09:50:57 +0000
commit9df37a56ec3b498a89df4b1a3bccb0298fd9c1ed (patch)
tree37deacc6ee89c9171dcf71b80acfcc7b898d48fd /org.eclipse.jubula.client.autagent
parent474adaf22c39054b17c3565de5263d72fc4ef87c (diff)
downloadorg.eclipse.jubula.core-9df37a56ec3b498a89df4b1a3bccb0298fd9c1ed.tar.gz
org.eclipse.jubula.core-9df37a56ec3b498a89df4b1a3bccb0298fd9c1ed.tar.xz
org.eclipse.jubula.core-9df37a56ec3b498a89df4b1a3bccb0298fd9c1ed.zip
Adds AUT Agent functionality to ITE.
This allows an AUT Agent to be started from the ITE, which will permit Eclipse for Testers users to start AUTs and execute tests.
Diffstat (limited to 'org.eclipse.jubula.client.autagent')
-rw-r--r--org.eclipse.jubula.client.autagent/.checkstyle7
-rw-r--r--org.eclipse.jubula.client.autagent/.classpath7
-rw-r--r--org.eclipse.jubula.client.autagent/.gitignore2
-rw-r--r--org.eclipse.jubula.client.autagent/.project34
-rw-r--r--org.eclipse.jubula.client.autagent/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--org.eclipse.jubula.client.autagent/META-INF/MANIFEST.MF18
-rw-r--r--org.eclipse.jubula.client.autagent/about.html28
-rw-r--r--org.eclipse.jubula.client.autagent/build.properties18
-rw-r--r--org.eclipse.jubula.client.autagent/plugin.properties9
-rw-r--r--org.eclipse.jubula.client.autagent/plugin.xml50
-rw-r--r--org.eclipse.jubula.client.autagent/pom.xml24
-rw-r--r--org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/Activator.java56
-rw-r--r--org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/handlers/ConnectToEmbeddedAutAgentHandler.java71
-rw-r--r--org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/PreferenceInitializer.java40
-rw-r--r--org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/ui/EmbeddedAutAgentPreferencePage.java104
15 files changed, 476 insertions, 0 deletions
diff --git a/org.eclipse.jubula.client.autagent/.checkstyle b/org.eclipse.jubula.client.autagent/.checkstyle
new file mode 100644
index 000000000..0afff8669
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/.checkstyle
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+ <fileset name="all" enabled="true" check-config-name="Jubula" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
diff --git a/org.eclipse.jubula.client.autagent/.classpath b/org.eclipse.jubula.client.autagent/.classpath
new file mode 100644
index 000000000..64c5e31b7
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.jubula.client.autagent/.gitignore b/org.eclipse.jubula.client.autagent/.gitignore
new file mode 100644
index 000000000..4dc009173
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/.gitignore
@@ -0,0 +1,2 @@
+/target
+/bin
diff --git a/org.eclipse.jubula.client.autagent/.project b/org.eclipse.jubula.client.autagent/.project
new file mode 100644
index 000000000..8e63485c9
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jubula.client.autagent</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.jubula.client.autagent/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jubula.client.autagent/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..6f189f3e7
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Jun 28 15:22:05 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.jubula.client.autagent/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.autagent/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..3acf5c1e2
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Jubula Client / AUT Agent Integration
+Bundle-SymbolicName: org.eclipse.jubula.client.autagent;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.jubula.client.autagent.Activator
+Bundle-Vendor: Eclipse Jubula
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui;bundle-version="[3.6.1,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
+ org.eclipse.core.databinding;bundle-version="[1.3.1,2.0.0)",
+ org.eclipse.jface.databinding;bundle-version="[1.4.0,2.0.0)",
+ org.eclipse.jubula.tools;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jubula.communication;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jubula.autagent;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.jubula.client.ui;bundle-version="[1.0.0,2.0.0)"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jubula.client.autagent/about.html b/org.eclipse.jubula.client.autagent/about.html
new file mode 100644
index 000000000..f1be81099
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 22, 2011</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/org.eclipse.jubula.client.autagent/build.properties b/org.eclipse.jubula.client.autagent/build.properties
new file mode 100644
index 000000000..fa8dec58c
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/build.properties
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright (c) 2004, 2011 BREDEX GmbH.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+bin.includes = about.html,\
+ META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+javacSource = 1.5
+javacTarget = 1.5
+javacErrors.. = -assertIdentifier
diff --git a/org.eclipse.jubula.client.autagent/plugin.properties b/org.eclipse.jubula.client.autagent/plugin.properties
new file mode 100644
index 000000000..014657374
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/plugin.properties
@@ -0,0 +1,9 @@
+###############################################################################
+# Copyright (c) 2004, 2011 BREDEX GmbH.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+ConnectToEmbeddedAgent=Connect to Embedded AUT Agent
+EmbeddedAgentPreferencePageName=Embedded AUT Agent
diff --git a/org.eclipse.jubula.client.autagent/plugin.xml b/org.eclipse.jubula.client.autagent/plugin.xml
new file mode 100644
index 000000000..a00858d26
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/plugin.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?><!--
+ Copyright (c) 2004, 2011 BREDEX GmbH.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.jubula.client.ui.actions.ChooseServerAction.dropdown">
+ <command
+ commandId="org.eclipse.jubula.client.autagent.commands.ConnectToEmbeddedAutAgent"
+ style="toggle">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.jubula.client.autagent.handlers.ConnectToEmbeddedAutAgentHandler"
+ id="org.eclipse.jubula.client.autagent.commands.ConnectToEmbeddedAutAgent"
+ name="%ConnectToEmbeddedAgent">
+ <state
+ class="org.eclipse.jface.commands.ToggleState"
+ id="isAutAgentRunning">
+ </state>
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.jubula.client.autagent.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.jubula.client.ui.preferences.AutAgentPrefPage"
+ class="org.eclipse.jubula.client.autagent.preferences.ui.EmbeddedAutAgentPreferencePage"
+ id="org.eclipse.jubula.client.autagent.page1"
+ name="%EmbeddedAgentPreferencePageName">
+ </page>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.jubula.client.autagent/pom.xml b/org.eclipse.jubula.client.autagent/pom.xml
new file mode 100644
index 000000000..38da7dc9a
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/pom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2004, 2011 BREDEX GmbH.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.jubula.releng.client</artifactId>
+ <groupId>org.eclipse.jubula</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../org.eclipse.jubula.releng.client</relativePath>
+ </parent>
+ <groupId>org.eclipse.jubula</groupId>
+ <artifactId>org.eclipse.jubula.client.autagent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+</project>
diff --git a/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/Activator.java b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/Activator.java
new file mode 100644
index 000000000..00247074a
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/Activator.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.autagent;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author BREDEX GmbH
+ * @created Jun 29, 2011
+ */
+public class Activator extends AbstractUIPlugin {
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.jubula.client.autagent"; //$NON-NLS-1$
+
+ /** The shared instance */
+ private static Activator plugin;
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/handlers/ConnectToEmbeddedAutAgentHandler.java b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/handlers/ConnectToEmbeddedAutAgentHandler.java
new file mode 100644
index 000000000..60222d256
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/handlers/ConnectToEmbeddedAutAgentHandler.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.autagent.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jubula.autagent.AutStarter;
+import org.eclipse.jubula.autagent.AutStarter.Verbosity;
+import org.eclipse.jubula.client.autagent.Activator;
+import org.eclipse.jubula.client.autagent.preferences.PreferenceInitializer;
+import org.eclipse.jubula.client.ui.actions.StartServerAction;
+import org.eclipse.jubula.client.ui.utils.ServerManager.Server;
+
+/**
+ * Handler for "Connect to Embedded AUT Agent" command.
+ *
+ * @author BREDEX GmbH
+ * @created Jun 29, 2011
+ */
+public class ConnectToEmbeddedAutAgentHandler extends AbstractHandler
+ implements IHandler {
+
+ /**
+ * hostname to use for starting and accessing the embedded AUT Agent
+ */
+ private static final String EMBEDDED_AGENT_HOSTNAME = "localhost"; //$NON-NLS-1$
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ if (AutStarter.getInstance().getCommunicator() == null) {
+ // Embedded Agent is not running. We need to start it before
+ // trying to connect to it.
+ final int port = Platform.getPreferencesService().getInt(
+ Activator.PLUGIN_ID,
+ PreferenceInitializer.PREF_EMBEDDED_AGENT_PORT,
+ PreferenceInitializer.DEFAULT_EMBEDDED_AGENT_PORT, null);
+ try {
+ AutStarter.getInstance().start(
+ port, false, Verbosity.QUIET, false);
+ } catch (Exception e) {
+ throw new ExecutionException(
+ "An error occurred while starting the embedded AUT Agent", e); //$NON-NLS-1$
+ }
+ }
+
+ StartServerAction connectToServerAction =
+ new StartServerAction(
+ new Server(EMBEDDED_AGENT_HOSTNAME,
+ AutStarter.getInstance().getCommunicator().getLocalPort()),
+ IAction.AS_CHECK_BOX);
+ connectToServerAction.run();
+ return null;
+ }
+
+}
diff --git a/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/PreferenceInitializer.java b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/PreferenceInitializer.java
new file mode 100644
index 000000000..b56778f3d
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/PreferenceInitializer.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.autagent.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jubula.client.autagent.Activator;
+
+/**
+ *
+ * @author BREDEX GmbH
+ * @created Jun 29, 2011
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /** ID for "Embedded AUT Agent Port" preference */
+ public static final String PREF_EMBEDDED_AGENT_PORT =
+ "org.eclipse.jubula.autagent.preference.port"; //$NON-NLS-1$
+
+ /** default value for "Embedded AUT Agent Port" preference */
+ public static final int DEFAULT_EMBEDDED_AGENT_PORT = 60000;
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences preferenceNode =
+ new DefaultScope().getNode(Activator.PLUGIN_ID);
+ preferenceNode.putInt(PREF_EMBEDDED_AGENT_PORT,
+ DEFAULT_EMBEDDED_AGENT_PORT);
+ }
+
+}
diff --git a/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/ui/EmbeddedAutAgentPreferencePage.java b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/ui/EmbeddedAutAgentPreferencePage.java
new file mode 100644
index 000000000..27a61ae57
--- /dev/null
+++ b/org.eclipse.jubula.client.autagent/src/org/eclipse/jubula/client/autagent/preferences/ui/EmbeddedAutAgentPreferencePage.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 BREDEX GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.autagent.preferences.ui;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.observable.value.WritableValue;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.databinding.preference.PreferencePageSupport;
+import org.eclipse.jface.databinding.swt.SWTObservables;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jubula.client.autagent.Activator;
+import org.eclipse.jubula.client.autagent.preferences.PreferenceInitializer;
+import org.eclipse.jubula.client.ui.databinding.SimpleIntegerToStringConverter;
+import org.eclipse.jubula.client.ui.databinding.SimpleStringToIntegerConverter;
+import org.eclipse.jubula.client.ui.databinding.validators.StringToPortValidator;
+import org.eclipse.jubula.tools.i18n.I18n;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ *
+ * @author BREDEX GmbH
+ * @created Jun 29, 2011
+ */
+public class EmbeddedAutAgentPreferencePage extends PreferencePage
+ implements IWorkbenchPreferencePage {
+
+ /** the port number for the embedded AUT Agent */
+ private WritableValue m_portNumber;
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(new ScopedPreferenceStore(
+ new InstanceScope(), Activator.PLUGIN_ID));
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
+
+ DataBindingContext dbc = new DataBindingContext();
+ new Label(composite, SWT.NONE).setText(
+ I18n.getString("DatabaseConnection.HostBased.Port")); //$NON-NLS-1$
+ Text portText = new Text(composite, SWT.NONE);
+ m_portNumber = new WritableValue(
+ getPreferenceStore().getInt(
+ PreferenceInitializer.PREF_EMBEDDED_AGENT_PORT),
+ int.class);
+
+ UpdateValueStrategy portTargetToModelUpdateStrategy =
+ new UpdateValueStrategy();
+ portTargetToModelUpdateStrategy
+ .setConverter(new SimpleStringToIntegerConverter())
+ .setAfterGetValidator(new StringToPortValidator(
+ I18n.getString("DatabaseConnection.HostBased.Port"))); //$NON-NLS-1$
+ dbc.bindValue(SWTObservables.observeText(portText, SWT.Modify),
+ m_portNumber, portTargetToModelUpdateStrategy,
+ new UpdateValueStrategy().setConverter(
+ new SimpleIntegerToStringConverter()));
+
+ PreferencePageSupport.create(this, dbc);
+ return composite;
+ }
+
+ @Override
+ public boolean performOk() {
+ getPreferenceStore().setValue(
+ PreferenceInitializer.PREF_EMBEDDED_AGENT_PORT,
+ (Integer)m_portNumber.getValue());
+ return super.performOk();
+ }
+
+ @Override
+ protected void performDefaults() {
+ getPreferenceStore().setToDefault(
+ PreferenceInitializer.PREF_EMBEDDED_AGENT_PORT);
+ m_portNumber.setValue(getPreferenceStore().getInt(
+ PreferenceInitializer.PREF_EMBEDDED_AGENT_PORT));
+ super.performDefaults();
+ }
+
+}

Back to the top