Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
Compare Framework Basics
Tomasz Zarna
IBM Krakow Software Lab
tomasz.zarna@pl.ibm.com
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
2
Agenda
• Quick introduction
• Simple editor
• News
• Links
• Questions
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
3
The Compare Framework
• What is the purpose of the Compare framework?
 Support comparison of alternate states of a file system or
data store
• What does the Compare framework provide?
 API to define the input to a comparison
 Extensions for associating viewers with input types
 Containers to host comparisons in the UI
 A differencing engine
 API and actions related to file system resources
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
4
Overview of Compare Architecture
Compare Container
File System Repository Database
Compare Input
Compare Viewers
JDT
rightleft
ancestor
Clients
EMF
Model Providers
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
5
Compare/Merge viewers
• A simple text merge viewer and the JDT merge viewer
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
6
How to create the simplest Compare Editor?
• Ingredients:
 A CompareItem that implements
 ITypedElement for name, image and content type of the object
 IModificationDate for timestamp
 IStreamContentAccessor to supply the content
 CompareEditorInput subclass
 DiffNode computed in a CompareEditorInput subclass
 To specify which of the panes is editable use
CompareConfiguration
 An action to open the editor
 A contribution in org.eclipse.ui.popupMenus extension point
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
7
The input and the item
© Copyright 2008 IBM Corp. All rights reserved. This source code is
made available under the terms of the Eclipse Public License, v1.0.
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
8
The action and the popup menu entry
© Copyright 2008 IBM Corp. All rights reserved. This source code is
made available under the terms of the Eclipse Public License, v1.0.
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
9
The result
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
10
The panes of a Compare Editor
contentMergeViewers JavaContentViewerCreator
structureCreators
structureMergeViewers
ZipFileStructureCreator
JavaStructureDiffViewerCreator
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
11
News
• Richer Compare Editor
• Local diff
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
12
IRC, newsgroups and bugzilla
• IRC:
 Freenode: irc.freenode.net
 #eclipse, #eclipse-dev
 SzymonB, z4z4
 http://wiki.eclipse.org/IRC
• Newsgroups
 eclipse.platform
 More info: http://www.eclipse.org/newsgroups/
• Bugzilla
 https://bugs.eclipse.org
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
13
Web and mail
• Web
 http://www.eclipse.org
 http://wiki.eclipse.org/Workspace_Team
 http://planeteclipse.org
 http://polishineclipse.blogspot.com
• Mail
 Tomasz.Zarna@pl.ibm.com
 Szymon.Brandys@pl.ibm.com
 Pawel.Pogorzelski@pl.ibm.com
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
14
Questions
Compare Framework | Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under
the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15
Eclipse Demo Camp 2008
15
Legal Notices
• Java and all Java-based trademarks are trademarks
of Sun Microsystems, Inc. in the United States, other
countries, or both
• Other company, product, or service names may be
trademarks or service marks of others
• Question mark graphic is taken from Wikimedia
Commons and is part of the public domain

