Author: snjeza
Date: 2009-05-03 16:53:50 -0400 (Sun, 03 May 2009)
New Revision: 14996
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs
trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.seam.tutorial/bin/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml
trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java
Modified:
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4180 We should have the projects featured in Seam
tutorials available in Project Examples
Modified: trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
===================================================================
---
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml 2009-05-03
20:52:00 UTC (rev 14995)
+++
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml 2009-05-03
20:53:50 UTC (rev 14996)
@@ -2,7 +2,7 @@
<feature
id="org.jboss.tools.project.examples.feature"
label="%featureName"
- version="1.0.0"
+ version="1.0.1"
provider-name="%providerName"
plugin="org.jboss.tools.project.examples">
@@ -29,4 +29,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.tools.seam.tutorial"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2009-05-03
20:52:00 UTC (rev 14995)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2009-05-03
20:53:50 UTC (rev 14996)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.project.examples;singleton:=true
-Bundle-Version: 1.0.0
+Bundle-Version: 1.0.1
Bundle-Activator: org.jboss.tools.project.examples.ProjectExamplesActivator
Bundle-Vendor: %BunldeVendor
Require-Bundle: org.eclipse.ui,
@@ -24,3 +24,10 @@
org.eclipse.jdt.core
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
+Export-Package: org.jboss.tools.project.examples,
+ org.jboss.tools.project.examples.actions,
+ org.jboss.tools.project.examples.dialog,
+ org.jboss.tools.project.examples.dialog.xpl,
+ org.jboss.tools.project.examples.filetransfer,
+ org.jboss.tools.project.examples.model,
+ org.jboss.tools.project.examples.wizard
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2009-05-03
20:52:00 UTC (rev 14995)
+++
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2009-05-03
20:53:50 UTC (rev 14996)
@@ -96,8 +96,10 @@
private IStructuredSelection selection;
private NewProjectExamplesWizardPage page;
+
+ private static Shell shell;
- protected boolean overwrite;
+ protected static boolean overwrite;
private WorkspaceJob workspaceJob;
@@ -174,7 +176,6 @@
};
workspaceJob.setUser(true);
final boolean showQuickFix = page.showQuickFix();
- workspaceJob.schedule();
if (showQuickFix) {
workspaceJob.addJobChangeListener(new IJobChangeListener() {
@@ -205,7 +206,7 @@
List<IMarker> markers = ProjectExamplesActivator
.getMarkers(projects);
if (markers != null && markers.size() > 0) {
- showQuickFix();
+ showQuickFix(projects);
}
}
openWelcome();
@@ -227,6 +228,7 @@
} else {
openWelcome();
}
+ workspaceJob.schedule();
return true;
}
@@ -288,7 +290,7 @@
}
}
- private void showQuickFix() {
+ public static void showQuickFix(final List<Project> projects) {
Display.getDefault().asyncExec(new Runnable() {
@@ -303,7 +305,7 @@
});
}
- private void importProject(Project projectDescription, File file,
+ public static void importProject(Project projectDescription, File file,
IProgressMonitor monitor) throws Exception {
if (projectDescription.getIncludedProjects() == null) {
importSingleProject(projectDescription, file, monitor);
@@ -316,7 +318,7 @@
Display.getDefault().syncExec(new Runnable() {
public void run() {
- overwrite = MessageDialog.openQuestion(getShell(),
+ overwrite = MessageDialog.openQuestion(getActiveShell(),
Messages.NewProjectExamplesWizard_Question,
NLS.bind(Messages.NewProjectExamplesWizard_OverwriteProject,
projectName));
}
@@ -350,14 +352,26 @@
ImportOperation operation = new ImportOperation(workspace
.getRoot().getFullPath(), structureProvider.getRoot(),
structureProvider, OVERWRITE_ALL_QUERY, filesToImport);
- operation.setContext(getShell());
+ operation.setContext(getActiveShell());
operation.run(monitor);
reconfigure(project, monitor);
}
}
}
- private void importSingleProject(Project projectDescription, File file,
+ private static Shell getActiveShell() {
+ Display display = Display.getDefault();
+ shell = null;
+ display.syncExec(new Runnable() {
+
+ public void run() {
+ shell = Display.getCurrent().getActiveShell();
+ }
+
+ });
+ return shell;
+ }
+ private static void importSingleProject(Project projectDescription, File file,
IProgressMonitor monitor) throws CoreException, ZipException,
IOException, InvocationTargetException, InterruptedException {
final String projectName = projectDescription.getName();
@@ -367,7 +381,7 @@
Display.getDefault().syncExec(new Runnable() {
public void run() {
- overwrite = MessageDialog.openQuestion(getShell(),
+ overwrite = MessageDialog.openQuestion(getActiveShell(),
Messages.NewProjectExamplesWizard_Question,
NLS.bind(Messages.NewProjectExamplesWizard_OverwriteProject,
projectName));
}
@@ -387,7 +401,7 @@
ImportOperation operation = new ImportOperation(workspace.getRoot()
.getFullPath(), structureProvider.getRoot(), structureProvider,
OVERWRITE_ALL_QUERY);
- operation.setContext(getShell());
+ operation.setContext(getActiveShell());
operation.run(monitor);
reconfigure(project, monitor);
}
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath
(rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath 2009-05-03 20:53:50
UTC (rev 14996)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project
(rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project 2009-05-03 20:53:50 UTC
(rev 14996)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.seam.tutorial</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,7 @@
+#Wed Apr 29 22:17:17 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Seam Tutorials
+Bundle-SymbolicName: org.jboss.tools.seam.tutorial;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.seam.tutorial.Activator
+Bundle-Vendor: JBoss, a division of Red Hat
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.cheatsheets,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.text,
+ org.jboss.tools.jst.jsp,
+ org.eclipse.wst.sse.ui,
+ org.jboss.tools.common.text.ext,
+ org.jboss.tools.common,
+ org.jboss.tools.common.model,
+ org.jboss.tools.common.model.ui,
+ org.jboss.tools.project.examples,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.server.ui,
+ org.jboss.ide.eclipse.as.core
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
(rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ cheatsheets/
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,438 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<cheatsheet title="Your first Seam application: the registration
example">
+
+ <intro>
+ <description>
+ The registration example is a simple application that lets a new user store his
username, real name and password in the database. The example isn't intended to
show off all of the cool functionality of Seam. However, it demonstrates the use of an
EJB3 session bean as a JSF action listener, and basic configuration of Seam.
+<br/><br/>
+We'll go slowly, since we realize you might not yet be familiar with EJB 3.0.
+<br/><br/>
+The start page displays a very basic form with three input fields. Try filling them in
and then submitting the form. This will save a user object in the database.
+ </description>
+ </intro>
+
+ <item title="Open the Seam perspective" dialog="false"
skip="false"
href="/org.eclipse.platform.doc.user/concepts/concepts-4.htm">
+ <description>
+ If you're not already in the Seam perspective, in the main menu select
<b>Window</b> > <b>Open Perspective</b> >
<b>Other</b> > <b>Seam</b> or click on the "Click
to Perform" link below.
+ </description>
+ <command
serialization="org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.jboss.tools.seam.ui.SeamPerspective)"
required="false" translate="">
+ </command>
+ </item>
+
+ <item
+ title="Setup the Environment"
+ skip="true">
+ <description>
+ You must set up your environment before performing the steps in this tutorial.
+ <br/><br/>
+ <b>
+ If you have JBoss Developer Studio with EAP installed, your environment is already
set correctly.
+ </b>
+ </description>
+ <subitem
+ label="Create JBoss AS Runtime and Server using "File >
New > Other > Server > Server" and select "JBoss
Comunity" or "JBoss Enterprise Middleware" server type or click
the "Click to Perform" link."
+ skip="true">
+ <command
+
serialization="org.eclipse.ui.newWizard(newWizardId=org.eclipse.wst.server.ui.new.server)"
+ required="false" translate="">
+ </command>
+ </subitem>
+ <subitem
+ label="Create a Seam Runtime using "Window > Preferences
> JBoss Tools > Web > Seam." or click the "Click to
Perform" link."
+ skip="true">
+ <action
+ required="false"
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenPreferencePage"
+ param1="org.jboss.tools.common.model.ui.seam"/>
+ </subitem>
+ <subitem
+ label="Create a Database Connection Profile by selecting "File
> New > Other > Connection Profiles > Connection
Profile." or click the "Click to Perform" link."
+ skip="true">
+ <command
+
serialization="org.eclipse.ui.newWizard(newWizardId=org.eclipse.datatools.connectivity.internal.ui.wizards.newconnectionprofile)"
+ required="false" translate="">
+ </command>
+ </subitem>
+ </item>
+
+ <item
+ title="Import the registration example">
+ <description>
+ Import the registration example using <b>Help > Project Examples</b>
and select "Seam Registration Example - EAR" or click the "Click to
Perform" link below.
+ <br/><br/>
+ If you don't have JBoss Developer Studio with EAP, you will have to set your
Server Runtime, Seam Runtime and Database Connection Profile.
+After importing the project example, you will be able to use the Quick Fix dialog to set
them.
+ </description>
+ <action
+ required="true"
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.ImportProjectExample"
+ param1="registration2"
+ param2="registration,registration-ejb,registration-ear"
+
param3="http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/s...
+ />
+ </item>
+
+ <item
+ skip="true"
+ title="Understanding the code">
+ <description>
+ The example is implemented with two Facelets templates, one entity bean and one
stateless session bean. Let's take a look at the code, starting from the
"bottom".
+ </description>
+ </item>
+
+ <item
+ title="The entity bean: User.java">
+ <description>
+ The most important things to notice in this example are the @Name and @Scope
annotations. These annotations establish that this class is a Seam component.
+<br/><br/>
+We'll see below that the properties of our User class are bound directly to JSF
components and are populated by JSF during the update model values phase. We don't
need any tedious glue code to copy data back and forth between the JSP pages and the
entity bean domain model.
+<br/><br/>
+However, entity beans shouldn't do transaction management or database access. So we
can't use this component as a JSF action listener. For that we need a session bean.
+
+ </description>
+ <subitem
+ label="The EJB3 standard @Entity annotation indicates that the User
class is an entity bean."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="17" />
+ </subitem>
+ <subitem
+ label="A Seam component needs a component name specified by the @Name
annotation. This name must be unique within the Seam application. When JSF asks Seam to
resolve a context variable with a name that is the same as a Seam component name, and the
context variable is currently undefined (null), Seam will instantiate that component, and
bind the new instance to the context variable. In this case, Seam will instantiate a User
the first time JSF encounters a variable named user."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="18"/>
+ </subitem>
+ <subitem
+ label="Whenever Seam instantiates a component, it binds the new instance
to a context variable in the component's default context. The default context is
specified using the @Scope annotation. The User bean is a session scoped component.
"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="19"/>
+ </subitem>
+ <subitem
+ label="The EJB standard @Table annotation indicates that the User class
is mapped to the users table. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="20"/>
+ </subitem>
+ <subitem
+ label="name, password and username are the persistent attributes of the
entity bean. All of our persistent attributes define accessor methods. These are needed
when this component is used by JSF in the render response and update model values phases.
"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="25"
+ param3="27"/>
+ </subitem>
+ <subitem
+ label="An empty constructor is both required by both the EJB
specification and by Seam. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="36"/>
+ </subitem>
+ <subitem
+ label="The @NotNull and @Length annotations are part of the Hibernate
Validator framework. Seam integrates Hibernate Validator and lets you use it for data
validation (even if you are not using Hibernate for persistence). "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="49"/>
+ </subitem>
+ <subitem
+ label="The EJB standard @Id annotation indicates the primary key
attribute of the entity bean. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="60"/>
+ </subitem>
+ </item>
+
+ <item
+ title="The stateless session bean class: RegisterAction.java">
+ <description>
+ Most Seam application use session beans as JSF action listeners (you can use
JavaBeans instead if you like).
+<br/><br/>
+We have exactly one JSF action in our application, and one session bean method attached
to it. In this case, we'll use a stateless session bean, since all the state
associated with our action is held by the User bean.
+<br/><br/>
+This is the only really interesting code in the example!
+ </description>
+ <subitem
+ label="The EJB @Stateless annotation marks this class as a stateless
session bean."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="16" />
+ </subitem>
+ <subitem
+ label="The @In annotation marks an attribute of the bean as injected
by Seam. In this case, the attribute is injected from a context variable named user (the
instance variable name). "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="21" />
+ </subitem>
+ <subitem
+ label="The EJB standard @PersistenceContext annotation is used to inject
the EJB3 entity manager."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="24" />
+ </subitem>
+ <subitem
+ label="The Seam @Logger annotation is used to inject the component's
Log instance."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="27" />
+ </subitem>
+ <subitem
+ label="The action listener method uses the standard EJB3 EntityManager
API to interact with the database, and returns the JSF outcome. Note that, since this is a
session bean, a transaction is automatically begun when the register() method is called,
and committed when it completes. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="30"
+ param3="46" />
+ </subitem>
+ <subitem
+ label="Notice that Seam lets you use a JSF EL expression inside EJB-QL.
Under the covers, this results in an ordinary JPA setParameter() call on the standard JPA
Query object. Nice, huh?"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="32"/>
+ </subitem>
+ <subitem
+ label="The Log API lets us easily display templated log messages which
can also make use of JSF EL expressions. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="38"/>
+ </subitem>
+ <subitem
+ label="JSF action listener methods return a string-valued outcome that
determines what page will be displayed next. A null outcome (or a void action listener
method) redisplays the previous page. In plain JSF, it is normal to always use a JSF
navigation rule to determine the JSF view id from the outcome. For complex application
this indirection is useful and a good practice. However, for very simple examples like
this one, Seam lets you use the JSF view id as the outcome, eliminating the requirement
for a navigation rule. Note that when you use a view id as an outcome, Seam always
performs a browser redirect."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="39"/>
+ </subitem>
+ <subitem
+ label="Seam provides a number of built-in components to help solve
common problems. The FacesMessages component makes it easy to display templated error or
success messages. (As of Seam 2.1, you can use StatusMessages instead to remove the
semantic dependency on JSF). Built-in Seam components may be obtained by injection, or by
calling the instance() method on the class of the built-in component."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="43"/>
+ </subitem>
+ <subitem
+ label="Note that we did not explicitly specify a @Scope this time. Each
Seam component type has a default scope if not explicitly specified. For stateless session
beans, the default scope is the stateless context, which is the only sensible
value."
+ skip="true">
+ </subitem>
+ <subitem
+ label="Our session bean action listener performs the business and
persistence logic for our mini-application. In more complex applications, we might need
require a separate service layer. This is easy to achieve with Seam, but it's overkill
for most web applications. Seam does not force you into any particular strategy for
application layering, allowing your application to be as simple, or as complex, as you
want."
+ skip="true">
+ </subitem>
+ <subitem
+ label="Note that in this simple application, we've actually made it
far more complex than it needs to be. If we had used the Seam application framework
controllers, we would have eliminated all of our application code. However, then we
wouldn't have had much of an application to explain."
+ skip="true">
+ </subitem>
+ </item>
+
+ <item
+ skip="true"
+ title="The session bean local interface: Register.java">
+ <description>
+ Naturally, our session bean needs a local interface.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/Register.java"/>
+ </item>
+
+ <item
+ title="The view: register.xhtml">
+ <description>
+ The view pages for a Seam application could be implemented using any technology that
supports JSF. In this example we use Facelets, because we think it's better than JSP.
+ </description>
+ <subitem
+ label="The only thing here that is specific to Seam is the
<s:validateAll> tag. This JSF component tells JSF to validate all the
contained input fields against the Hibernate Validator annotations specified on the entity
bean."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/register.xhtml"
+ param2="15"
+ param4="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
+ </subitem>
+
+ </item>
+ <item
+ title="The view: registered.xhtml">
+ <description>
+ This is a simple Facelets page using some inline EL. There's nothing specific to
Seam here.
+ </description>
+ <subitem
+ label="Open registered.xhtml"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/registered.xhtml"
+ param4="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
+ </subitem>
+
+ </item>
+
+ <item
+ title="The Seam component deployment descriptor: components.xml">
+ <description>
+ Since this is the first Seam app we've seen, we'll take a look at the
deployment descriptors. Before we get into them, it is worth noting that Seam strongly
values minimal configuration. These configuration files will be created for you when you
create a Seam application. You'll never need to touch most of these files. We're
presenting them now only to help you understand what all the pieces in the example are
doing.
+<br/><br/>
+If you've used many Java frameworks before, you'll be used to having to declare
all your component classes in some kind of XML file that gradually grows more and more
unmanageable as your project matures. You'll be relieved to know that Seam does not
require that application components be accompanied by XML. Most Seam applications require
a very small amount of XML that does not grow very much as the project gets bigger.
+<br/><br/>
+Nevertheless, it is often useful to be able to provide for some external configuration of
some components (particularly the components built in to Seam). You have a couple of
options here, but the most flexible option is to provide this configuration in a file
called components.xml, located in the WEB-INF directory. We'll use the components.xml
file to tell Seam how to find our EJB components in JNDI.
+<br/><br/>
+This code configures a property named jndiPattern of a built-in Seam component named
org.jboss.seam.core.init. The funny @ symbols are there because our Ant build script puts
the correct JNDI pattern in when we deploy the application, which it reads from the
components.properties file.
+ </description>
+ <subitem label="Open components.xml"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/WEB-INF/components.xml"
+ param2="9"/>
+ </subitem>
+ <subitem label="Open components.properties"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/components.properties"/>
+ </subitem>
+ </item>
+
+ <item
+ title="The web deployment description: web.xml">
+ <description>
+ The presentation layer for our mini-application will be deployed in a WAR. So
we'll need a web deployment descriptor.
+ </description>
+ <subitem
+ label="This web.xml file configures Seam and JSF. The configuration you
see here is pretty much identical in all Seam applications."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/WEB-INF/web.xml"/>
+ </subitem>
+
+ </item>
+ <item
+ skip="true"
+ title="The JSF configuration: faces-config.xml">
+ <description>
+ Most Seam applications use JSF views as the presentation layer. So usually we'll
need faces-config.xml. In our case, we are going to use Facelets for defining our views,
so we need to tell JSF to use Facelets as its templating engine.
+<br/><br/>
+ Note that we don't need any JSF managed bean declarations! Our managed beans are
annotated Seam components. In Seam applications, the faces-config.xml is used much less
often than in plain JSF. Here, we are simply using it to enable Facelets as the view
handler instead of JSP.
+<br/><br/>
+In fact, once you have all the basic descriptors set up, the only XML you need to write
as you add new functionality to a Seam application is orchestration: navigation rules or
jBPM process definitions. Seam's stand is that process flow and configuration data are
the only things that truly belong in XML.
+<br/><br/>
+In this simple example, we don't even need a navigation rule, since we decided to
embed the view id in our action code.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/WEB-INF/faces-config.xml"/>
+
+ </item>
+
+ <item
+ skip="true"
+ title="The EJB deployment descriptor: ejb-jar.xml">
+ <description>
+ The ejb-jar.xml file integrates Seam with EJB3, by attaching the SeamInterceptor to
all session beans in the archive.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/META-INF/ejb-jar.xml"/>
+
+ </item>
+
+ <item
+ skip="true"
+ title="The EJB persistence deployment descriptor: persistence.xml">
+ <description>
+ The persistence.xml file tells the EJB persistence provider where to find the
datasource, and contains some vendor-specific settings. In this case, enables automatic
schema export at startup time.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/META-INF/persistence.xml"/>
+
+ </item>
+
+ <item
+ skip="true"
+ title="The EAR deployment descriptor: application.xml">
+ <description>
+ The persistence.xml file tells the EJB persistence provider where to find the
datasource, and contains some vendor-specific settings. In this case, enables automatic
schema export at startup time.
+<br/><br/>
+This deployment descriptor links modules in the enterprise archive and binds the web
application to the context root /registration.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ear/EarContent/META-INF/application.xml"/>
+ </item>
+
+ <item
+ skip="true"
+ title="Run and deploy the application">
+ <description>
+ Right-click the registration-ear/resources/registration-ds.xml file and select
<b>Make Deployable.</b>
+ <br/>
+ Right-click the registration project and select <b>Run As</b> >
<b>Run On Server</b> or click on the "Click to Perform" link
below.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.RunOnServer"
+ param1="registration"
+ param2="registration-ear/resources/registration-ds.xml"/>
+
+ </item>
+</cheatsheet>
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml
(rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml 2009-05-03 20:53:50
UTC (rev 14996)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.cheatsheets.cheatSheetContent">
+ <category
+ id="org.jboss.tools.seam.tutorial"
+ name="JBoss Seam Tutorials">
+ </category>
+ <cheatsheet
+ category="org.jboss.tools.seam.tutorial"
+ contentFile="$nl$/cheatsheets/registration.xml"
+ id="org.jboss.tools.seam.tutorial.registration"
+ name="Your first Seam application: the registration example">
+ <description>
+ The registration example is a simple application that lets a new user store
his username, real name and password in the database.
+ </description>
+ </cheatsheet>
+ </extension>
+
+</plugin>
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,50 @@
+package org.jboss.tools.seam.tutorial;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.seam.tutorial";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,129 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard;
+import org.jboss.tools.seam.tutorial.Activator;
+
+public class ImportProjectExample extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null || params[1] == null || params[2] == null ) {
+ return;
+ }
+
+ Project project = new Project();
+ project.setName(params[0]);
+ StringTokenizer tokenizer = new StringTokenizer(params[1],",");
+ List<String> includedProjects = new ArrayList<String>();
+ while (tokenizer.hasMoreTokens()) {
+ includedProjects.add(tokenizer.nextToken().trim());
+ }
+ project.setIncludedProjects(includedProjects);
+ project.setUrl(params[2]);
+ importProject(project);
+
+ }
+
+ private void importProject(final Project project) {
+ WorkspaceJob workspaceJob = new
WorkspaceJob(Messages.NewProjectExamplesWizard_Downloading) {
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ String urlString = project.getUrl();
+ String name = project.getName();
+ URL url = null;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ return Status.CANCEL_STATUS;
+ }
+ final File file = ProjectUtil.getProjectExamplesFile(
+ url, name, ".zip", monitor); //$NON-NLS-1$
+ if (file == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ setName(Messages.NewProjectExamplesWizard_Importing);
+ try {
+ NewProjectExamplesWizard.importProject(project, file, monitor);
+ } catch (Exception e) {
+ IStatus status = new Status(IStatus.ERROR,Activator.PLUGIN_ID,e.getMessage(),e);
+ throw new CoreException(status);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ };
+ workspaceJob.setUser(true);
+
+ workspaceJob.addJobChangeListener(new IJobChangeListener() {
+
+ public void aboutToRun(IJobChangeEvent event) {
+
+ }
+
+ public void awake(IJobChangeEvent event) {
+
+ }
+
+ public void done(IJobChangeEvent event) {
+ try {
+ ProjectExamplesActivator.waitForBuildAndValidation
+ .schedule();
+ ProjectExamplesActivator.waitForBuildAndValidation
+ .join();
+ } catch (InterruptedException e) {
+ return;
+ }
+ List<Project> projects = new ArrayList<Project>();
+ projects.add(project);
+ List<IMarker> markers = ProjectExamplesActivator
+ .getMarkers(projects);
+ if (markers != null && markers.size() > 0) {
+ NewProjectExamplesWizard.showQuickFix(projects);
+ }
+
+ }
+
+ public void running(IJobChangeEvent event) {
+
+ }
+
+ public void scheduled(IJobChangeEvent event) {
+
+ }
+
+ public void sleeping(IJobChangeEvent event) {
+
+ }
+
+ });
+ workspaceJob.schedule();
+ }
+
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,119 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+
+public class OpenFileInEditor extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null ) {
+ return;
+ }
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ IPath path = new Path(params[0]);
+ IFile file = workspaceRoot.getFile(path);
+ IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart editor = null;
+ try {
+ if (params[3] != null && params[3].trim().length() > 0) {
+ String editorID = params[3];
+ try {
+ editor = IDE.openEditor(page, file, editorID, true);
+ } catch (Exception e) {
+ }
+ }
+ if (editor == null) {
+ editor = IDE.openEditor(page, file, true);
+ }
+ } catch (PartInitException e) {
+ setStatusMessage(page,"Cannot open the " + params[0] + " file");
+ return;
+ }
+ ITextEditor textEditor = getTextEditor(editor);
+ if (params[1] != null && textEditor != null) {
+ try {
+ int lineStart = Integer.parseInt(params[1]);
+ int lineEnd = lineStart;
+ if (params[2] != null) {
+ lineEnd = Integer.parseInt(params[2]);
+ }
+ IDocument document =
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+ IRegion lineInfoStart = document.getLineInformation(lineStart-1);
+ IRegion lineInfoEnd = document.getLineInformation(lineEnd-1);
+ textEditor.selectAndReveal(lineInfoStart.getOffset(), lineInfoEnd.getOffset() -
lineInfoStart.getOffset() + lineInfoEnd.getLength());
+ } catch (Exception e) {
+ setStatusMessage(page, e.getLocalizedMessage());
+ }
+
+ }
+ }
+
+ private ITextEditor getTextEditor(IEditorPart editor) {
+ if (editor instanceof ITextEditor) {
+ return (ITextEditor) editor;
+ }
+ if (editor instanceof MultiPageEditorPart) {
+ MultiPageEditorPart multiPageEditor = (MultiPageEditorPart) editor;
+ IEditorPart[] editors = multiPageEditor.findEditors(editor.getEditorInput());
+ for (int i = 0; i < editors.length; i++) {
+ if (editors[i] instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) editors[i];
+ if (textEditor.getDocumentProvider() != null) {
+ return (ITextEditor) editors[i];
+ }
+ }
+ }
+ }
+ if (editor instanceof EditorPartWrapper) {
+ EditorPartWrapper wrapper = (EditorPartWrapper) editor;
+ IEditorPart nestedEditor = wrapper.getEditor();
+ return getTextEditor(nestedEditor);
+ }
+ return null;
+ }
+
+ private void setStatusMessage(IWorkbenchPage page,String message) {
+ IWorkbenchPart activePart = page.getActivePart();
+ IWorkbenchPartSite site = activePart.getSite();
+ IActionBars actionBar = null;
+ if (site instanceof IViewSite) {
+ IViewSite viewSite = (IViewSite) site;
+ actionBar = viewSite.getActionBars();
+ } else if (site instanceof IEditorSite) {
+ IEditorSite editorSite = (IEditorSite) site;
+ actionBar = editorSite.getActionBars();
+ }
+ if (actionBar == null) {
+ return;
+ }
+ IStatusLineManager lineManager = actionBar.getStatusLineManager();
+ if (lineManager == null) {
+ return;
+ }
+ lineManager.setMessage(message);
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,24 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog;
+
+public class OpenPreferencePage extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null) {
+ return;
+ }
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
+ PreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(
+ shell, params[0]);
+ dialog.open();
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java 2009-05-03
20:53:50 UTC (rev 14996)
@@ -0,0 +1,65 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.actions.RunOnServerAction;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.tools.seam.tutorial.Activator;
+
+public class RunOnServer extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null) {
+ return;
+ }
+ IWorkspaceRoot wRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = wRoot.getProject(params[0]);
+ if (project == null || !project.isOpen()) {
+ return;
+ }
+ if (params[1] != null) {
+ IFile file = wRoot.getFile(new Path(params[1]));
+ if (file != null || file.exists()) {
+ try {
+ SingleDeployableFactory.makeDeployable(file.getFullPath());
+ IServer[] deployableServersAsIServers = ServerConverter
+ .getDeployableServersAsIServers();
+ if (deployableServersAsIServers.length == 1) {
+ IServer server = deployableServersAsIServers[0];
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ IModule[] modules = new IModule[1];
+ modules[0] = SingleDeployableFactory.findModule(file
+ .getFullPath());
+ copy.modifyModules(modules, new IModule[0],
+ new NullProgressMonitor());
+ IServer saved = copy.save(false,
+ new NullProgressMonitor());
+ saved.publish(IServer.PUBLISH_INCREMENTAL,
+ new NullProgressMonitor());
+ }
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.INFO,Activator.PLUGIN_ID,e.getMessage(),e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+ }
+ IAction action = new RunOnServerAction(project);
+ action.run();
+ }
+
+}