In this video we will look at some of the coolest features for P4Eclipse, Perforce's plug-in for the Eclipse IDE. Note that P4Eclipse was formerly known as P4WSAD.

Installing P4Eclipse is easy. You'll start by going to Eclipses Help Menu and selecting Install New Software. If you don't yet have Perforce's update site in your list of available sites so you'll need to go to available software sites and click Add. You'll just need to give it a name, which can be anything you choose and a url. The url for Perforce's Eclipse update site can be found by going to our website, perforce.com, click on products, plug-ins, then Eclipse plug-in, and the urls for the update sites are towards the bottom of the page. And note that there are separate urls for Eclipse 3.5 and 3.6.

Once you have Perforce's update site installed, select it and you'll see 2 components. The core pieces which you'll always need and there are a few optional components you can choose to install as well. Once you have P4Eclipse installed, you're ready to go.

So now let me start by setting up the new Java project in Eclipse. I'll give this project a name and I'm going to connect it to an existing Perforce workspace that I have set up on disk. So I'll just select that local folder and click ok. For now I'll accept all of the other default settings for an Eclipse java project.

Now I want to connect this project to Perforce. So I'll right click on it, go to the team menu and select share project. I'll choose a Perforce repository type and I'll use an existing Perforce connection I have set up to my local Perforce server and the workspace bruno_gwt.

Of course you can create a new Perforce server connection by simply providing your P4 port setting, your perforce user name, and the name of your Perforce workspace.

The project is now connected to Perforce so if I go to the package explorer and start drilling down into some of the source packages, I'll see Perforce information next to the files. For instance, for Person.java I can see that I have revision 5, the head revision is also 5 and this is a text file type.

Now let's start making some changes. I'm going to double click on DynaTableWidget.java and just put in a new line of text. Notice that back in the package explorer the file is now open for edit, so P4Eclipse automatically checked it out for me when I started making changes.

I'm going to add a Perforce pending changelist to my current view so that I can more easily see the files I have checked out for work. So I'll go to the Window menu, select Show View, Other and then under the Perforce section I'll select P4 Pending Changelists. Once I click on a file in the package explorer to refresh the view, you'll notice that the file I have checked out.

I can also add a Perforce pending changelist tab to my current view to get a quicker glance of what I'm working on. To do that I'll just go to Window, Show View, Other, and then under the Perforce section I'll select P4 Pending Changelists. Once I click on a package or file in the package explorer to refresh the view, I'll see all of my current work in progress. So right now all I have is DynaTableWidget.java.

Now let's see how my changes are going. I'm going to right click in the editor and under the Team menu I'm going to select Diff File Against Depot. This brings up the Diff View, and in P4Eclipse the Diff View is language sensitive, so I can easily see the specific parts of the java class that I'm modifying. Now let's go ahead and submit this change. I can do that from a few places, but for now I'll right click in the editor window for DynaTableWidget, go to the Team menu and select Submit. That brings up a changelist submit dialog. I just need to fill out the changelist description. I can review the set of files that are included and right now of course I only have 1 checked out. And then I can click on Submit.

Now let's take a little bit more of an in-depth look at this file's history. So I could right click on the file, go to the Team menu, and select Revision History. That opens up a new History tab in my view and I can see the complete revision history of this file in the depot. I can also access a Time Lapse View under the Team menu. That brings up a tool that lets me step back through the history of a file to let me see how its evolved.And like some of the other tools in P4Eclipse, the TimeLapse View is language aware, so I can focus on a specific part of the java class and see how its changed over time.

P4Eclipse gives you access to a lot of the other Perforce tools. And you can see some of them by right clicking on a file or folder in the package explorer going to the team menu and looking at your available options.

For instance, at the top you have an option to Synchronize with Depot, Get the Latest Revision of file so that you can fetch new work that other people have checked into the server. You can check a file out, add new files, delete files, compare files that are checked out and have been edited, look at history, you can drive some of Perforce's integration commands, and just like in P4V, you can do this with either a file or using a branch specification.

P4Eclipse also fully supports refactoring. So I can go to a file or package in the package explorer, right click and select Refactor. And in this case I'll just rename the file from Person to People. And I'll select Finish. On the Perforce side, if I look at my Pending Changelist tab again, I can see that all of the actions that Eclipse took to support refactoring, including actually renaming Person.java to People.java and checking out and updating a few other files that reference that class, in the background P4Eclipse also did whatever was necessary on the Perforce side to model the refactoring. So the files that had to be updated for new references are checked out for edit, the file under the original name Person.java is opened for move/delete, and the file under the new name People.java is open for move/add. At this point, all I need to do is submit the change. I'll do that by right clicking on the changelist and selecting Submit and filling in the changelist description.

Right clicking on another file and going to the Team menu, I can choose to look at the Revision Graph. Now I have to have P4V, Perforce's other GUI client installed to use the Revision Graph, but once I have it, I can access that Revision Graph directly from inside Eclipse.

And finally, let's look at how to use the shelving feature in P4Eclipse. So I can select several files in the package explorer. Go to the Team menu and select Check Out. I'll open one of them in the editor and make some changes. And maybe I'll just put in an updated piece of Javadoc. Now I can right click on this file since I've started modifying it and if I'd like to set this work aside to work on something else or if I'd just like to make this work temporarily available to someone else, say for code review, I can access the Team menu and select Shelve. I'll put in a description for the new shelf. I can see that I have a single file that's going to be included in the shelf and now I'll just select OK. And looking back at my Pending Changelist View, I can see that this file has been moved to the new shelved changelist. It's still checked out and it's also shelved on the server.

P4Eclipse makes all of Perforce's powerful features available to you directly inside of the IDE and also adds some cool new features like the language sensitive parts of the Diff tool and the TimeLapse View. That wraps up our quick overview of working with Perforce and Eclipse. Thanks for watching and if you have any questions, please contact support at perforce.com.

 

Course - Using IDEs and Plugins to Access Helix