Compare framework

  • 1.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 Compare Framework Basics Tomasz Zarna IBM Krakow Software Lab tomasz.zarna@pl.ibm.com
  • 2.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 2 Agenda • Quick introduction • Simple editor • News • Links • Questions
  • 3.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 3 The Compare Framework • What is the purpose of the Compare framework?  Support comparison of alternate states of a file system or data store • What does the Compare framework provide?  API to define the input to a comparison  Extensions for associating viewers with input types  Containers to host comparisons in the UI  A differencing engine  API and actions related to file system resources
  • 4.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 4 Overview of Compare Architecture Compare Container File System Repository Database Compare Input Compare Viewers JDT rightleft ancestor Clients EMF Model Providers
  • 5.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 5 Compare/Merge viewers • A simple text merge viewer and the JDT merge viewer
  • 6.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 6 How to create the simplest Compare Editor? • Ingredients:  A CompareItem that implements  ITypedElement for name, image and content type of the object  IModificationDate for timestamp  IStreamContentAccessor to supply the content  CompareEditorInput subclass  DiffNode computed in a CompareEditorInput subclass  To specify which of the panes is editable use CompareConfiguration  An action to open the editor  A contribution in org.eclipse.ui.popupMenus extension point
  • 7.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 7 The input and the item © Copyright 2008 IBM Corp. All rights reserved. This source code is made available under the terms of the Eclipse Public License, v1.0.
  • 8.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 8 The action and the popup menu entry © Copyright 2008 IBM Corp. All rights reserved. This source code is made available under the terms of the Eclipse Public License, v1.0.
  • 9.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 9 The result
  • 10.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 10 The panes of a Compare Editor contentMergeViewers JavaContentViewerCreator structureCreators structureMergeViewers ZipFileStructureCreator JavaStructureDiffViewerCreator
  • 11.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 11 News • Richer Compare Editor • Local diff
  • 12.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 12 IRC, newsgroups and bugzilla • IRC:  Freenode: irc.freenode.net  #eclipse, #eclipse-dev  SzymonB, z4z4  http://wiki.eclipse.org/IRC • Newsgroups  eclipse.platform  More info: http://www.eclipse.org/newsgroups/ • Bugzilla  https://bugs.eclipse.org
  • 13.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 13 Web and mail • Web  http://www.eclipse.org  http://wiki.eclipse.org/Workspace_Team  http://planeteclipse.org  http://polishineclipse.blogspot.com • Mail  Tomasz.Zarna@pl.ibm.com  Szymon.Brandys@pl.ibm.com  Pawel.Pogorzelski@pl.ibm.com
  • 14.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 14 Questions
  • 15.
    Compare Framework |Copyright © IBM Corp., 2008. All rights reserved. Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license. | 2008-11-15 Eclipse Demo Camp 2008 15 Legal Notices • Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both • Other company, product, or service names may be trademarks or service marks of others • Question mark graphic is taken from Wikimedia Commons and is part of the public domain

Editor's Notes

  • #2 Tomasz Zarna, IBM KSL since 2 years, 1 year eclipse committer in Compare, Team, CVS
  • #4 The Compare Framework allows to compare alternate states of a file system, or in the simplest case: two files or two different versions of the same file. In some cases we’re comparing 3 files at the same time but I’ll talk about it in a minute. What does the framework provide? It gives us the API to define the input to a comparison because we need a way to point what to compare. It gives as extensions for associating viewers with input types because sometimes we want to compare different types of inputs in a different way (using different viewers). And finally it gives us containers to display the result in the UI, so we don’t need to the UI part from the scratch. Diff engine: For tree or range based differences , API and action: Compare with Each Other, Local History, Apply Patch
  • #5 Here is a quick view on the compare architecture. As I said we usually compare two states of a file, named „left” and „right” here. If there is a third one it’s treated as a common ancestor of the previous two. Comparison result is displayed in compare viewers, which can support specific model providers like JDT or EMF. There are many clients of the compare framework, some of the are shown at the top.
  • #7 What do we need to create the simplest compare editor? First we will need a CompareItem that represents a resource we are going to compare. Then we will need a CompareEditorInput class that manages the panes of the comparison. Diff nodes are used as the compare result of the differencing engine. With CompareConfiguration we can set details of the comparison, like which of the panes is editable or set lables for panes.
  • #8 Let’s take a look at the code. As mentioned before we need to subclass the CompareEditorInput. In the simplest example we will only implement the prepareInput method. Inside we will create 3 CompareItems, set lables for compare panes and create the DiffNode. In the action class all we need to do is open a compare editor and pass our compare input as an argument.
  • #9 Now let’s have a look at the CompareItem class. It implements 3 interfaces, but because we want to keep it as simple as possible the implementation is rather straightforward. Definition of the popupMenus extension point is also trivial.
  • #10 And here is the result!
  • #11 Here you can see how structure viewers can be used. This is a result of comparing two zip archives. There is a change in the Three.java file. We can see where is it located by looking at the „Zip Archive Compare” pane, on the right in the „Java Structure Compare” pane we can see what parts of the java files has been changed. Below we can see what exactly happened.
  • #12 Some of you have probably noticed that when comparing Java files, the Compare Editor doesn’t give us many Java Editor editor as it could. We’re working on making these diffs less visible, by adding more Java features to Compare Editor. Some of the bugs are even 7 years old, but that’s a good thing because if the bug is older more people will be happy when it’s finally fixed :)