NetBeans - Subversion Tutorial


NetBeans has Subversion features integrated into the IDE.

Prerequisites


The instructor must have prepared the repository by importing the source code and setting SVN_WRITE permission for anonymous.
You must have installed NetBeans ver 6.5 or later.  (These directions are for version 6.5 and up.)

Checkout the NetBeans project

Checkout the repository into NetBeans.

  1. Start NetBeans.
  2. (Ver 6.5) From the menubar select Versioning > Subversion > Checkout.
    (Ver 6.9+) From the menubar select Team > Subversion > Checkout.
    In the Checkout dialog, enter
    Repository URL: https://xp-dev.com/svn/AccordionSolitaire
    Supply Username/Password (for xp-dev account). 
  3. Click Next. (Observe "connecting to Subversion Repository" progress bar).
  4. If a Server Certificate Verification Failed dialog appears, double check the Certification Information, then click "Accept".
  5. In the Folders to Checkout dialog, enter
    Repository folder: branches/PizzaOrderIntl
    Check the box:  Scan for NetBeans Projects after Checkout.
    Verify Local Folder: /path/to/folder/NetBeansProjects
    Click Finish.
  6. Checkout Completed dialog will appear. Click Open Project.
  7. PizzaOrderIntl will appear in the Projects panel. Right-click on the project name and select "Run" from the context menu.
  8. A window should appear with the Pizza Order International application.
  9. main window
  10. To operate the application,
    1. Check one or more checkboxes for your desired toppings and click the Submit button. 
    2. Display the toppings in a different language by choosing a locale from the combo box. (Initially, only English and Spanish are enabled).
    3. View the authors by selecting Credits from the Help menu.

Modify the project

You will be enhancing the application to include labels in another language.

Create a new label properties file

  1. Decide which language you want to implement.   View the locales in the combo box and select one that does NOT have an author in the Credits page. You can verify that it has not been implemented by selecting it and observing that the labels remain in English.
  2. In the project pane,
    expand the project node (PizzaOrderIntl),
    expand Source Packages,
    expand resources
  3. Right-click on Labels.properties and select Add -> Locale.
  4. In the New Locale dialog, select the language code you have chosen from the Language Code combo box (NOT the Predefined Locales list). Click OK.
  5. Observe a new properties file appears in the list of Labels files. It will be colored green because it isn't yet part of Subversion. Double-click on your new language file and and edit window will appear containing the default properties:
    # This is the default Labels.properties file
    label1 = Toppings
    choice1 = Onions
    choice2 = Mushrooms
    choice3 = Peppers
    choice4 = Olives
    choice5 = Tomatoes
    choice6 = Pepperoni
    button1 = Submit
    message1 = You ordered a pizza with these toppings:

  6. Using Google Translate or other resource, replace each english word with the corresponding phrase in the target language. (You won't be graded on correctness). 
  7. Change 'default' in the first line to whatever locale you are creating.
  8. Save the file. (Ctrl-S)
  9. Run the application, select your language from the combo box, and you should observe the labels are changed appropriately. Click Submit and verify the message appears correctly.
  10. Exit the application, correct any mistakes in your properties file.
  11. When the properties file is complete and correct, add it to Subversion by right-clicking on the file in the project pane and choose Subversion > Show Changes
  12. NetBeans displays a Subversion status window. Your new file should appear with a status "Locally New". Click the "Update All" icon.
  13. It's unlikely, but possible, that someone else picked the same language as you and created the same file since you began this activity. If they completed the activity before you did, when you do "Update All" you'll get this error:
    Failed to add file 'NetBeansProjects/PizzaOrderIntl/src/pizzaorderintl/resources/Labels_xx.properties': an unversioned file of the same name already exists
    If that happens, right-click and delete the file, then choose a different language, and go back to step 1 of this section.
  14. Right-click on the file and choose "Commit". Enter a Commit Message such as "Labels_FI.properties added for Finnish language." Click the Commit button. Note: It's usually helpful to include the name of the file being modified as the first item in the commit message.
  15. The Subversion status window should clear and the file text color turns from green to black.


Add yourself to the Credits page

  1. In the project pane, right-click on Source Packages, and from the context menu select Subversion > Update.  This updates your working copy with the most recent additions in the repository.
  2. In the project pane,
    expand the project node (PizzaOrderIntl),
    expand Source Packages,
    expand resources. 
    Double-click on Credits.txt.
  3. The text file opens in the editor window.
  4. Add your Language Code and your first initial and last name to the bottom of the file.  Save the file.
  5. Run the application, and verify that your name appears properly in the Credits box (Help -> Credits).

Update your files from the repository.

  1. In the project pane, right-click on the Source Packages, and from the context menu select Subversion > Update.
  2. If no one else made any changes to the Credits.txt while you were working on it, the Update step will be successful.  Skip to the Commit step.
  3. If the Versioning Output shows a status of "Conflict" then someone else updated the Credits at the same time.
    1. Right-click on the file and select Subversion > Revert Modifications.
    2. Select the .txt file in the dialog which appears and click Select.
    3. In the Revert Modifications Dialog, "Revert Local Changes" radio button should be selected. Click Revert.
    4. Now repeat the steps in adding yourself to the credits page.


Commit your changes to the repository.

  1. In the project pane, right-click on Source Packages, and from the context menu select Subversion > Commit. Enter a Commit Message such as "Added J. Smith to credits box." Click the Commit button.
  2. You can use the Browse Source tab in the Trac site to observe your additions.
  3. Exit NetBeans.  You're done!
  4. If you somehow made a mistake and destroyed someone else's work (or otherwise messed things up), inform the instructor and he will revert the repository for you.

Here's some tips on writing good commit messages.


Suggestions to improve this page? Send feedback.