Eclipse

From Wiki RB4

Einleitung[edit]

Eclipse ist ein Rahmenwerk zur Integration verschiedenster Anwendungen. Eine solche Anwendung ist z.B. die mitgelieferte Java Entwicklungsumgebung JDT (Java Development Toolkit). Diese Anwendungen werden in Form sogenannter Plugins zur Verfügung gestellt und von der Eclipse-Plattform automatisch erkannt und integriert. Plug-Ins werden mit der so genannten Plug-In Development Environment (PDE), die mit ausgeliefert wird, entwickelt. Eclipse bietet weiterhin Funktionalität zum Verwalten von Ressourcen (normalerweise Dateien) auf der Festplatte. Diese befinden sich im so genannten Workspace, einem speziellen Verzeichnis im Dateisystem. Verändert eine Anwendung eine solche Ressource aus Eclipse heraus, werden auch die anderen Anwendungen - über entsprechende Benachrichtigungsmechanismen - davon erfahren. Der Benutzer arbeitet dabei immer in der Workbench, dem grafisch sichtbaren Teil der Eclipse-Plattform. Man kann mehrere Workbench Fenster geöffnet haben. Das konkrete Aussehen der Workbench wird von den gerade ausgewählten Perspektiven bestimmt. Diese fassen jeweils eine Menge von sogenannte Views und Editoren zusammen und stellen spezielle Befehle für die Menü- und Werkzeugleisten zur Verfügung. The first text in the title bar of the Workbench window indicates which perspective is active.

Java Perspective is active

Different Perspectives can be selected with:

Select Perspective

The primary use of Views is to provide navigation of the information in the Workbench. Je nach View werden nur Teile oder auch innere Zusammenhänge zwischen den Ressourcen angezeigt. A perspective determines which views may be required and displays these on the Windows->Show View sub-menu.

Ein Editor dient zum Bearbeiten einer Ressource. Hierbei wird ein strikter Laden-Verändern-Speichern Lebenszyklus eingehalten. Erst wenn eine im Editor veränderte Ressource auch gespeichert wird, können alle oben erwähnten Benachrichtigungsmechanismen greifen. Spezielle Views können auch direkt mit einem Editor (und nicht mit der eigentlichen Ressource) gekoppelt werden. Zum Beispiel ist der Outline View der Java-Perspektive direkt an den Java-Quelltexteditor gekoppelt. Eine Besonderheit bei Eclipse - und teilweise Grund zur Frustration - ist nun die äußerste Flexibilität, mit der vorhandene Views und Editoren kombiniert werden können. Nicht nur die Anordnung in der Workbench ist frei wählbar. Man kann in eine geöffnete Perspektive jeden anderen View und jeden Editor hinzufügen - auch wenn diese in einem ganz anderen Plugin definiert wurden. Dies ermöglicht es dem Benutzer, eine auf ihn zugeschnittene Entwicklungsumgebung zusammenzustellen.

Eclipse can be configured (Window->Preferences->General->Workspace->Local History) to keep a local history.

Plug-In Installation[edit]

see http://www.venukb.com/2006/08/20/install-eclipse-plugins-the-easy-way/

Versions[edit]

  • 4.2 Juno 2012
  • 4.3 Kepler 2013
  • 4.4 Luna 2014
  • 4.5 Mars 2015
  • 4.6 Neon 2016
  • 4.7 Oxygen 2017

Upgrade[edit]

Upgrade eclipse itself requires a complete new download. To upgrade plug-ins you can use Help -> Software Update -> Find and Install ...

Rich Client Platform[edit]

Eclipse Packaging Project (EPP)[edit]

Packaged Eclipse IDE for different languages.

Configuration of Version 2022-06 2022-09[edit]

Java Code Style[edit]

  • Windows -> Preferences

Icons[edit]

Views[edit]

Ant View[edit]

Breakpoints View[edit]

Debug View[edit]

Project Explorer[edit]

  • View Menu -> Link with Editor

Navigator View[edit]

The Navigator View provides a hierarchical view of the resources in the Workbench including hidden files.

Logging[edit]

Das Logfile liegt unter <eclipse-dir>/workspace/.metadata/.log.

Plug-Ins[edit]

Angular IDE[edit]

  • installed via eclipse marketplace

Ant[edit]

Das Ant-Plug-In ist integraler Bestandteil von Eclipse. Ein Ant-Build fügt man an folgender Stelle in den Properties eines Projekts ein:

"Ant View"

und kann dort editiert werden. Der AntBuild kann entweder mit dem konfigurierten Target (s. 2. in Screeshot) oder aber mit einer manuellen Auswahl des Targets mit Doppelklick (s. 3. in Screenshot) erfolgen: CallAntFromEclipse.jpg

EGit[edit]

  • Egit is the Eclipse standard and in most cases part of an Eclipse distribution
  • tutorial and detailed description see here
  • installation s. Help -> About Eclipse IDE -> Installation Details -> Plug-Ins -> Filter to EGit
  • available view s. Window -> Show View -> Others -> Git
    • Git Staging
    • Git Repositories
    • History
  • for adding, commiting and pushing use the 'Git Staging' view starting with 'Unstaged Changes' and adding or ignoring and committing or see below

