<!-- <questionid="arch-what"> Whatisthisprojectgoodfor? <hint> Pleaseprovidehereafewlinesdescribingtheproject, whatproblemitshouldsolve,providelinkstodocumentation, specifications,etc. </hint> </question>
-->
<answer id="arch-what">
The diff module provides the ability to visualize differences between source files.
It also has a graphical conflicts resolver tool and built-in patch algorithm.
<p>List of the main features:</p>
<ul>
<li>Simple APIs, that provide access to registered diff and merge engines and visualizers.</li>
<li>Built in and external diff engines defined.</li>
<li>Graphical diff vizualizer and conflicts resolver.</li>
<li>Extensible with additional diff and merge engines and vizualizers.</li>
<li>Patch algorithm implemented for UNIX-style, unidiff and contextual diff formats.</li>
</ul>
</answer>
<!-- <questionid="compat-standards"> Doesthemoduleimplementordefineanystandards?Isthe implementationexactordoesitdeviatesomehow? </question>
-->
<answer id="compat-standards">
The external diff engine expect the standard UNIX-style output of the external
diff executable.
The patching algorithm supports three diff formats:
<ul>
<li>Standard UNIX-style diff format,</li>
<li>Unidiff format,</li>
<li>Contextual diff format.</li>
</ul>
</answer>
<!-- <questionid="compat-version"> Canyourmodulecoexistwithearlierandfuture versionsofitself?Canyoucorrectlyreadalloldsettings?Willfuture versionsbeabletoreadyourcurrentsettings?Canyouread orpolitelyignoresettingsstoredbyafutureversion? <hint> Veryhelpfulforreadingsettingsistostoreversionnumber there,sofutureversionscandecidewhetherhowtoread/convert thesettingsandolderversionscanignorethenewones. </hint> </question>
-->
<answer id="compat-version">
Only one version of the module can be installed at a time.
The settings are shared across different versions, stored
and read by Java serialization and will be read in future as well.
</answer>
<!-- <questionid="dep-jre"> WhichversionofJREdoyouneed(1.2,1.3,1.4,etc.)? <hint> Itisexpectedthatifyourmodulerunson1.xthatitwillrun on1.x+1ifno,statethatplease.Alsodescribeherecaseswhere yourundifferentcodeondifferentversionsofJREandwhy. </hint> </question>
-->
<answer id="dep-jre">
Needs at least JRE 1.4.
</answer>
<!-- <questionid="dep-platform"> Onwhichplatformsdoesyourmodulerun?Doesitruninthesame wayoneach? <hint> IfyourmoduleisusingJNIordealswithspecialdifferencesof OSeslikefilesystems,etc.pleasedescribeherewhattheyare. </hint> </question>
-->
<answer id="dep-platform">
The module is 100% pure Java and runs on any platform.
</answer>
<!-- <questionid="deploy-packages"> Arepackagesofyourmodulemadeinaccessiblebynotdeclaringthem public? <hint> NetBeansmodulesystemallowsrestrictionofaccessrightsto publicclassesofyourmodulefromothermodules.Thisprevents unwanteddependenciesofothersonyourcodeandshouldbeused wheneverpossible(<ahref="http://www.netbeans.org/download/apis/org/openide/doc-files/upgrade.html#3.4-public-packages"> publicpackages </a>). </hint> </question>
-->
<answer id="deploy-packages">
All public packages are accessible, no restriction applied. Diff module contains <api group="java" name="DiffAPI"type="export" category="official"/>.
Some parts of VCS modules can use semi-private API <api group="java" name="DiffImplementationAPI"type="export" category="friend"/>, namely org.netbeans.modules.diff.builtin.DiffPresenter.
</answer>
<!-- <questionid="deploy-shared"> Doyouneedtobeinstalledinthesharedlocationonly,orintheuserdirectoryonly, orcanyourmodulebeinstalledanywhere? <hint> Installationlocationshallnotmatter,ifitdoesexplainwhy. Consideralsowhether<code>InstalledFileLocator</code>canhelp. </hint> </question>
-->
<answer id="deploy-shared">
Module can be installed anywhere.
</answer>
<!-- <questionid="exec-introspection"> Doesyourmoduleuseanykindofruntimetypeinformation(<code>instanceof</code>, workwith<code>java.lang.Class</code>,etc.)? <hint> CheckforcaseswhenyouhaveanobjectoftypeAandyoualso expectitto(possibly)beoftypeBanddosomespecialaction.That shouldbedocumented.Thesameappliesonoperationsinmeta-level (Class.isInstance(...),Class.isAssignableFrom(...),etc.). </hint> </question>
-->
<answer id="exec-introspection">
Yes.
<ul>
<li>DiffAction needs to detect whether the provided diff component is a TopComponent or not in order to open it in an appropriate way.</li>
<li>DiffPanel and MergePanel need to check whether the supplied document is a StyledDocument or not.</li>
<li>DiffSettings needs to alter diff services when the default is changed and thus it needs to cast the service to InstanceDataObject</li>
<li>LinesComponent needs to cast the settings objects retrieved from editor's settings</li>
<li>MergeDialogComponent needs to check class types for presenting pop-up menu actions</li>
<li>PatchAction in order to disable itself on InstanceDataObjects</li>
</ul>
</answer>
<!-- <questionid="exec-process"> Doyouexecuteanexternalprocessfromyourmodule?Howdoyouensure thattheresultisthesameondifferentplatforms?Doyouparseoutput? Doyoudependonresultcode? <hint> Ifyoufeedaninput,parsetheoutputpleasedeclarethatasanAPI. </hint> </question>
-->
<answer id="exec-process">
Yes, for an external diff engine. The standard UNIX diff output is expected,
it's the responsibility of the user to supply the correct executable.
</answer>
<!-- <questionid="exec-property"> Isexecutionofyourcodeinfluencedbyanyenvironmentor Javasystem(<code>System.getProperty</code>)property? <hint> Ifthereisapropertythatcanchangethebehaviourofyour code,somebodywilllikelyuseit.Youshoulddescribewhatitdoes andthestabilitycategoryofthisAPI.Youmayuse <pre> <propertyname="id"category="private"> descriptionoftheproperty,whereitisused,whatitinfluence,etc. </property> </pre> </hint> </question>
-->
<answer id="exec-property">
<api type="import" group="systemproperty" name="user.dir" category="private">
Used as a default directory in the file chooser, that is used by the patch action.
</api>
</answer>
<!-- <questionid="lookup-lookup"> Doesyourmoduleuse<code>org.openide.util.Lookup</code> tofindanycomponentstocommunicatewith?Whichones? <hint> Pleasedescribetheinterfacesyouaresearchingfor,where aredefined,whetheryouaresearchingforjustoneormoreofthem, iftheorderisimportant,etc.Alsoclasifythestabilityofsuch APIcontract. </hint> </question>
-->
<answer id="lookup-lookup">
Yes. Lookup is used to get all registered diff and merge engines and visualizers.
</answer>
<!-- <questionid="lookup-register"> Doyouregisteranythingintolookupforothercodetofind? <hint> Doyouregisterusinglayerfileorusing<code>META-INF/services</code>? Whoissupposedtofindyourcomponent? </hint> </question>
-->
<answer id="lookup-register">
Yes. The module registers two diff engines, two diff visualizers and one merge
visualizer (visual conflicts resolver).
</answer>
<!-- <questionid="perf-limit"> Arethereanyhardcodedorpracticallimitsinthenumberorsizeof elementsyourcodecanhandle? </question>
-->
<answer id="perf-limit">
No explicit limits. Technically, the available memory size is the limit...
</answer>
<!-- <questionid="perf-progress"> Doesyourmoduleexecuteanylong-runningtasks? <hint>Typicallytheyaretaskslikeconnectingover network,computinghugeamountofdata,compilation. Suchcommunicationshouldbedoneasynchronously(forexample using<code>RequestProcessor</code>),definitivelyitshould notblockAWTthread. </hint> </question>
-->
<answer id="perf-progress">
The diff engines and patch action run in background to prevent blocking the
AWT thread. The running time depends on the file size.
</answer>
<!-- <questionid="perf-scale"> Whichexternalcriteriainfluencetheperformanceofyour program(sizeoffileineditor,numberoffilesinmenu, insourcedirectory,etc.)andhowwellyourcodescales? Pleaseincludesomeestimates. </question>
-->
<answer id="perf-scale">
Size of the files, that are diffing or patching.
</answer>
<!-- <questionid="resources-file"> Doesyourmoduleuse<code>java.io.File</code>directly? <hint> NetBeansprovidealogicalwrapperoverplainfilescalled <code>org.openide.filesystems.FileObject</code>that providesuniformaccesstosuchresourcesandistheprefered waythatshouldbeused.Butofcoursetherecanbesituationswhen thisisnotsuitable. </hint> </question>
-->
<answer id="resources-file">
Yes, for temporary files and for location of the patch file.
</answer>
<!-- <questionid="resources-layer"> Doesyourmoduleprovideownlayer?Doesitcreateanyfilesor foldersinit?Whatitistryingtocommunicatebythatandwithwhich components? <hint> NetBeansallowsautomaticanddeclarativeinstallationofresources bymodulelayers.Moduleregisterfilesintoappropriateplaces andothercomponentsusethatinformationtoperformtheirtask (buildmenu,toolbar,windowlayout,listoftemplates,setof options,etc.). </hint> </question>
-->
<answer id="resources-layer">
Yes. The module defines the provided diff and merge engines and visualizers
so that they can be accessed by lookup. Also settings are defined there.
</answer>
<!-- <questionid="arch-overall"when="init"> Describetheoverallarchitecture. <hint> WhatwillbeAPIfor <ahref="http://openide.netbeans.org/tutorial/api-design.html#design.apiandspi"shape="rect"> clientsandwhatsupportAPI</a>? Whatpartswillbepluggable? Howwillplug-insberegistered?Pleaseuse<code><apitype="export"/></code> todescribeyourgeneralAPIsandspecifytheir <ahref="http://openide.netbeans.org/tutorial/api-design.html#category-private"shape="rect"> stabilitycategories</a>. Ifpossiblepleaseprovidesimplediagrams. </hint> </question>
-->
<answer id="arch-overall">
<p>
Support to everything related to creation and visualization of diffs.
This library allows registrations of various diff providers and visualizers
and provides programatic access to their functionality.
</p>
</answer>
<usecase id="diff-action" name="Show a diff from action">
<p>
From an action or wherever you like you can call this:
</p>
<pre> public void diff(final StreamSource local, final StreamSource remote){
SwingUtilities.invokeLater(new Runnable() { public void run() {
try {
<a href="@TOP@/org/netbeans/api/diff/DiffView.html">DiffView</a> view = <a href="@TOP@/org/netbeans/api/diff/Diff.html">Diff</a>.getDefault().createDiff(local, remote);
showDiff(view);
} catch (IOException ex) {
Logger.getLogger(ThisClass.class.getName()).throwing(ex);
}
}
});
} public void showDiff(final <a href="@TOP@/org/netbeans/api/diff/DiffView.html">DiffView</a> view){
SwingUtilities.invokeLater(new Runnable() { public void run() {
//create our panel with our view
//right now I am just going to use the diff component
// instead of a panel
//create a topcomponent with our panel
DiffTopComponent tc = new DiffTopComponent(view);
tc.setName("MY_DIFF");
tc.setDisplayName("Some display name");
tc.open();
tc.requestActive();
}
});
}
</pre>
</usecase>
<usecase id="diff-component" name="Embeded into TopComponent">
<p>
Here is a top component to display it:
</p>
<pre> public class DiffTopComponent extends <a href="@org-openide-windows@/org/openide/windows/TopComponent.html">TopComponent</a> {
/** Creates a new instance of DiffTopComponent */ public DiffTopComponent(Component diffPanel) {
setLayout(new BorderLayout());
add(diffPanel, BorderLayout.CENTER);
getAccessibleContext().setAccessibleName(
NbBundle.getMessage(DiffTopComponent.class, "ACSN_Diff_Top_Component")); // NOI18N
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.