[jboss-cvs] JBossAS SVN: r112579 - in projects/jboss-jca/trunk: eclipse and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 17 03:02:59 EST 2012
Author: jeff.zhang
Date: 2012-01-17 03:02:58 -0500 (Tue, 17 Jan 2012)
New Revision: 112579
Added:
projects/jboss-jca/trunk/eclipse/
projects/jboss-jca/trunk/eclipse/.classpath
projects/jboss-jca/trunk/eclipse/.project
projects/jboss-jca/trunk/eclipse/META-INF/
projects/jboss-jca/trunk/eclipse/META-INF/MANIFEST.MF
projects/jboss-jca/trunk/eclipse/build.properties
projects/jboss-jca/trunk/eclipse/build.xml
projects/jboss-jca/trunk/eclipse/icons/
projects/jboss-jca/trunk/eclipse/icons/ij.png
projects/jboss-jca/trunk/eclipse/libs/
projects/jboss-jca/trunk/eclipse/plugin.xml
projects/jboss-jca/trunk/eclipse/src/
projects/jboss-jca/trunk/eclipse/src/main/
projects/jboss-jca/trunk/eclipse/src/main/java/
projects/jboss-jca/trunk/eclipse/src/main/java/org/
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/Activator.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/BuildHandler.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/package.html
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/package.html
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AddPropertyDialog.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AoWizardPage.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/BuildWizardPage.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/CodeGenWizard.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/DefinitionWizardPage.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/InboundWizardPage.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/McfWizardPage.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsContentProvider.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsLabelProvider.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/RaWizardPage.java
projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/package.html
Log:
[JBJCA-731] Eclipse plugin for Ironjacamar, initial commit
Added: projects/jboss-jca/trunk/eclipse/.classpath
===================================================================
--- projects/jboss-jca/trunk/eclipse/.classpath (rev 0)
+++ projects/jboss-jca/trunk/eclipse/.classpath 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-codegenerator.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-common-api.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-common-impl-papaki.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-common-impl.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-common-spi.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-core-api.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-core-impl.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-sjc.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ironjacamar-spec-api.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-codegenerator"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-common"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-sjc"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ironjacamar-api"/>
+ <classpathentry kind="output" path="eclipse-target/classes"/>
+</classpath>
Added: projects/jboss-jca/trunk/eclipse/.project
===================================================================
--- projects/jboss-jca/trunk/eclipse/.project (rev 0)
+++ projects/jboss-jca/trunk/eclipse/.project 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ironjacamar-eclipse</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/jboss-jca/trunk/eclipse/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-jca/trunk/eclipse/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-jca/trunk/eclipse/META-INF/MANIFEST.MF 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss JCA Container - Ironjacamar Plugin
+Bundle-SymbolicName: org.jboss.jca.eclipse;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.jca.eclipse.Activator
+Bundle-Vendor: JBoss Ironjacamar Team
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.jdt.core;bundle-version="3.6.2",
+ org.eclipse.jdt.launching
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6,
+ CDC-1.0/Foundation-1.0
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .,
+ libs/ironjacamar-codegenerator.jar,
+ libs/ironjacamar-common-api.jar,
+ libs/ironjacamar-common-impl-papaki.jar,
+ libs/ironjacamar-common-impl.jar,
+ libs/ironjacamar-common-spi.jar,
+ libs/ironjacamar-core-api.jar,
+ libs/ironjacamar-core-impl.jar,
+ libs/ironjacamar-sjc.jar,
+ libs/ironjacamar-spec-api.jar
Added: projects/jboss-jca/trunk/eclipse/build.properties
===================================================================
--- projects/jboss-jca/trunk/eclipse/build.properties (rev 0)
+++ projects/jboss-jca/trunk/eclipse/build.properties 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,15 @@
+source.. = src/main/java
+output.. = eclipse-target/classes
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/,\
+ libs/ironjacamar-codegenerator.jar,\
+ libs/ironjacamar-common-api.jar,\
+ libs/ironjacamar-common-impl-papaki.jar,\
+ libs/ironjacamar-common-impl.jar,\
+ libs/ironjacamar-common-spi.jar,\
+ libs/ironjacamar-core-api.jar,\
+ libs/ironjacamar-core-impl.jar,\
+ libs/ironjacamar-sjc.jar,\
+ libs/ironjacamar-spec-api.jar
Added: projects/jboss-jca/trunk/eclipse/build.xml
===================================================================
--- projects/jboss-jca/trunk/eclipse/build.xml (rev 0)
+++ projects/jboss-jca/trunk/eclipse/build.xml 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,161 @@
+<!--
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<project name="ironjacamar-eclipse"
+ default="compile"
+ xmlns:ivy="antlib:org.apache.ivy.ant">
+
+ <!-- =================================
+ Properties
+ ================================= -->
+ <property name="build.eclipse.dir" value="${build.dir}/eclipse" />
+ <property name="eclipse.home" value="/opt/eclipse" />
+
+ <path id="eclipse-sdk-jars">
+
+ <fileset dir="${target.dir}">
+ <include name="**/*.jar"/>
+ </fileset>
+
+ <fileset dir="${eclipse.home}/plugins/">
+ <include name="org.eclipse.ui*.jar"/>
+ <include name="org.eclipse.jdt*.jar"/>
+ <include name="org.eclipse.core*.jar"/>
+ <include name="org.eclipse.equinox*.jar"/>
+ <include name="org.eclipse.debug*.jar"/>
+ <include name="org.eclipse.osgi*.jar"/>
+ <include name="org.eclipse.swt*.jar"/>
+ <include name="org.eclipse.jface*.jar"/>
+
+ <include name="org.eclipse.team.cvs.ssh2*.jar"/>
+ <include name="com.jcraft.jsch*.jar"/>
+ </fileset>
+ </path>
+ <!-- =================================
+ Target: compile
+ ================================= -->
+ <target name="compile">
+
+ <copy todir="libs/">
+ <fileset dir="${target.dir}"
+ includes="ironjacamar-codegenerator.jar ironjacamar-common*.jar
+ ironjacamar-core*.jar ironjacamar-sjc.jar ironjacamar-spec-api.jar"/>
+ </copy>
+
+ <mkdir dir="${build.eclipse.dir}" />
+ <mkdir dir="${build.eclipse.dir}/impl" />
+
+ <javac srcdir="src/main"
+ destdir="${build.eclipse.dir}/impl"
+ classpathref="eclipse-sdk-jars"
+ debug="${javac.debug}"
+ deprecation="${javac.deprecation}"
+ optimize="${javac.optimize}"
+ includeAntRuntime="false">
+ <compilerarg value="-Xlint"/>
+ </javac>
+ </target>
+
+ <!-- =================================
+ Target: jars
+ ================================= -->
+ <target name="jars" depends="compile">
+ <mkdir dir="${build.eclipse.dir}/jars" />
+
+ <!-- eclipse -->
+ <mkdir dir="${build.eclipse.dir}/jars/eclipse" />
+
+ <copy todir="${build.eclipse.dir}/jars/eclipse">
+ <fileset dir="${build.eclipse.dir}/impl"
+ includes="**"/>
+ </copy>
+
+ <copy todir="${build.eclipse.dir}/jars/eclipse">
+ <fileset dir="."
+ includes="plugin.xml build.properties icons/** libs/** META-INF/**"/>
+ </copy>
+
+ <jar destfile="${target.dir}/${name}-eclipse.jar"
+ basedir="${build.eclipse.dir}/jars/eclipse"
+ manifest="META-INF/MANIFEST.MF"
+ update="true"
+ level="9">
+
+ </jar>
+ </target>
+
+ <!-- =================================
+ Target: artifacts
+ ================================= -->
+ <target name="artifacts" depends="jars">
+
+ <jar destfile="${target.dir}/${name}-eclipse-sources.jar"
+ basedir="src/main/java"
+ index="true"
+ indexMetaInf="true"
+ update="true"
+ level="9">
+ <manifest>
+ <attribute name="Implementation-Title" value="IronJacamar eclipse - Sources"/>
+ <attribute name="Implementation-Version" value="${major}.${minor}.${patch}.${type}"/>
+ <attribute name="Implementation-Vendor" value="The IronJacamar project (http://www.jboss.org/ironjacamar)"/>
+ <attribute name="Implementation-Vendor-Id" value="org.jboss"/>
+ </manifest>
+ </jar>
+
+ <mkdir dir="${build.eclipse.dir}/docs"/>
+ <javadoc packagenames="org.*"
+ sourcepath="src/main/java"
+ destdir="${build.eclipse.dir}/docs"
+ doclet="org.jboss.apiviz.APIviz"
+ docletpathref="main.lib.path.id"
+ author="true"
+ version="true"
+ windowtitle="IronJacamar eclipse"
+ doctitle="IronJacamar eclipse"
+ use="true"
+ additionalparam="-author -version"
+ classpath="${build.eclipse.dir}"
+ classpathref="main.lib.path.id"
+ bottom="Copyright © 2008 Red Hat Middleware LLC (http://www.jboss.com/)">
+ <link offline="true" href="http://java.sun.com/j2se/5/docs/api/" packagelistLoc="${java.home}/../docs/api"/>
+ </javadoc>
+ <copy todir="${build.eclipse.dir}/docs" overwrite="true">
+ <fileset dir="${tools.dir}/api"/>
+ </copy>
+
+ <jar destfile="${target.dir}/${name}-eclipse-javadoc.jar"
+ basedir="${build.eclipse.dir}/docs"
+ index="true"
+ indexMetaInf="true"
+ update="true"
+ level="9">
+ <manifest>
+ <attribute name="Implementation-Title" value="IronJacamar eclipse - JavaDoc"/>
+ <attribute name="Implementation-Version" value="${major}.${minor}.${patch}.${type}"/>
+ <attribute name="Implementation-Vendor" value="The IronJacamar project (http://www.jboss.org/ironjacamar)"/>
+ <attribute name="Implementation-Vendor-Id" value="org.jboss"/>
+ </manifest>
+ </jar>
+
+ </target>
+
+</project>
Added: projects/jboss-jca/trunk/eclipse/icons/ij.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-jca/trunk/eclipse/icons/ij.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: projects/jboss-jca/trunk/eclipse/plugin.xml
===================================================================
--- projects/jboss-jca/trunk/eclipse/plugin.xml (rev 0)
+++ projects/jboss-jca/trunk/eclipse/plugin.xml 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ name="Build Category"
+ id="ironjacamar-eclipse.commands.category">
+ </category>
+ <command
+ name="Build Command"
+ categoryId="ironjacamar-eclipse.commands.category"
+ id="ironjacamar-eclipse.commands.buildCommand">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ commandId="ironjacamar-eclipse.commands.buildCommand"
+ class="org.jboss.jca.eclipse.command.BuildHandler">
+ </handler>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="ironjacamar-eclipse.commands.buildCommand"
+ contextId="org.eclipse.ui.contexts.window"
+ sequence="M1+6"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </key>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="menu:org.eclipse.ui.main.menu?after=additions">
+ <menu
+ label="Build Menu"
+ mnemonic="M"
+ id="ironjacamar-eclipse.menus.buildMenu">
+ <command
+ commandId="ironjacamar-eclipse.commands.buildCommand"
+ mnemonic="S"
+ id="ironjacamar-eclipse.menus.buildCommand">
+ </command>
+ </menu>
+ </menuContribution>
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
+ <toolbar
+ id="ironjacamar-eclipse.toolbars.buildToolbar">
+ <command
+ commandId="ironjacamar-eclipse.commands.buildCommand"
+ icon="icons/build.png"
+ tooltip="Say hello world"
+ id="ironjacamar-eclipse.toolbars.buildCommand">
+ </command>
+ </toolbar>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ name="Ironjcamar"
+ id="org.jboss.jca.eclipse.wizards.category">
+ </category>
+ <wizard
+ name="IronJacamar 1.1 project"
+ icon="icons/ij.png"
+ category="org.jboss.jca.eclipse.wizards.category"
+ hasPages="true"
+ class="org.jboss.jca.eclipse.wizards.CodeGenWizard"
+ id="org.jboss.jca.eclipse.wizards.CodeGenWizard"
+ project="true">
+ </wizard>
+ </extension>
+
+</plugin>
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/Activator.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/Activator.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/Activator.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class Activator extends AbstractUIPlugin
+{
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "ironjacamar-eclipse";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator()
+ {
+ }
+
+ /**
+ * start
+ * @param context BundleContext
+ * @throws Exception Exception
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ super.start(context);
+ plugin = this;
+ }
+
+ /**
+ * stop
+ * @param context BundleContext
+ * @throws Exception Exception
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ 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;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path)
+ {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/BuildHandler.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/BuildHandler.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/BuildHandler.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.command;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Our sample handler extends AbstractHandler, an IHandler base class.
+ *
+ * @see org.eclipse.core.commands.IHandler
+ * @see org.eclipse.core.commands.AbstractHandler
+ */
+public class BuildHandler extends AbstractHandler
+{
+ /**
+ * The constructor.
+ */
+ public BuildHandler()
+ {
+ }
+
+ /**
+ * the command has been executed, so extract extract the needed information
+ * from the application context.
+ *
+ * @param event ExecutionEvent
+ * @return Object null
+ * @throws ExecutionException ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+ MessageDialog.openInformation(window.getShell(), "Ironjacamar-eclipse", "Hello, Eclipse world");
+ return null;
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/package.html
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/package.html (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/command/package.html 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,3 @@
+<body>
+Eclipse plugin command
+</body>
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/package.html
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/package.html (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/package.html 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,3 @@
+<body>
+Eclipse plugin
+</body>
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AddPropertyDialog.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AddPropertyDialog.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AddPropertyDialog.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * AddPropertyDialog
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class AddPropertyDialog extends Dialog
+{
+
+ private String name;
+
+ private String value;
+
+ private String type;
+
+ private String title;
+
+ private Label nameLabel;
+
+ private Text nameText;
+
+ private Label valueLabel;
+
+ private Text valueText;
+
+ private String[] initialValues;
+
+ /**
+ * AddPropertyDialog
+ * @param shell shell
+ * @param title dialog title
+ * @param initialValues initialValues
+ */
+ public AddPropertyDialog(Shell shell, String title, String[] initialValues)
+ {
+ super(shell);
+ this.title = title;
+ this.initialValues = initialValues;
+ }
+
+ /** (non-Javadoc)
+ * @param parent Composite
+ * @return Control Control
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent)
+ {
+ Composite comp = (Composite) super.createDialogArea(parent);
+ ((GridLayout) comp.getLayout()).numColumns = 2;
+
+ nameLabel = new Label(comp, SWT.NONE);
+ nameLabel.setText("&Name");
+ nameLabel.setFont(comp.getFont());
+
+ nameText = new Text(comp, SWT.BORDER | SWT.SINGLE);
+ nameText.setText(initialValues[0]);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 300;
+ nameText.setLayoutData(gd);
+ nameText.setFont(comp.getFont());
+ nameText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ updateButtons();
+ }
+ });
+
+ nameLabel = new Label(comp, SWT.NONE);
+ nameLabel.setText("&Type");
+ nameLabel.setFont(comp.getFont());
+
+ final String[] items =
+ {"String", "Integer", "Float"};
+ final Combo combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
+ combo.setItems(items);
+ combo.setText("String");
+ type = initialValues[1];
+ if (type.equals(""))
+ {
+ type = "String";
+ }
+
+ combo.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ type = combo.getText();
+ }
+ });
+
+ valueLabel = new Label(comp, SWT.NONE);
+ valueLabel.setText("&Value");
+ valueLabel.setFont(comp.getFont());
+
+ valueText = new Text(comp, SWT.BORDER | SWT.SINGLE);
+ valueText.setText(initialValues[2]);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 300;
+ valueText.setLayoutData(gd);
+ valueText.setFont(comp.getFont());
+ valueText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ updateButtons();
+ }
+ });
+
+ return comp;
+ }
+
+ /**
+ * Return the name/value pair entered in this dialog. If the cancel button was hit,
+ * both will be <code>null</code>.
+ *
+ * @return arrays of String
+ */
+ public String[] getNameValuePair()
+ {
+ return new String[] {name, type, value};
+ }
+
+ /** (non-Javadoc)
+ *
+ * @param buttonId buttonId
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void buttonPressed(int buttonId)
+ {
+ if (buttonId == IDialogConstants.OK_ID)
+ {
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=248316
+ name = nameText.getText().trim();
+ value = valueText.getText().trim();
+ //fType = fTypeText.getText().trim();
+ }
+ else
+ {
+ name = null;
+ value = null;
+ //fType = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /** (non-Javadoc)
+ *
+ * @param shell shell
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell shell)
+ {
+ super.configureShell(shell);
+ if (title != null)
+ {
+ shell.setText(title);
+ }
+ }
+
+ /**
+ * Enable the OK button if valid input
+ */
+ protected void updateButtons()
+ {
+ String name = nameText.getText().trim();
+ String value = valueText.getText().trim();
+ getButton(IDialogConstants.OK_ID).setEnabled((name.length() > 0) && (value.length() > 0));
+ }
+
+ /**
+ * Enable the buttons on creation.
+ * @see org.eclipse.jface.window.Window#create()
+ */
+ public void create()
+ {
+ super.create();
+ updateButtons();
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AoWizardPage.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AoWizardPage.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/AoWizardPage.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,457 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.jboss.jca.codegenerator.AdminObjectType;
+import org.jboss.jca.codegenerator.ConfigPropType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * AoWizardPage
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class AoWizardPage extends WizardPage
+{
+ private Composite container;
+
+ private Text aoText;
+
+ private Text aoImplText;
+
+ private ISelection selection;
+
+ private TableViewer propsTableViewer;
+
+ private final PropsLabelProvider labelProvider = new PropsLabelProvider();
+
+ private Button editButton;
+
+ private Button removeButton;
+
+ private Button addButton;
+
+ private AdminObjectType aoDef;
+
+ /**
+ * Constructor for AoWizardPage.
+ *
+ * @param selection selection
+ */
+ public AoWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("Create Admin Object");
+ setDescription("Input Admin Object Information.");
+ this.selection = selection;
+
+ }
+
+ /**
+ * createControl
+ *
+ * @param parent Composite
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent)
+ {
+ aoDef = new AdminObjectType();
+ List<AdminObjectType> aoTypes = new ArrayList<AdminObjectType>();
+ aoTypes.add(aoDef);
+ ((CodeGenWizard) getWizard()).getDef().setAdminObjects(aoTypes);
+
+ List<ConfigPropType> propList = aoDef.getAoConfigProps();
+ if (propList == null)
+ {
+ propList = new ArrayList<ConfigPropType>();
+ aoDef.setAoConfigProps(propList);
+ }
+
+ Composite wholeContainer = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ wholeContainer.setLayout(layout);
+ layout.numColumns = 1;
+
+ Composite inContainer = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ inContainer.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ Label label = new Label(inContainer, SWT.NULL);
+ label.setText("Include an admin object:");
+ final Button aoButton = new Button(inContainer, SWT.CHECK);
+
+ aoButton.setSelection(true);
+ ((CodeGenWizard) getWizard()).getDef().setGenAdminObject(true);
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("Use ResourceAdapterAssociation on admin object:");
+
+ final Button raaButton = new Button(inContainer, SWT.CHECK);
+
+ raaButton.setSelection(true);
+ ((CodeGenWizard) getWizard()).getDef().setAdminObjectImplRaAssociation(true);
+ raaButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+
+ ((CodeGenWizard) getWizard()).getDef().setAdminObjectImplRaAssociation(raaButton.getSelection());
+
+ }
+ });
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("Admin object interface name:");
+
+ aoButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+
+ ((CodeGenWizard) getWizard()).getDef().setGenAdminObject(aoButton.getSelection());
+ if (aoButton.getSelection())
+ {
+ raaButton.setEnabled(true);
+ aoText.setEnabled(true);
+ aoImplText.setEnabled(true);
+ }
+ else
+ {
+ raaButton.setEnabled(false);
+ aoText.setEnabled(false);
+ aoImplText.setEnabled(false);
+ }
+ }
+ });
+
+ aoText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
+ aoText.setBounds(5, 5, 600, 10);
+ aoText.setText("AcmeAdminObjectInterface");
+ aoDef.setAdminObjectInterface("AcmeAdminObjectInterface");
+ aoText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = aoText.getText();
+ if (string.length() > 0)
+ {
+ aoDef.setAdminObjectInterface(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("Admin object class name:");
+
+ aoImplText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
+ aoImplText.setBounds(5, 5, 600, 10);
+ aoImplText.setText("AcmeAdminObjectImpl");
+ aoDef.setAdminObjectClass("AcmeAdminObjectImpl");
+ aoImplText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = aoImplText.getText();
+ if (string.length() > 0)
+ {
+ aoDef.setAdminObjectClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("Admin object config properties:");
+
+ container = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+
+ propsTableViewer = createTableViewer(container);
+
+ Composite buttonGroup = new Composite(container, SWT.NONE);
+ GridLayout layoutBtns = new GridLayout();
+ layoutBtns.marginHeight = 0;
+ layoutBtns.marginWidth = 0;
+ buttonGroup.setLayout(layoutBtns);
+ buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
+ buttonGroup.setFont(buttonGroup.getFont());
+
+ addButtonsToButtonGroup(buttonGroup);
+
+ initialize();
+ dialogChanged();
+ setControl(wholeContainer);
+ }
+
+ /**
+ * addButtonsToButtonGroup
+ * @param parent Composite
+ */
+ protected void addButtonsToButtonGroup(Composite parent)
+ {
+ if (editButton == null)
+ {
+ addButton = createPushButton(parent, "Add");
+ editButton = createPushButton(parent, "Edit");
+ removeButton = createPushButton(parent, "Remove");
+ }
+ }
+
+ /**
+ * Creates and returns a configured button in the given composite with the given
+ * label. Widget selection call-backs for the returned button will be processed
+ * by the <code>buttonListener</code>
+ */
+ private Button createPushButton(Composite parent, String label)
+ {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ button.setText(label);
+ this.setButtonLayoutData(button);
+
+ button.addSelectionListener(buttonListener);
+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
+ button.setLayoutData(gridData);
+ return button;
+ }
+
+ /**
+ * Button listener that delegates for widget selection events.
+ */
+ private SelectionAdapter buttonListener = new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ if (event.widget == addButton)
+ {
+ addProperty();
+ }
+ else if (event.widget == editButton)
+ {
+ edit();
+ }
+ else if (event.widget == removeButton)
+ {
+ remove(propsTableViewer);
+ }
+ }
+ };
+
+ /**
+ * Allows the user to enter a user property
+ */
+ private void addProperty()
+ {
+ String title = "Add";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {"", "", ""});
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!overwrite(name)) {
+ return;
+ }
+ */
+
+ List<ConfigPropType> propList = aoDef.getAoConfigProps();
+
+ ConfigPropType prop = new ConfigPropType();
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).add(prop);
+ propList.add(prop);
+ container.update();
+
+ }
+
+ private void edit()
+ {
+ IStructuredSelection selection = (IStructuredSelection) propsTableViewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) selection.getFirstElement();
+
+ String title = "Edit";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {prop.getName(), prop.getType(), prop.getValue()});
+
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!name.equals(originalName)) {
+ if (!overwrite(name)){
+ return;
+ }
+ }
+ */
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).update(prop);
+
+ container.update();
+
+ }
+
+ private void remove(TableViewer viewer)
+ {
+ PropsContentProvider propContentProvider = (PropsContentProvider) viewer.getContentProvider();
+ IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) sel.getFirstElement();
+ aoDef.getAoConfigProps().remove(prop);
+ propContentProvider.remove(sel);
+
+ container.update();
+ }
+
+ /**
+ * Handles selection changes in the Property table viewer.
+ */
+ private void propertyTableSelectionChanged(IStructuredSelection newSelection)
+ {
+
+ }
+
+ private ISelectionChangedListener tableListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+
+ if (event.getSource() == propsTableViewer)
+ {
+ propertyTableSelectionChanged((IStructuredSelection) event.getSelection());
+ }
+ }
+
+ };
+
+ private TableViewer createTableViewer(Composite parent)
+ {
+ String fTableColumnHeaders[] =
+ {"Name", "Type", "Value"};
+ final ColumnLayoutData[] fTableColumnLayouts =
+ {new ColumnWeightData(30), new ColumnWeightData(20), new ColumnWeightData(50)};
+
+ Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+
+ data.widthHint = 600;
+ table.setLayoutData(data);
+ table.setFont(parent.getFont());
+
+ TableViewer tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new PropsContentProvider(tableViewer));
+ tableViewer.setLabelProvider(labelProvider);
+ tableViewer.addSelectionChangedListener(tableListener);
+
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ for (int i = 0; i < fTableColumnHeaders.length; i++)
+ {
+ tableLayout.addColumnData(fTableColumnLayouts[i]);
+ TableColumn column = new TableColumn(table, SWT.NONE, i);
+ column.setResizable(fTableColumnLayouts[i].resizable);
+ column.setText(fTableColumnHeaders[i]);
+ }
+
+ return tableViewer;
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize()
+ {
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged()
+ {
+
+ if (aoText.getText().length() == 0)
+ {
+ updateStatus("Admin object class name must be specified");
+ return;
+ }
+
+ updateStatus(null);
+ return;
+
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/BuildWizardPage.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/BuildWizardPage.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/BuildWizardPage.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * BuildWizardPage
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class BuildWizardPage extends WizardPage
+{
+
+ private ISelection selection;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param selection ISelection
+ */
+ public BuildWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("MBean and build information");
+ setDescription("Input mbean and build information.");
+ this.selection = selection;
+ }
+
+ /**
+ * createControl
+ * @param parent Composite
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent)
+ {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Generate a MBean class:");
+ final Button mbeanButton = new Button(container, SWT.CHECK);
+ mbeanButton.setSelection(false);
+ ((CodeGenWizard) getWizard()).getDef().setGenMbean(false);
+ mbeanButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setGenMbean(mbeanButton.getSelection());
+ }
+ });
+ createBuildGroup(container);
+
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ /**
+ * @param container
+ */
+ private void createBuildGroup(Composite container)
+ {
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Build environment:");
+
+ final String[] items =
+ {"ant", "ant+ivy", "maven"};
+ final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
+ combo.setItems(items);
+ combo.setText("ant");
+ ((CodeGenWizard) getWizard()).getDef().setVersion("ant");
+
+ combo.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setVersion(combo.getText());
+ }
+ });
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize()
+ {
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged()
+ {
+
+ updateStatus(null);
+ return;
+
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/CodeGenWizard.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/CodeGenWizard.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/CodeGenWizard.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,360 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.jboss.jca.codegenerator.BaseProfile;
+import org.jboss.jca.codegenerator.Definition;
+import org.jboss.jca.codegenerator.JCA10Profile;
+import org.jboss.jca.codegenerator.JCA15Profile;
+import org.jboss.jca.codegenerator.JCA16Profile;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.LibraryLocation;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * CodeGenWizard
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class CodeGenWizard extends Wizard implements INewWizard
+{
+ private DefinitionWizardPage defPage;
+
+ private RaWizardPage raPage;
+
+ private McfWizardPage mcfPage;
+
+ private InboundWizardPage inboundPage;
+
+ private AoWizardPage aoPage;
+
+ private BuildWizardPage buildPage;
+
+ private ISelection selection;
+
+ private Definition def;
+
+ private String projectName;
+
+ /**
+ * Constructor for CodeGenWizard.
+ */
+ public CodeGenWizard()
+ {
+ super();
+ setNeedsProgressMonitor(true);
+ def = new Definition();
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages()
+ {
+ defPage = new DefinitionWizardPage(selection);
+ addPage(defPage);
+ raPage = new RaWizardPage(selection);
+ addPage(raPage);
+
+ mcfPage = new McfWizardPage(selection);
+ addPage(mcfPage);
+
+ inboundPage = new InboundWizardPage(selection);
+ addPage(inboundPage);
+
+ aoPage = new AoWizardPage(selection);
+ addPage(aoPage);
+
+ buildPage = new BuildWizardPage(selection);
+ addPage(buildPage);
+ }
+
+ /**
+ * get Definition
+ * @return Definition
+ */
+ public Definition getDef()
+ {
+ return def;
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in
+ * the wizard. We will create an operation and run it
+ * using wizard as execution context.
+ *
+ * @return boolean finished
+ */
+ public boolean performFinish()
+ {
+
+ IRunnableWithProgress op = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException
+ {
+ try
+ {
+ doFinish(monitor);
+ }
+ catch (CoreException e)
+ {
+ throw new InvocationTargetException(e);
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ };
+ try
+ {
+ getContainer().run(true, false, op);
+ }
+ catch (InterruptedException e)
+ {
+ return false;
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * The worker method. It will find the container, create the
+ * file if missing or just replace its contents, and open
+ * the editor on the newly created file.
+ */
+
+ private void doFinish(IProgressMonitor monitor) throws CoreException
+ {
+
+ monitor.beginTask("Initialize generator", 1);
+ IProgressMonitor progressMonitor = new NullProgressMonitor();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(getProjectName());
+ project.create(progressMonitor);
+ project.open(progressMonitor);
+
+ IProjectDescription description = project.getDescription();
+ String[] natures = description.getNatureIds();
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ newNatures[natures.length] = JavaCore.NATURE_ID;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, progressMonitor);
+
+ String path = new File(project.getLocationURI()).toString();
+ System.out.println(path);
+
+ def.setOutputDir(path);
+
+ BaseProfile profile;
+ if (def.getVersion().equals("1.6"))
+ profile = new JCA16Profile();
+ else if (def.getVersion().equals("1.5"))
+ profile = new JCA15Profile();
+ else
+ profile = new JCA10Profile();
+
+ profile.generate(def);
+
+ IJavaProject javaProject = JavaCore.create(project);
+
+ String[] ijJars =
+ {"ironjacamar-spec-api.jar"};
+
+ Bundle bundle = Platform.getBundle("org.jboss.jca.eclipse");
+
+ IFolder firstFolder = project.getFolder("lib");
+ firstFolder.create(true, true, progressMonitor);
+
+ for (String ijJarName : ijJars)
+ {
+ Path srcPath = new Path("libs/" + ijJarName);
+ InputStream stream;
+ try
+ {
+
+ stream = FileLocator.openStream(bundle, srcPath, false);
+ IFile file = project.getFile("lib/" + ijJarName);
+ if (!file.exists())
+ {
+ file.create(stream, true, null);
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+
+ Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>();
+ entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
+ entries.remove(JavaCore.newSourceEntry(new Path("/" + getProjectName())));
+ entries.add(JavaCore.newSourceEntry(new Path("/" + getProjectName() + "/src/main/java")));
+
+ IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
+ LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
+ for (LibraryLocation element : locations)
+ {
+ entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
+ }
+
+ for (String ijJarName : ijJars)
+ {
+ entries.add(JavaCore.newLibraryEntry(new Path("/" + getProjectName() + "/lib/" + ijJarName), null, null));
+ }
+
+ javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), progressMonitor);
+
+ monitor.worked(1);
+
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if
+ * we can initialize from it.
+ *
+ * @param workbench IWorkbench
+ * @param selection IStructuredSelection
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ this.selection = selection;
+ }
+
+ /**
+ * setProjectName
+ * @param projectName projectName
+ */
+ public void setProjectName(String projectName)
+ {
+ this.projectName = projectName;
+ }
+
+ /**
+ * getProjectName
+ * @return projectName
+ */
+ public String getProjectName()
+ {
+ return projectName;
+ }
+
+ /**
+ * getWizardPage
+ * @return WizardPage
+ */
+ public DefinitionWizardPage getDefPage()
+ {
+ return defPage;
+ }
+
+ /**
+ * getWizardPage
+ * @return WizardPage
+ */
+ public RaWizardPage getRaPage()
+ {
+ return raPage;
+ }
+
+ /**
+ * getWizardPage
+ * @return WizardPage
+ */
+ public McfWizardPage getMcfPage()
+ {
+ return mcfPage;
+ }
+
+ /**
+ * getWizardPage
+ * @return WizardPage
+ */
+ public InboundWizardPage getInboundPage()
+ {
+ return inboundPage;
+ }
+
+ /**
+ * getWizardPage
+ * @return WizardPage
+ */
+ public AoWizardPage getAoPage()
+ {
+ return aoPage;
+ }
+
+ /**
+ * getWizardPage
+ * @return WizardPage
+ */
+ public BuildWizardPage getBuildPage()
+ {
+ return buildPage;
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/DefinitionWizardPage.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/DefinitionWizardPage.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/DefinitionWizardPage.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,308 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * DefinitionWizardPage
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class DefinitionWizardPage extends WizardPage
+{
+ private Text projectText;
+
+ private Text packageText;
+
+ private ISelection selection;
+
+ private Combo boundCombo;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param selection ISelection
+ */
+ public DefinitionWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("Create JCA Project");
+ setDescription("This wizard creates a new jca project.");
+ this.selection = selection;
+ }
+
+ /**
+ * @param parent Composite
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent)
+ {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Project name:");
+ projectText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ projectText.setLayoutData(gd);
+
+ projectText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = projectText.getText();
+ ((CodeGenWizard) getWizard()).setProjectName(string);
+ if (string.length() > 0)
+ {
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(container, SWT.NULL);
+ label.setText("Pac&kage name:");
+ packageText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ packageText.setLayoutData(gd);
+ packageText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = packageText.getText();
+ if (string.length() > 0)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setRaPackage(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ createProfileGroup(container);
+ createBoundTypeGroup(container);
+
+ createTransactionGroup(container);
+
+ label = new Label(container, SWT.NULL);
+ label.setText("&Reauthentication:");
+ final Button reauthButton = new Button(container, SWT.CHECK);
+ reauthButton.setSelection(false);
+ ((CodeGenWizard) getWizard()).getDef().setSupportReauthen(false);
+ reauthButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setSupportReauthen(reauthButton.getSelection());
+ }
+ });
+
+ label = new Label(container, SWT.NULL);
+ label.setText("&Annotations:");
+ final Button annotationshButton = new Button(container, SWT.CHECK);
+ annotationshButton.setSelection(true);
+ ((CodeGenWizard) getWizard()).getDef().setUseAnnotation(true);
+ annotationshButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setUseAnnotation(reauthButton.getSelection());
+ }
+ });
+
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ /**
+ * @param container
+ */
+ private void createProfileGroup(Composite container)
+ {
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Profile version:");
+
+ final String[] items = {"1.6", "1.5", "1.0"};
+ final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
+ combo.setItems(items);
+ combo.setText("1.6");
+ ((CodeGenWizard) getWizard()).getDef().setVersion("1.6");
+
+ combo.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setVersion(combo.getText());
+ if (combo.getText().equals("1.0"))
+ {
+ String[] newdirect =
+ {"Outbound"};
+ boundCombo.setItems(newdirect);
+ boundCombo.setText("Outbound");
+ }
+ else
+ {
+ String[] newdirect =
+ {"Outbound", "Inbound", "Bidirectional"};
+ boundCombo.setItems(newdirect);
+ boundCombo.setText("Outbound");
+ }
+ }
+ });
+ }
+
+ /**
+ * @param container
+ */
+ private void createBoundTypeGroup(Composite container)
+ {
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Type:");
+
+ final String[] items =
+ {"Outbound", "Inbound", "Bidirectional"};
+ boundCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
+ boundCombo.setItems(items);
+ boundCombo.setText("Outbound");
+ ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(true);
+ ((CodeGenWizard) getWizard()).getDef().setSupportInbound(false);
+
+ boundCombo.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ if (boundCombo.getText().equals("Outbound"))
+ {
+ ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(true);
+ ((CodeGenWizard) getWizard()).getDef().setSupportInbound(false);
+ }
+ else if (boundCombo.getText().equals("Inbound"))
+ {
+ ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(false);
+ ((CodeGenWizard) getWizard()).getDef().setSupportInbound(true);
+ }
+ else if (boundCombo.getText().equals("Bidirectional"))
+ {
+ ((CodeGenWizard) getWizard()).getDef().setSupportOutbound(true);
+ ((CodeGenWizard) getWizard()).getDef().setSupportInbound(true);
+ }
+ }
+ });
+ }
+
+ /**
+ * @param container
+ */
+ private void createTransactionGroup(Composite container)
+ {
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Transaction support:");
+
+ final String[] items =
+ {"NoTransaction", "LocalTransaction", "XATransaction"};
+ final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
+ combo.setItems(items);
+ combo.setText("NoTransaction");
+ ((CodeGenWizard) getWizard()).getDef().setSupportTransaction("NoTransaction");
+
+ combo.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setSupportTransaction(combo.getText());
+ }
+ });
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+ private void initialize()
+ {
+
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+ private void dialogChanged()
+ {
+
+ String outDir = projectText.getText();
+ if (outDir.length() == 0)
+ {
+ updateStatus("Project name must be specified");
+ return;
+ }
+ if (packageText.getText().length() == 0)
+ {
+ updateStatus("Package name must be specified");
+ return;
+ }
+
+ updateStatus(null);
+
+ return;
+
+ }
+
+ @Override
+ public IWizardPage getNextPage()
+ {
+ if (((CodeGenWizard) getWizard()).getDef().getVersion().equals("1.0"))
+ {
+ return ((CodeGenWizard) getWizard()).getMcfPage();
+ }
+ return super.getNextPage();
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/InboundWizardPage.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/InboundWizardPage.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/InboundWizardPage.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,437 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.jboss.jca.codegenerator.ConfigPropType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * InboundWizardPage
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class InboundWizardPage extends WizardPage
+{
+ private Composite container;
+
+ private Text mlText;
+
+ private Text asText;
+
+ private Text acText;
+
+ private ISelection selection;
+
+ private TableViewer propsTableViewer;
+
+ private final PropsLabelProvider labelProvider = new PropsLabelProvider();
+
+ private Button editButton;
+
+ private Button removeButton;
+
+ private Button addButton;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param selection ISelection
+ */
+ public InboundWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("Create Inbound");
+ setDescription("Input Inbound Information.");
+ this.selection = selection;
+
+ }
+
+ /**
+ * @param parent Composite
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent)
+ {
+ Composite wholeContainer = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ wholeContainer.setLayout(layout);
+ layout.numColumns = 1;
+
+ Composite inContainer = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ inContainer.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ List<ConfigPropType> propList = ((CodeGenWizard) getWizard()).getDef().getAsConfigProps();
+ if (propList == null)
+ {
+ propList = new ArrayList<ConfigPropType>();
+ ((CodeGenWizard) getWizard()).getDef().setAsConfigProps(propList);
+ }
+
+ Label label = new Label(inContainer, SWT.NULL);
+ label.setText("MessageListener:");
+
+ mlText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ mlText.setLayoutData(gd);
+ mlText.setText("AcmeMessageListener");
+ ((CodeGenWizard) getWizard()).getDef().setDefaultPackageInbound(true);
+ ((CodeGenWizard) getWizard()).getDef().setMlClass("AcmeMessageListener");
+ mlText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = mlText.getText();
+ if (string.length() > 0)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setMlClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("ActivationSpec:");
+
+ asText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ asText.setLayoutData(gd);
+ asText.setText("AcmeActivationSpec");
+ ((CodeGenWizard) getWizard()).getDef().setAsClass("AcmeActivationSpec");
+ asText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = asText.getText();
+ if (string.length() > 0)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setAsClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("ActivationSpec config properties:");
+
+ container = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+
+ propsTableViewer = createTableViewer(container);
+ Composite buttonGroup = new Composite(container, SWT.NONE);
+ GridLayout layoutBtns = new GridLayout();
+ layoutBtns.marginHeight = 0;
+ layoutBtns.marginWidth = 0;
+ buttonGroup.setLayout(layoutBtns);
+ buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
+ buttonGroup.setFont(buttonGroup.getFont());
+
+ addButtonsToButtonGroup(buttonGroup);
+
+ inContainer = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ inContainer.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ label = new Label(inContainer, SWT.NULL);
+ label.setText("Activation:");
+
+ acText = new Text(inContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ acText.setLayoutData(gd);
+ acText.setText("AcmeActivation");
+ ((CodeGenWizard) getWizard()).getDef().setActivationClass("AcmeActivation");
+ acText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = acText.getText();
+ if (string.length() > 0)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setActivationClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ initialize();
+ dialogChanged();
+ setControl(wholeContainer);
+ }
+
+ private void addButtonsToButtonGroup(Composite parent)
+ {
+ if (editButton == null)
+ {
+ addButton = createPushButton(parent, "Add");
+ editButton = createPushButton(parent, "Edit");
+ removeButton = createPushButton(parent, "Remove");
+ }
+ }
+
+ /**
+ * Creates and returns a configured button in the given composite with the given
+ * label. Widget selection call-backs for the returned button will be processed
+ * by the <code>buttonListener</code>
+ */
+ private Button createPushButton(Composite parent, String label)
+ {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ button.setText(label);
+ this.setButtonLayoutData(button);
+
+ button.addSelectionListener(buttonListener);
+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
+ button.setLayoutData(gridData);
+ return button;
+ }
+
+ /**
+ * Button listener that delegates for widget selection events.
+ */
+ private SelectionAdapter buttonListener = new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ if (event.widget == addButton)
+ {
+ addProperty();
+ }
+ else if (event.widget == editButton)
+ {
+ edit();
+ }
+ else if (event.widget == removeButton)
+ {
+ remove(propsTableViewer);
+ }
+ }
+ };
+
+ /**
+ * Allows the user to enter a user property
+ */
+ private void addProperty()
+ {
+ String title = "Add";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {"", "", ""});
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!overwrite(name)) {
+ return;
+ }
+ */
+
+ List<ConfigPropType> propList = ((CodeGenWizard) getWizard()).getDef().getAsConfigProps();
+
+ ConfigPropType prop = new ConfigPropType();
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).add(prop);
+ propList.add(prop);
+ container.update();
+
+ }
+
+ private void edit()
+ {
+ IStructuredSelection selection = (IStructuredSelection) propsTableViewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) selection.getFirstElement();
+
+ String title = "Edit";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {prop.getName(), prop.getType(), prop.getValue()});
+
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!name.equals(originalName)) {
+ if (!overwrite(name)){
+ return;
+ }
+ }
+ */
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).update(prop);
+
+ container.update();
+
+ }
+
+ private void remove(TableViewer viewer)
+ {
+ PropsContentProvider propContentProvider = (PropsContentProvider) viewer.getContentProvider();
+ IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) sel.getFirstElement();
+ ((CodeGenWizard) getWizard()).getDef().getAsConfigProps().remove(prop);
+ propContentProvider.remove(sel);
+
+ container.update();
+ }
+
+ /**
+ * Handles selection changes in the Property table viewer.
+ */
+ private void propertyTableSelectionChanged(IStructuredSelection newSelection)
+ {
+
+ }
+
+ private ISelectionChangedListener tableListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+
+ if (event.getSource() == propsTableViewer)
+ {
+ propertyTableSelectionChanged((IStructuredSelection) event.getSelection());
+ }
+ }
+
+ };
+
+ private TableViewer createTableViewer(Composite parent)
+ {
+ String fTableColumnHeaders[] =
+ {"Name", "Type", "Value"};
+ final ColumnLayoutData[] fTableColumnLayouts =
+ {new ColumnWeightData(30), new ColumnWeightData(40), new ColumnWeightData(30)};
+
+ Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+
+ data.widthHint = 600;
+ table.setLayoutData(data);
+ table.setFont(parent.getFont());
+
+ TableViewer tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new PropsContentProvider(tableViewer));
+ tableViewer.setLabelProvider(labelProvider);
+ tableViewer.addSelectionChangedListener(tableListener);
+
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ for (int i = 0; i < fTableColumnHeaders.length; i++)
+ {
+ tableLayout.addColumnData(fTableColumnLayouts[i]);
+ TableColumn column = new TableColumn(table, SWT.NONE, i);
+ column.setResizable(fTableColumnLayouts[i].resizable);
+ column.setText(fTableColumnHeaders[i]);
+ }
+
+ return tableViewer;
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize()
+ {
+
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged()
+ {
+
+ if (mlText.getText().length() == 0)
+ {
+ updateStatus("ResourceAdapter class name must be specified");
+ return;
+ }
+
+ updateStatus(null);
+ return;
+
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/McfWizardPage.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/McfWizardPage.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/McfWizardPage.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,570 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.jboss.jca.codegenerator.ConfigPropType;
+import org.jboss.jca.codegenerator.McfDef;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * McfWizardPage
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class McfWizardPage extends WizardPage
+{
+ private Composite container;
+
+ private Text mcfText;
+
+ private Text mcText;
+
+ private Text cfText;
+
+ private Text cfImplText;
+
+ private Text connText;
+
+ private Text connImplText;
+
+ private ISelection selection;
+
+ private TableViewer propsTableViewer;
+
+ private final PropsLabelProvider labelProvider = new PropsLabelProvider();
+
+ private Button editButton;
+
+ private Button removeButton;
+
+ private Button addButton;
+
+ private McfDef mcfDef;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param selection ISelection
+ */
+ public McfWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("Create Mcf");
+ setDescription("Input Mcf Information.");
+ this.selection = selection;
+
+ }
+
+ /**
+ * @param parent Composite
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent)
+ {
+ mcfDef = new McfDef(1, ((CodeGenWizard) getWizard()).getDef());
+ List<McfDef> mcfDefs = new ArrayList<McfDef>();
+ mcfDefs.add(mcfDef);
+ ((CodeGenWizard) getWizard()).getDef().setMcfDefs(mcfDefs);
+
+ List<ConfigPropType> propList = mcfDef.getMcfConfigProps();
+ if (propList == null)
+ {
+ propList = new ArrayList<ConfigPropType>();
+ mcfDef.setMcfConfigProps(propList);
+ }
+ Composite wholeContainer = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ wholeContainer.setLayout(layout);
+ layout.numColumns = 1;
+
+ Composite mcfContainer = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ mcfContainer.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ Label label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Management Connection Factory class name:");
+
+ mcfText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ mcfText.setLayoutData(gd);
+ mcfText.setText("AcmeManagedConnectionFactory");
+ mcfDef.setMcfClass("AcmeManagedConnectionFactory");
+ mcfText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = mcfText.getText();
+ if (string.length() > 0)
+ {
+ mcfDef.setMcfClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Management Connection Factory Properties:");
+
+ container = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+
+ propsTableViewer = createTableViewer(container);
+ Composite buttonGroup = new Composite(container, SWT.NONE);
+ GridLayout layoutBtns = new GridLayout();
+ layoutBtns.marginHeight = 0;
+ layoutBtns.marginWidth = 0;
+ buttonGroup.setLayout(layoutBtns);
+ buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
+ buttonGroup.setFont(buttonGroup.getFont());
+
+ addButtonsToButtonGroup(buttonGroup);
+
+ mcfContainer = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ mcfContainer.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Use ResourceAdapterAssociation:");
+
+ final Button annoButton = new Button(mcfContainer, SWT.CHECK);
+ annoButton.setSelection(true);
+ mcfDef.setImplRaAssociation(true);
+ annoButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+
+ mcfDef.setImplRaAssociation(annoButton.getSelection());
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Management Connection:");
+
+ mcText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ mcText.setLayoutData(gd);
+ mcText.setText("AcmeManagedConnection");
+ mcfDef.setMcClass("AcmeManagedConnection");
+ mcText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = mcText.getText();
+ if (string.length() > 0)
+ {
+ mcfDef.setMcClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Use CCi:");
+
+ final Button cciButton = new Button(mcfContainer, SWT.CHECK);
+ cciButton.setSelection(false);
+ mcfDef.setUseCciConnection(false);
+ cciButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+
+ mcfDef.setUseCciConnection(cciButton.getSelection());
+ if (cciButton.getSelection())
+ {
+ cfText.setEnabled(false);
+ cfImplText.setEnabled(false);
+ connText.setEnabled(false);
+ connImplText.setEnabled(false);
+ }
+ else
+ {
+ cfText.setEnabled(true);
+ cfImplText.setEnabled(true);
+ connText.setEnabled(true);
+ connImplText.setEnabled(true);
+ }
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Connection factory interface:");
+
+ cfText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ cfText.setLayoutData(gd);
+ cfText.setText("AcmeConnectionFactory");
+ mcfDef.setCfInterfaceClass("AcmeConnectionFactory");
+ cfText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = cfText.getText();
+ if (string.length() > 0)
+ {
+ mcfDef.setCfInterfaceClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Management Connection:");
+
+ cfImplText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ cfImplText.setLayoutData(gd);
+ cfImplText.setText("AcmeConnectionFactoryImpl");
+ mcfDef.setCfClass("AcmeConnectionFactoryImpl");
+ cfImplText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = cfImplText.getText();
+ if (string.length() > 0)
+ {
+ mcfDef.setCfClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Connection interface:");
+
+ connText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ connText.setLayoutData(gd);
+ connText.setText("AcmeConnection");
+ mcfDef.setConnInterfaceClass("AcmeConnection");
+ connText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = connText.getText();
+ if (string.length() > 0)
+ {
+ mcfDef.setConnInterfaceClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(mcfContainer, SWT.NULL);
+ label.setText("Connection implementation:");
+
+ connImplText = new Text(mcfContainer, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ connImplText.setLayoutData(gd);
+ connImplText.setText("AcmeConnectionImpl");
+ mcfDef.setConnImplClass("AcmeConnectionImpl");
+ connImplText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = connImplText.getText();
+ if (string.length() > 0)
+ {
+ mcfDef.setConnImplClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+ initialize();
+ dialogChanged();
+ setControl(wholeContainer);
+ }
+
+ private void addButtonsToButtonGroup(Composite parent)
+ {
+ if (editButton == null)
+ {
+ addButton = createPushButton(parent, "Add");
+ editButton = createPushButton(parent, "Edit");
+ removeButton = createPushButton(parent, "Remove");
+ }
+ }
+
+ /**
+ * Creates and returns a configured button in the given composite with the given
+ * label. Widget selection call-backs for the returned button will be processed
+ * by the <code>buttonListener</code>
+ */
+ private Button createPushButton(Composite parent, String label)
+ {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ button.setText(label);
+ this.setButtonLayoutData(button);
+
+ button.addSelectionListener(buttonListener);
+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
+ button.setLayoutData(gridData);
+ return button;
+ }
+
+ /**
+ * Button listener that delegates for widget selection events.
+ */
+ private SelectionAdapter buttonListener = new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ if (event.widget == addButton)
+ {
+ addProperty();
+ }
+ else if (event.widget == editButton)
+ {
+ edit();
+ }
+ else if (event.widget == removeButton)
+ {
+ remove(propsTableViewer);
+ }
+ }
+ };
+
+ /**
+ * Allows the user to enter a user property
+ */
+ private void addProperty()
+ {
+ String title = "Add";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {"", "", ""});
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!overwrite(name)) {
+ return;
+ }
+ */
+
+ List<ConfigPropType> propList = mcfDef.getMcfConfigProps();
+
+ ConfigPropType prop = new ConfigPropType();
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).add(prop);
+ propList.add(prop);
+ container.update();
+
+ }
+
+ private void edit()
+ {
+ IStructuredSelection selection = (IStructuredSelection) propsTableViewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) selection.getFirstElement();
+
+ String title = "Edit";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {prop.getName(), prop.getType(), prop.getValue()});
+
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!name.equals(originalName)) {
+ if (!overwrite(name)){
+ return;
+ }
+ }
+ */
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).update(prop);
+
+ container.update();
+
+ }
+
+ private void remove(TableViewer viewer)
+ {
+ PropsContentProvider propContentProvider = (PropsContentProvider) viewer.getContentProvider();
+ IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) sel.getFirstElement();
+ mcfDef.getMcfConfigProps().remove(prop);
+ propContentProvider.remove(sel);
+
+ container.update();
+ }
+
+ /**
+ * Handles selection changes in the Property table viewer.
+ */
+ private void propertyTableSelectionChanged(IStructuredSelection newSelection)
+ {
+
+ }
+
+ private ISelectionChangedListener tableListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+
+ if (event.getSource() == propsTableViewer)
+ {
+ propertyTableSelectionChanged((IStructuredSelection) event.getSelection());
+ }
+ }
+
+ };
+
+ private TableViewer createTableViewer(Composite parent)
+ {
+ String fTableColumnHeaders[] =
+ {"Name", "Type", "Value"};
+ final ColumnLayoutData[] fTableColumnLayouts =
+ {new ColumnWeightData(30), new ColumnWeightData(40), new ColumnWeightData(30)};
+
+ Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+
+ data.widthHint = 600;
+ table.setLayoutData(data);
+ table.setFont(parent.getFont());
+
+ TableViewer tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new PropsContentProvider(tableViewer));
+ tableViewer.setLabelProvider(labelProvider);
+ tableViewer.addSelectionChangedListener(tableListener);
+
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ for (int i = 0; i < fTableColumnHeaders.length; i++)
+ {
+ tableLayout.addColumnData(fTableColumnLayouts[i]);
+ TableColumn column = new TableColumn(table, SWT.NONE, i);
+ column.setResizable(fTableColumnLayouts[i].resizable);
+ column.setText(fTableColumnHeaders[i]);
+ }
+
+ return tableViewer;
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize()
+ {
+
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged()
+ {
+
+ if (mcfText.getText().length() == 0)
+ {
+ updateStatus("ResourceAdapter class name must be specified");
+ return;
+ }
+
+ updateStatus(null);
+ return;
+
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ @Override
+ public IWizardPage getNextPage()
+ {
+ if (!((CodeGenWizard) getWizard()).getDef().isSupportInbound())
+ {
+ return ((CodeGenWizard) getWizard()).getAoPage();
+ }
+ return super.getNextPage();
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsContentProvider.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsContentProvider.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsContentProvider.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * Content provider that maintains a generic list of objects which are shown in
+ * a table viewer.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class PropsContentProvider implements IStructuredContentProvider
+{
+ private List elements = new ArrayList();
+
+ private TableViewer tableViewer;
+
+ private ViewerComparator fComparator = null;
+
+ private boolean defaultcomparator = true;
+
+ /**
+ * Default Constructor
+ *
+ * @param tableViewer TableViewer
+ */
+ public PropsContentProvider(TableViewer tableViewer)
+ {
+ this.tableViewer = tableViewer;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param defaultcomparator if the default comparator should be used for the returned data
+ * @since 3.5
+ */
+ public PropsContentProvider(boolean defaultcomparator)
+ {
+ this.defaultcomparator = defaultcomparator;
+ }
+
+ /**
+ * Add an element to the current listing of elements and to the underlying viewer. Does nothing
+ * if the listing already contains the given element
+ * @param o object
+ */
+ public void add(Object o)
+ {
+ if (elements.contains(o))
+ {
+ return;
+ }
+ elements.add(o);
+ tableViewer.add(o);
+ tableViewer.setSelection(new StructuredSelection(o), true);
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose()
+ {
+ }
+
+ /**
+ * getElements
+ *
+ * @param inputElement object
+ * @return Object[] array of object
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement)
+ {
+ return elements.toArray();
+ }
+
+ /**
+ * inputChanged
+ *
+ * @param viewer Viewer
+ * @param oldInput Object
+ * @param newInput Object
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ }
+
+ /**
+ * update
+ * @param o Object
+ */
+ public void update(Object o)
+ {
+ tableViewer.update(o, null);
+ }
+
+ /**
+ * Removes the given element from the listing of elements and from the backing viewer.
+ * @param o Object
+ */
+ public void remove(Object o)
+ {
+ elements.remove(o);
+ tableViewer.remove(o);
+ }
+
+ /**
+ * Removes the given selection of the listing of elements and from the backing viewer
+ * @param selection IStructuredSelection
+ */
+ public void remove(IStructuredSelection selection)
+ {
+ Object[] array = selection.toArray();
+ elements.removeAll(Arrays.asList(array));
+ tableViewer.remove(array);
+ }
+
+ /**
+ * Returns the default comparator which compares the {@link #toString()} value of the elements for ordering
+ * @return the default comparator
+ */
+ protected ViewerComparator getComparator()
+ {
+ if (fComparator == null)
+ {
+ fComparator = new ViewerComparator()
+ {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
+ * java.lang.Object, java.lang.Object)
+ */
+ public int compare(Viewer viewer, Object e1, Object e2)
+ {
+ return e1.toString().compareToIgnoreCase(e2.toString());
+ }
+ };
+ }
+ return fComparator;
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsLabelProvider.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsLabelProvider.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/PropsLabelProvider.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.jboss.jca.codegenerator.ConfigPropType;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Label provider for type elements
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class PropsLabelProvider extends LabelProvider implements ITableLabelProvider
+{
+
+ /**
+ * Method declared on IBaseLabelProvider.
+ */
+ @Override
+ public void dispose()
+ {
+ }
+
+ /**
+ * Method declared on ITableLabelProvider.
+ *
+ * @param element object
+ * @param columnIndex integer
+ * @return Image image reference
+ */
+ @Override
+ public Image getColumnImage(Object element, int columnIndex)
+ {
+ if (columnIndex != 0)
+ {
+ return null;
+ }
+
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
+ }
+
+ /**
+ * Method declared on ITableLabelProvider.
+ *
+ * @param element object
+ * @param columnIndex integer
+ * @return String column text
+ */
+ @Override
+ public String getColumnText(Object element, int columnIndex)
+ {
+
+ if (element instanceof ConfigPropType)
+ {
+ return getPropertyText((ConfigPropType) element, columnIndex);
+ }
+ return element.toString();
+ }
+
+ /**
+ * getPropertyText
+ *
+ * @param property ConfigPropType
+ * @param columnIndex int
+ * @return string
+ */
+ public String getPropertyText(ConfigPropType property, int columnIndex)
+ {
+ switch (columnIndex)
+ {
+ case 0 :
+ return property.getName();
+ case 1 :
+ return property.getType();
+ case 2 :
+ return property.getValue();
+ }
+ return "";
+ }
+
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/RaWizardPage.java
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/RaWizardPage.java (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/RaWizardPage.java 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,401 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.eclipse.wizards;
+
+import org.jboss.jca.codegenerator.ConfigPropType;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * RaWizardPage
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+
+public class RaWizardPage extends WizardPage
+{
+ private Composite container;
+
+ private Text raText;
+
+ private ISelection selection;
+
+ private TableViewer propsTableViewer;
+
+ private final PropsLabelProvider labelProvider = new PropsLabelProvider();
+
+ private Button editButton;
+
+ private Button removeButton;
+
+ private Button addButton;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param selection ISelection
+ */
+ public RaWizardPage(ISelection selection)
+ {
+ super("wizardPage");
+ setTitle("Resource adapter information");
+ setDescription("Input information about resource adapter.");
+ this.selection = selection;
+ }
+
+ /**
+ * @param parent Composite
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent)
+ {
+ List<ConfigPropType> propList = ((CodeGenWizard) getWizard()).getDef().getRaConfigProps();
+ if (propList == null)
+ {
+ propList = new ArrayList<ConfigPropType>();
+ ((CodeGenWizard) getWizard()).getDef().setRaConfigProps(propList);
+ }
+ Composite wholeContainer = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ wholeContainer.setLayout(layout);
+ layout.numColumns = 1;
+
+ Composite raContainer = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ raContainer.setLayout(layout);
+ layout.numColumns = 2;
+ layout.verticalSpacing = 9;
+
+ Label label = new Label(raContainer, SWT.NULL);
+ label.setText("Include a ResourceAdapter:");
+ final Button raButton = new Button(raContainer, SWT.CHECK);
+ raButton.setSelection(true);
+ ((CodeGenWizard) getWizard()).getDef().setUseRa(true);
+ raButton.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+
+ ((CodeGenWizard) getWizard()).getDef().setUseRa(raButton.getSelection());
+ raText.setEnabled(raButton.getSelection());
+ }
+ });
+
+ label = new Label(raContainer, SWT.NULL);
+ label.setText("Resource adapter class name:");
+ raText = new Text(raContainer, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.widthHint = 600;
+ raText.setLayoutData(gd);
+ raText.setText("AcmeResourceAdapter");
+ ((CodeGenWizard) getWizard()).getDef().setRaClass("AcmeResourceAdapter");
+ raText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ String string = raText.getText();
+ if (string.length() > 0)
+ {
+ ((CodeGenWizard) getWizard()).getDef().setRaClass(string);
+ updateStatus(null);
+ }
+ dialogChanged();
+ }
+ });
+
+ label = new Label(raContainer, SWT.NULL);
+ label.setText("ResourceAdapter Properties:");
+
+ container = new Composite(wholeContainer, SWT.NULL);
+ layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+
+ propsTableViewer = createTableViewer(container);
+
+ Composite buttonGroup = new Composite(container, SWT.NONE);
+ GridLayout layoutBtns = new GridLayout();
+ layoutBtns.marginHeight = 0;
+ layoutBtns.marginWidth = 0;
+ buttonGroup.setLayout(layoutBtns);
+ buttonGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL));
+ buttonGroup.setFont(buttonGroup.getFont());
+
+ addButtonsToButtonGroup(buttonGroup);
+
+ initialize();
+ dialogChanged();
+ setControl(wholeContainer);
+ }
+
+ private void addButtonsToButtonGroup(Composite parent)
+ {
+ if (editButton == null)
+ {
+ addButton = createPushButton(parent, "Add");
+ editButton = createPushButton(parent, "Edit");
+ removeButton = createPushButton(parent, "Remove");
+ }
+ }
+
+ /**
+ * Creates and returns a configured button in the given composite with the given
+ * label. Widget selection call-backs for the returned button will be processed
+ * by the <code>buttonListener</code>
+ */
+ private Button createPushButton(Composite parent, String label)
+ {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ button.setText(label);
+ this.setButtonLayoutData(button);
+
+ button.addSelectionListener(buttonListener);
+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
+ button.setLayoutData(gridData);
+ return button;
+ }
+
+ /**
+ * Button listener that delegates for widget selection events.
+ */
+ private SelectionAdapter buttonListener = new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent event)
+ {
+ if (event.widget == addButton)
+ {
+ addProperty();
+ }
+ else if (event.widget == editButton)
+ {
+ edit();
+ }
+ else if (event.widget == removeButton)
+ {
+ remove(propsTableViewer);
+ }
+ }
+ };
+
+ /**
+ * Allows the user to enter a user property
+ */
+ private void addProperty()
+ {
+ String title = "Add";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {"", "", ""});
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!overwrite(name)) {
+ return;
+ }
+ */
+
+ List<ConfigPropType> propList = ((CodeGenWizard) getWizard()).getDef().getRaConfigProps();
+
+ ConfigPropType prop = new ConfigPropType();
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).add(prop);
+ propList.add(prop);
+ container.update();
+
+ }
+
+ private void edit()
+ {
+ IStructuredSelection selection = (IStructuredSelection) propsTableViewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) selection.getFirstElement();
+
+ String title = "Edit";
+ AddPropertyDialog dialog = new AddPropertyDialog(propsTableViewer.getControl().getShell(), title, new String[]
+ {prop.getName(), prop.getType(), prop.getValue()});
+
+ if (dialog.open() == Window.CANCEL)
+ {
+ return;
+ }
+
+ String[] pair = dialog.getNameValuePair();
+ String name = pair[0];
+ /*
+ if (!name.equals(originalName)) {
+ if (!overwrite(name)){
+ return;
+ }
+ }
+ */
+ prop.setName(name);
+ prop.setType(pair[1]);
+ prop.setValue(pair[2]);
+ ((PropsContentProvider) propsTableViewer.getContentProvider()).update(prop);
+
+ container.update();
+
+ }
+
+ private void remove(TableViewer viewer)
+ {
+ PropsContentProvider propContentProvider = (PropsContentProvider) viewer.getContentProvider();
+ IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
+ ConfigPropType prop = (ConfigPropType) sel.getFirstElement();
+ ((CodeGenWizard) getWizard()).getDef().getRaConfigProps().remove(prop);
+ propContentProvider.remove(sel);
+
+ container.update();
+ }
+
+ /**
+ * Handles selection changes in the Property table viewer.
+ */
+ private void propertyTableSelectionChanged(IStructuredSelection newSelection)
+ {
+
+ }
+
+ private ISelectionChangedListener tableListener = new ISelectionChangedListener()
+ {
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+
+ if (event.getSource() == propsTableViewer)
+ {
+ propertyTableSelectionChanged((IStructuredSelection) event.getSelection());
+ }
+ }
+
+ };
+
+ private TableViewer createTableViewer(Composite parent)
+ {
+ String fTableColumnHeaders[] =
+ {"Name", "Type", "Value"};
+ final ColumnLayoutData[] fTableColumnLayouts =
+ {new ColumnWeightData(30), new ColumnWeightData(20), new ColumnWeightData(50)};
+
+ Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+
+ data.widthHint = 600;
+ table.setLayoutData(data);
+ table.setFont(parent.getFont());
+
+ TableViewer tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new PropsContentProvider(tableViewer));
+ tableViewer.setLabelProvider(labelProvider);
+ tableViewer.addSelectionChangedListener(tableListener);
+
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ for (int i = 0; i < fTableColumnHeaders.length; i++)
+ {
+ tableLayout.addColumnData(fTableColumnLayouts[i]);
+ TableColumn column = new TableColumn(table, SWT.NONE, i);
+ column.setResizable(fTableColumnLayouts[i].resizable);
+ column.setText(fTableColumnHeaders[i]);
+ }
+
+ return tableViewer;
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize()
+ {
+
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged()
+ {
+
+ if (raText.getText().length() == 0)
+ {
+ updateStatus("ResourceAdapter class name must be specified");
+ return;
+ }
+
+ updateStatus(null);
+ return;
+
+ }
+
+ private void updateStatus(String message)
+ {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ @Override
+ public IWizardPage getNextPage()
+ {
+ if (!((CodeGenWizard) getWizard()).getDef().isSupportOutbound())
+ {
+ return ((CodeGenWizard) getWizard()).getInboundPage();
+ }
+ return super.getNextPage();
+ }
+}
Added: projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/package.html
===================================================================
--- projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/package.html (rev 0)
+++ projects/jboss-jca/trunk/eclipse/src/main/java/org/jboss/jca/eclipse/wizards/package.html 2012-01-17 08:02:58 UTC (rev 112579)
@@ -0,0 +1,3 @@
+<body>
+Eclipse plugin wizard
+</body>
More information about the jboss-cvs-commits
mailing list