Class DiffController
java.lang.Object
org.netbeans.api.diff.DiffController
Encapsulates a single Diff window that displays differences between two files (sources).
- Since:
- 1.18
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumerates Base (left) and Modified (right) panes of a Diff view for setLocation() methodstatic enum
Enumerates types of location for setLocation() method. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Property change that indicates that set of differences OR the current difference changed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a property change listener.static DiffController
create
(StreamSource base, StreamSource modified) Creates a Diff Controller for supplied left and right sources.static DiffController
createEnhanced
(StreamSource base, StreamSource modified) Creates a Diff Controller for supplied left and right sources capable of creating enhanced UI.int
Gets total number of Differences between sources currently displayed in the Diff view.int
Gets the current (highlighted) difference in the Diff view.Intializes the Controller and creates visual presenter of the Diff.void
Removes a property change listener.void
setLocation
(DiffController.DiffPane pane, DiffController.LocationType type, int location) Ensure the requested location in the Diff view is visible on screen.
-
Field Details
-
PROP_DIFFERENCES
Property change that indicates that set of differences OR the current difference changed. Current difference changes as the user navigates in the view and set of differences may change if the view is editable or a source changes programatically. Clients should update their state that depends on the current difference index or total number of differences.- See Also:
-
-
Method Details
-
create
Creates a Diff Controller for supplied left and right sources.- Parameters:
base
- defines content of the Base Diff panemodified
- defines content of the Modified (possibly editable) Diff pane- Returns:
- DiffController implementation of the DiffController class
- Throws:
IOException
- when the reading from input streams fails.
-
createEnhanced
public static DiffController createEnhanced(StreamSource base, StreamSource modified) throws IOException Creates a Diff Controller for supplied left and right sources capable of creating enhanced UI.- Parameters:
base
- defines content of the Base Diff panemodified
- defines content of the Modified (possibly editable) Diff pane- Returns:
- DiffController implementation of the DiffController class
- Throws:
IOException
- when the reading from input streams fails.- Since:
- 1.27
-
setLocation
public void setLocation(DiffController.DiffPane pane, DiffController.LocationType type, int location) Ensure the requested location in the Diff view is visible on screen. Diff view can be requested to jump to a given line in either source or to a given Difference. Diff controller may ignore the request if it does not support this functionality. This method must be called from AWT thread.- Parameters:
pane
- defines which pane the location parameter refers totype
- defines the location parameter, see belowlocation
- depending on the type parameter this defines either a line number or a Difference index, both 0-based- Throws:
IllegalArgumentException
- if location parameter is out of range for the given pane and location type
-
getJComponent
Intializes the Controller and creates visual presenter of the Diff.- Returns:
- JComponent component to be embedded into client UI
-
getDifferenceCount
public int getDifferenceCount()Gets total number of Differences between sources currently displayed in the Diff view.- Returns:
- total number of Differences in sources, an integer >= 0
-
getDifferenceIndex
public int getDifferenceIndex()Gets the current (highlighted) difference in the Diff view.- Returns:
- current difference index or -1 of there is no Current difference
-
addPropertyChangeListener
Adds a property change listener.- Parameters:
listener
- property change listener
-
removePropertyChangeListener
Removes a property change listener.- Parameters:
listener
- property change listener
-