Egit uses the same configuration files as git. The label decoration is shown in the views 'package explorer', 'project explorer' and 'navigator'.

Text Decorations[edit]

  • see Window -> Preferences -> Git -> Label Decorations -> Text Decorations

Icon Decorations[edit]

The decorations icons are:

Gitting an Eclipse Project[edit]

There is a discussion if you should put multiple projects in one git repository or having a git repository for each eclipse projects. It seems that the second options is better if the projects are not related. The same applies to what should be included in a git repository and what should be ignored (see here).

See list below which files and folders should be in scope of git:

  • \src\...
  • \.settings\ // if projects settings differ from workspace settings
  • \.classpath // e.g. what is the source, where does the class files go, ...
  • \.project

See list below which should be ignored:

  • \bin\... // or anything which can be recreated
  • Right click on project -> Team -> Share Project
  • Select repository or create a new one // moves the complete project to the repository
  • select files or folder and Team -> Add/Ignore

Adding a file to the Index[edit]

  • Right Click on File -> Team -> Add to Index

Unignore File or Directory[edit]

  • edit .gitignore and delete the rows
  • add to file to index

Committing Changes[edit]

  • Right Click on Project -> Team -> Commit opens the commit view

Creating Project from Local Repository[edit]

  • File -> Import
  • Git -> Projects
  • Existing Local Repository
  • Select Repository Directory
  • Import as General Project
  • Right Mouse on Project -> Configure -> ...Facet...
  • Select Java (and additional)

Show Differences[edit]

  • right click on project resource -> Compare with

Maven[edit]

Name is M2E. Documentation can be found here.

If you have added a dependency manually to pom.xml then right click on project -> Maven -> Update Project.

PDT[edit]

  • s. Installation of PDT
  • adjust php.ini for XDebug
  • adjusted Window->Preferences->PHP->Debug and PHP Executables

BPMN2 Modeler[edit]

JBoss Tools[edit]

Installation[edit]

Description[edit]

The JBoss Tools are somehow an extension of the Java EE WTP Tools. The JBoss Tools contain a set of tools for Hibernate among others tools for reverse engineering an existing database and code generation. The documentation is here. My description is here

JDT[edit]

The Jave Development Tools adds a Java project nature and Java perspective to the Eclipse Workbench as well as a number of views, editors, wizards, builders, and code merging and refactoring tools. The JDT project allows Eclipse to be a development environment for itself.

Spring Tools[edit]

  • was called STS
  • installed via Help -> Eclipse Marketplace (will not work in Eon CN)


Subversion[edit]

Subclipse[edit]

Installation[edit]

  1. Help->Software Updates->Find and Install...
  2. Search for new features to install
  3. New Remote Site
  4. http://subclipse.tigris.org/update_1.2.x
  5. Restart

Using[edit]

If you add a file to your project, it's not automatically part of version control. Right-click the new file, then choose Team -> Add to Version Control. If you've added a file to the repository that's no longer relevant to your project, you can easily delete it. Right-click the file, then choose Delete. No need for the Team menu. To rename a file or directory under Subclipse's control, right-click it, then choose Rename. Type the item's new name in the entry field and click Enter. The file is renamed in the project, and the rename operation (an Add for the new name, and a Delete for the old one) is queued for your next commit. If your project generates files, or otherwise includes files that you don't want to check in to the Subversion repository, you can tell Subclipse to ignore them. Right-click the file or directory you want to exclude from version control, then choose Team > Add to svn:ignore to display the Add to svn:ignore dialog. To ignore an already added file from a repository delete it with the SVN Repository Perspective and then sign it as svn:ignore.

WTP[edit]

Workspace[edit]

JBoss 7 Quickstarts[edit]

  • File -> Import -> Existing Maven Projects -> C:\Uwes\java\jboss\jboss-as-quickstarts-7.1.0.Beta1b

Bedienung[edit]

Show Bin Directory in Project Explorer[edit]

  • Window -> Show View -> Project Explorer
  • Select little triangle at top right -> Customize View ...
  • Filters -> deselect 'Java Output Folder'

Show Open Files[edit]

  • CTRL + E or
  • CTRL + SHIFT + E

Show Hidden Files[edit]

  • like .gitignore
  • select project in Project Explorer and click the filter icon on top bar
  • deselect .* resources

Create a new JBoss 7 Maven project[edit]

  • File -> New -> Project -> Other -> Maven -> JBoss Archetype -> jboss-javaee-webapp

Create a Java Project from existing file system[edit]

  1. copy folder to eclipse workspace folder
  2. right click navigator->new project->Java
  3. name the project like the project folder

Create PHP Project from Filesystem[edit]

  1. right click navigator->new project->PHP
  2. insert the path of the root manually (otherwise crash)

Lookup library for Java element[edit]

  1. select in editor and right click
  2. Open declaration
  3. Package or Project explorer (left window)->Link with editor (icon with arrows to left and right)

Create new HTML page[edit]

  1. right click folder -> new -> others -> web -> html file

New JPA Project[edit]

  1. new project->JPA->JPA procect

