JBoss Tools SVN: r5486 - trunk/jbpm/docs/reference/en/modules.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2007-12-29 10:10:27 -0500 (Sat, 29 Dec 2007)
New Revision: 5486
Modified:
trunk/jbpm/docs/reference/en/modules/Quick_Howto_Guide.xml
trunk/jbpm/docs/reference/en/modules/Test_Drive_Proc.xml
trunk/jbpm/docs/reference/en/modules/jboss_jbpm_runtime_installation.xml
Log:
http://jira.jboss.com/jira/browse/JBDS-233 - updating according to the Svetlana Mukhina
Modified: trunk/jbpm/docs/reference/en/modules/Quick_Howto_Guide.xml
===================================================================
--- trunk/jbpm/docs/reference/en/modules/Quick_Howto_Guide.xml 2007-12-29 13:48:06 UTC (rev 5485)
+++ trunk/jbpm/docs/reference/en/modules/Quick_Howto_Guide.xml 2007-12-29 15:10:27 UTC (rev 5486)
@@ -89,8 +89,8 @@
</mediaobject>
</figure>
- <para>The <property>General</property> page is a place where you can specify the name of
- a Task and its description. For instance, let it be <emphasis>
+ <para>The <property>General</property> page is a place where you can specify the name of a
+ Task and its description. For instance, let it be <emphasis>
<property>approve oder</property>
</emphasis> with appropriate description that you can see in the figure below.</para>
@@ -108,8 +108,9 @@
that is a mandatory property for the Task. The due date is the date on which the task
should be accomplished. Here you can also set a Task priority as well as signalling,
notifying or blocking. The <emphasis>
- <property>Blocking</property></emphasis> attribute indicates that the process will not be
- able to continue if this task is still unaccomplished. The <emphasis>
+ <property>Blocking</property>
+ </emphasis> attribute indicates that the process will not be able to continue if this
+ task is still unaccomplished. The <emphasis>
<property>Generate Form...</property>
</emphasis> button is for creating a simple task form that can be rendered by the jBPM
console.</para>
@@ -126,11 +127,12 @@
<para>For our example, we specify the due date as 2 business days, choose the high priority
and also check the <emphasis>
- <property>Signalling</property></emphasis> and <emphasis>
- <property>Notify</property></emphasis> attributes. It means that the Task should be
- accomplished in 2 business days and the assignee will be notified by email when the task
- is assigned. To specify how the Task should be assigned switch on to the
- <property>Assignment</property> page.</para>
+ <property>Signalling</property>
+ </emphasis> and <emphasis>
+ <property>Notify</property>
+ </emphasis> attributes. It means that the Task should be accomplished in 2 business days
+ and the assignee will be notified by email when the task is assigned. To specify how the
+ Task should be assigned switch on to the <property>Assignment</property> page.</para>
<figure>
<title>The Task Assignment Page</title>
@@ -155,8 +157,8 @@
</mediaobject>
</figure>
- <para>In our case, the assignee will be reminded by email after two business hours and continue
- to get reminding every business hour after that.</para>
+ <para>In our case, the assignee will be reminded by email after two business hours and
+ continue to get reminding every business hour after that.</para>
<para>In the next figure you can see our configuring generated into XML.</para>
<figure>
<title>The Task Reminder Page</title>
@@ -167,7 +169,10 @@
</imageobject>
</mediaobject>
</figure>
-
+
</section>
+ <para>We hope, our guide will help you to get started with the jPDL process language and jBPM
+ workflow on the whole. Besides, for additional information you are welcome on <ulink
+ url="http://www.jboss.com/index.html?module=bb&op=viewforum&f=217">our forum</ulink>.</para>
</chapter>
Modified: trunk/jbpm/docs/reference/en/modules/Test_Drive_Proc.xml
===================================================================
--- trunk/jbpm/docs/reference/en/modules/Test_Drive_Proc.xml 2007-12-29 13:48:06 UTC (rev 5485)
+++ trunk/jbpm/docs/reference/en/modules/Test_Drive_Proc.xml 2007-12-29 15:10:27 UTC (rev 5486)
@@ -89,8 +89,10 @@
<para>By default JUnite 3 version of testing framework is selected. Of course, you can choose
new advanced JUnit 4 version. In this case you'll be prompted to add new JUnit
- Library to your build path. To add it automatically just click on the appropriate link. In the <emphasis>
- <property>Class under test</property></emphasis> section you can specify the class to test.</para>
+ Library to your build path. To add it automatically just click on the appropriate link. In
+ the <emphasis>
+ <property>Class under test</property>
+ </emphasis> section you can specify the class to test.</para>
<figure>
<title>A First Test Scenario</title>
@@ -162,7 +164,10 @@
show how you can reuse your development skills in a very straightforward way when doing
process development. To see how more interesting processes and process test
scenario's can be developed, we suggest you to read the <ulink
- url="http://docs.jboss.com/jbpm/v3/userguide/">JBoss jBPM User Guide</ulink> and to
- study the API reference. Moreover some more examples will be given later in this book.</para>
+ url="http://docs.jboss.com/jbpm/v3/userguide/">JBoss jBPM User Guide</ulink> and to
+ study the API reference. You can find it in the jBPM download folder. (To get started we
+ downloaded jbpm-jpdl-3.2.2 in <link linkend="jboss_jbpm_runtime_installation">the second
+ chapter</link>. You should just remember where you extracted it.) All we've mentioned are in the 'javadoc- *' subfolders of the 'doc' folder.
+ Moreover, some more examples will be given later in this book.</para>
</chapter>
Modified: trunk/jbpm/docs/reference/en/modules/jboss_jbpm_runtime_installation.xml
===================================================================
--- trunk/jbpm/docs/reference/en/modules/jboss_jbpm_runtime_installation.xml 2007-12-29 13:48:06 UTC (rev 5485)
+++ trunk/jbpm/docs/reference/en/modules/jboss_jbpm_runtime_installation.xml 2007-12-29 15:10:27 UTC (rev 5486)
@@ -13,15 +13,16 @@
<title>JBoss jBPM Runtime Installation</title>
<para>The main purpose of this chapter is to let you know how to launch the <property>JBoss
jBPM</property> (business process management).</para>
- <para>The jBPM plugin (jBPM Designer) is already included in the <property>JBoss Tools</property>. To make it work, you should only download the jBPM runtime (jbpm-jpdl-3.2.2
- currently) from <ulink url="http://labs.jboss.com/jbossjbpm/downloads/">here</ulink> and specify
- the directory where you extracted the runtime either when you create a jBPM project or by using
- the jBPM preference pages.</para>
+ <para>The jBPM plugin (jBPM Designer) is already included in the <property>JBoss Tools</property>.
+ To make it work, you should only download the jBPM runtime (<ulink
+ url="http://labs.jboss.com/jbossjbpm/downloads/">jbpm-jpdl-3.2.2</ulink> currently) and specify the
+ directory where you extracted the runtime either when you create a jBPM project or by using the
+ jBPM preference pages.</para>
<para>Navigate to <emphasis>
<property>Window > Preferences > JBoss jBPM > Runtime Locations</property>
</emphasis>. Here you can add, edit and remove JBoss jBPM installation locations. Click <emphasis>
<property>Add</property>
- </emphasis> button. In the diallog that appeared enter a name for a newly added jBPM runtime and
+ </emphasis> button. In the dialog that appeared enter a name for a newly added jBPM runtime and
point to the correct location of this package on your harddrive. Click <emphasis>
<property>OK</property>
</emphasis> then click <emphasis>
@@ -36,5 +37,6 @@
</imageobject>
</mediaobject>
</figure>
- <para>Now, when you have a runtime installed, we are going to demonstrate some powerful features of the jBPM.</para>
+ <para>Now, when you have a runtime installed, we are going to demonstrate some powerful features of
+ the jBPM.</para>
</chapter>
16 years, 12 months
JBoss Tools SVN: r5485 - trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2007-12-29 08:48:06 -0500 (Sat, 29 Dec 2007)
New Revision: 5485
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1571
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java 2007-12-29 13:46:43 UTC (rev 5484)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java 2007-12-29 13:48:06 UTC (rev 5485)
@@ -96,7 +96,7 @@
IPath resourcePath = new Path(RESOURCE_PATH);
File resourceFolder = resourcePath.toFile();
if (!resourceFolder.exists())
- throw new RuntimeException("Folder " + RESOURCE_PATH + " not found!");
+ throw new RuntimeException("Folder " + RESOURCE_PATH + " does not found!");
IPackageFragmentRoot sourceFolder = buildSourceFolder(project, javaProject);
recursiveCopyFiles(resourceFolder, (IFolder) sourceFolder.getResource());
16 years, 12 months
JBoss Tools SVN: r5484 - in trunk/hibernatetools/tests/org.hibernate.eclipse.console.test: res and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2007-12-29 08:46:43 -0500 (Sat, 29 Dec 2007)
New Revision: 5484
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateMappingTests.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateNatureTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenJavaEditors.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1571
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateMappingTests.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateMappingTests.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateMappingTests.java 2007-12-29 13:46:43 UTC (rev 5484)
@@ -0,0 +1,133 @@
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.ui.IPackagesViewPart;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+public class HibernateMappingTests extends TestCase {
+
+ private MappingTestProject project;
+
+ public HibernateMappingTests(String name) {
+ super(name);
+ }
+
+ private TestResult result = null;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.project = MappingTestProject.getTestProject();
+
+ //PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllPerspectives(false, true);
+
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective(
+ PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId("org.eclipse.ui.resourcePerspective"));
+
+ IPackagesViewPart packageExplorer = null;
+ try {
+ packageExplorer = (IPackagesViewPart) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().showView(JavaUI.ID_PACKAGES);
+ } catch (PartInitException e) {
+ throw new RuntimeException(e);
+ }
+
+ packageExplorer.selectAndReveal(project.getIJavaProject());
+
+ waitForJobs();
+ delay(2000);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#run(junit.framework.TestResult)
+ */
+ @Override
+ public void run(TestResult result) {
+ this.result = result;
+ super.run(result);
+
+ }
+
+ public void tearDown() throws Exception {
+ waitForJobs();
+ this.project.deleteIProject();
+ waitForJobs();
+ super.tearDown();
+ }
+
+
+ /**
+ * Process UI input but do not return for the specified time interval.
+ *
+ * @param waitTimeMillis
+ * the number of milliseconds
+ */
+ protected void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+
+ // If this is the UI thread,
+ // then process input.
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
+ }
+
+ /**
+ * Wait until all background tasks are complete.
+ */
+ public void waitForJobs() {
+ while (Platform.getJobManager().currentJob() != null)
+ delay(1000);
+ }
+
+ protected MappingTestProject getProject() {
+ return this.project;
+ }
+
+ public void testRunTestSet() {
+ TestSuite suite = TestSet.getTests();
+ //is waytForJob() necessary between each test?
+ //suite.run(result);
+ for (int i = 0; i < suite.testCount(); i++) {
+ Test test = suite.testAt(i);
+ test.run(result);
+ /*if (result.failureCount() > 0){
+ fail("Test " + test.getClass().getName() + " failed.");
+ }
+ if (result.errorCount() > 0){
+ fail("Test " + test.getClass().getName() + " has errors.");
+ }*/
+ waitForJobs();
+ delay(20000);
+ }
+ if (result.failureCount() > 0){
+ fail("One or more test failed.");
+ }
+ if (result.errorCount() > 0){
+ fail("One or more test has error(s).");
+ }
+ }
+}
+
\ No newline at end of file
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateMappingTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateNatureTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateNatureTest.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateNatureTest.java 2007-12-29 13:46:43 UTC (rev 5484)
@@ -0,0 +1,33 @@
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jdt.core.IJavaProject;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNatureTest extends TestCase {
+ public void testEnableHibernateNature() throws BackingStoreException, CoreException {
+ MappingTestProject project = MappingTestProject.getTestProject();
+ IJavaProject prj = project.getIJavaProject();
+ IScopeContext scope = new ProjectScope(prj.getProject() );
+
+ Preferences node = scope.getNode("org.hibernate.eclipse.console");
+
+ node.putBoolean("hibernate3.enabled", true );
+ node.put("default.configuration", "testcfg" );
+ node.flush();
+
+ ProjectUtils.addProjectNature(prj.getProject(), "org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
+ ProjectUtils.removeProjectNature(prj.getProject(), "org.hibernate.eclipse.console.hibernateNature", new NullProgressMonitor() );
+ }
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HibernateNatureTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java 2007-12-29 13:46:43 UTC (rev 5484)
@@ -0,0 +1,324 @@
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+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.IWorkspace;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class MappingTestProject{
+
+ private static MappingTestProject singleton= null;
+
+ private static final Path JRE_CONTAINER = new Path("org.eclipse.jdt.launching.JRE_CONTAINER");
+
+ public static String PROJECT_NAME = "MappingTestProject";
+ public static String RESOURCE_PATH = "res/project/";
+
+ private static FileFilter fileFilter = new FileFilter(){
+ public boolean accept(File pathname) {
+ return !pathname.isDirectory();
+ }};
+
+ private static FileFilter dirFilter = new FileFilter(){
+ public boolean accept(File pathname) {
+ //exclude ".svn" and other unnessesary folders
+ if (pathname.getName().charAt(0) == '.') return false;
+ return pathname.isDirectory();
+ }};
+
+ private IProject project;
+ private IJavaProject javaProject;
+
+ public static MappingTestProject getTestProject(){
+ if (singleton == null){
+ singleton = new MappingTestProject();
+ }
+ return singleton;
+ }
+
+ private MappingTestProject() {
+ initialize();
+ }
+
+ private void initialize(){
+ try{
+ buildBigTestProject();
+ }catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+
+ public IProject getIProject(){
+ return this.project;
+ }
+
+ public IJavaProject getIJavaProject(){
+ return this.javaProject;
+ }
+
+ public void deleteIProject() throws CoreException {
+ project.delete(true, true, null);
+ }
+
+ private void buildBigTestProject() throws JavaModelException, CoreException {
+ project = buildNewProject(PROJECT_NAME);
+ javaProject = buildJavaProject(project);
+
+
+ IPath resourcePath = new Path(RESOURCE_PATH);
+ File resourceFolder = resourcePath.toFile();
+ if (!resourceFolder.exists())
+ throw new RuntimeException("Folder " + RESOURCE_PATH + " not found!");
+
+ IPackageFragmentRoot sourceFolder = buildSourceFolder(project, javaProject);
+ recursiveCopyFiles(resourceFolder, (IFolder) sourceFolder.getResource());
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
+ }
+
+ private void recursiveCopyFiles(File src, IFolder dst){
+ File[] files = src.listFiles(fileFilter);
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ if (!file.exists()) continue;
+ IFile iFile = dst.getFile(file.getName());
+ try {
+ iFile.create(new FileInputStream(file), true, null);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ continue;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ continue;
+ }
+ }
+
+ File[] dirs = src.listFiles(dirFilter);
+ for (int i = 0; i < dirs.length; i++) {
+ File dir = dirs[i];
+ if (!dir.exists()) continue;
+ IFolder iFolder = dst.getFolder(dir.getName());
+ try {
+ iFolder.create(true, true, null);
+ recursiveCopyFiles(dir, iFolder);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ continue;
+ }
+ }
+ }
+
+
+ private IProject buildNewProject(String projectName) {
+ // get a project handle
+ final IProject newProjectHandle = ResourcesPlugin.getWorkspace()
+ .getRoot().getProject(projectName);
+
+ // get a project descriptor
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IProjectDescription description = workspace
+ .newProjectDescription(newProjectHandle.getName());
+
+ try {
+ createAndOpenProject(description, newProjectHandle);
+ } catch (CoreException ce) {
+ throw new RuntimeException(ce);
+ }
+
+ return newProjectHandle;
+ }
+
+ private void createAndOpenProject(IProjectDescription description,
+ IProject projectHandle) throws CoreException {
+
+ projectHandle.create(description, null);
+ projectHandle.open(IResource.BACKGROUND_REFRESH, null);
+ }
+
+ private IJavaProject buildJavaProject(IProject project) {
+ IJavaProject javaProject = JavaCore.create(project);
+ try {
+ setJavaNature(project);
+ } catch (CoreException ce) {
+ throw new RuntimeException(ce);
+ }
+
+ javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
+ javaProject.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
+ javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
+ return javaProject;
+ }
+
+ private void setJavaNature(IProject project) throws CoreException {
+ IProjectDescription description = project.getDescription();
+ description.setNatureIds(new String[] { JavaCore.NATURE_ID });
+ project.setDescription(description, null);
+ }
+
+
+ private IPackageFragmentRoot buildSourceFolder(IProject project,
+ IJavaProject javaProject) throws CoreException {
+ IFolder folder = project.getFolder("src");
+ if (!folder.exists()){
+ folder.create(false, true, null);
+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
+ IClasspathEntry[] newEntries = { JavaCore
+ .newSourceEntry(root.getPath()) , JavaCore
+ .newContainerEntry(JRE_CONTAINER)};
+ javaProject.setRawClasspath(newEntries, null);
+ return root;
+ }
+ return javaProject.getPackageFragmentRoot(folder);
+ }
+
+
+
+ /*private boolean removePackage(String name, IProject project,
+ IJavaProject javaProject) {
+ IFolder folder = project.getFolder("src");
+ IPackageFragmentRoot root = javaProject.getPackageFragmentRoot(folder);
+ IPackageFragment useless = root.getPackageFragment(name);
+ if (useless != null){
+ try {
+ useless.delete(true, new NullProgressMonitor());
+ } catch (JavaModelException e) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /*private IPackageFragment buildPackage(String name, IProject project,
+ IJavaProject javaProject) throws CoreException {
+ IPackageFragmentRoot sourceFolder = buildSourceFolder(project,
+ javaProject);
+ return sourceFolder.createPackageFragment(name, false, null);
+ }
+
+ private IType[] buildTypes(IProject project, IJavaProject javaProject, CompilationPack compPack) throws CoreException
+ /*throws CoreException*/ //{
+
+ //create empty ICompilationUnit
+ //String cuName = compPack.getPack().getName();
+ /*IPackageFragment jPack = buildPackage(compPack.getPack(), project, javaProject);
+ ICompilationUnit cu = null;//jPack.createCompilationUnit(cuName,
+ //"", false, null);
+
+ List<IType> result = new ArrayList<IType>();
+
+ InputStream is;
+ try {
+ File[] files = compPack.getFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].getName().endsWith(".java")){
+ is = new FileInputStream(files[i]);
+ String fileBody = getStringFromStream(is);
+
+ //ASTParser parser = ASTParser.newParser(AST.JLS3);
+ //parser.setSource(fileBody.toCharArray());
+ //CompilationUnit cu2 = (CompilationUnit) parser.createAST(null);
+ String cuName = files[i].getName();
+
+ try {
+ cu = jPack.createCompilationUnit(cuName, fileBody, false, null);
+ result.addAll(Arrays.asList(cu.getAllTypes()));
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ System.out.println("Error compiling file " + files[i].getAbsolutePath());
+ }
+ }
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ for (int i = 0; i < result.size(); i++) {
+ System.out.println(((IType)result.get(i)).getElementName());
+ }
+ return (IType[])result.toArray(new IType[0]);
+ }
+
+ public static String getStringFromStream (InputStream is)
+ throws IOException
+ {
+ try {
+ InputStreamReader reader = new InputStreamReader(is);
+ char[] buffer = new char[1024];
+ StringWriter writer = new StringWriter();
+ int bytes_read;
+ while ((bytes_read = reader.read(buffer)) != -1)
+ {
+ writer.write(buffer, 0, bytes_read);
+ }
+ return (writer.toString());
+ }
+ finally {
+ if (null != is) is.close();
+ }
+ }
+
+ private void createCompilationPacks(File pack, List<CompilationPack> compPacks, String packName){
+ if (pack.isDirectory()){
+ if (packName.length() != 0) packName += '.';
+ packName += pack.getName();
+
+ File[] files = pack.listFiles(fileFilter);
+ if (files.length > 0) compPacks.add(new CompilationPack(packName, files));
+
+ File[] dirs = pack.listFiles(dirFilter);
+ for (int i = 0; i < dirs.length; i++) {
+ createCompilationPacks(dirs[i], compPacks, packName);
+ }
+ }
+ }
+
+ public class CompilationPack {
+
+ private String pack = null;
+
+ private File[] files = null;
+
+ CompilationPack (String pack, File[] files){
+ this.pack = pack;
+ this.files = files;
+ }
+
+ public String getPack() {
+ return pack;
+ }
+
+ public File[] getFiles() {
+ return files;
+ }
+ }*/
+
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/MappingTestProject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenJavaEditors.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenJavaEditors.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenJavaEditors.java 2007-12-29 13:46:43 UTC (rev 5484)
@@ -0,0 +1,51 @@
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * @author Dmitry Geraskov
+ * just to test that our external Unit tests work right with MappingTestProject
+ */
+public class OpenJavaEditors extends TestCase {
+
+ public void testOpenJavaEditor() throws JavaModelException {
+ MappingTestProject mapProject = MappingTestProject.getTestProject();
+
+ IPackageFragmentRoot[] roots = mapProject.getIJavaProject().getAllPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getClass() != PackageFragmentRoot.class) continue;
+ PackageFragmentRoot packageFragmentRoot = (PackageFragmentRoot) roots[i];
+ IJavaElement[] els = packageFragmentRoot.getChildren();//.getCompilationUnits();
+ for (int j = 0; j < els.length; j++) {
+ IJavaElement javaElement = els[j];
+ if (javaElement instanceof IPackageFragment){
+ ICompilationUnit[] cus = ((IPackageFragment)javaElement).getCompilationUnits();
+ for (int k = 0; k < cus.length; k++) {
+ ICompilationUnit compilationUnit = cus[k];
+ FileEditorInput input = new FileEditorInput((IFile) compilationUnit.getCorrespondingResource());
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, JavaUI.ID_CU_EDITOR );
+ } catch (PartInitException e) {
+ fail("Error opening CompilationUnit: " + e.getMessage());
+ }
+ }
+ }
+ }
+ }
+
+ //PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ }
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/OpenJavaEditors.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java 2007-12-29 13:46:43 UTC (rev 5484)
@@ -0,0 +1,20 @@
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class TestSet{
+
+ public static TestSuite getTests(){
+ TestSuite suite = new TestSuite("Test for MappingTestProject" );
+ //use only addTestSuit to prevent errors
+ suite.addTestSuite( OpenJavaEditors.class );
+ suite.addTestSuite( HibernateNatureTest.class );
+
+ return suite;
+ }
+
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
16 years, 12 months
JBoss Tools SVN: r5483 - trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2007-12-29 08:00:06 -0500 (Sat, 29 Dec 2007)
New Revision: 5483
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1550
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2007-12-29 12:54:53 UTC (rev 5482)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2007-12-29 13:00:06 UTC (rev 5483)
@@ -105,6 +105,9 @@
refreshProject(project);
+ number = getMarkersNumber(bbcComponentFile);
+ assertFalse("Problem marker 'Duplicate component name' not found", number == 0);
+
String[] messages = getMarkersMessage(bbcComponentFile);
assertTrue("Problem marker 'Duplicate component name' not found","Duplicate component name: abcComponent".equals(messages[0]));
@@ -127,6 +130,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Stateful component does not contain @Remove method' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Stateful component does not contain @Remove method' not found", "Stateful component \"statefulComponent\" must have a method marked @Remove".equals(messages[0]));
@@ -148,6 +154,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Stateful component does not contain @Destroy method' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Stateful component does not contain @Destroy method' not found", "Stateful component \"statefulComponent\" must have a method marked @Destroy".equals(messages[0]));
@@ -169,6 +178,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Stateful component has wrong scope' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Stateful component has wrong scope' not found", "Stateful component \"statefulComponent\" should not have org.jboss.seam.ScopeType.PAGE, nor org.jboss.seam.ScopeType.STATELESS".equals(messages[0]));
@@ -191,6 +203,9 @@
refreshProject(project);
+ number = getMarkersNumber(componentsFile);
+ assertFalse("Problem marker 'Component class name cannot be resolved to a type' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(componentsFile);
assertTrue("Problem marker 'Component class name cannot be resolved to a type' not found", "\"org.domain.SeamWebTestProject.session.StateComponent\" cannot be resolved to a type".equals(messages[0]));
@@ -223,6 +238,9 @@
refreshProject(project);
+ number = getMarkersNumber(componentsFile);
+ assertFalse("Problem marker 'Component class does not contain setter for property' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(componentsFile);
assertTrue("Problem marker 'Component class does not contain setter for property' not found", "Class \"StatefulComponent\" of component \"statefulComponent\" does not contain setter for property \"abc\"".equals(messages[0]));
@@ -263,6 +281,9 @@
refreshProject(project);
+ number = getMarkersNumber(abcEntityFile);
+ assertFalse("Problem marker 'Entity component has wrong scope' not found' not found' not found", number == 0);
+
String[] messages = getMarkersMessage(abcEntityFile);
assertTrue("Problem marker 'Entity component has wrong scope' not found", "Entity component \"abcEntity\" should not have org.jboss.seam.ScopeType.STATELESS".equals(messages[0]));
@@ -284,6 +305,9 @@
refreshProject(project);
+ number = getMarkersNumber(abcEntityFile);
+ assertFalse("Problem marker 'Duplicate @Remove method' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(abcEntityFile);
assertTrue("Problem marker 'Duplicate @Remove method' not found", messages[0].startsWith("Duplicate @Remove method \"removeMethod"));
@@ -324,6 +348,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Duplicate @Destroy method' not found' not found' not found", number == 0);
+
String[] messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Duplicate @Destroy method' not found", messages[0].startsWith("Duplicate @Destroy method \"destroyMethod"));
@@ -354,6 +381,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Duplicate @Create method' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Duplicate @Create method' not found", messages[0].startsWith("Duplicate @Create method \"createMethod"));
@@ -384,6 +414,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Duplicate @Unwrap method' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Duplicate @Unwrap method' not found", messages[0].startsWith("Duplicate @Unwrap method \"unwrapMethod"));
@@ -423,6 +456,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Only component class can have @Destroy method' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Only component class can have @Destroy method' not found", "Only component class can have @Destroy method \"destroyMethod\"".equals(messages[0]));
@@ -444,6 +480,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Only component class can have @Create method' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Only component class can have @Create method' not found", "Only component class can have @Create method \"createMethod\"".equals(messages[0]));
@@ -465,6 +504,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Only component class can have @Unwrap method' not found' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Only component class can have @Unwrap method' not found", "Only component class can have @Unwrap method \"unwrapMethod\"".equals(messages[0]));
@@ -486,6 +528,9 @@
refreshProject(project);
+ number = getMarkersNumber(statefulComponentFile);
+ assertFalse("Problem marker 'Only component class can have @Observer method' not found' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(statefulComponentFile);
assertTrue("Problem marker 'Only component class can have @Observer method' not found", "Only component class can have @Observer method \"observerMethod\"".equals(messages[0]));
@@ -518,6 +563,9 @@
refreshProject(project);
+ number = getMarkersNumber(Component12File);
+ assertFalse("Problem marker 'Unknown factory name' not found' not found' not found' not found", number == 0);
+
String[] messages = getMarkersMessage(Component12File);
assertTrue("Problem marker 'Unknown factory name' not found", "Factory method \"messageList2\" with a void return type must have an associated @Out/Databinder".equals(messages[0]));
@@ -525,7 +573,6 @@
int[] lineNumbers = getMarkersNumbersOfLine(Component12File);
assertTrue("Problem marker has wrong line number", lineNumbers[0] == 24);
-
}
public void testBijectionsValidator() {
@@ -564,6 +611,9 @@
}
refreshProject(project);
+
+ number = getMarkersNumber(selectionTestFile);
+ assertFalse("Problem marker 'Multiple data binder' not found' not found' not found' not found", number == 0);
String[] messages = getMarkersMessage(selectionTestFile);
assertTrue("Problem marker 'Multiple data binder", messages[0].startsWith("@DataModelSelection and @DataModelSelectionIndex without name of the DataModel requires the only one @DataModel in the component"));
@@ -575,6 +625,9 @@
assertTrue("Problem marker has wrong line number", lineNumbers[0] == 21 || lineNumbers[0] == 24);
assertTrue("Problem marker has wrong line number", lineNumbers[0] == 21 || lineNumbers[0] == 24);
+ number = getMarkersNumber(selectionIndexTestFile);
+ assertFalse("Problem marker 'Multiple data binder' not found' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(selectionIndexTestFile);
assertTrue("Problem marker 'Multiple data binder", messages[0].startsWith("@DataModelSelection and @DataModelSelectionIndex without name of the DataModel requires the only one @DataModel in the component"));
@@ -607,6 +660,9 @@
}
refreshProject(project);
+
+ number = getMarkersNumber(selectionTestFile);
+ assertFalse("Problem marker 'Unknown @DataModel/@Out name' not found' not found' not found' not found", number == 0);
messages = getMarkersMessage(selectionTestFile);
assertTrue("Problem marker 'Unknown @DataModel/@Out name", messages[0].startsWith("Unknown @DataModel/@Out name: messageList2"));
@@ -614,6 +670,9 @@
lineNumbers = getMarkersNumbersOfLine(selectionTestFile);
assertTrue("Problem marker has wrong line number", lineNumbers[0] == 27);
+
+ number = getMarkersNumber(selectionIndexTestFile);
+ assertFalse("Problem marker 'Unknown @DataModel/@Out name' not found' not found' not found' not found", number == 0);
messages = getMarkersMessage(selectionIndexTestFile);
assertTrue("Problem marker 'Unknown @DataModel/@Out name", messages[0].startsWith("Unknown @DataModel/@Out name: messageList2"));
@@ -650,16 +709,18 @@
}
refreshProject(project);
-
+
String[] messages = getMarkersMessage(contextVariableTestFile);
assertTrue("Not all problem markers 'Duplicate variable name' was found", messages.length == 4);
- assertTrue("Problem marker 'Duplicate variable name' not found", "Duplicate variable name: messageList".equals(messages[0]));
+ for(int i=0;i<4;i++)
+ assertTrue("Problem marker 'Duplicate variable name' not found", "Duplicate variable name: messageList".equals(messages[i]));
int[] lineNumbers = getMarkersNumbersOfLine(contextVariableTestFile);
- assertTrue("Problem marker has wrong line number", (lineNumbers[0] == 16)||(lineNumbers[0] == 17)||(lineNumbers[0] == 36)||(lineNumbers[0] == 41));
+ for(int i=0;i<4;i++)
+ assertTrue("Problem marker has wrong line number", (lineNumbers[i] == 16)||(lineNumbers[i] == 17)||(lineNumbers[i] == 36)||(lineNumbers[i] == 41));
// Unknown variable name
System.out.println("Test - Unknown variable name");
@@ -675,6 +736,9 @@
refreshProject(project);
+ number = getMarkersNumber(contextVariableTestFile);
+ assertFalse("Problem marker 'Unknown variable name' not found' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(contextVariableTestFile);
assertTrue("Problem marker 'Unknown variable name' not found", "Unknown context variable name: messageList5".equals(messages[0]));
@@ -719,6 +783,9 @@
refreshProject(project);
+ number = getMarkersNumber(abcComponentXHTMLFile);
+ assertFalse("Problem marker 'Context variable cannot be resolved' not found' not found' not found' not found", number == 0);
+
String[] messages = getMarkersMessage(abcComponentXHTMLFile);
assertTrue("Problem marker 'Context variable cannot be resolved' not found", "bcComponent cannot be resolved".equals(messages[0]));
@@ -741,6 +808,9 @@
refreshProject(project);
+ number = getMarkersNumber(abcComponentXHTMLFile);
+ assertFalse("Problem marker 'Property cannot be resolved' not found' not found' not found' not found", number == 0);
+
messages = getMarkersMessage(abcComponentXHTMLFile);
assertTrue("Problem marker 'Property cannot be resolved' not found", "actionType2 cannot be resolved".equals(messages[0]));
@@ -776,6 +846,9 @@
}
refreshProject(project);
+
+ number = getMarkersNumber(abcComponentXHTMLFile);
+ assertFalse("Problem marker 'Unpaired Getter/Setter' not found' not found' not found' not found", number == 0);
messages = getMarkersMessage(abcComponentXHTMLFile);
@@ -795,6 +868,9 @@
}
refreshProject(project);
+
+ number = getMarkersNumber(abcComponentXHTMLFile);
+ assertFalse("Problem marker 'Unpaired Getter/Setter' not found' not found' not found' not found", number == 0);
messages = getMarkersMessage(abcComponentXHTMLFile);
16 years, 12 months
JBoss Tools SVN: r5482 - trunk/jbpm/docs.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2007-12-29 07:54:53 -0500 (Sat, 29 Dec 2007)
New Revision: 5482
Removed:
trunk/jbpm/docs/build/
Log:
build folder delete
16 years, 12 months
JBoss Tools SVN: r5481 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test: resources/jsfTest/WebContent/pages/JBIDE and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2007-12-29 06:16:12 -0500 (Sat, 29 Dec 2007)
New Revision: 5481
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/JBIDE-1467.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ImportProvider.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfJbideTest.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfUtil.java
Removed:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfComponentsUtil.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentTest.java
Log:
junit tests was updated
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/JBIDE-1467.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/JBIDE-1467.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/JBIDE-1467.jsp 2007-12-29 11:16:12 UTC (rev 5481)
@@ -0,0 +1,22 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<html>
+<head>
+</head>
+<body>
+
+<f:view>
+
+ <h:selectOneRadio>
+
+ <f:selectItem itemLabel="value1" />
+ <f:selectItem itemLabel="value2" />
+ <f:selectItem itemLabel="value3" />
+ <f:selectItem itemLabel="value4" />
+
+ </h:selectOneRadio>
+
+</f:view>
+</body>
+</html>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ImportProvider.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ImportProvider.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/ImportProvider.java 2007-12-29 11:16:12 UTC (rev 5481)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
+
+/**
+ * @author sdzmitrovich
+ *
+ */
+public class ImportProvider implements IImportStructureProvider {
+
+ /**
+ * list of files which will not be imported
+ */
+ List unimportedFiles = new ArrayList();
+
+ /**
+ * Creates an instance of <code>ImportProvider</code>.
+ */
+ public ImportProvider() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IImportStructureProvider
+ */
+ public List getChildren(Object element) {
+ File folder = (File) element;
+ String[] children = folder.list();
+ int childrenLength = children == null ? 0 : children.length;
+ List result = new ArrayList(childrenLength);
+
+ for (int i = 0; i < childrenLength; i++) {
+ if (!unimportedFiles.contains(children[i]))
+ result.add(new File(folder, children[i]));
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IImportStructureProvider
+ */
+ public InputStream getContents(Object element) {
+ try {
+ return new FileInputStream((File) element);
+ } catch (FileNotFoundException e) {
+ IDEWorkbenchPlugin.log(e.getLocalizedMessage(), e);
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IImportStructureProvider
+ */
+ public String getFullPath(Object element) {
+ return ((File) element).getPath();
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IImportStructureProvider
+ */
+ public String getLabel(Object element) {
+
+ // Get the name - if it is empty then return the path as it is a file
+ // root
+ File file = (File) element;
+ String name = file.getName();
+ if (name.length() == 0) {
+ return file.getPath();
+ }
+ return name;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IImportStructureProvider
+ */
+ public boolean isFolder(Object element) {
+ return ((File) element).isDirectory();
+ }
+
+ public List getUnimportedFiles() {
+ return unimportedFiles;
+ }
+
+ public void setUnimportedFiles(List unimportedFiles) {
+ this.unimportedFiles = unimportedFiles;
+ }
+
+}
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2007-12-29 01:50:30 UTC (rev 5480)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2007-12-29 11:16:12 UTC (rev 5481)
@@ -26,7 +26,7 @@
private static void prepareTests() {
- TestJsfComponentsUtil.importJsfPages(JsfTestPlugin
+ TestJsfUtil.importJsfPages(JsfTestPlugin
.getPluginResourcePath()
+ TEST_PROJECT_PATH);
@@ -40,6 +40,7 @@
// $JUnit-BEGIN$
suite.addTestSuite(JsfComponentTest.class);
+// suite.addTestSuite(JsfJideTest.class);
// $JUnit-END$
return suite;
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentTest.java 2007-12-29 01:50:30 UTC (rev 5480)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentTest.java 2007-12-29 11:16:12 UTC (rev 5481)
@@ -13,9 +13,7 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.ILogListener;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IEditorInput;
@@ -32,7 +30,6 @@
public class JsfComponentTest extends TestCase implements ILogListener {
private final static String EDITOR_ID = "org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"; // $NON-NLS-1$
- // private final static String TEST_PROJECT_JAR_PATH = "/jsfTest.jar"; //
// $NON-NLS-1$
// check warning log
@@ -54,19 +51,6 @@
protected void setUp() throws Exception {
super.setUp();
- // TODO: Use TestSetup to create and remove project once for all tests
- // not for every one
- // if (ResourcesPlugin.getWorkspace().getRoot().findMember("JsfTest") ==
- // null) {
- //
- // ImportJsfComponents.importJsfPages(JsfTestPlugin
- // .getPluginResourcePath()
- // + TEST_PROJECT_JAR_PATH);
- //
- // waitForJobs();
- // waitForJobs();
- // delay(5000);
- // }
Platform.addLogListener(this);
}
@@ -79,8 +63,6 @@
*/
protected void tearDown() throws Exception {
super.tearDown();
- // ImportJsfComponents.removeProject();
- // waitForJobs();
Platform.removeLogListener(this);
}
@@ -271,21 +253,26 @@
private void performTestForJsfComponent(String componentPage)
throws PartInitException, Throwable {
- TestJsfComponentsUtil.waitForJobs();
+ TestJsfUtil.waitForJobs();
exception = null;
- IPath componentPath = TestJsfComponentsUtil
+
+ // IPath componentPath = TestJsfComponentsUtil
+ // .getComponentPath(componentPage);
+ //
+ // IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ // componentPath);
+
+ IFile file = (IFile) TestJsfUtil
.getComponentPath(componentPage);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
- componentPath);
IEditorInput input = new FileEditorInput(file);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.openEditor(input, EDITOR_ID, true);
- TestJsfComponentsUtil.waitForJobs();
- TestJsfComponentsUtil.delay(3000);
+ TestJsfUtil.waitForJobs();
+ TestJsfUtil.delay(3000);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.closeAllEditors(true);
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfJbideTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfJbideTest.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfJbideTest.java 2007-12-29 11:16:12 UTC (rev 5481)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Class for testing all jsf components
+ *
+ * @author sdzmitrovich
+ *
+ */
+public class JsfJbideTest extends TestCase implements ILogListener {
+
+ private final static String EDITOR_ID = "org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"; // $NON-NLS-1$
+ // $NON-NLS-1$
+
+ // check warning log
+ private final static boolean checkWarning = false;
+ private Throwable exception;
+
+ public JsfJbideTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Platform.addLogListener(this);
+ }
+
+ /**
+ * Perform post-test cleanup.
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ Platform.removeLogListener(this);
+ }
+
+ /*
+ * JBIDE's test cases
+ */
+
+ public void testJBIDE_1467() throws PartInitException, Throwable {
+ String path = "JBIDE/JBIDE-1467.jsp";
+
+ }
+
+ /*private void performTestForJsfComponent(String componentPage)
+ throws PartInitException, Throwable {
+ TestJsfComponentsUtil.waitForJobs();
+
+ exception = null;
+ IPath componentPath = TestJsfComponentsUtil
+ .getComponentPath(componentPage);
+
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ componentPath);
+ IEditorInput input = new FileEditorInput(file);
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .openEditor(input, EDITOR_ID, true);
+
+ TestJsfComponentsUtil.waitForJobs();
+ TestJsfComponentsUtil.delay(3000);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .closeAllEditors(true);
+
+ if (exception != null) {
+ throw exception;
+ }
+ }*/
+
+ public void logging(IStatus status, String plugin) {
+ switch (status.getSeverity()) {
+ case IStatus.ERROR:
+ exception = status.getException();
+ break;
+ case IStatus.WARNING:
+ if (checkWarning)
+ exception = status.getException();
+ break;
+ default:
+ break;
+ }
+
+ }
+
+}
Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfComponentsUtil.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfComponentsUtil.java 2007-12-29 01:50:30 UTC (rev 5480)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfComponentsUtil.java 2007-12-29 11:16:12 UTC (rev 5481)
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jsf.vpe.jsf.test;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.IOverwriteQuery;
-import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
-import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-
-/**
- * Class for importing project from jar file
- *
- * @author sdzmitrovich
- *
- */
-public class TestJsfComponentsUtil {
- private static final String PROJECT_NAME = "JsfTest"; // $NON-NLS-1$
- private static final String COMPONENTS_PATH = "WebContent/pages"; // $NON-NLS-1$
-
- @SuppressWarnings("restriction")
- static void importJsfPages(String path) {
-
- if (ResourcesPlugin.getWorkspace().getRoot().findMember(
- TestJsfComponentsUtil.PROJECT_NAME) != null) {
- waitForJobs();
-
- try {
- removeProject();
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- PROJECT_NAME);
-
- try {
-
- IOverwriteQuery overwrite = new IOverwriteQuery() {
- public String queryOverwrite(String pathString) {
- return ALL;
- }
- };
-
- // source file
- File source = new File(path);
-
- // create import operation
- ImportOperation importOp = new ImportOperation(project
- .getFullPath(), null, FileSystemStructureProvider.INSTANCE,
- overwrite, Arrays.asList(source.listFiles()));
-
- // import files just to project folder ( without old structure )
- importOp.setCreateContainerStructure(false);
-
- importOp.setContext(PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell());
-
- // run import
- importOp.run(new NullProgressMonitor());
-
- } catch (InvocationTargetException ite) {
- JsfTestPlugin.getPluginLog().logError(ite.getCause());
- } catch (InterruptedException ie) {
- JsfTestPlugin.getPluginLog().logError(ie);
- }
- }
-
- /**
- *
- * @return
- * @throws CoreException
- */
- static IPath getComponentPath(String componentPage) throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- PROJECT_NAME);
- if (project != null) {
- IResource resource = project.getFolder(COMPONENTS_PATH).findMember(
- componentPage);
- if (resource != null) {
- return resource.getFullPath();
- }
-
- }
-
- return null;
- }
-
- /**
- *
- * @throws CoreException
- */
- static void removeProject() throws CoreException {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- PROJECT_NAME);
- if (project != null) {
- project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
- new NullProgressMonitor());
- }
- }
-
- /**
- * Process UI input but do not return for the specified time interval.
- *
- * @param waitTimeMillis
- * the number of milliseconds
- */
- public static void delay(long waitTimeMillis) {
- Display display = Display.getCurrent();
- if (display != null) {
- long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
- while (System.currentTimeMillis() < endTimeMillis) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.update();
- }
- // Otherwise, perform a simple sleep.
- else {
- try {
- Thread.sleep(waitTimeMillis);
- } catch (InterruptedException e) {
- // Ignored.
- }
- }
- }
-
- /**
- * Wait until all background tasks are complete.
- */
- public static void waitForJobs() {
- while (Job.getJobManager().currentJob() != null)
- delay(5000);
- }
-
-}
Copied: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfUtil.java (from rev 5472, trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfComponentsUtil.java)
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfUtil.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/TestJsfUtil.java 2007-12-29 11:16:12 UTC (rev 5481)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+
+/**
+ * Class for importing project from jar file
+ *
+ * @author sdzmitrovich
+ *
+ */
+public class TestJsfUtil {
+ private static final String PROJECT_NAME = "JsfTest"; // $NON-NLS-1$
+ private static final String COMPONENTS_PATH = "WebContent/pages"; // $NON-NLS-1$
+
+ @SuppressWarnings("restriction")
+ static void importJsfPages(String path) {
+
+ if (ResourcesPlugin.getWorkspace().getRoot().findMember(
+ TestJsfUtil.PROJECT_NAME) != null) {
+ waitForJobs();
+
+ try {
+ removeProject();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+
+ try {
+
+ IOverwriteQuery overwrite = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return ALL;
+ }
+ };
+
+ ImportProvider importProvider = new ImportProvider();
+
+ // need to remove from imported project "svn" files
+ List<String> unimportedFiles = new ArrayList<String>();
+ unimportedFiles.add(".svn");
+
+ importProvider.setUnimportedFiles(unimportedFiles);
+
+ // create import operation
+ ImportOperation importOp = new ImportOperation(project
+ .getFullPath(), new File(path), importProvider, overwrite);
+
+ // import files just to project folder ( without old structure )
+ importOp.setCreateContainerStructure(false);
+
+ importOp.setContext(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getShell());
+
+ // run import
+ importOp.run(new NullProgressMonitor());
+
+ } catch (InvocationTargetException ite) {
+ JsfTestPlugin.getPluginLog().logError(ite.getCause());
+ } catch (InterruptedException ie) {
+ JsfTestPlugin.getPluginLog().logError(ie);
+ }
+ }
+
+ /**
+ *
+ * @return
+ * @throws CoreException
+ */
+ static IResource getComponentPath(String componentPage)
+ throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+ if (project != null) {
+ return project.getFolder(COMPONENTS_PATH).findMember(componentPage);
+ // if (resource != null) {
+ // return resource.getFullPath();
+ // }
+
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @throws CoreException
+ */
+ static void removeProject() throws CoreException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+ if (project != null) {
+ project.delete(IResource.ALWAYS_DELETE_PROJECT_CONTENT,
+ new NullProgressMonitor());
+ }
+ }
+
+ /**
+ * Process UI input but do not return for the specified time interval.
+ *
+ * @param waitTimeMillis
+ * the number of milliseconds
+ */
+ public static void delay(long waitTimeMillis) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
+ }
+
+ /**
+ * Wait until all background tasks are complete.
+ */
+ public static void waitForJobs() {
+ while (Job.getJobManager().currentJob() != null)
+ delay(5000);
+ }
+
+}
16 years, 12 months
JBoss Tools SVN: r5480 - in trunk/seam/plugins/org.jboss.tools.seam.ui: src/org/jboss/tools/seam/ui/preferences and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-12-28 20:50:30 -0500 (Fri, 28 Dec 2007)
New Revision: 5480
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490
1. JUnit test for JBIDE-1490 was added
2. Javadoc comments were added
3. Coding style was improved to reduce amount of Checkstyle violations
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-12-29 01:49:25 UTC (rev 5479)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2007-12-29 01:50:30 UTC (rev 5480)
@@ -403,7 +403,9 @@
class="org.jboss.tools.seam.ui.preferences.SeamSettingsPreferencePage"
id="org.jboss.tools.seam.ui.propertyPages.SeamSettingsPreferencePage">
<enabledWhen>
- <adapt type="org.eclipse.core.resources.IProject"/>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.jdt.core.javanature"/>
+ </adapt>
</enabledWhen>
</page>
</extension>
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java 2007-12-29 01:49:25 UTC (rev 5479)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencePage.java 2007-12-29 01:50:30 UTC (rev 5480)
@@ -7,100 +7,81 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.ui.preferences;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor;
/**
+ * Seam preference page that allows editing list of available Seam Runtimes:
+ * <ul>
+ * <li>define new </li>
+ * <li>change exists</li>
+ * <li>remove</li>
+ * </ul>
+ *
* @author eskimo
- *
*/
public class SeamPreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage, PropertyChangeListener {
-
- public static String SEAM_PREFERENCES_ID = "org.jboss.tools.common.model.ui.seam";
-
+ IWorkbenchPreferencePage {
+
/**
- *
+ * Seam Preferences page ID
*/
- SeamRuntimeListFieldEditor seamRuntimes
- = new SeamRuntimeListFieldEditor("rtlist",SeamPreferencesMessages.SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES,new ArrayList<SeamRuntime>(Arrays.asList(SeamRuntimeManager.getInstance().getRuntimes()))); //$NON-NLS-1$
+ public static final String SEAM_PREFERENCES_ID = "org.jboss.tools.common.model.ui.seam";
+ private static final int COLUMNS = 3;
+
+ SeamRuntimeListFieldEditor seamRuntimes = new SeamRuntimeListFieldEditor(
+ "rtlist", SeamPreferencesMessages.SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES, new ArrayList<SeamRuntime>(Arrays.asList(SeamRuntimeManager.getInstance().getRuntimes()))); //$NON-NLS-1$
+
SeamRuntime initialDefault;
/**
+ * Create contents of Seam preferences page. SeamRuntime list editor is
+ * created
*
+ * @return Control
*/
- public SeamPreferencePage() {
- }
-
- /**
- * @param title
- */
- public SeamPreferencePage(String title) {
- super(title);
- }
-
- /**
- * @param title
- * @param image
- */
- public SeamPreferencePage(String title, ImageDescriptor image) {
- super(title, image);
- }
-
- /**
- *
- */
@Override
protected Control createContents(Composite parent) {
Composite root = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout(3,false);
- root.setLayout(gl);
+ GridLayout gl = new GridLayout(COLUMNS, false);
+ root.setLayout(gl);
seamRuntimes.doFillIntoGrid(root);
initialDefault = SeamRuntimeManager.getInstance().getDefaultRuntime();
-
+
return root;
}
/**
+ * Inherited from IWorkbenchPreferencePage
*
+ * @param workbench
+ * {@link IWorkbench}
+ *
*/
public void init(IWorkbench workbench) {
}
/**
- *
+ * Save SeamRuntime list
*/
- public void propertyChange(PropertyChangeEvent arg0) {
- }
-
- /**
- *
- */
@Override
protected void performApply() {
for (SeamRuntime rt : seamRuntimes.getAddedSeamRuntimes()) {
@@ -111,27 +92,33 @@
SeamRuntimeManager.getInstance().removeRuntime(rt);
}
seamRuntimes.getRemoved().clear();
- if(initialDefault != null && seamRuntimes.getDefaultSeamRuntime() != initialDefault) {
+ if (initialDefault != null
+ && seamRuntimes.getDefaultSeamRuntime() != initialDefault) {
initialDefault.setDefault(false);
}
- Map<SeamRuntime,SeamRuntime> changed = seamRuntimes.getChangedSeamRuntimes();
- for (SeamRuntime c: changed.keySet()) {
+ Map<SeamRuntime, SeamRuntime> changed = seamRuntimes
+ .getChangedSeamRuntimes();
+ for (SeamRuntime c : changed.keySet()) {
SeamRuntime o = changed.get(c);
o.setHomeDir(c.getHomeDir());
o.setVersion(c.getVersion());
String oldName = o.getName();
String newName = c.getName();
- if(!oldName.equals(newName)) {
- SeamRuntimeManager.getInstance().changeRuntimeName(oldName, newName);
+ if (!oldName.equals(newName)) {
+ SeamRuntimeManager.getInstance().changeRuntimeName(oldName,
+ newName);
}
}
seamRuntimes.getChangedSeamRuntimes().clear();
- seamRuntimes.getDefaultSeamRuntime().setDefault(true);
+
+ if (seamRuntimes.getDefaultSeamRuntime() != null) {
+ seamRuntimes.getDefaultSeamRuntime().setDefault(true);
+ }
SeamRuntimeManager.getInstance().save();
}
/**
- *
+ * Restore original preferences values
*/
@Override
protected void performDefaults() {
@@ -140,10 +127,14 @@
performApply();
}
+ /**
+ * See {@link PreferencePage} for details
+ *
+ * @return Boolean
+ */
@Override
public boolean performOk() {
performApply();
return super.performOk();
}
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2007-12-29 01:49:25 UTC (rev 5479)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java 2007-12-29 01:50:30 UTC (rev 5480)
@@ -19,8 +19,10 @@
import java.util.List;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.seam.ui.SeamUIMessages;
@@ -37,19 +39,27 @@
@Override
public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite, SeamUIMessages.COMPOSITE_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
- Assert.isTrue(((Composite)parent).getLayout() instanceof GridLayout,SeamUIMessages.COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
+ Assert.isTrue(parent instanceof Composite,
+ SeamUIMessages.COMPOSITE_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ SeamUIMessages.COMPOSITE_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
+
Composite aComposite = (Composite) parent;
- Control[] controls = (Control[])getEditorControls(aComposite);
- GridLayout gl = (GridLayout)((Composite)parent).getLayout();
+ Control[] controls = (Control[]) getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
- for(int i=0;i<controls.length;i++) {
- GridData gd = new GridData();
- gd.horizontalSpan = i==1?gl.numColumns-controls.length+1:1;
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = (i==1);
- controls[i].setLayoutData(gd);
- }
+ for (int i = 0; i < controls.length; i++) {
+ GridData gd = new GridData();
+ gd.horizontalSpan = i == 1 ? gl.numColumns - controls.length + 1 : 1;
+ if (controls[i] instanceof Combo && i == (controls.length - 1)) {
+ gd.horizontalAlignment = SWT.BEGINNING;
+ } else {
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = (i == 1);
+ }
+
+ controls[i].setLayoutData(gd);
+ }
}
List<Control> controls = new ArrayList<Control>();
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2007-12-29 01:49:25 UTC (rev 5479)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2007-12-29 01:50:30 UTC (rev 5480)
@@ -104,7 +104,7 @@
*/
IFieldEditor createUneditableTextEditor(String jdbcDriverClassName,
String string, String string2);
-
+
/**
*
* @param name
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-12-29 01:49:25 UTC (rev 5479)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SeamRuntimeListFieldEditor.java 2007-12-29 01:50:30 UTC (rev 5480)
@@ -7,10 +7,9 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.ui.widget.editor;
-import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
@@ -18,7 +17,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -28,9 +26,12 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
@@ -50,136 +51,168 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
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.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
-import org.jboss.tools.common.model.ui.action.CommandBar;
-import org.jboss.tools.common.model.ui.action.CommandBarListener;
-import org.jboss.tools.common.model.ui.objecteditor.XChildrenEditor;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
-import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
import org.jboss.tools.seam.ui.wizard.SeamFormWizard;
/**
+ * Control that have table and buttons for editing Seam Runtime list
+ *
* @author eskimo
- *
+ *
*/
-public class SeamRuntimeListFieldEditor extends BaseFieldEditor implements ISelectionChangedListener, SelectionListener, CommandBarListener {
- static String REMOVE = "&Remove";
- CheckboxTableViewer tableView = null;
- Composite root = null;
- protected CommandBar bar = new CommandBar();
+public class SeamRuntimeListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private CheckboxTableViewer tableView = null;
+
+ private Composite root = null;
+
+ private Map<SeamRuntime, SeamRuntime> changed = new HashMap<SeamRuntime, SeamRuntime>();
+
+ private SeamRuntime checkedElement = null;
+
+ private List<SeamRuntime> added = new ArrayList<SeamRuntime>();
+
+ private List<SeamRuntime> removed = new ArrayList<SeamRuntime>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
/**
+ * Control for editing SeamRuntime list
+ *
* @param name
+ * String
* @param label
+ * String
* @param defaultValue
+ * Object
*/
- public SeamRuntimeListFieldEditor(String name, String label, Object defaultValue) {
+ public SeamRuntimeListFieldEditor(String name, String label,
+ Object defaultValue) {
super(name, label, defaultValue);
- bar.addCommandBarListener(this);
}
- private SeamRuntime checkedElement = null;
-
/**
+ * TBD
*
- * @return
+ * @return List<SeamRuntime>
*/
public SeamRuntime getDefaultSeamRuntime() {
return checkedElement;
}
-
- private List<SeamRuntime> added = new ArrayList<SeamRuntime>();
-
+
/**
+ * TBD
*
- * @return
+ * @return List<SeamRuntime>
*/
public List<SeamRuntime> getAddedSeamRuntimes() {
return added;
}
-
- private Map<SeamRuntime,SeamRuntime> changed = new HashMap<SeamRuntime,SeamRuntime>();
-
+
/**
+ * TBD
*
- * @return
+ * @return List<SeamRuntime>
*/
- public Map<SeamRuntime,SeamRuntime> getChangedSeamRuntimes() {
+ public Map<SeamRuntime, SeamRuntime> getChangedSeamRuntimes() {
return changed;
}
-
- private List<SeamRuntime> removed = new ArrayList<SeamRuntime>();
-
+
/**
+ * TBD
*
- * @return
+ * @return List<SeamRuntime>
*/
public List<SeamRuntime> getRemoved() {
return removed;
}
-
+
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
@Override
public Object[] getEditorControls(Object composite) {
-
- root = new Composite((Composite)composite,SWT.NONE);
- root.setLayout(new GridLayout(2,false));
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- root.setLayoutData(gd);
-
- tableView = CheckboxTableViewer.newCheckList(root,
- SWT.V_SCROLL|SWT.BORDER|SWT.FULL_SELECTION|SWT.SINGLE);
-
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ root.setLayout(new GridLayout(GL_COLUMNS, false));
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+
gd = new GridData();
- gd.heightHint = 200;
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
-
+ gd.heightHint = GL_HINT_HEIGHT;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
tableView.getControl().setLayoutData(gd);
- tableView.addSelectionChangedListener(this);
-
- createCommandBar(root);
- bar.setEnabled(REMOVE, false);
- bar.setEnabled(XChildrenEditor.EDIT, false);
-
- TableColumn tc1 = new TableColumn(tableView.getTable(),SWT.CENTER);
- tc1.setWidth(21);
+
+ TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
+ tc1.setWidth(TC_DEFAULT_WIDTH);
tc1.setResizable(false);
-
- TableColumn tc2 = new TableColumn(tableView.getTable(),SWT.LEFT);
- tc2.setWidth(100);
- tc2.setText(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NAME);
- TableColumn tc3 = new TableColumn(tableView.getTable(),SWT.LEFT);
- tc3.setWidth(50);
- tc3.setText(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_VERSION);
-
- TableColumn tc4 = new TableColumn(tableView.getTable(),SWT.LEFT);
- tc4.setWidth(100);
+ TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc2.setWidth(TC_NAME_WIDTH);
+ tc2.setText(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NAME);
+
+ TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc3.setWidth(TC_VERSION_WIDTH);
+ tc3.setText(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_VERSION);
+
+ TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc4.setWidth(TC_PATH_WIDTH);
tc4.setText(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_PATH);
-
+
tableView.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
- if(inputElement instanceof List)
- return ((List<SeamRuntime>)inputElement).toArray();
- else
- throw new IllegalArgumentException(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_INPUTELEMENT_MUST_BE +
- SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_AN_INSTANCEOF_OF_LIST);
+ if (inputElement instanceof List) {
+ return ((List<SeamRuntime>) inputElement).toArray();
+ } else {
+ throw new IllegalArgumentException(
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_INPUTELEMENT_MUST_BE
+ + SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_AN_INSTANCEOF_OF_LIST);
+ }
}
public void dispose() {
@@ -193,135 +226,222 @@
tableView.setLabelProvider(new ITableLabelProvider() {
- public void addListener(ILabelProviderListener listener) {}
+ private static final int TC_DEFAULT_NUMBER = 0;
+ private static final int TC_NAME_NUMBER = 1;
+ private static final int TC_VERSION_NUMBER = 2;
+ private static final int TC_PATH_NUMBER = 3;
- public void dispose() { }
+ public void addListener(ILabelProviderListener listener) {
+ }
+ public void dispose() {
+ }
+
public boolean isLabelProperty(Object element, String property) {
return false;
}
- public void removeListener(ILabelProviderListener listener) {}
+ public void removeListener(ILabelProviderListener listener) {
+ }
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
- SeamRuntime rt = (SeamRuntime)element;
- if(columnIndex==0) return ""; //$NON-NLS-1$
- if(columnIndex==1) return rt.getName();
- if(columnIndex==2) return rt.getVersion().toString();
- if(columnIndex==3) return rt.getHomeDir();
+ SeamRuntime rt = (SeamRuntime) element;
+ if (columnIndex == TC_DEFAULT_NUMBER) {
+ return ""; //$NON-NLS-1$
+ }
+ if (columnIndex == TC_NAME_NUMBER) {
+ return rt.getName();
+ }
+ if (columnIndex == TC_VERSION_NUMBER) {
+ return rt.getVersion().toString();
+ }
+ if (columnIndex == TC_PATH_NUMBER) {
+ return rt.getHomeDir();
+ }
return ""; //$NON-NLS-1$
}
});
-
+
tableView.setInput(getValue());
tableView.getTable().setLinesVisible(true);
tableView.getTable().setHeaderVisible(true);
- tableView.addCheckStateListener( new ICheckStateListener () {
+ tableView.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
- if(event.getChecked()) {
- tableView.setCheckedElements(new Object[]{event.getElement()});
- //checkedElement.setDefault(false);
- checkedElement = (SeamRuntime)event.getElement();
- //checkedElement.setDefault(true);
- } else if(checkedElement==event.getElement()) {
- tableView.setCheckedElements(new Object[]{event.getElement()});
+ if (event.getChecked()) {
+ SeamRuntime deselRt = null;
+ SeamRuntime selRt = (SeamRuntime) event.getElement();
+ Object[] selRts = tableView.getCheckedElements();
+
+ for (int i = 0; i < selRts.length; i++) {
+ SeamRuntime rt = (SeamRuntime) selRts[i];
+ if (rt.getVersion() == selRt.getVersion()
+ && rt != selRt) {
+ deselRt = rt;
+ break;
+ }
+ }
+
+ if (deselRt != null) {
+ Object[] newChecked = new Object[selRts.length - 1];
+ int i = 0;
+ for (Object object : selRts) {
+ SeamRuntime rt = (SeamRuntime) object;
+ if (rt.getVersion() != selRt.getVersion()
+ || rt == selRt) {
+ newChecked[i] = rt;
+ i++;
+ }
+ }
+ tableView.setCheckedElements(newChecked);
+ }
+
+ // checkedElement.setDefault(false);
+ checkedElement = (SeamRuntime) event.getElement();
+ // checkedElement.setDefault(true);
}
pcs.firePropertyChange(getName(), null, getValue());
}
});
-
+
for (SeamRuntime rt : (List<SeamRuntime>) getValue()) {
- if(rt.isDefault()) {
- tableView.setCheckedElements(new Object[]{rt});
+ if (rt.isDefault()) {
+ tableView.setCheckedElements(new Object[] {rt});
checkedElement = rt;
break;
}
}
-
- return new Control[]{tableView.getControl()};
+ ActionPanel actionPanel = new ActionPanel(root, new BaseAction[] {
+ new AddAction(), new EditAction(), new RemoveAction()});
+ tableView.addSelectionChangedListener(actionPanel);
+ return new Control[] {root};
}
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
@Override
public Object[] getEditorControls() {
- return new Control[]{root};
+ return new Control[] {root};
}
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
@Override
public int getNumberOfControls() {
return 1;
}
/**
+ * Fill wizard page with editors
*
* @param parent
+ * Composite - parent composite
*/
@Override
public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite,
- SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
- Assert.isTrue(((Composite)parent).getLayout()
- instanceof GridLayout,SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
+ Assert
+ .isTrue(
+ parent instanceof Composite,
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_PARENT_CONTROL_SHOULD_BE_COMPOSITE);
+ Assert
+ .isTrue(
+ ((Composite) parent).getLayout() instanceof GridLayout,
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_EDITOR_SUPPORTS_ONLY_GRID_LAYOUT);
Composite aComposite = (Composite) parent;
- Control[] controls = (Control[])getEditorControls(aComposite);
- GridLayout gl = (GridLayout)((Composite)parent).getLayout();
-
+ Control[] controls = (Control[]) getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
GridData gd = new GridData();
gd.horizontalSpan = gl.numColumns;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = GridData.FILL;
- ((Control)getEditorControls()[0]).setLayoutData(gd);
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
}
- public static class SeamRuntimeWizardPage extends WizardPage implements PropertyChangeListener {
+ /**
+ * Wizard page for editing Seam Runtime parameters
+ *
+ * @author eskimo
+ */
+ public static class SeamRuntimeWizardPage extends WizardPage implements
+ PropertyChangeListener {
+ private static final String SRT_NAME = "name";
+ private static final String SRT_HOMEDIR = "homeDir";
+ private static final String SRT_VERSION = "version";
+
+ private static final int GL_PARENT_COLUMNS = 1;
+ private static final int GL_CONTENT_COLUMNS = 3;
+
List<SeamRuntime> value = null;
-
+
IFieldEditor name = IFieldEditorFactory.INSTANCE.createTextEditor(
- "name", SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NAME2, ""); //$NON-NLS-1$ //$NON-NLS-2$
-
+ SRT_NAME, SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NAME2,
+ ""); //$NON-NLS-1$
+
IFieldEditor version = null;
-
- IFieldEditor homeDir = IFieldEditorFactory.INSTANCE.createBrowseFolderEditor(
- "homeDir", SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_HOME_FOLDER, ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- IFieldEditor dflt = IFieldEditorFactory.INSTANCE.createCheckboxEditor(
- "default", SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_USE_AS_DEFAULT, false); //$NON-NLS-1$
-
+
+ IFieldEditor homeDir = IFieldEditorFactory.INSTANCE
+ .createBrowseFolderEditor(
+ SRT_HOMEDIR,
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_HOME_FOLDER,
+ ""); //$NON-NLS-1$
+
SeamRuntime current = null;
List<SeamVersion> validSeamVersions = null;
-
+
/**
- * @param parent
- * @param style
+ * Create Seam Runtime editing wizard page with all SeamVersion in
+ * version selection combo
+ *
+ * @param editedList
+ * List<SeamVersion> - list of existing Seam Runtimes
*/
public SeamRuntimeWizardPage(List<SeamRuntime> editedList) {
- this(editedList, null);
+ this(editedList, (List<SeamVersion>) null);
}
/**
- * @param parent
- * @param style
+ * Create Seam Runtime editing wizard page with validSeamVersions in
+ * version selection combo
+ *
+ * @param editedList
+ * List<SeamVersion> - list of existing Seam Runtimes
+ * @param validSeamVersions
+ * List<SeamVersion> - list of allowed Seam Versions
*/
- public SeamRuntimeWizardPage(List<SeamRuntime> editedList, List<SeamVersion> validSeamVersions) {
- super(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NEW_SEAM_RUNTIME);
- if(validSeamVersions==null) {
+ public SeamRuntimeWizardPage(List<SeamRuntime> editedList,
+ List<SeamVersion> validSeamVersions) {
+ super(
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NEW_SEAM_RUNTIME);
+ if (validSeamVersions == null) {
this.version = IFieldEditorFactory.INSTANCE.createComboEditor(
- "version", SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_VERSION2, Arrays.asList( //$NON-NLS-1$
- new String[]{SeamVersion.SEAM_1_2.toString(), SeamVersion.SEAM_2_0.toString()}),
- SeamVersion.SEAM_1_2.toString(), false);
+ SRT_VERSION,
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_VERSION2,
+ Arrays.asList(new String[] {
+ SeamVersion.SEAM_1_2.toString(),
+ SeamVersion.SEAM_2_0.toString()}),
+ SeamVersion.SEAM_1_2.toString(), false);
this.validSeamVersions = new ArrayList<SeamVersion>();
this.validSeamVersions.add(SeamVersion.SEAM_1_2);
- this.validSeamVersions.add(SeamVersion.SEAM_2_0);
+ this.validSeamVersions.add(SeamVersion.SEAM_2_0);
} else {
this.version = IFieldEditorFactory.INSTANCE.createComboEditor(
- "version", SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_VERSION2, validSeamVersions,
- SeamVersion.SEAM_1_2.toString(), false);
- this.validSeamVersions = validSeamVersions;
+ SRT_VERSION,
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_VERSION2,
+ validSeamVersions, SeamVersion.SEAM_1_2.toString(),
+ false);
+ this.validSeamVersions = validSeamVersions;
}
setMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CREATE_A_SEAM_RUNTIME);
@@ -332,34 +452,56 @@
}
/**
+ * Wizard page for editing SeamRuntime were is only single version of
+ * SeamRuntime can be used
*
+ * @param editedList
+ * List<SeamRuntime> - TBD
+ * @param validVersion
+ * SeamVersion - TBD
*/
+ public SeamRuntimeWizardPage(List<SeamRuntime> editedList,
+ SeamVersion validVersion) {
+ this(editedList, Arrays.asList(new SeamVersion[] {validVersion}));
+ }
+
+ /**
+ * Create Wizard page content
+ *
+ * @param parent
+ * Composite - parent composite
+ */
public void createControl(Composite parent) {
- parent.setLayout(new GridLayout(1, false));
+ parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
GridData dg = new GridData();
dg.horizontalAlignment = GridData.FILL;
dg.grabExcessHorizontalSpace = true;
Composite root = new Composite(parent, SWT.NONE);
root.setLayoutData(dg);
- GridLayout gl = new GridLayout(3, false);
+ GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
root.setLayout(gl);
homeDir.doFillIntoGrid(root);
homeDir.addPropertyChangeListener(this);
name.doFillIntoGrid(root);
name.addPropertyChangeListener(this);
version.doFillIntoGrid(root);
+ version.setValue(validSeamVersions.get(0));
version.addPropertyChangeListener(this);
setPageComplete(false);
setControl(root);
}
/**
+ * Process evt: setup default values based on Seam Home folder and
+ * validate user input
*
+ * @param evt
+ * PropertyChangeEvent describes changes in wizard
*/
- public void propertyChange(PropertyChangeEvent evt) {
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
if ("homeDir".equals(evt.getPropertyName())) {
- if (name.getValueAsString() == null ||
- "".equals(name.getValueAsString().trim())) {
+ if (name.getValueAsString() == null
+ || "".equals(name.getValueAsString().trim())) {
String homeDirName = homeDir.getValueAsString();
if (homeDirName != null && !"".equals(homeDirName.trim())) {
File folder = new File(homeDirName);
@@ -367,147 +509,219 @@
}
name.setValue(homeDirName);
- String seamVersion = getSeamVersion(homeDir.getValueAsString());
+ String seamVersion = getSeamVersion(homeDir
+ .getValueAsString());
if (validSeamVersions != null) {
for (SeamVersion ver : validSeamVersions) {
- if (seamVersion.matches(ver.toString().replace(".","\\.")+".*")) {
+ if (seamVersion.matches(ver.toString().replace(".",
+ "\\.")
+ + ".*")) {
version.setValue(ver.toString());
break;
}
}
}
}
- }
- if(name.getValueAsString()==null || "".equals( //$NON-NLS-1$
- name.getValueAsString().toString().trim())) {
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NAME_CANNOT_BE_EMPTY);
- setPageComplete(false);
- return;
+ }
+
+ if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
+ name.getValueAsString().toString().trim())) {
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NAME_CANNOT_BE_EMPTY);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!name.getValueAsString().matches(
+ "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_RUNTIME_NAME_IS_NOT_CORRECT);
+ setPageComplete(false);
+ return;
+ }
+ for (SeamRuntime rt : value) {
+ if (current != null && current.getName().equals(rt.getName())) {
+ continue;
}
-
- if(!name.getValueAsString().matches("[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_RUNTIME_NAME_IS_NOT_CORRECT);
+ if (rt.getName().equals(name.getValueAsString())) {
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_RUNTIME
+ + name.getValueAsString()
+ + SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_ALREADY_EXISTS);
setPageComplete(false);
return;
}
- for (SeamRuntime rt : value) {
- if(current != null && current.getName().equals(rt.getName())) continue;
- if(rt.getName().equals(name.getValueAsString())) {
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_RUNTIME+name.getValueAsString()+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_ALREADY_EXISTS);
- setPageComplete(false);
- return;
- }
- }
-
- if(current != null && current.getName().equals(name.getValueAsString())
- && current.getVersion().toString().equals(version.getValueAsString())
- && current.getHomeDir().equals(homeDir.getValueAsString())
- ) {
- setErrorMessage(null);
- setPageComplete(false);
- return;
- }
+ }
- if(homeDir.getValueAsString()==null || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_PATH_TO_SEAM_HOME_DIRECTORY_CANNOT_BE_EMPTY);
- setPageComplete(false);
- return;
- }
-
- String seamVersion = getSeamVersion(homeDir.getValueAsString());
- if(seamVersion == null){
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_FIND_JBOSS_SEAM_JAR);
- setPageComplete(false);
- return;
- }else if("".equals(seamVersion)) { //$NON-NLS-1$
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_OBTAIN_SEAM_VERSION_NUMBER);
- setPageComplete(false);
- return;
- } else if(!seamVersion.matches(version.getValueAsString().replace(".","\\.")+".*")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_THE_SELECTED_SEAM_APPEARS_TO_BE_OF_INCOMATIBLE_VERSION + seamVersion + "'"); //$NON-NLS-1$
- setPageComplete(false);
- return;
- }
-
- Map errors = ValidatorFactory.JBOSS_SEAM_HOME_FOLDER_VALIDATOR.validate(
- homeDir.getValueAsString(), seamVersion);
- if( errors != ValidatorFactory.NO_ERRORS) {
- setErrorMessage(errors.get(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME).toString());
- setPageComplete(false);
- return;
- }
-
-
+ if (current != null
+ && current.getName().equals(name.getValueAsString())
+ && current.getVersion().toString().equals(
+ version.getValueAsString())
+ && current.getHomeDir().equals(homeDir.getValueAsString())) {
+ setErrorMessage(null);
+ setPageComplete(false);
+ return;
+ }
+
+ if (homeDir.getValueAsString() == null
+ || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_PATH_TO_SEAM_HOME_DIRECTORY_CANNOT_BE_EMPTY);
+ setPageComplete(false);
+ return;
+ }
+
+ String seamVersion = getSeamVersion(homeDir.getValueAsString());
+ if (seamVersion == null) {
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_FIND_JBOSS_SEAM_JAR);
+ setPageComplete(false);
+ return;
+ } else if ("".equals(seamVersion)) { //$NON-NLS-1$
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_OBTAIN_SEAM_VERSION_NUMBER);
+ setPageComplete(false);
+ return;
+ } else if (!seamVersion.matches(version.getValueAsString().replace(
+ ".", "\\.") + ".*")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ setErrorMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_THE_SELECTED_SEAM_APPEARS_TO_BE_OF_INCOMATIBLE_VERSION
+ + seamVersion + "'"); //$NON-NLS-1$
+ setPageComplete(false);
+ return;
+ }
+
+ Map errors = ValidatorFactory.JBOSS_SEAM_HOME_FOLDER_VALIDATOR
+ .validate(homeDir.getValueAsString(), seamVersion);
+ if (errors != ValidatorFactory.NO_ERRORS) {
+ setErrorMessage(errors.get(
+ ISeamFacetDataModelProperties.JBOSS_SEAM_HOME)
+ .toString());
+ setPageComplete(false);
+ return;
+ }
+
setErrorMessage(null);
setPageComplete(true);
}
-
+
+ /**
+ * Return Seam runtime version obtained form jboss-seam.jar manifest
+ * 'Seam Version' property
+ *
+ * @param path
+ * path to Seam home folder
+ * @return String value of 'Seam Version' manifest property
+ */
public static String getSeamVersion(String path) {
File seamJarFile = new File(path, "jboss-seam.jar"); //$NON-NLS-1$
- if(!seamJarFile.exists()) {
- seamJarFile = new File(path, "lib/jboss-seam.jar"); // hack to make it work for seam2
- if(!seamJarFile.exists()) return null;
+ if (!seamJarFile.exists()) {
+ seamJarFile = new File(path, "lib/jboss-seam.jar"); // hack to
+ // make it
+ // work for
+ // seam2
+ if (!seamJarFile.exists()) {
+ return null;
+ }
}
- InputStream str=null;
+ InputStream str = null;
ZipFile seamJar;
try {
seamJar = new ZipFile(seamJarFile);
- ZipFileStructureProvider provider = new ZipFileStructureProvider(seamJar);
+ ZipFileStructureProvider provider = new ZipFileStructureProvider(
+ seamJar);
ZipEntry entry = seamJar.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
str = provider.getContents(entry);
Properties manifest = new Properties();
manifest.load(str);
- Object sv = manifest.get(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_SEAM_VERSION);
- return sv==null?"":sv.toString(); //$NON-NLS-1$
-
+ Object sv = manifest
+ .get(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_SEAM_VERSION);
+ return sv == null ? "" : sv.toString(); //$NON-NLS-1$
+
} catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_READ_JAR_FILE,e);
+ SeamCorePlugin
+ .getPluginLog()
+ .logError(
+ SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_CANNOT_READ_JAR_FILE,
+ e);
} finally {
- if(str!=null)
+ if (str != null) {
try {
str.close();
} catch (IOException e) {
- // nothing to do with that
+ SeamGuiPlugin.getPluginLog().logError(e);
}
+ }
}
return ""; //$NON-NLS-1$
}
-
+
/**
+ * Return Seam Runtime instance initialized by user input
*
- * @return
+ * @return SeamRuntime instance
*/
public SeamRuntime getRuntime() {
SeamRuntime newRt = new SeamRuntime();
newRt.setName(name.getValueAsString());
- newRt.setVersion(SeamVersion.parseFromString(version.getValueAsString()));
+ newRt.setVersion(SeamVersion.parseFromString(version
+ .getValueAsString()));
newRt.setHomeDir(homeDir.getValueAsString());
- //newRt.setDefault((Boolean)dflt.getValue());
return newRt;
}
}
-
+
+ /**
+ * Wizard collect information and creates new SeamRuntime instances.
+ *
+ * @author eskimo
+ */
public static class SeamRuntimeNewWizard extends Wizard {
SeamRuntimeWizardPage page1 = null;
List<SeamRuntime> added = null;
List<SeamRuntime> value = null;
- public SeamRuntimeNewWizard(List<SeamRuntime> value, List<SeamRuntime> added, List<SeamVersion> validSeamVersions) {
+ /**
+ * Constructor for creating a SeamRuntime wizard with default title and
+ * one page to edit new Seam Runtime parameters as name, Seam version
+ * and path to Seam home folder. Wizard allows constraining the list of
+ * Seam version to handle creating of Seam Runtime form Seam Facet
+ * Installation page.
+ *
+ * @param exist
+ * list of exists SeamRuntimes, that will be used during
+ * created SeamRuntime name validation
+ * @param added
+ * List<SeamRuntime> - TBD
+ * @param validSeamVersions
+ * List<SeamRuntime> - List of Seam Runtime versions
+ * that can be created
+ */
+ public SeamRuntimeNewWizard(List<SeamRuntime> exist,
+ List<SeamRuntime> added, List<SeamVersion> validSeamVersions) {
super();
setWindowTitle(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_NEW_SEAM_RUNTIME);
- page1 = new SeamRuntimeWizardPage(value, validSeamVersions);
+ page1 = new SeamRuntimeWizardPage(exist, validSeamVersions);
addPage(page1);
- this.value = value;
+ this.value = exist;
this.added = added;
}
- public SeamRuntimeNewWizard(List<SeamRuntime> value, List<SeamRuntime> added) {
- this(value, added, null);
+ /**
+ * Create wizard that shows all available seam version in version selection
+ * combobox
+ *
+ * @param existing
+ * List of existing Seam Runtimes
+ * @param added
+ * TBD
+ */
+ public SeamRuntimeNewWizard(List<SeamRuntime> existing,
+ List<SeamRuntime> added) {
+ this(existing, added, null);
}
-
+
+ /**
+ * Do finish steps
+ *
+ * @return boolean
+ */
@Override
public boolean performFinish() {
SeamRuntime rt = page1.getRuntime();
@@ -517,20 +731,43 @@
}
}
+ /**
+ * Wizard for editing Seam Runrtime parameters: name, version and path to
+ * home folder
+ *
+ * @author eskimo
+ */
public static class SeamRuntimeEditWizard extends Wizard {
SeamRuntimeWizardPage page1 = null;
List<SeamRuntime> added = null;
Map<SeamRuntime, SeamRuntime> changed = null;
List<SeamRuntime> value = null;
SeamRuntime source = null;
- public SeamRuntimeEditWizard(List<SeamRuntime> value, SeamRuntime source, List<SeamRuntime> added, Map<SeamRuntime, SeamRuntime> changed) {
+
+ /**
+ * Constructor with almost all initialization parameters
+ *
+ * @param existing
+ * List<SeamRuntime> - edited list of Seam Runtimes
+ * @param source
+ * SeamRuntime - edited Seam Runtime
+ * @param added
+ * List<SeamRuntime> - TBD
+ * @param changed
+ * List<SeamRuntime> - TBD
+ */
+ public SeamRuntimeEditWizard(List<SeamRuntime> existing,
+ SeamRuntime source, List<SeamRuntime> added,
+ Map<SeamRuntime, SeamRuntime> changed) {
super();
setWindowTitle(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_EDIT_SEAM_RUNTIME);
- page1 = new SeamRuntimeWizardPage(value);
- page1.setMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_MODIFY_SEAM_RUNTIME);
- page1.setTitle(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_EDIT_SEAM_RUNTIME);
+ page1 = new SeamRuntimeWizardPage(existing);
+ page1
+ .setMessage(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_MODIFY_SEAM_RUNTIME);
+ page1
+ .setTitle(SeamUIMessages.SEAM_RUNTIME_LIST_FIELD_EDITOR_EDIT_SEAM_RUNTIME);
addPage(page1);
- this.value = value;
+ this.value = existing;
this.added = added;
this.changed = changed;
this.source = source;
@@ -539,24 +776,29 @@
page1.version.setValue(source.getVersion().toString());
page1.current = source;
}
-
+
+ /**
+ * Perform operations to finish editing Seam Runtime parameters
+ *
+ * @return boolean - always true
+ */
@Override
public boolean performFinish() {
SeamRuntime rt = page1.getRuntime();
- if(rt.getName().equals(source.getName())
- && rt.getVersion().toString().equals(source.getVersion().toString())
- && rt.getHomeDir().equals(source.getHomeDir())
- ) {
+ if (rt.getName().equals(source.getName())
+ && rt.getVersion().toString().equals(
+ source.getVersion().toString())
+ && rt.getHomeDir().equals(source.getHomeDir())) {
return true;
}
- if(added.contains(source) || changed.containsKey(source)) {
+ if (added.contains(source) || changed.containsKey(source)) {
source.setName(rt.getName());
source.setHomeDir(rt.getName());
source.setVersion(rt.getVersion());
} else {
changed.put(rt, source);
int i = value.indexOf(source);
- if(i >= 0) {
+ if (i >= 0) {
value.set(i, rt);
} else {
value.remove(source);
@@ -568,145 +810,355 @@
}
/**
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ * @author eskimo
*/
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection)event.getSelection();
- selectionChanged((SeamRuntime)selection.getFirstElement());
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = true;
+ setLayoutData(gd);
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
}
/**
- * @param firstElement
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ * @author eskimo
*/
- public void selectionChanged(SeamRuntime selection) {
- if(selection == null) {
- bar.setEnabled(REMOVE, false);
- bar.setEnabled(XChildrenEditor.EDIT, false);
- } else {
- bar.setEnabled(REMOVE, true);
- bar.setEnabled(XChildrenEditor.EDIT, true);
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private static final int DEFAULT_WIDTH_HINT = 50;
+
+ private Button button;
+
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ gd.widthHint = DEFAULT_WIDTH_HINT;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
}
- if(selection==null
- || selection == SeamRuntimeManager.getInstance().getDefaultRuntime()) {
- } else {
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
}
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
}
/**
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ * Action that changes state enable/disable based on current table selection
+ *
+ * @author eskimo
*/
- public void widgetDefaultSelected(SelectionEvent e) {}
+ public abstract class BaseAction extends Action {
+ SeamRuntime[] runtimes = new SeamRuntime[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<SeamRuntime> rts = new ArrayList<SeamRuntime>();
+ for (Object rt : ((IStructuredSelection) selection).toArray()) {
+ rts.add((SeamRuntime) rt);
+ }
+ runtimes = rts.toArray(new SeamRuntime[] {});
+ } else {
+ runtimes = new SeamRuntime[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
/**
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ * Action that invokes New Seam Runtime Dialog
+ *
+ * @author eskimo
*/
- public void widgetSelected(SelectionEvent e) {
- }
-
- private void removeRuntime(SeamRuntime r) {
- boolean used = isRuntimeUsed(r.getName());
- String title = SeamUIMessages.RUNTIME_DELETE_CONFIRM_TITLE;
- String message = (used)
- ? NLS.bind(SeamUIMessages.RUNTIME_DELETE_USED_CONFIRM, r.getName())
- : NLS.bind(SeamUIMessages.RUNTIME_DELETE_NOT_USED_CONFIRM, r.getName());
- boolean b = MessageDialog.openConfirm(bar.getControl().getShell(), title, message);
- if(!b) return;
- if(changed.containsKey(r)) {
- r = changed.remove(r);
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructior create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
}
- removed.add(r);
- if(added.contains(r)) {
- added.remove(r);
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
}
- ((List)getValue()).remove(r);
- }
-
- private boolean isRuntimeUsed(String runtimeName) {
- IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < ps.length; i++) {
- ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
- if(sp != null && runtimeName.equals(sp.getRuntimeName())) return true;
+
+ /**
+ * Invoke New Seam Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ Wizard wiz = new SeamRuntimeNewWizard(
+ (List<SeamRuntime>) getValue(), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
}
- return false;
}
- public void action(String command) {
- if(XChildrenEditor.ADD.equals(command)) {
- Wizard wiz = new SeamRuntimeNewWizard((List<SeamRuntime>)getValue(), added);
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
+ /**
+ * Action starts an editing selected Seam Runtime in Edit Seam Runtime
+ * dialog
+ *
+ * @author eskimo
+ */
+ public class EditAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Edit";
+
+
+ /**
+ * Create EditAction with default name
+ *
+ * @param text
+ */
+ public EditAction() {
+ super(ACTION_NAME);
+ }
+
+ /**
+ * Edit action is enabled when the only Seam Runtime is selected
+ */
+ @Override
+ protected void updateEnablement() {
+ // available when the only SeamRuntime is selected
+ setEnabled(runtimes.length == 1);
+ }
+
+ /**
+ * Start editing selected Seam Runtime in Edit Seam Runtime Wizard
+ * Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ Wizard wiz = new SeamRuntimeEditWizard(
+ (List<SeamRuntime>) getValue(), runtimes[0], added, changed);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
dialog.open();
tableView.refresh();
- } else if(REMOVE.equals(command)) {
- ISelection s = tableView.getSelection();
- if(s == null || s.isEmpty() || !(s instanceof IStructuredSelection)) return;
- IStructuredSelection ss = (IStructuredSelection)s;
- Iterator<?> i = ss.iterator();
- while(i.hasNext()) {
- Object o = i.next();
- if(o instanceof SeamRuntime) {
- removeRuntime((SeamRuntime)o);
+ if (changed.containsValue(runtimes[0])) {
+ SeamRuntime c = findChangedRuntime(runtimes[0]);
+ if (c != null) {
+ tableView.setSelection(new StructuredSelection(c));
}
}
- tableView.refresh();
- } else if(XChildrenEditor.EDIT.equals(command)) {
- ISelection s = tableView.getSelection();
- if(s == null || s.isEmpty() || !(s instanceof IStructuredSelection)) return;
- IStructuredSelection ss = (IStructuredSelection)s;
- Iterator<?> i = ss.iterator();
- while(i.hasNext()) {
- Object o = i.next();
- if(o instanceof SeamRuntime) {
- Wizard wiz = new SeamRuntimeEditWizard((List<SeamRuntime>)getValue(), (SeamRuntime)o, added, changed);
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
- dialog.open();
- tableView.refresh();
- if(changed.containsValue(o)) {
- SeamRuntime c = findChangedRuntime((SeamRuntime)o);
- if(c != null) {
- tableView.setSelection(new StructuredSelection(c));
- }
- }
+ }
+
+ private SeamRuntime findChangedRuntime(SeamRuntime source) {
+ for (SeamRuntime r : changed.keySet()) {
+ if (source == changed.get(r)) {
+ return r;
}
}
+ return null;
}
}
-
- private SeamRuntime findChangedRuntime(SeamRuntime source) {
- for(SeamRuntime r: changed.keySet()) {
- if(source == changed.get(r)) return r;
+
+ /**
+ * Action deletes all selected Seam Runtimes. A worning message is shown for
+ * used Seam Runtimes
+ *
+ * @author eskimo
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
}
- return null;
- }
-
- public void dispose() {
- bar.dispose();
- super.dispose();
- }
- protected void createCommandBar(Composite control) {
- //TODO insert EDIT command
- String[] commands = new String[]{XChildrenEditor.ADD, XChildrenEditor.EDIT, REMOVE};
- bar.setCommands(commands);
- bar.getLayout().direction = SWT.VERTICAL;
- bar.getLayout().buttonWidth = convertHorizontalDLUsToPixels(control, IDialogConstants.BUTTON_WIDTH);
- setMargins(bar);
- bar.createControl(control);
- bar.getControl().setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ @Override
+ protected void updateEnablement() {
+ setEnabled(runtimes.length > 0);
+ }
+
+ /**
+ * Remove all selected Seam Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (SeamRuntime rt : runtimes) {
+ removeRuntime(rt);
+ }
+ tableView.refresh();
+ }
+
+ private void removeRuntime(SeamRuntime r) {
+ boolean used = isRuntimeUsed(r.getName());
+ String title = SeamUIMessages.RUNTIME_DELETE_CONFIRM_TITLE;
+ String message = (used) ? NLS.bind(
+ SeamUIMessages.RUNTIME_DELETE_USED_CONFIRM, r.getName())
+ : NLS.bind(SeamUIMessages.RUNTIME_DELETE_NOT_USED_CONFIRM,
+ r.getName());
+ boolean b = MessageDialog.openConfirm(tableView.getControl()
+ .getShell(), title, message);
+ if (b) {
+ if (changed.containsKey(r)) {
+ r = changed.remove(r);
+ }
+ removed.add(r);
+ if (added.contains(r)) {
+ added.remove(r);
+ }
+ ((List) getValue()).remove(r);
+ }
+ }
+
+ private boolean isRuntimeUsed(String runtimeName) {
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ for (int i = 0; i < ps.length; i++) {
+ ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
+ if (sp != null && runtimeName.equals(sp.getRuntimeName())) {
+ return true;
+ }
+ }
+ return false;
+ }
}
-
- protected void setMargins(CommandBar bar) {
- bar.getLayout().setMargins(0,10,0,0);
- }
- protected int convertHorizontalDLUsToPixels(Control control, int dlus) {
- GC gc= new GC(control);
- gc.setFont(control.getFont());
- int averageWidth= gc.getFontMetrics().getAverageCharWidth();
- gc.dispose();
-
- double horizontalDialogUnitSize = averageWidth * 0.25;
-
- return (int)Math.round(dlus * horizontalDialogUnitSize);
- }
-
-}
+}
\ No newline at end of file
16 years, 12 months
JBoss Tools SVN: r5479 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: core/project/facet and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-12-28 20:49:25 -0500 (Fri, 28 Dec 2007)
New Revision: 5479
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490
1. JUnit test for JBIDE-1490 was added
2. Javadoc comments were added
3. Coding style was improved to reduce amount of Checkstyle violations
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -26,11 +26,18 @@
List<Change> children;
/**
+ * Constructs object with initial values
*
* @param target
- * @param property - name of property changed or null, if change is adding/removing a child.
- * @param oldValue - old value; if null and property = null, then child (newValue) is added
- * @param newValue - new value; if null and property = null, then child (oldValue) is removed
+ * @param property
+ * name of property changed or null, if change is adding/removing
+ * a child.
+ * @param oldValue
+ * old value; if null and property = null, then child (newValue)
+ * is added
+ * @param newValue
+ * new value; if null and property = null, then child (oldValue)
+ * is removed
*/
public Change(Object target, String property, Object oldValue, Object newValue) {
this.target = target;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -7,34 +7,73 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import org.jboss.tools.seam.core.SeamCorePlugin;
/**
+ * Seam project related preferences constants
+ *
* @author eskimo
- *
*/
public class SeamProjectPreferences {
- public static final String SEAM_DEFAULT_RUNTIME_NAME
- = SeamCorePlugin.PLUGIN_ID + ".project.facet.default.runtime.name"; //$NON-NLS-1$
- public static final String SEAM_DEFAULT_CONNECTION_PROFILE
- = SeamCorePlugin.PLUGIN_ID + ".project.facet.default.conn.profile"; //$NON-NLS-1$
- public static final String RUNTIME_CONFIG_FORMAT_VERSION
- = SeamCorePlugin.PLUGIN_ID + ".runtime.config.format.version"; //$NON-NLS-1$
- public static final String RUNTIME_LIST
- = SeamCorePlugin.PLUGIN_ID+".runtime.list"; //$NON-NLS-1$
- public static final String RUNTIME_DEFAULT
- = SeamCorePlugin.PLUGIN_ID+".runtime.default"; //$NON-NLS-1$
- public static final String JBOSS_AS_DEFAULT_DEPLOY_AS
- = SeamCorePlugin.PLUGIN_ID + ".project.default.deployment.type"; //$NON-NLS-1$
- public static final String HIBERNATE_DEFAULT_DB_TYPE
- = SeamCorePlugin.PLUGIN_ID + ".hibernate.default.db.type"; //$NON-NLS-1$
- public static final String SEAM_LAST_SERVER_NAME
- = SeamCorePlugin.PLUGIN_ID + ".project.facet.last.server.name"; //$NON-NLS-1$
-
+ /**
+ * Last selected SeamRuntime name
+ */
+ public static final String SEAM_DEFAULT_RUNTIME_NAME = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.default.runtime.name"; //$NON-NLS-1$
+
+ /**
+ * Last selected connection profile
+ */
+ public static final String SEAM_DEFAULT_CONNECTION_PROFILE = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.default.conn.profile"; //$NON-NLS-1$
+
+ /**
+ * TODO
+ */
+ public static final String RUNTIME_CONFIG_FORMAT_VERSION = SeamCorePlugin.PLUGIN_ID
+ + ".runtime.config.format.version"; //$NON-NLS-1$
+
+ /**
+ * String represents list of available runtimes
+ */
+ public static final String RUNTIME_LIST = SeamCorePlugin.PLUGIN_ID
+ + ".runtime.list"; //$NON-NLS-1$
+
+ /**
+ * TODO
+ */
+ public static final String RUNTIME_DEFAULT = SeamCorePlugin.PLUGIN_ID
+ + ".runtime.default"; //$NON-NLS-1$
+
+ /**
+ * Last selected deployment type
+ */
+ public static final String JBOSS_AS_DEFAULT_DEPLOY_AS = SeamCorePlugin.PLUGIN_ID
+ + ".project.default.deployment.type"; //$NON-NLS-1$
+
+ /**
+ * Last selected DB type
+ */
+ public static final String HIBERNATE_DEFAULT_DB_TYPE = SeamCorePlugin.PLUGIN_ID
+ + ".hibernate.default.db.type"; //$NON-NLS-1$
+
+ /**
+ * Last selected server
+ */
+ public static final String SEAM_LAST_SERVER_NAME = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.last.server.name"; //$NON-NLS-1$
+
+ /**
+ * Return String value from SeamCore preferences by name
+ *
+ * @param name
+ * preference property name
+ * @return preference property value
+ */
public static String getStringPreference(final String name) {
return SeamCorePlugin.getDefault().getPreferenceStore().getString(name);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -7,124 +7,174 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
/**
+ * Class represent Seam Runtime parameters:
+ * <ul>
+ * <li>name</li>
+ * <li>path to home directory</li>
+ * <li>version number</li>
+ * <li>default flag</li>
+ * </ul>
+ * and provide methods to get path to most relevant folders:
+ * <ul>
+ * <li>root templates</li>
+ * <li>source templates</li>
+ * <li>test templates</li>
+ * <li>view templates</li>
+ * </ul>
+
* @author eskimo
- *
+ *
*/
public class SeamRuntime {
-
- /**
- *
- */
+
SeamVersion version = null;
-
- /**
- *
- */
+
String name = null;
-
- /**
- *
- */
+
String homeDir = null;
- /**
- *
- */
boolean defaultRt = false;
-
+
/**
- *
+ * Default constructor
*/
- public SeamRuntime() {}
-
+ public SeamRuntime() {
+ }
+
/**
+ * Get SeamVersion for Runtime
*
* @return
+ *
+ * SeamVersion constant
*/
public SeamVersion getVersion() {
return version;
}
-
+
/**
+ * Get SeamRuntime name
*
- * @return
+ * @return name
*/
public String getName() {
return name;
}
-
+
/**
+ * Get path to home directory
*
- * @return
+ * @return home directory path as string
*/
public String getHomeDir() {
return homeDir;
}
/**
+ * Set SeamVersion
*
* @param version
+ * new SeamVersion
*/
public void setVersion(SeamVersion version) {
this.version = version;
}
/**
+ * Set SeamRuntime name
*
* @param name
+ * new SeamRuntime name
*/
public void setName(String name) {
this.name = name;
}
/**
+ * Set home directory
*
* @param homeDir
+ * new SeamRuntime's home directory
*/
public void setHomeDir(String homeDir) {
this.homeDir = homeDir;
}
/**
+ * Mark runtime as default
+ *
* @param b
+ * new value for default property
*/
public void setDefault(boolean b) {
- this.defaultRt = b;
+ this.defaultRt = b;
}
-
+
/**
- * @return
+ * Get default flag
+ *
+ * @return default property
*/
public boolean isDefault() {
return defaultRt;
}
-
+
+ /**
+ * Calculate path to seam-gen
+ *
+ * @return absolute path to seam-gen folder
+ */
public String getSeamGenDir() {
- return getHomeDir()+"/seam-gen"; //$NON-NLS-1$
+ return getHomeDir() + "/seam-gen"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to source templates
+ *
+ * @return absolute path to source templates
+ */
public String getSrcTemplatesDir() {
- return getSeamGenDir()+"/src"; //$NON-NLS-1$
+ return getSeamGenDir() + "/src"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to view templates
+ *
+ * @return absolute path to view templates
+ */
public String getViewTemplatesDir() {
- return getSeamGenDir()+"/view"; //$NON-NLS-1$
+ return getSeamGenDir() + "/view"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to resource templates
+ *
+ * @return absolute path to resource templates
+ */
public String getResourceTemplatesDir() {
- return getSeamGenDir()+"/resources"; //$NON-NLS-1$
+ return getSeamGenDir() + "/resources"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to test templates
+ *
+ * @return absolute path to test templates
+ */
public String getTestTemplatesDir() {
- return getSeamGenDir()+"/test"; //$NON-NLS-1$
+ return getSeamGenDir() + "/test"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to templates root directory
+ *
+ * @return absolute path to templates root directory
+ */
public String getTemplatesDir() {
return getSeamGenDir();
}
-
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import java.util.HashMap;
@@ -15,56 +15,94 @@
import java.util.StringTokenizer;
/**
+ * Converter is responsible for transformation String to
+ * Map<String, SeamRuntime> and vice versa
+ *
* @author eskimo
- *
*/
public class SeamRuntimeListConverter {
-
- public Map<String,SeamRuntime> getMap(String input) {
-
- Map<String,SeamRuntime> result = new HashMap<String,SeamRuntime>();
- if(input==null || "".equals(input.trim())) { //$NON-NLS-1$
+
+ /*
+ * Constants definitions
+ */
+ private static final String REGEXP_ESCAPE = "\\";
+ private static final String COMMA = ",";
+ private static final String EMPTY_STRING = "";
+ private static final String FIELD_SEPARATOR = "|";
+ private static final String DEFAULT = "default";
+ private static final String VERSION = "version";
+ private static final String HOME_DIR = "homeDir";
+ private static final String NAME = "name";
+
+ /**
+ * Load String to SeamRuntime map from String
+ * @param input
+ * String representation of map
+ * @return
+ * Map<String, SeamRuntime> loaded from string
+ * TODO - switch to XML?
+ * TODO - write converter from old serialization format to XML?
+ * TODO - handle errors in string format
+ */
+ public Map<String, SeamRuntime> getMap(String input) {
+
+ Map<String, SeamRuntime> result = new HashMap<String, SeamRuntime>();
+ if (input == null || EMPTY_STRING.equals(input.trim())) {
return result;
}
-
- StringTokenizer runtimes = new StringTokenizer(input,","); //$NON-NLS-1$
+ StringTokenizer runtimes = new StringTokenizer(input, COMMA);
while (runtimes.hasMoreTokens()) {
String runtime = runtimes.nextToken();
- String[] map = runtime.split("\\|"); //$NON-NLS-1$
+ String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
SeamRuntime rt = new SeamRuntime();
- for (int i=0;i<map.length;i+=2) {
+ final int step = 2;
+ for (int i = 0; i < map.length; i += step) {
String name = map[i];
- String value = i+1<map.length?map[i+1]:""; //$NON-NLS-1$
- if("name".equals(name)) { //$NON-NLS-1$
+ String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
+ if (NAME.equals(name)) {
rt.setName(value);
- } else if("homeDir".equals(name)) { //$NON-NLS-1$
+ } else if (HOME_DIR.equals(name)) {
rt.setHomeDir(value);
- } else if ("version".equals(name)) { //$NON-NLS-1$
+ } else if (VERSION.equals(name)) {
rt.setVersion(SeamVersion.parseFromString(value));
- } else if("default".equals(name)) { //$NON-NLS-1$
+ } else if (DEFAULT.equals(name)) {
rt.setDefault(Boolean.parseBoolean(value));
}
}
- result.put(rt.getName(),rt);
+ result.put(rt.getName(), rt);
}
-
+
return result;
}
- public String getString(Map<String,SeamRuntime> runtimeMap) {
+ /**
+ * Convert map String to SeamRUntime to string representation
+ * @param runtimeMap
+ * Map<String, SeamRuntime> - map of String to Seam Runtime to convert
+ * in String
+ * @return
+ * String representation of String to Seam Runtime map
+ */
+ public String getString(Map<String, SeamRuntime> runtimeMap) {
StringBuffer buffer = new StringBuffer();
- SeamRuntime[] runtimes = runtimeMap.values().toArray(new SeamRuntime[runtimeMap.size()]);
- for (int i=0;i<runtimes.length;i++) {
- buffer.append("name|"); //$NON-NLS-1$
+ SeamRuntime[] runtimes = runtimeMap.values().toArray(
+ new SeamRuntime[runtimeMap.size()]);
+ for (int i = 0; i < runtimes.length; i++) {
+ buffer.append(NAME).append(FIELD_SEPARATOR);
buffer.append(runtimes[i].getName());
- buffer.append("|version|"); //$NON-NLS-1$
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
buffer.append(runtimes[i].getVersion().toString());
- buffer.append("|homeDir|"); //$NON-NLS-1$
+ buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
+ FIELD_SEPARATOR);
buffer.append(runtimes[i].getHomeDir());
- buffer.append("|default|"); //$NON-NLS-1$
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
buffer.append(runtimes[i].isDefault());
- if(i!=runtimes.length-1) buffer.append(","); //$NON-NLS-1$
- }
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
return buffer.toString();
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import java.io.IOException;
@@ -28,94 +28,115 @@
import org.jboss.tools.seam.internal.core.validation.SeamRuntimeValidation;
/**
+ * This class is responsible for managing available SeamRuntime list.
+ *
* @author eskimo
- *
*/
public class SeamRuntimeManager {
-
+
private static SeamRuntimeListConverter converter = new SeamRuntimeListConverter();
-
+
private Map<String, SeamRuntime> runtimes = new HashMap<String, SeamRuntime>();
private SeamRuntime defaultRt = null;
-
+
private SeamRuntimeValidation validator = new SeamRuntimeValidation();
-
+
/**
- *
+ * Private constructor
*/
+ private SeamRuntimeManager() {
+ String configVersion = SeamProjectPreferences
+ .getStringPreference(SeamProjectPreferences.RUNTIME_CONFIG_FORMAT_VERSION);
+ String runtimeListString = SeamProjectPreferences
+ .getStringPreference(SeamProjectPreferences.RUNTIME_LIST);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+ /**
+ * This class make Java Runtime responsible for solving synchronization
+ * problems during initialization if there is any
+ *
+ * @author eskimo
+ */
static class SeamRuntimeManagerHolder {
private static final SeamRuntimeManager INSTANCE = new SeamRuntimeManager();
}
-
+
/**
+ * Return SeamRuntimeManaher instance
*
* @return
+ * SeamRuntimeManager instance
*/
public static SeamRuntimeManager getInstance() {
return SeamRuntimeManagerHolder.INSTANCE;
}
-
+
/**
+ * Return Array of configured SeamRuntimes
*
- */
- private SeamRuntimeManager() {
- String configVersion = SeamProjectPreferences.getStringPreference(
- SeamProjectPreferences.RUNTIME_CONFIG_FORMAT_VERSION);
- String runtimeListString = SeamProjectPreferences.getStringPreference(
- SeamProjectPreferences.RUNTIME_LIST);
-
- runtimes = converter.getMap(runtimeListString);
- }
-
- /**
- *
* @return
+ * SeamRuntime[]
*/
public SeamRuntime[] getRuntimes() {
Collection<SeamRuntime> c = runtimes.values();
return c.toArray(new SeamRuntime[runtimes.size()]);
}
-
+
/**
+ * Return array of SeamRuntimes that is compatible with given version
*
* @param version
+ * SeamVersion
* @return
+ * SeamRuntime[]
*/
public SeamRuntime[] getRuntimes(SeamVersion version) {
Collection<SeamRuntime> c = runtimes.values();
List<SeamRuntime> rts = new ArrayList<SeamRuntime>();
for (SeamRuntime seamRuntime : c) {
- if(seamRuntime.getVersion()==version)rts.add(seamRuntime);
+ if (seamRuntime.getVersion() == version) {
+ rts.add(seamRuntime);
+ }
}
return rts.toArray(new SeamRuntime[rts.size()]);
}
-
+
/**
+ * Add new SeamRuntime
*
* @param runtime
+ * SeamRuntime
*/
public void addRuntime(SeamRuntime runtime) {
- if(runtimes.size()==0) {
+ if (runtimes.size() == 0) {
runtime.setDefault(true);
- }
-
- if(getDefaultRuntime()!=null && runtime.isDefault()) {
+ }
+
+ if (getDefaultRuntime() != null && runtime.isDefault()) {
getDefaultRuntime().setDefault(false);
}
- runtimes.put(runtime.getName(),runtime);
+ runtimes.put(runtime.getName(), runtime);
save();
validateProjects();
}
-
+
/**
+ * Add new SeamRuntime with given parameters
*
* @param name
+ * String - runtime name
* @param path
+ * String - runtime home folder
* @param version
+ * String - string representation of version number
* @param defaultRt
+ * boolean - default flag
*/
- public void addRuntime(String name, String path, SeamVersion version, boolean defaultRt) {
+ public void addRuntime(String name, String path, SeamVersion version,
+ boolean defaultRt) {
SeamRuntime seamRt = new SeamRuntime();
seamRt.setVersion(version);
seamRt.setHomeDir(path);
@@ -123,88 +144,134 @@
seamRt.setDefault(defaultRt);
addRuntime(seamRt);
}
-
+
/**
+ * Return SeamRuntime by given name
*
* @param name
+ * String - SeamRuntime name
* @return
+ * SeamRuntime - found SeamRuntime instance or null
*/
public SeamRuntime findRuntimeByName(String name) {
for (SeamRuntime seamRuntime : runtimes.values()) {
- if(seamRuntime.getName().equals(name))return seamRuntime;
+ if (seamRuntime.getName().equals(name)) {
+ return seamRuntime;
+ }
}
return null;
}
-
+
/**
- *
+ * Remove given SeamRuntime from manager
* @param rt
+ * SeamRuntime
*/
public void removeRuntime(SeamRuntime rt) {
runtimes.remove(rt.getName());
validateProjects();
}
-
+
/**
+ * Return SeamRuntime instance for given project
*
* @param project
+ * IProject
* @return
+ * SeamRuntime - instance of available SeamRuntime or null
*/
public SeamRuntime getRuntimeForProject(IProject project) {
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ ISeamProject seamProject = SeamCorePlugin
+ .getSeamProject(project, false);
return (seamProject == null) ? null : seamProject.getRuntime();
}
-
+
/**
* Save preference value and force save changes to disk
*/
public void save() {
SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.RUNTIME_LIST, converter.getString(runtimes));
- IPreferenceStore store = SeamCorePlugin.getDefault().getPreferenceStore();
- if(store instanceof IPersistentPreferenceStore) {
+ SeamProjectPreferences.RUNTIME_LIST,
+ converter.getString(runtimes));
+ IPreferenceStore store = SeamCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
try {
- ((IPersistentPreferenceStore)store).save();
+ ((IPersistentPreferenceStore) store).save();
} catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
+ SeamCorePlugin.getPluginLog().logError(
+ "Seam Runtime List was not saved", e);
}
}
}
/**
+ * Return first default SeamRuntime
*
* @return
+ * SeamRuntime
*/
public SeamRuntime getDefaultRuntime() {
for (SeamRuntime rt : runtimes.values()) {
- if(rt.isDefault())return rt;
+ if (rt.isDefault()) {
+ return rt;
+ }
}
return null;
}
+
+ /**
+ * Return default runtime for given SeamVersion
+ *
+ * @param version
+ * given SeamVersion
+ * @return
+ * Default SeamRuntime for given version
+ */
+ public SeamRuntime getDefaultRuntime(SeamVersion version) {
+ for (SeamRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return rt;
+ }
+ }
+ return null;
+ }
/**
+ * Return version of configuration
*
+ * @return
+ * String - string representation of version
*/
public String getConfigurationVersion() {
return SeamFacetPreferenceInitializer.RUNTIME_CONFIG_FORMAT_VERSION;
}
/**
+ * Return list of available SeamRuntime names
+ *
* @return
+ * List<String>
*/
public List<String> getRuntimeNames() {
SeamRuntime[] rts = getRuntimes(SeamVersion.SEAM_1_2);
List<String> result = new ArrayList<String>();
- for(SeamRuntime seamRuntime : rts) {
+ for (SeamRuntime seamRuntime : rts) {
result.add(seamRuntime.getName());
}
return result;
}
+ /**
+ * Return a list of all runtime names
+ *
+ * @return
+ * List of all runtime names
+ */
public List<String> getAllRuntimeNames() {
SeamRuntime[] rts = getRuntimes();
List<String> result = new ArrayList<String>();
- for(SeamRuntime seamRuntime : rts) {
+ for (SeamRuntime seamRuntime : rts) {
result.add(seamRuntime.getName());
}
return result;
@@ -214,7 +281,9 @@
IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < ps.length; i++) {
ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
- if(sp == null) continue;
+ if (sp == null) {
+ continue;
+ }
try {
validator.validate(sp);
} catch (CoreException e) {
@@ -222,24 +291,31 @@
}
}
}
-
+
+ /**
+ * TBD
+ *
+ * @param oldName
+ * old runtime name
+ * @param newName
+ * new runtime name
+ */
public void changeRuntimeName(String oldName, String newName) {
SeamRuntime o = findRuntimeByName(oldName);
- if(o == null) {
+ if (o == null) {
return;
}
o.setName(newName);
- onRuntimeNameChanged(oldName, newName);
+ onRuntimeNameChanged(oldName, newName);
}
private void onRuntimeNameChanged(String oldName, String newName) {
IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < ps.length; i++) {
ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
- if(sp != null && oldName.equals(sp.getRuntimeName())) {
+ if (sp != null && oldName.equals(sp.getRuntimeName())) {
sp.setRuntimeName(newName);
}
}
}
-
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -7,39 +7,61 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import org.eclipse.osgi.util.NLS;
/**
+ * Seam Versions enumeration
+ *
* @author eskimo
- *
*/
-public enum SeamVersion{
- SEAM_1_2("1.2"), SEAM_2_0("2.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+public enum SeamVersion {
+ /**
+ * Seam versions 1.2.X
+ */
+ SEAM_1_2("1.2"),
+ /**
+ * Seam versions 2.0.X
+ */
+ SEAM_2_0("2.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
String version = ""; //$NON-NLS-1$
-
- public static final String V_1_2 = "1.2"; //$NON-NLS-1$
-
- public static final String V_2_0 = "2.0"; //$NON-NLS-1$
-
+
SeamVersion(String version) {
this.version = version;
}
-
+
+ /**
+ * Return string representation of version
+ *
+ * @return
+ * version number as string
+ */
public String toString() {
return version;
}
-
- static public SeamVersion parseFromString(String version) {
- if(V_1_2.equals(version)) {
+
+ /**
+ * Get enumeration by string
+ * TODO support for compatible version? should 1.2.1 return SEAM_1_2?
+ *
+ * @param version
+ * string representation of version
+ * @return
+ * version enumeration corresponding to version string
+ */
+ public static SeamVersion parseFromString(String version) {
+ if (SEAM_1_2.toString().equals(version)) {
return SEAM_1_2;
- } else if(V_2_0.equals(version)) {
+ } else if (SEAM_2_0.toString().equals(version)) {
return SEAM_2_0;
}
- throw new IllegalArgumentException(NLS.bind("Seam version ''{0}'' is not supported",version)); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(NLS.bind(
+ "Seam version ''{0}'' is not supported", version)); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2007-12-29 01:47:45 UTC (rev 5478)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2007-12-29 01:49:25 UTC (rev 5479)
@@ -93,7 +93,7 @@
if(seamFolder.exists() && seamFolder.isDirectory()) {
SeamRuntime rt = new SeamRuntime();
rt.setHomeDir(seamGenBuildPath);
- rt.setName("Seam " + SeamVersion.V_1_2+".AP"); //$NON-NLS-1$ //$NON-NLS-2$
+ rt.setName("Seam " + SeamVersion.SEAM_1_2 + ".AP"); //$NON-NLS-1$ //$NON-NLS-2$
rt.setDefault(true);
rt.setVersion(SeamVersion.SEAM_1_2);
map.put(rt.getName(), rt);
16 years, 12 months
JBoss Tools SVN: r5478 - trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-12-28 20:47:45 -0500 (Fri, 28 Dec 2007)
New Revision: 5478
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490
1. JUnit test for JBIDE-1490 was added
2. Javadoc comments were added
3. Coding style was improved to reduce amount of Checkstyle violations
Modified: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java 2007-12-29 01:47:41 UTC (rev 5477)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java 2007-12-29 01:47:45 UTC (rev 5478)
@@ -7,42 +7,44 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.test.util;
import junit.framework.TestCase;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.wizards.IWizardDescriptor;
/**
* @author eskimo
- *
+ *
*/
public class WorkbenchUtils {
-
+
static public IWizard findWizardByDefId(String definitionId) {
- IWizardDescriptor aWizardDescr =
- getWorkbench().getNewWizardRegistry()
- .findWizard(definitionId);
- TestCase.assertNotNull("Cannot find wizard "
- + definitionId
- + " definition in wizard registry", aWizardDescr);
- IWorkbenchWizard aWizard=null;
- try {
- aWizard = aWizardDescr.createWizard();
- } catch (CoreException e) {
- JUnitUtils.fail("Cannot create IWorkbenchWizard instance",e);
- }
- return aWizard;
+ IWizardDescriptor aWizardDescr = getWorkbench().getNewWizardRegistry()
+ .findWizard(definitionId);
+ TestCase.assertNotNull("Cannot find wizard " + definitionId
+ + " definition in wizard registry", aWizardDescr);
+ IWorkbenchWizard aWizard = null;
+ try {
+ aWizard = aWizardDescr.createWizard();
+ } catch (CoreException e) {
+ JUnitUtils.fail("Cannot create IWorkbenchWizard instance", e);
+ }
+ return aWizard;
}
-
+
public static IWorkbench getWorkbench() {
return PlatformUI.getWorkbench();
}
@@ -54,4 +56,25 @@
// TODO Auto-generated method stub
return getWorkbench().getActiveWorkbenchWindow().getActivePage();
}
+
+ /**
+ * To show modal dialog parent shell is required, this method can be used to
+ * obtain active workbench window shell
+ *
+ * @return active workbench window shell
+ */
+ public static Shell getActiveShell() {
+ return getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+
+ public static PreferenceManager getPreferenceManager() {
+ return getWorkbench().getPreferenceManager();
+ }
+
+ public static PreferenceDialog createPreferenceDialog(String pageId) {
+
+ return PreferencesUtil.createPreferenceDialogOn(WorkbenchUtils
+ .getActiveShell(), pageId, new String[] {pageId}, null);
+ }
+
}
16 years, 12 months
JBoss Tools SVN: r5477 - in trunk/seam/tests/org.jboss.tools.seam.ui.test: src/org/jboss/tools/seam/ui/test and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-12-28 20:47:41 -0500 (Fri, 28 Dec 2007)
New Revision: 5477
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/preferences/
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/preferences/SeamPreferencesPageTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/widget/
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/widget/editor/
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/build.properties
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490
1. JUnit test for JBIDE-1490 was added
2. Javadoc comments were added
3. Coding style was improved to reduce amount of Checkstyle violations
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/build.properties
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/build.properties 2007-12-29 01:43:27 UTC (rev 5476)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/build.properties 2007-12-29 01:47:41 UTC (rev 5477)
@@ -1,9 +1,11 @@
bin.includes = META-INF/,\
seam-ui.jar,\
- projects/
+ projects/,\
+ seam/
source.seam-ui.jar = src/
jars.compile.order = seam-ui.jar
src.includes = src/,\
build.properties,\
META-INF/,\
- projects/
+ projects/,\
+ seam/
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java 2007-12-29 01:43:27 UTC (rev 5476)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/SeamUiAllTests.java 2007-12-29 01:47:41 UTC (rev 5477)
@@ -14,6 +14,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.jboss.tools.seam.ui.test.preferences.SeamPreferencesPageTest;
import org.jboss.tools.seam.ui.test.hyperlink.SeamViewHyperlinkPartitionerTest;
import org.jboss.tools.seam.ui.test.view.SeamComponentsViewTest;
import org.jboss.tools.seam.ui.test.wizard.SeamFormNewWizardTest;
@@ -30,6 +31,7 @@
suite.addTestSuite(SeamComponentsViewTest.class);
suite.addTestSuite(SeamProjectNewWizardTest.class);
suite.addTestSuite(SeamFormNewWizardTest.class);
+ suite.addTestSuite(SeamPreferencesPageTest.class);
suite.addTestSuite(SeamViewHyperlinkPartitionerTest.class);
return suite;
}
Added: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/preferences/SeamPreferencesPageTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/preferences/SeamPreferencesPageTest.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/preferences/SeamPreferencesPageTest.java 2007-12-29 01:47:41 UTC (rev 5477)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.test.preferences;
+
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
+import org.jboss.tools.seam.ui.preferences.SeamPreferencePage;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * @author eskimo
+ *
+ */
+
+public class SeamPreferencesPageTest extends TestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ // TODO Auto-generated method stub
+ super.tearDown();
+ }
+
+ /**
+ * Test that preference page is showed up without errors
+ */
+ public void testShowSeamPreferencePage() {
+
+ PreferenceDialog prefDialog =
+ WorkbenchUtils.createPreferenceDialog(
+ SeamPreferencePage.SEAM_PREFERENCES_ID);
+
+ try {
+ prefDialog.setBlockOnOpen(false);
+ prefDialog.open();
+
+ Object selectedPage = prefDialog.getSelectedPage();
+ assertTrue("Selected page is not an instance of SeamPreferencePage", selectedPage instanceof SeamPreferencePage);
+ } finally {
+ prefDialog.close();
+ }
+ }
+
+ public void testJiraJbide1490 () {
+ SeamRuntime[] seamRts = SeamRuntimeManager.getInstance().getRuntimes();
+
+ for (SeamRuntime seamRuntime : seamRts) {
+ SeamRuntimeManager.getInstance().removeRuntime(seamRuntime);
+ }
+
+ PreferenceDialog prefDialog =
+ WorkbenchUtils.createPreferenceDialog(
+ SeamPreferencePage.SEAM_PREFERENCES_ID);
+
+ try {
+ prefDialog.setBlockOnOpen(false);
+ prefDialog.open();
+ SeamPreferencePage selectedPage = (SeamPreferencePage)prefDialog.getSelectedPage();
+ selectedPage.performOk();
+ } finally {
+ prefDialog.close();
+ }
+
+ }
+
+}
Property changes on: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/preferences/SeamPreferencesPageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2007-12-29 01:43:27 UTC (rev 5476)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/SeamProjectNewWizardTest.java 2007-12-29 01:47:41 UTC (rev 5477)
@@ -75,7 +75,7 @@
* first page of New Seam Project Wizard must enable Finish button.
* See http://jira.jboss.com/jira/browse/JBIDE-1111
*/
- public void testSeamProjectNewWizardAllowsToFinishAtFirstPage() {
+ public void testJiraJbide1111() {
// Check Finish button
boolean canFinish = wizard.canFinish();
assertFalse("Finish button is enabled at first wizard page before all requerd fileds are valid.", canFinish);
16 years, 12 months