/
IntelliJ.shtml
677 lines (563 loc) · 30.5 KB
/
IntelliJ.shtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.17), see www.w3.org">
<title>JMRI: Building with IntelliJ IDEA</title>
<meta name="author" content="Egbert Broerse">
<meta name="keywords" content=
"JMRI technical code IntelliJ IDEA 2017.2 IDE">
<!--#include virtual="/Style.shtml" -->
</head><!--#include virtual="/Header.shtml" -->
<body>
<div id="mBody">
<!--#include virtual="Sidebar.shtml" -->
<div id="mainContent">
<h1>JMRI Code: Building with IntelliJ IDEA</h1>
<p>IntelliJ IDEA Community Edition (available from <a href=
"https://www.jetbrains.com/idea/">www.jetbrains.com/idea/</a>)
makes a great platform for working with JMRI and Java on OS
X, Windows and *nix.</p>
<ul class="snav">
<!-- TOC -->
<li><a href="#install">Installation</a></li>
<li><a href="#getgit">Get Git</a></li>
<li><a href="#ijprojectwin">The Project Window</a></li>
<li><a href="#push">Push changes</a></li>
<li><a href="#debug">Debugging (Setup)</a></li>
<li><a href="#tricks">Tricks</a></li>
<li><a href="#more">More</a></li>
</ul>
<p>JMRI developers use Git for source control. Source control
using Git is including as part of the IntelliJ IDEA download.
For more information for getting the JMRI source, see
<a href="getgitcode.shtml">JMRI: Getting the Code</a>.</p>
<p>These instructions were developed and tested using
IntelliJ IDEA 15 and 16 Community Edition (free).</p><a name=
"install" id="install"></a>
<h2>Installing IntelliJ IDEA</h2>
<h3>Preparations</h3>
<ol>
<li>Go to <a href="https://github.com/">GitHub.com</a> and
create an account.</li>
<li>In GitHub web, go to the JMRI/JMRI repo and "Fork" the
JMRI repository to your own remote copy. To do this, log on
to your account at <a href=
"https://github.com/">GitHub.com</a> and navigate to the
JMRI repository <a href=
"https://github.com/JMRI/JMRI">https://github.com/JMRI/JMRI</a>
In the upper right hand corner of the page you will find a
button labeled "Fork". Press the "Fork" button to create
your own repository of the JMRI source. (see <a href=
"getgitcode.shtml#get">Getting the Code</a>).</li>
</ol>
<p>After downloading and running the installer for your OS,
configure the IntelliJ application as follows:<br></p>
<h3>Set vmoptions</h3>
<h4>On OS X</h4>
<ul>
<li>Open IntelliJ</li>
<li>From the Help menu, select "Edit Custom VM
Options":<br>
<a href="images/IntelliJ/IjVMOptionsMenu.png"><img src=
"images/IntelliJ/IjVMOptionsMenu.png" width="251" height=
"170" alt="IntelliJ Edit vmoptions menu"></a></li>
<li>In the dialog, answer "Yes" to create a copy of the
application's vmoptions file:<br>
<a href="images/IntelliJ/IjVMOptionsDialog.png"><img src=
"images/IntelliJ/IjVMOptionsDialog.png" width="248" height=
"97" alt="IntelliJ Edit vmoptions dialog"></a></li>
<li>Add the line "-Didea.native2ascii.lowercase=true" to
the contents of this file and select Save All from the File
menu:<br>
<a href="images/IntelliJ/IjVMOptions.png"><img src=
"images/IntelliJ/IjVMOptions.png" width="240" height="114"
alt="IntelliJ Edit vmoptions"></a></li>
<li>IntelliJ 2016 and up are now ready to use for development with
JMRI. The vmoptions file is store in
<code>˜/Users/Preferences/IdeaIC2016.1/</code><br>
But in version 15, IntelliJ on OS X did not correctly name
this vmoptions file ( <a href=
"https://youtrack.jetbrains.com/issue/IDEA-150830#tab=Linked%20Issues">
read more</a>).<br>
To correct this, close IntelliJ 15 and in Finder go to
the <code>˜/Library/Preferences/IdeaIC15/</code>
folder.<br>
Rename the newly created file <code>idea64.vmoptions</code>
to <code>idea.vmoptions</code> (effectively removing the
"64" part).</li>
</ul>
<h4>On Windows and *nix</h4>
<ul>
<li>From the Help menu, select "Edit Custom VM
Options".</li>
<li>Add the line "-Didea.native2ascii.lowercase=true" to
the contents of this file and select Save All from the File
menu.<br>
It will be saved into the location under user home. That's
<code>$HOME/.IdeaICXX/idea$BITS.vmoptions</code> for *nix
and
<code>%USERPROFILE%\.IdeaICXX\idea%BITS%.exe.vmoptions</code>
for Windows (XX = the version number, BITS = the chip
version installed).</li>
</ul>
<p>If the IDEA_VM_OPTIONS environment variable is defined, or
a *.vmoptions file exists, then this file is used instead of
the file located in the IntelliJ IDEA installation
folder.</p>
<p>More info on setting these important vmoptions is
available on the <a href=
"https://www.jetbrains.com/idea/help/tuning-intellij-idea.html">
Idea web site</a>.<br>
Note: If you have a hint how to set this at the Project level
instead of tinkering with local application settings, please
tell <a href=
"https://groups.io/g/jmriusers">JMRI
users</a> at Groups.io.</p>
<h3>Set Preferences</h3>
<p>Start IntelliJ and choose "Preferences" from the
application menu (OS X) or Edit menu (Win).</p>
<ol>
<li>From the Editor -> File Encodings tab, check
"Transparent native-to-ascii conversion":<br>
<a href=
"images/IntelliJ/IjPrefsFileEncodings.png"><img src="images/IntelliJ/IjPrefsFileEncodings.png"
width="516" height="263" alt=
"IntelliJ encoding prefs"></a></li>
<li>From the Version Control -> GitHub tab, enter
"github.com" as the Host and enter your Login
credentials:<br>
<a href="images/IntelliJ/IjPrefsGitLogin.png"><img src=
"images/IntelliJ/IjPrefsGitLogin.png" width="375" height=
"243" alt="IntelliJ build Git Login prefs"></a></li>
<li>From the Build, Execution, Deployment -> Java
Compiler tab, select "1.8" as the Project bytecode
version:<br>
<a href="images/IntelliJ/IjPrefsJava18.png"><img src=
"images/IntelliJ/IjPrefsJava18.png" width="408" height=
"263" alt="IntelliJ build java SDK prefs"></a></li>
<li>Click OK to close the Preferences.</li>
</ol><a name="getgit" id="getgit"></a>
<h2>Getting the JMRI Source using Git</h2>
<p>To get the source code from GitHub into IntelliJ, follow
these steps:</p>
<ol>
<li>Open IntelliJ.</li>
<li>From the main menu bar select File -> New ->
Project from Version Control -> GitHub<br>
<a href="images/IntelliJ/IjImportMenu.png"><img src=
"images/IntelliJ/IjImportMenu.png" width="366" height="100"
alt="IntelliJ Git import pane"></a></li>
<li>If prompted, enter your GitHub username (Login) and
Password in the authentication fields and click
"Login":<br>
<a href="images/IntelliJ/IjLoginGit.png"><img src=
"images/IntelliJ/IjLoginGit.png" width="200" height="110"
alt="IntelliJ git login"></a></li>
<li>The Clone Repository pane should now appear. Select a
Git Repository URL from your account and point to your
local repo folder as "Parent Directory":<br>
<a href="images/IntelliJ/IjCloneRepo.png"><img src=
"images/IntelliJ/IjCloneRepo.png" width="313" height="100"
alt="IntelliJ Git import pane3"></a><br>
Optionally click "Test" at top right to check your
connection:<br>
<a href="images/IntelliJ/IjCloneTest.png"><img src=
"images/IntelliJ/IjCloneTest.png" width="315" height="100"
alt="IntelliJ Git import pane3"></a><br></li>
<li>Click "Clone" and follow progress in the indicator at
the bottom of the Project window:<br>
<a href="images/IntelliJ/IjCloningProgress.png"><img src=
"images/IntelliJ/IjCloningProgress.png" width="410" height=
"37" alt="IntelliJ Git clone progress"></a></li>
<li>In the pane that opens after download is complete,
check the location on disk,<br>
confirm the project name (like the original i.e. "JMRI")
and click "Next":<br>
<a href="images/IntelliJ/IjImportProject1.png"><img src=
"images/IntelliJ/IjImportProject1.png" width="396" height=
"97" alt="IntelliJ Git import pane1"></a></li>
<li>Select "Create project from existing sources" and click
"Next" again:<br>
<a href="images/IntelliJ/IjImportProject2.png"><img src=
"images/IntelliJ/IjImportProject2.png" width="396" height=
"123" alt="IntelliJ Git import pane2"></a></li>
<li>Click "Mark all" and then "Finish":<br>
<a href="images/IntelliJ/IjImportProject3.png"><img src=
"images/IntelliJ/IjImportProject3.png" width="396" height=
"119" alt="IntelliJ Git import pane3"></a></li>
</ol>
<p>This will add JMRI to the IntelliJ Project
window.</p><a name="ijprojectwin" id="ijprojectwin"></a>
<h2>The Project window</h2>
<p>After cloning is completed, the IntelliJ Project window
should look like this (OS X example):<br>
<a href="images/IntelliJ/IjProjectPanel.png"><img src=
"images/IntelliJ/IjProjectPanel.png" width="342" height="372"
alt="IntelliJ main project window"></a></p>
<p>Along the edges of the window are several groups of tools,
often used are:</p>
<ol>
<li>the <strong>Project</strong> tab on the left</li>
<li>the <strong>JMRI</strong> directory in the left
half</li>
<li>the <strong>Ant Build</strong> tab on the right
and</li>
<li>the <strong>Version Control</strong> tab at the
bottom.</li>
<li>the <strong>Git: master</strong> at the bottom
righthand corner, showing the current Branch ("master")
with a menu to change to another Branch.</li>
</ol>
<p>You can also access this panel from the main VCS -> Git
-> Branches... menu or right clicking the JMRI Project
folder and selecting Git -> Repository ->
Branches...<br>
<a href="images/IntelliJ/IjGitRepoMenu.png"><img src=
"images/IntelliJ/IjGitRepoMenu.png" width="407" height="142"
alt="IntelliJ Project Git context menu"></a></p>
<p>To check out another Branch from the remote repo, select
its name under "Remote Branches", right click and select
"Checkout as new local branch":<br>
<a href="images/IntelliJ/IjNewBranch.png"><img src=
"images/IntelliJ/IjNewBranch.png" width="292" height="236"
alt="IntelliJ checkout branch"></a></p>
<p>When the information from the new Branch is downloaded,
the Message Center will confirm:<br>
<a href="images/IntelliJ/IjNewBranchMsg.png"><img src=
"images/IntelliJ/IjNewBranchMsg.png" width="312" height="50"
alt="IntelliJ checkout branch OK"></a></p>
<h3>Making Changes</h3>
<p>To work on the JMRI code, always start a new Branch, so
your own "master" will stay intact.<br>
To create a new Branch in IntelliJ, from the <strong>Git
Branches</strong> pane, select "New Branch":<br>
<a href="images/IntelliJ/IjGitBranches.png"><img src=
"images/IntelliJ/IjGitBranches.png" width="323" height="172"
alt="IntelliJ main project window"></a><br>
Supply a name i.e. <code>my-dialog-2</code> and click OK.<br>
Note: Starting your Branch name with a unique two letter
combination will make it stand out from the long list much
better than a name like <code>patch-1</code>.</p><a name=
"setant" id="setant"></a>
<h2>Building and running JMRI using Ant</h2>
<p>We recommend that before you try to build and run one of
the applications within IntelliJ, you run the Ant Build ->
<Default target> first. This will create the necessary
working directories, load some resource icons, and create
needed Java files. To run the <code>ant build.xml</code> do
the following:</p>
<ol>
<li>Ant needs a JDK (Java Development Kit) in order to run
the supplied "build.xml" file. The IntelliJ IDEA 15
download comes with a JDK, but you have to configure ant to
use the right JDK.<br>
To verify the JDK is set to java 1.8, open the Ant Build
tab [1], click a file in the Ant Build list [3] and select
the Properties button [2] at the top right of the pane:<br>
<a href="images/IntelliJ/IjAntPropertiesOpen.png"><img src=
"images/IntelliJ/IjAntPropertiesOpen.png" width="340"
height="196" alt="IntelliJ Ant menu"></a></li>
<li>Select <strong>1.8</strong> as "Run under JDK" if not
yet set:<br>
<a href=
"images/IntelliJ/IjAntBuildFilePropertiesPane.png"><img src="images/IntelliJ/IjAntBuildFilePropertiesPane.png"
width="318" height="175" alt="IntelliJ Ant Settings"></a><br>
Click "OK" and save your JMRI Project (Cmd-S/Ctrl-S).</li>
<li>Select the <Default target> file in the Ant Build
list, right click, and select "Run", or click the green
triangle "Run" button at the top of the pane. This should
start the ant build. Follow any messages in the Event Log
that pops up from the bottom edge of the Project
window.</li>
<li>A new JMRI checkout should build cleanly. If not,
please check with the JMRIusers or jmri-developers mailings
lists for help.</li>
</ol>
<p>If the ant build is successful, you can launch any of the
JMRI applications from the Ant Build tab.</p><a name="build"
id="build"></a>
<h3>Building and running JMRI using IntelliJ</h3>
<p>To run an application, either:</p>
<ol>
<li>From the main menubar open the "Build" menu and select
a JMRI package like <code>panelpro</code> or</li>
<li>open the Ant Build tab and from the "Ant Build" list,
right click the desired package i.e.
<code>decoderpro</code> and select "Run Target".</li>
</ol>
<p>Note: The first two "JMRI" sets will build the English and
French JHelpDev TOC & Index files respectively. Hover
your mouse over them and read the tooltip to learn which is
which.</p>
<p>The Message Center Console will list all steps of the
build process, after which a Java icon will open with the
application running including all your new edits.</p>
<!-- to do: write instructions for configurations? -->
<a name="push" id="push"></a>
<h2>Pushing changes to your GitHub branch</h2>
<p>The standard practice for getting your changes included in
the main JMRI code repository is to Commit them to your local
repository periodically and, when ready to publish
everything, "Push" an entire set of Commits to your own
remote repository on GitHub, and finally make a Pull Request
for the maintainers to "Pull" your changes into the main JMRI
repository.<br>
When working on more than one computer or different IDEs,
Committing and Pushing makes your new edit available on the
other computers.<br>
See the <a href="GitFAQ.shtml">JMRI: Git FAQ</a> "Setting up
a Git environment for JMRI Developers" for more
information.</p>
<h3>Pulling</h3>
<p>It is also good practice to "Pull" all of the recent
changes from the main JMRI repository before performing your
Commits. After a "pull" your workspace and eventually your
remote GitHub repository will be in synch with the main JMRI
repository and you will see recent work by others. To perform
a "Pull":</p>
<ul>
<li>Select your project i.e. <strong>JMRI</strong> in the
Project tab, right click and select "Git" ->
"Repository" -> "Pull..." from the context menu:<br>
<a href="images/IntelliJ/IjGitPullMenu.png"><img src=
"images/IntelliJ/IjGitPullMenu.png" width="408" height=
"117" alt="IntelliJ Pull"></a><br>
or from the VCS menu select "Git" -> "Pull..."</li>
<li>You may be asked first to confirm the origin of your
remote repo, in our case "JMRI/JMRI":<br>
<a href="images/IntelliJ/IjGitRemoteConfig.png"><img src=
"images/IntelliJ/IjGitRemoteConfig.png" width="203" height=
"74" alt="IntelliJ Pull options"></a></li>
<li>The Pull Changes dialog opens:<br>
<a href="images/IntelliJ/IjPullDialog.png"><img src=
"images/IntelliJ/IjPullDialog.png" width="313" height=
"197" alt="IntelliJ Pull dialog"></a><br>
[1] Select a remote repository (depending
on the way you want to manage that, either your own repo
or JMRI's as in the example).<br>
[2] From the displayed list, select the appropriate Branch
to merge (you might also Pull an extra Branch to switch to
later).<br>
If what you expect is not in the list, click the Refres
button [3].</li>
<li>To conclude, click "Pull" and answer how you would like
to combine the new data into the existing local repo:<br>
<a href="images/IntelliJ/IjPullOptionsdialog.png"><img src=
"images/IntelliJ/IjPullOptionsdialog.png" width="256"
height="107" alt="IntelliJ Pull options"></a></li>
</ul>
<h3>Pushing</h3>
<p>Pushing to your GitHub Branch:</p>
<ul>
<li>First, commit your changes to the local repository on
your computer.<br>
To commit a set of changes, choose "Save All" from the Edit
menu, select your project i.e. <strong>JMRI</strong> in the
Project tab, right click and select "Git" -> "Commit
Directory..." from the context menu:<br>
<a href="images/IntelliJ/IjCommitMenu1.png"><img src=
"images/IntelliJ/IjCommitMenu1.png" width="345" height=
"372" alt="IntelliJ Commit menu"></a></li>
<li>In the Commit Changes pane, enter a Commit Message [1]
describing your changes/fix (line 1 will be used as the
short title, add more detail from line 2).<br>
Select the files [2] you wish to commit and deselect files
you don't.<br>
Choose your name from the list as Author [3]:<br>
<a href="images/IntelliJ/IjCommitPush2.png"><img src=
"images/IntelliJ/IjCommitPush2.png" width="361" height=
"284" alt="IntelliJ Commit"></a></li>
<li>Click the "Commit" button [4] to add your saved edits
to the local GitHub Branch...</li>
<li>Or hover over the Commit button and choose "Commit and
Push..." to continue to Push this set of changes from your
local repository to your remote repository on GitHub right
after the Commit (so others can access it and study it for
inclusion into JMRI).<br>
<a href="images/IntelliJ/IjCommitPush.png"><img src=
"images/IntelliJ/IjCommitPush.png" width="181" height="98"
alt="IntelliJ Commit and Push"></a></li>
<li>In the Push Commits pane, review your description and
click "Push".</li>
<li>To push to your GitHub repository after a local Commit,
just select "Push..." from the "VCS" -> Git menu:<br>
<a href="images/IntelliJ/IjGitPushOptions.png"><img src=
"images/IntelliJ/IjGitPushOptions.png" width="300" height=
"279" alt="IntelliJ Push options"></a></li>
<li>If this went fine, a confirmation will appear at bottom
left over the Version Control tab:<br>
<a href="images/IntelliJ/IjVCSmenu.png"><img src=
"images/IntelliJ/IjVCSmenu.png" width="210" height=
"69" alt="IntelliJ Push OK balloon"></a></li>
</ul>
<p>Before you can Push your changes to GitHub for the first
time, you'll have to <a href="gitdeveloper.shtml#repo">create
your own GitHub repository</a> (which you have already done
<a href="#install">in step 1</a>).</p>
<a name="debug" id="debug"></a>
<h2>Debugging</h2>
<p>We've documented the following steps to help you get started. (Note that step 4. as yet is not complete.
When you know what to enter as the Main Class Path, please report on JMRI Users)</p>
<ol>
<li>In IntelliJ, start by opening Preferences > Build, Execution, Deployment
and check "Generate debugging info":<br>
<img src="images/IntelliJ/IjDebugPrefs.png" width="655" height="436"></li>
<li>Then, doubleclick "jar-resources" in the Build tab to have IntelliJ build afresh .jar Java archive to use
for our debugging.</li>
<li>When that has run, choose "Debug..." from the Run menu.<br>
<img src="images/IntelliJ/IjDebug1Menu.png" width="377" height="145"><br>
On the small "Debug" pane that appears, click "Edit Configurations..."<br>
Alternatively, on the top right, click on the downward triangle "Select Run/Debug Configuration" button
and select the "Edit Configurations..." option from there:<br>
<img src="images/IntelliJ/IjDebug1Button.png" width="216" height="71"></li>
<li>On the top left of the new pane that appears, click the + sign (Add New Configuration).<br>
<img src="images/IntelliJ/IjDebug2Plus.png" width="134" height="91"><br>
Or simply type Command + N.<br>
Select "JAR Application" in the list.</li>
<li>This opens the "Run/Debug Configurations" pane:<br>
<img src="images/IntelliJ/IjDebug3ConfigPane.png" width="734" height="611"><br>
<ul>
<li>As the Name of this Configuration, enter "JMRI DP debug".</li>
<li>Make sure "Build" is visible in the "Before launch:" table, select "Run Ant target" and choose
"jar-resources" from the build.xml list</li>
<li>Check "Activate tool window" near the bottom of the pane.</li>
<li>Enter <b>"jmri.jar"</b> as the "Path to JAR" or use the "..." button to navigate to the freshly built
jmri.jar in your Project.</li>
<li>Make sure the prefilled "Working directory:" is showing your local path to JMRI (see example).<br>
Set "Default" as the "JRE:" choice.</li>
<li>Select "JMRI" using the "Search sources using module's classpath:" drop down.</li>
<li>Click "OK" to complete the configuration setup.</li>
</ul>
<li>To run your first debug session, start by opening a .java file and setting a Breakpoint on a line in your
code by clicking in the left margin of the central edit pane:<br>
<img src="images/IntelliJ/IjDebug5Breakpoint.png" width="302" height="184"></li>
<li>We're now ready to start a Debug session by clicking the Bug button at the top right, making sure our
"JMRI debug" configuration is selected in the drop down to the left of it:<br>
<img src="images/IntelliJ/IjDebug4StartDebug.png" width="272" height="79">
</li>
<li>After a short while, at the bottom of the main IntelliJ IDE interface, the Debug pane appears, stopping
just before your Breakpoint (or some previous error):<br>
<img src="images/IntelliJ/IjDebug6DebugInterface.png" width="782" height="398"></li>
<li>Inspect the current values of the active variables, and click the Step Into button to execute 1 line of
code:<br>
<img src="images/IntelliJ/IjDebug7StepInto.png" width="118" height="49"></li>
</ol>
<p>A further explanation of this pane and debugging in general can be found in the
<a href="https://www.jetbrains.com/help/idea/debugging.html">IntelliJ Help</a>.<br>
If your code has not been compiled before debugging, the source and class files might be out of sync, so be
sure to build first. You could add that to your Debug Configuration too.</p>
<a name="tricks" id="tricks"></a>
<h3>Tricks</h3>
<h4>Edit .properties files</h4>
<p class="important">Make sure you have set up IntelliJ to
convert special characters using <strong>lower case</strong>
encoding strings, as only then will your changes be accepted
for merging into JMRI.<br>
The - not trivial - instructions to set this via
<code>vmoptions</code> are <a href="#install">at the top of
this page</a>.</p>
<p>To easily edit Resource Bundle .properties files,
containing translations in different languages, right-click
on one of these (closed) folders in the Project file list and
select "Jump to Source":<br>
<a href="images/IntelliJ/IjResourceJump.png">
<img src="images/IntelliJ/IjResourceJump.png" width="267" height="139" alt="IntelliJ Bundle edit menu"></a></p>
<p>This will open a window with a list of coded keywords on
the left and a text box for every translation to the
right:<br>
<a href="images/IntelliJ/IjEditProperties.png">
<img src="images/IntelliJ/IjEditProperties.png" width="480" height="260" alt="IntelliJ Bundle edit window"></a></p>
<h4>Error: Can't start Git</h4>
<p>On macOS, when you run into this error, usually when starting IntelliJ for the
first time after a system update:<br>
<a href="images/IntelliJ/IjXcodeGitProblem1.png">
<img src="images/IntelliJ/IjXcodeGitProblem1.png" width="373" height="110" alt="IntelliJ Git error"></a></p>
<ol>
<li>Quit and restart IntelliJ</li>
<li>If that does not fix it, quit IntelliJ and start the Apple Xcode application.<br>
By this you be asked to agree with the licence agreement, and that will reenable
the Git installation to be used inside IntelliJ too.<br>
<a href="images/IntelliJ/IjXcode1.png">
<img src="images/IntelliJ/IjXcode1.png" width="223" height="111" alt="IntelliJ Git error"></a>
</li>
</ol>
<h4>Reset HEAD</h4>
<p>When in testing your app you conclude that you would like
to remove your last couple of Commits, IntelliJ gives you the
option to graphically Reset your HEAD.<br>
To do this, open the "Version Control" -> "Log" tab at the
lower left of the Project window to view a "Track Plan" of
the history of your Branch, all the way back to the different
parts that made JMRI:<br>
<a href="images/IntelliJ/IjVersionControlPane.png">
<img src="images/IntelliJ/IjVersionControlPane.png" width="634" height="161" alt="IntelliJ VCS tab"></a></p>
<p>Click on any line to view the changes that were Committed
at that point in time (listed to the right).<br>
To reset your repo (HEAD) back to a certain point, right
click on the corresponding line and select "Reset Current
Branch to Here...".<br>
<a href="images/IntelliJ/IjResetBranchTo.png">
<img src="images/IntelliJ/IjResetBranchTo.png" width="172" height="197" alt="IntelliJ History reset"></a><br>
Confirm the way you want to save or discard your Commits
after that point in the dialog:<br>
<a href="images/IntelliJ/IjResetBranchDialog.png">
<img src="images/IntelliJ/IjResetBranchDialog.png" width="234" height="149"
alt="IntelliJ Reset HEAD dialog"></a></p>
<h4>Master password</h4>
<p>To securely store your GitHub login, you might
periodically be asked to unlock it:<br>
<a href="images/IntelliJ/IjMasterPasswd.png">
<img src="images/IntelliJ/IjMasterPasswd.png" width="232" height="110" alt="IntelliJ Git Master Pwd dialog"></a></p>
<h3>Make a Pull Request</h3>
<p>Finally, when ready, submit a "Pull Request" to the main
JMRI code repository on the GitHub website so the maintainers
of JMRI can study your proposed changes and merge them into
the master JMRI repo.</p>
<p>To make a PR from within IntelliJ IDEA, select "Create
Pull Request" from the "VCS" -> Git menu (that's the last
item, supported by the Git plug in).<br>
<a href="images/IntelliJ/IjGitPRCreate.png">
<img src="images/IntelliJ/IjGitPRCreate.png" width="265" height="120" alt="IntelliJ Git Create PR"></a></p>
<p>To Make a PR from GitHub web - outside IntelliJ - start by
signing on to the <a href="http://github.com">GitHub web
site</a>, selecting your repository & branch and clicking
the <a href="gitdeveloper.shtml#pull">Pull Request
button</a>. For more info, see the <a href="gitdeveloper.shtml#pull">Git Developer Help</a> page.</p>
<a name="test" id="test"></a><h3>Testing with IntelliJ</h3>
<p>When you create or edit a <a href="JUnit.shtml">test</a>
(located in your Project at JMRI.java.test etc.) you can
test it either as part of the <code>alltest</code> Ant Build
(double click its name in the IntelliJ Ant Build right hand
column to run) or run it on its own using <code>test-single</code>.<br>
In the latter case, enter the name of your test in the Ant Build
Properties by either clicking the Properties button at the top or
right-clicking on any line in the Ant Build column,
choosing "Properties". Open the "Properties" tab, click the
+ (Add) sign at lower left and enter "test.includes"
in the Name column and the path to your test under Value,
starting with either <code>apps.</code> or <code>jmri.</code> as shown:<br>
<a href="images/IntelliJ/IjAntProps.png"><img src="images/IntelliJ/IjAntProps.png" width="318" height="174"
alt="IntelliJ Ant Property"></a>
</p>
<!-- to do suppress errors
<a name="errors"></a>
<h2>Compiler Errors and Warnings</h2>
The default IntelliJ compiler configuration may produce some unnecessary
warnings. You can adjust the warnings to match the screen shots as
shown below by going to Window -> Preferences and selecting
"Java -> Compiler -> Errors/Warnings".
-->
<a name="more" id="more"></a>
<h2>More Help</h2>
<p>See the IntelliJ IDEA <a href=
"https://www.jetbrains.com/idea/help/reference.html">web
reference</a> and other <a href=
"https://www.jetbrains.com/idea/help/using-online-resources.html">
resources</a> for more information on using this IDE.</p>
<!--#include virtual="/Footer.shtml" -->
</div><!-- closes #mainContent-->
</div><!-- closes #mBody-->
</body>
</html>