New JPA Entity[edit]

  1. see also JPA entities
  2. right click on package below Java Resources -> new Class
  3. add fields in Java code to new class
  4. right click on classname -> Source -> Generate Setters and Getters
  5. right click on classname -> Source -> Generate Hibernate/JPA Annotations
  6. create DB table or deployment will create DB table in case persistence.xml contains <property name="hibernate.hbm2ddl.auto" value="create-drop" />

Revers Engineer a database with Hibernate[edit]

For reverse engineering perform the following steps in eclipse:

  1. create a Hibernate Console Configuration via File->New->Other->Hibernate->Hibernate Console Configuration (edit it by changing to the perspective Hibernate) and double click in the Hibernate Configurations view
  2. specify Database Connection, Property file, Hibernate configuration file. The rest seems to be unneccessary.
  3. Run->Hibernate Code Generation...->Open Hibernate Code Generation Dialog...
  4. Create a new Code Generation Configuration or edit an existing
    1. specify the existing output directory
    2. specify via the reveng.xml setup dialog the tables for reverse engineering
    3. select the exporters
    4. press Run or later Run->Hibernate Code Generation-><Code Generation Configuration>

Anzeigen der Plug-Ins[edit]

  1. Help -> About -> Plug-In Details

Perspektiven öffnen[edit]

Window -> Open Perspective ...

Source Verzeichnis einrichten[edit]

  1. Project Properties
  2. Java Build Path
  3. file card 'source'

Configuration and Using of Server[edit]

  • File -> New -> Other
  • Windows -> Show View -> Server


Deploy to Server[edit]

  • e.g. JBoss AS Quickstart 'right click project -> Run As -> Run on Server' will build the project, copy the war file to the deployment directory and call the browser

Tastatur/Keyboard[edit]

see also http://www.allapplabs.com/eclipse/eclipse_shortcuts.htm

CTRL + K find selection next
CTRL + N new structure
CTRL + L goto line
CTRL + <Dot> Focus in Search results goto next find
CTRL + <Space> Code Completion or Java API Documentation
CTRL + SHIFT + B Breakpoint einfügen
CTRL + SHIFT + C compare with other resources, resource must be selected in project explorer
CTRL + SHIFT + K find selection previous
CTRL + SHIFT + P find matching brace (cursor behind brace)
CTRL + SHIFT + T open class search dialog
F6 Step over

Getter/Setter generieren[edit]

  1. right click in editor
  2. Source->Generate Getter/Setter

Java Files Formatieren[edit]

  1. select file in project navigator
  2. context menu -> source -> format

Compare Files[edit]

  1. select files to compare in project navigator (CTRL+left mouse)
  2. context menu -> compare with -> each other

Compare with external File[edit]

  • select resource in project explorer
  • CTRL + SHIFT + C

Adding a jar file to the build path[edit]

  1. see here

or you can now either add a JAR file which is contained in your workspace or which is somewhere else:

  1. to add a JAR file which is inside your workspace click the Add JARs button
  2. to add an external JAR file click the Add External JARs button

Using the type hierachy[edit]

  • F4 actualizes the type hierachy with the current class in the editor

Debugging[edit]

Java Remote Debugging[edit]

For example uweheuer:

  1. start Wildfly for Debugginging
  2. select 'Debug Configuration' form Debug Menu and press 'Debug'
  3. after change to Debug View set breakpoints

Java Applet Debugging[edit]

There is a integrated applet viewer but setting breakpoints doesn't work, so it's better to use remote debugging. For example configuration 'uweheuer_applet_laptop'. Precondition is the configuration of the java runtime for applets:


PHP Debugging[edit]

s. http://www.eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf

  • set breapoints
  • Run->Debug Configurations...-> e.g Local XT Sport Boeckmann -> Debug

Convert a project to a java or javascript project[edit]

  • right click project in project explorer
  • properties
  • project facets

or

  • open .project
  • add
<buildSpec>
  <buildCommand>
    <name>org.eclipse.jdt.core.javabuilder</name>
    <arguments>
    </arguments>
  </buildCommand>
</buildSpec>
<natures>
  <nature>org.eclipse.jdt.core.javanature</nature>
</natures>

Set Preferences for HTML Editor[edit]

  • Window->Preferences->Web->HTML Files->Editor

Use the jQuery Mobile Palette[edit]

  • right click on HTML file -> Open With -> JBoss Tools HTML editor => Palette will be available as tab in the bottom area

Insert jQuery Mobile link to HTML file[edit]

  • click JS/CSS icon in palette

Browser Sim[edit]

  • Icon in icon bar or
  • Right click on html file -> Open With -> Browser Sim

Javascript console goes to Console tab in the bottom, perhaps select by icon 'Display selected console'

Einschränkungen[edit]

Eine Aufteilung der Sourcen in unterschiedliche Verzeichnisse unabhängig von der Package Struktur ist nicht vorgesehen.



Sources[edit]

  1. my own diagrams s. eclipse.vsd in file:///C:/Uwes/jspwiki/graphics/eclipse.vsd
  2. Eclipse wiki http://wiki.eclipse.org/