Author: snjeza
Date: 2009-05-05 08:59:27 -0400 (Tue, 05 May 2009)
New Revision: 15019
Added:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.classpath
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.project
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.settings/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.settings/org.eclipse.jdt.core.prefs
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/META-INF/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/build.properties
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/cheatsheets/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/cheatsheets/projectExamples.xml
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.properties
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.xml
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Activator.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Messages.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenFileInEditor.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenPreferencePage.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunOnServer.java
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/messages.properties
Modified:
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
workspace/snjeza/seam-examples/registration2.zip
Log:
https://jira.jboss.org/jira/browse/JBIDE-4259 Add the org.jboss.tools.seam.tutorial plugin
to the examples builder
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-05
12:55:27 UTC (rev 15018)
+++
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml 2009-05-05
12:59:27 UTC (rev 15019)
@@ -30,7 +30,7 @@
unpack="false"/>
<plugin
- id="org.jboss.tools.seam.tutorial"
+ id="org.jboss.tools.project.examples.cheatsheet"
download-size="0"
install-size="0"
version="0.0.0"
Added: trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.classpath
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.classpath
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.classpath 2009-05-05
12:59:27 UTC (rev 15019)
@@ -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.project.examples.cheatsheet/.project
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.project
(rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.project 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.project.examples.cheatsheet</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.project.examples.cheatsheet/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/.settings/org.eclipse.jdt.core.prefs 2009-05-05
12:59:27 UTC (rev 15019)
@@ -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.project.examples.cheatsheet/META-INF/MANIFEST.MF
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/META-INF/MANIFEST.MF 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %BundleName
+Bundle-SymbolicName: org.jboss.tools.project.examples.cheatsheet;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.project.examples.cheatsheet.Activator
+Bundle-Vendor: %BundleVendor
+Bundle-Localization: plugin
+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.project.examples.cheatsheet/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/build.properties
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/build.properties 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ cheatsheets/,\
+ plugin.properties
Added:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/cheatsheets/projectExamples.xml
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/cheatsheets/projectExamples.xml
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/cheatsheets/projectExamples.xml 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<cheatsheet title="Project Examples Tutorial">
+
+ <intro>
+ <description>
+ Learn how to use Project Examples Wizard.
+ </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.project.examples.cheatsheet"
+ class="org.jboss.tools.project.examples.cheatsheet.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="Call the Project Examples wizard">
+ <description>
+ Click <b>Help > Project Examples</b> or 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>
+ <command
+
serialization="org.eclipse.ui.newWizard(newWizardId=org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard)"
+ required="false" translate="">
+ </command>
+ </item>
+
+</cheatsheet>
Added:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.properties
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.properties 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.project.examples.cheatsheet
+BundleVendor = JBoss, a division of Red Hat
+BundleName = Seam Tutorials
\ No newline at end of file
Added: trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.xml
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/plugin.xml 2009-05-05
12:59:27 UTC (rev 15019)
@@ -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.project.examples.cheatsheet"
+ name="Project Examples Tutorial">
+ </category>
+ <cheatsheet
+ category="org.jboss.tools.project.examples.cheatsheet"
+ contentFile="$nl$/cheatsheets/projectExamples.xml"
+ id="org.jboss.tools.project.examples.cheatsheet.projectExamples"
+ name="Project Examples Tutorial">
+ <description>
+ Learn how to use Project Examples Wizard
+ </description>
+ </cheatsheet>
+ </extension>
+
+</plugin>
Added:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Activator.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Activator.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Activator.java 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,50 @@
+package org.jboss.tools.project.examples.cheatsheet;
+
+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.project.examples.cheatsheet"; //$NON-NLS-1$
+
+ // 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.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Messages.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Messages.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/Messages.java 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,15 @@
+package org.jboss.tools.project.examples.cheatsheet;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.project.examples.cheatsheet.messages"; //$NON-NLS-1$
+ public static String OpenFileInEditor_Cannot_open;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/ImportProjectExample.java 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,129 @@
+package org.jboss.tools.project.examples.cheatsheet.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.cheatsheet.Activator;
+import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard;
+
+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],",");
//$NON-NLS-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.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenFileInEditor.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenFileInEditor.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenFileInEditor.java 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,121 @@
+package org.jboss.tools.project.examples.cheatsheet.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.osgi.util.NLS;
+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;
+import org.jboss.tools.project.examples.cheatsheet.Messages;
+
+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,NLS.bind(Messages.OpenFileInEditor_Cannot_open, params[0]));
+ 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.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenPreferencePage.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenPreferencePage.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/OpenPreferencePage.java 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,24 @@
+package org.jboss.tools.project.examples.cheatsheet.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.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunOnServer.java
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunOnServer.java
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/actions/RunOnServer.java 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1,65 @@
+package org.jboss.tools.project.examples.cheatsheet.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.project.examples.cheatsheet.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();
+ }
+
+}
Added:
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/messages.properties
===================================================================
---
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/messages.properties
(rev 0)
+++
trunk/examples/plugins/org.jboss.tools.project.examples.cheatsheet/src/org/jboss/tools/project/examples/cheatsheet/messages.properties 2009-05-05
12:59:27 UTC (rev 15019)
@@ -0,0 +1 @@
+OpenFileInEditor_Cannot_open=Cannot open the {0} file.
Modified: workspace/snjeza/seam-examples/registration2.zip
===================================================================
(Binary files differ)