-
Notifications
You must be signed in to change notification settings - Fork 33
Documentation for new wizard #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.. include:: /global_defs.hrst | ||
|
||
Wizards |new| | ||
============= | ||
|
||
Scala IDE 4 includes a new wizard, which is a simplified version compared to the old wizards. It basically looks like this: | ||
|
||
.. image:: images/new-file-wizard.png | ||
|
||
There are two ways to open this new wizard. The easiest one is to press ``Ctrl+3`` to open the quick access search field. You can find the new wizard under the name "New Scala File": | ||
|
||
.. image:: images/search-field-scala-file-entry.png | ||
:width: 100% | ||
|
||
The second way is to navigate to the "New" menu and select "New Scala File": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beautifiul ! I'd put this as close to the top of the page as possible. |
||
|
||
.. image:: images/new-menu-scala-file-entry.png | ||
|
||
|
||
What functionality is provided? | ||
------------------------------- | ||
|
||
You have the possibility to select the kind of file (for example a Scala Class), the source folder of a project and of course the fully qualified name of the file. | ||
|
||
For example, if you want to create a Scala type in a package you have to prepend the package names separated by dots to the type name. If you don't specify any package name the file will be created in the default package of the selected source folder. | ||
|
||
While you type you get code completion support. Whenever you type a dot the wizard will automatically show you a completion popup for available package names. In case you don't want to wait until the wizard opens the completion popup for you, you can explicitly ask for code completion by pressing ``Ctrl+Space``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can send a link from the top of the post (how to trigger the completion dialog) to there and re-start the explanation from this point (possibly under a header : "completion and other features"). It's fine if this is towards the end of the doc page. |
||
|
||
.. image:: images/code-completion-support.png | ||
|
||
The wizard is made to be controlled easily with your keyboard, which means that you can reach all input fields without touching the mouse. You can rotate through the list of file kinds by pressing the up or down keys of your keyboard while the file name field is focused and with ``Ctrl+Tab`` you can move the focus to the source folder field. By pressing ``Enter`` when the source folder field is selected you get a dialog that shows you all available projects and their source folders. After you selected one of them, the focus is automatically moved back to the file name field. | ||
|
||
Configurable templates | ||
---------------------- | ||
|
||
Once you press *Finish* on the wizard, it will create a file and insert content based on a template. For example if you select the kind *Scala Trait* and enter the name ``a.test.pkg.TestClass`` the following file content will be created by default:: | ||
|
||
package a.test.pkg | ||
|
||
/** | ||
* @author nickname | ||
*/ | ||
trait TestClass { | ||
^ | ||
} | ||
|
||
where ``^`` denotes the position of the cursor. If you don't like the automatically created content you can easily change it by navigating to ``Window → Preferences → Scala → Editor → Templates`` and search for template names that start with ``wizard_``. The *Scala Trait* type for example will choose the ``wizard_trait`` template. | ||
|
||
.. image:: images/template-preference-page.png | ||
:width: 100% | ||
|
||
All the other features of the old wizards like the automatic adding of a super type are no longer supported. The design goal of the new wizard is to send users as fast as possible back to the editor where they can do whatever they want. | ||
|
||
Developer support | ||
----------------- | ||
|
||
One further important property of the new wizard is that it can be extended by users of the IDE with their own file kinds. Basically this means that once a template and the corresponding configuration is provided, the wizard will automatically find it and provide it as a selection option in the "kind" section. However, this requires that an OSGi bundle is provided and is therefore not as straightforward as just changing the content of a template in the preferences. If it is your interest to provide such an OSGi bundle, you should take a look to the `developer documentation`_ of the wizard. | ||
|
||
.. _developer documentation: ../../../dev/ide-extensions/wizards/index.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. include:: /global_defs.hrst | ||
|
||
IDE Extensions |new| | ||
==================== | ||
|
||
It is possible to extend the Scala IDE with your own plugins - this section provides the necessary documentation to help you to write your own extensions. | ||
|
||
Contents: | ||
|
||
.. toctree:: | ||
wizards/index |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.. include:: /global_defs.hrst | ||
|
||
Wizards |new| | ||
============= | ||
|
||
It is possible to add entries to the file kind option of the wizard. To do so one has to provide an OSGi bundle. | ||
|
||
In the following there is a description on how to create such an OSGi bundle: | ||
|
||
1. Create a new Plug-in Project in Eclipse and add the Scala nature. | ||
2. Add the Scala IDE bundle as a dependency in the dependencies section of your manifest file. This bundle is called ``org.scala-ide.sdt.core`` and its minimum version needs to be 4.0.0. Because the public API of the wizard makes use of Eclipse based classes, you also have to add ``org.eclipse.core.resources`` and ``org.eclipse.core.runtime`` as dependencies. | ||
3. In the extensions section add the extension point ``org.scala-ide.sdt.core.fileCreator``. | ||
4. Create a new ``fileCreator``. | ||
5. In order to fill out all values of the ``fileCreator`` you have to provide a class that implements ``org.scalaide.ui.wizards.FileCreator``. See the Scaladoc of this trait to find out how to implement it correctly. | ||
6. Once you are done with implementing the class, you have to provide a template, which is later used by the wizard to create the contents of a newly created file. To do so, first add a new dependency to ``org.eclipse.ui.editors`` and then add the extension point ``org.eclipse.ui.editors.templates``. | ||
7. Create a ``template``, whose ``contextTypeId`` must be ``org.scala-ide.sdt.core.templates``. Fill in the template ID into the corresponding field in your ``fileCreator``. | ||
|
||
You can now export a bundle and install it to your Eclipse installation. If you made everything correctly, the new wizard should show your template in the kind field. | ||
|
||
In the following we show you an example bundle manifest and plugin configuration: | ||
|
||
``plugin.xml``:: | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="org.scala-ide.sdt.core.fileCreator"> | ||
<fileCreator | ||
class="org.scalaide.wizardextension.TestFileCreator" | ||
description="test dcription" | ||
id="org.scalaide.wizardextension.id" | ||
name="test name" | ||
templateId="org.scalaide.wizardextension.template"> | ||
</fileCreator> | ||
</extension> | ||
<extension | ||
point="org.eclipse.ui.editors.templates"> | ||
<template | ||
autoinsert="true" | ||
contextTypeId="org.scala-ide.sdt.core.templates" | ||
id="org.scalaide.wizardextension.template" | ||
name="wizard_test"> | ||
<pattern> | ||
My test content | ||
</pattern> | ||
</template> | ||
</extension> | ||
</plugin> | ||
|
||
``MANIFEST.MF``:: | ||
|
||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Wizardextension | ||
Bundle-SymbolicName: org.scalaide.wizardextension;singleton:=true | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 | ||
Require-Bundle: org.scala-ide.sdt.core;bundle-version="4.0.0", | ||
org.scala-lang.scala-library, | ||
org.eclipse.core.resources;bundle-version="3.8.101", | ||
org.eclipse.core.runtime;bundle-version="3.9.100", | ||
org.eclipse.ui.editors;bundle-version="3.8.100" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect ! Right to the point. As a first time Eclipse user, how do I get to that window /