|
|||||||||
| Home >> All >> org >> eclipse >> [ compare overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.compare
Class EditionSelectionDialog

java.lang.Objectorg.eclipse.jface.window.Window
org.eclipse.jface.dialogs.Dialog
org.eclipse.compare.internal.ResizableDialog
org.eclipse.compare.EditionSelectionDialog
- public class EditionSelectionDialog
- extends org.eclipse.compare.internal.ResizableDialog
A dialog where one input element can be compared against a list of historic variants (editions) of the same input element. The dialog can be used to implement functions like "Compare/Replace with Version" or "Compare/Replace from Local History" on workspace resources.
In addition it is possible to specify a subsection of the input element (e.g. a method in a Java source file) by means of a "path". In this case the dialog compares only the subsection (as specified by the path) with the corresponding subsection in the list of editions. Only those editions are shown where the subsection differs from the same subsection in another edition thereby minimizing the number of presented variants. This functionality can be used to implement "Replace from Local History" for the Java language.
Subsections of an input element are determined by first finding an
IStructureCreator for the input's type.
Then the method locate is used to extract the subsection.
Each edition (variant in the list of variants) must implement the IModificationDate interface
so that the dialog can sort the editions and present them in a tree structure where every
node corresponds one day.
The functionality is surfaced in a single function selectEdition.
Clients may instantiate this class; it is not intended to be subclassed.
| Nested Class Summary | |
private static class |
EditionSelectionDialog.Pair
An item in an underlying edition. |
| Nested classes inherited from class org.eclipse.jface.window.Window |
org.eclipse.jface.window.Window.IExceptionHandler |
| Field Summary | |
private boolean |
fAddMode
add mode if true, otherwise replace mode |
private java.util.ArrayList |
fArrayList
|
private org.eclipse.swt.widgets.Button |
fCommitButton
|
private boolean |
fCompare
use a side-by-side compare viewer |
private CompareConfiguration |
fCompareConfiguration
|
private boolean |
fCompareMode
compare mode if true, otherwise replace/add mode |
private CompareViewerSwitchingPane |
fContentPane
|
private java.util.List |
fCurrentEditions
The editions of the current selected member |
private org.eclipse.swt.graphics.Image |
fDateImage
|
private CompareViewerPane |
fEditionPane
|
private org.eclipse.swt.widgets.Tree |
fEditionTree
|
private boolean |
fHideIdentical
hide entries which have identical content |
private java.util.HashMap |
fMemberEditions
Maps from members to their corresponding editions. |
private CompareViewerPane |
fMemberPane
|
private java.util.HashMap |
fMemberSelection
Maps from members to their corresponding selected edition. |
private org.eclipse.swt.widgets.Table |
fMemberTable
|
private boolean |
fMultiSelect
allow for multiple selection |
private ITypedElement |
fSelectedItem
The selected edition in the edition viewer |
private boolean |
fStructureCompare
perform structure compare on editions |
private CompareViewerSwitchingPane |
fStructuredComparePane
|
private boolean |
fTargetIsRight
show target on right hand side |
private EditionSelectionDialog.Pair |
fTargetPair
|
private java.lang.Thread |
fThread
|
private org.eclipse.swt.graphics.Image |
fTimeImage
|
private java.lang.String |
fTitleArg
|
private org.eclipse.swt.graphics.Image |
fTitleImage
|
| Fields inherited from class org.eclipse.compare.internal.ResizableDialog |
fBundle |
| Fields inherited from class org.eclipse.jface.dialogs.Dialog |
blockedHandler, buttonBar, dialogArea, DLG_IMG_ERROR, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS |
| Fields inherited from class org.eclipse.jface.window.Window |
CANCEL, OK |
| Constructor Summary | |
EditionSelectionDialog(org.eclipse.swt.widgets.Shell parent,
java.util.ResourceBundle bundle)
Creates a new modal, resizable dialog. |
|
| Method Summary | |
private void |
addEdition(EditionSelectionDialog.Pair pair)
Adds the given Pair to the edition tree. |
private void |
addMemberEdition(EditionSelectionDialog.Pair pair)
Adds the given Pair to the member editions. |
protected void |
createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent)
Adds buttons to this dialog's button bar. |
protected org.eclipse.swt.widgets.Control |
createDialogArea(org.eclipse.swt.widgets.Composite parent2)
Creates and returns the contents of the upper part of this dialog (above the button bar). |
private EditionSelectionDialog.Pair |
createPair(org.eclipse.compare.structuremergeviewer.IStructureCreator sc,
java.lang.Object path,
ITypedElement input)
|
private long |
dayNumber(long date)
Returns the number of s since Jan 1st, 1970. |
private void |
feedInput(org.eclipse.swt.widgets.Widget w)
|
private void |
feedInput2(org.eclipse.jface.viewers.ISelection sel)
|
private CompareConfiguration |
getCompareConfiguration()
|
protected org.eclipse.swt.graphics.Image |
getEditionImage(ITypedElement selectedEdition,
ITypedElement item)
Returns an image for identifying the edition side of a compare viewer. |
protected java.lang.String |
getEditionLabel(ITypedElement selectedEdition,
ITypedElement item)
Returns a label for identifying the edition side of a compare viewer. |
ITypedElement[] |
getSelection()
Returns the editions that have been selected with the most recent call to selectEdition. |
protected java.lang.String |
getShortEditionLabel(ITypedElement edition,
ITypedElement item,
java.util.Date date)
Returns a label for identifying a node in the edition tree viewer. |
ITypedElement |
getTarget()
Returns the input target that has been specified with the most recent call to selectEdition. |
protected java.lang.String |
getTargetLabel(ITypedElement target,
ITypedElement item)
Returns a label for identifying the target side of a compare viewer. |
private void |
handleMemberSelect(org.eclipse.swt.widgets.Widget w)
Feeds selection from member viewer to edition viewer. |
private static void |
internalSort(IModificationDate[] keys,
int left,
int right)
|
protected void |
okPressed()
Overidden to disable dismiss on double click in compare mode. |
ITypedElement |
selectEdition(ITypedElement target,
ITypedElement[] inputEditions,
java.lang.Object ppath)
Presents this modal dialog with the functionality described in the class comment above. |
ITypedElement |
selectPreviousEdition(ITypedElement target,
ITypedElement[] inputEditions,
java.lang.Object ppath)
Select the previous edition (presenting a UI). |
private void |
sendPair(EditionSelectionDialog.Pair pair)
Asynchroneously sends a Pair (or null) to the UI thread. |
void |
setAddMode(boolean addMode)
Controls whether the EditionSelectionDialog is in 'add' mode
or 'replace' mode (the default). |
void |
setCompareMode(boolean compareMode)
Controls whether the EditionSelectionDialog is in 'compare' mode
or 'add/replace' (the default) mode. |
void |
setEditionTitleArgument(java.lang.String titleArgument)
Sets an additional and optional argument for the edition pane's title. |
void |
setEditionTitleImage(org.eclipse.swt.graphics.Image titleImage)
Sets an optional image for the edition pane's title. |
void |
setHideIdenticalEntries(boolean hide)
Controls whether identical entries are shown or not (default). |
private void |
setInput(java.lang.Object input)
|
void |
setTargetIsRight(boolean isRight)
Controls whether workspace target is on the left (the default) or right hand side. |
| Methods inherited from class org.eclipse.compare.internal.ResizableDialog |
close, configureShell, getInitialLocation, getInitialSize, setHelpContextId |
| Methods inherited from class org.eclipse.jface.window.Window |
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
fCompareConfiguration
private CompareConfiguration fCompareConfiguration
fArrayList
private java.util.ArrayList fArrayList
fCompare
private boolean fCompare
- use a side-by-side compare viewer
fTargetIsRight
private boolean fTargetIsRight
- show target on right hand side
fHideIdentical
private boolean fHideIdentical
- hide entries which have identical content
fAddMode
private boolean fAddMode
- add mode if true, otherwise replace mode
fCompareMode
private boolean fCompareMode
- compare mode if true, otherwise replace/add mode
fStructureCompare
private boolean fStructureCompare
- perform structure compare on editions
fMultiSelect
private boolean fMultiSelect
- allow for multiple selection
fMemberEditions
private java.util.HashMap fMemberEditions
- Maps from members to their corresponding editions.
Has only a single entry if dialog is used in "Replace" (and not "Add") mode.
fMemberSelection
private java.util.HashMap fMemberSelection
- Maps from members to their corresponding selected edition.
fCurrentEditions
private java.util.List fCurrentEditions
- The editions of the current selected member
fThread
private java.lang.Thread fThread
fTargetPair
private EditionSelectionDialog.Pair fTargetPair
fSelectedItem
private ITypedElement fSelectedItem
- The selected edition in the edition viewer
fTitleArg
private java.lang.String fTitleArg
fTitleImage
private org.eclipse.swt.graphics.Image fTitleImage
fContentPane
private CompareViewerSwitchingPane fContentPane
fCommitButton
private org.eclipse.swt.widgets.Button fCommitButton
fMemberTable
private org.eclipse.swt.widgets.Table fMemberTable
fMemberPane
private CompareViewerPane fMemberPane
fEditionTree
private org.eclipse.swt.widgets.Tree fEditionTree
fEditionPane
private CompareViewerPane fEditionPane
fDateImage
private org.eclipse.swt.graphics.Image fDateImage
fTimeImage
private org.eclipse.swt.graphics.Image fTimeImage
fStructuredComparePane
private CompareViewerSwitchingPane fStructuredComparePane
| Constructor Detail |
EditionSelectionDialog
public EditionSelectionDialog(org.eclipse.swt.widgets.Shell parent, java.util.ResourceBundle bundle)
- Creates a new modal, resizable dialog.
Various titles, icons, and labels are configured from the given resource bundle.
The following resource keys are used:
key type description title String dialog title width Integer initial width of dialog height Integer initial height of dialog treeTitleFormat MessageFormat pane title for edition tree; arg 0 is the target dateIcon String icon for node in edition tree; path relative to plugin timeIcon String icon for leaf in edition tree; path relative to plugin todayFormat MessageFormat format string if date is todays date; arg 0 is date yesterdayFormat MessageFormat format string if date is yesterdays date; arg 0 is date dayFormat MessageFormat format string if date is any other date; arg 0 is date editionLabel String label for editions side of compare viewer; arg 0 is the date targetLabel String label for target side of compare viewer buttonLabel String label for OK button; default is IDialogConstants.OK_LABEL
| Method Detail |
getCompareConfiguration
private CompareConfiguration getCompareConfiguration()
setEditionTitleArgument
public void setEditionTitleArgument(java.lang.String titleArgument)
- Sets an additional and optional argument for the edition pane's title.
- Since:
- 2.0
setEditionTitleImage
public void setEditionTitleImage(org.eclipse.swt.graphics.Image titleImage)
- Sets an optional image for the edition pane's title.
- Since:
- 2.0
selectPreviousEdition
public ITypedElement selectPreviousEdition(ITypedElement target, ITypedElement[] inputEditions, java.lang.Object ppath)
- Select the previous edition (presenting a UI).
- Since:
- 2.0
selectEdition
public ITypedElement selectEdition(ITypedElement target, ITypedElement[] inputEditions, java.lang.Object ppath)
- Presents this modal dialog with the functionality described in the class comment above.
createPair
private EditionSelectionDialog.Pair createPair(org.eclipse.compare.structuremergeviewer.IStructureCreator sc, java.lang.Object path, ITypedElement input)
setHideIdenticalEntries
public void setHideIdenticalEntries(boolean hide)
- Controls whether identical entries are shown or not (default).
This method must be called before
selectEdition.- Since:
- 2.0
setTargetIsRight
public void setTargetIsRight(boolean isRight)
- Controls whether workspace target is on the left (the default) or right hand side.
- Since:
- 2.0
setAddMode
public void setAddMode(boolean addMode)
- Controls whether the
EditionSelectionDialogis in 'add' mode or 'replace' mode (the default).- Since:
- 2.0
setCompareMode
public void setCompareMode(boolean compareMode)
- Controls whether the
EditionSelectionDialogis in 'compare' mode or 'add/replace' (the default) mode.- Since:
- 2.0
getTarget
public ITypedElement getTarget()
- Returns the input target that has been specified with the most recent call
to
selectEdition. If a notnullpath was specified this method returns a subsection of this target (IStructureCreator.locate(path, target)) instead of the input target.For example if the
targetis a Java compilation unit andpathspecifies a method, the value returned fromgetTargetwill be the method not the compilation unit.
getSelection
public ITypedElement[] getSelection()
- Returns the editions that have been selected with the most
recent call to
selectEdition.- Since:
- 2.1
getTargetLabel
protected java.lang.String getTargetLabel(ITypedElement target, ITypedElement item)
- Returns a label for identifying the target side of a compare viewer.
This implementation extracts the value for the key "targetLabel" from the resource bundle
and passes it as the format argument to
MessageFormat.format. The single format argument forMessageFormat.format("{0}" in the format string) is the name of the given input element.Subclasses may override to create their own label.
getEditionLabel
protected java.lang.String getEditionLabel(ITypedElement selectedEdition, ITypedElement item)
- Returns a label for identifying the edition side of a compare viewer.
This implementation extracts the value for the key "editionLabel" from the resource bundle
and passes it as the format argument to
MessageFormat.format. The single format argument forMessageFormat.format("{0}" in the format string) is the formatted modification date of the given input element.Subclasses may override to create their own label.
getShortEditionLabel
protected java.lang.String getShortEditionLabel(ITypedElement edition, ITypedElement item, java.util.Date date)
- Returns a label for identifying a node in the edition tree viewer.
This implementation extracts the value for the key "workspaceTreeFormat" or
"treeFormat" (in that order) from the resource bundle
and passes it as the format argument to
MessageFormat.format. The single format argument forMessageFormat.format("{0}" in the format string) is the formatted modification date of the given input element.Subclasses may override to create their own label.
- Since:
- 2.0
getEditionImage
protected org.eclipse.swt.graphics.Image getEditionImage(ITypedElement selectedEdition, ITypedElement item)
- Returns an image for identifying the edition side of a compare viewer.
This implementation extracts the value for the key "editionLabel" from the resource bundle
and passes it as the format argument to
MessageFormat.format. The single format argument forMessageFormat.format("{0}" in the format string) is the formatted modification date of the given input element.Subclasses may override to create their own label.
- Since:
- 2.0
createDialogArea
protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent2)
- Description copied from class:
org.eclipse.jface.dialogs.Dialog - Creates and returns the contents of the upper part of this dialog (above
the button bar).
The
Dialogimplementation of this framework method creates and returns a newCompositewith standard margins and spacing.The returned control's layout data must be an instance of
GridData. This method must not modify the parent's layout.Subclasses must override this method but may call
superas in the following example:Composite composite = (Composite) super.createDialogArea(parent); //add controls to composite as necessary return composite;
createButtonsForButtonBar
protected void createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent)
- Description copied from class:
org.eclipse.jface.dialogs.Dialog - Adds buttons to this dialog's button bar.
The
Dialogimplementation of this framework method adds standard ok and cancel buttons using thecreateButtonframework method. These standard buttons will be accessible fromgetCancelButton, andgetOKButton. Subclasses may override.
okPressed
protected void okPressed()
- Overidden to disable dismiss on double click in compare mode.
- Since:
- 2.0
sendPair
private void sendPair(EditionSelectionDialog.Pair pair)
- Asynchroneously sends a Pair (or null) to the UI thread.
internalSort
private static void internalSort(IModificationDate[] keys, int left, int right)
addMemberEdition
private void addMemberEdition(EditionSelectionDialog.Pair pair)
- Adds the given Pair to the member editions.
If HIDE_IDENTICAL is true the new Pair is only added if its contents
is different from the preceeding Pair.
If the argument is
nullthe message "No Editions found" is shown in the member or edition viewer.
dayNumber
private long dayNumber(long date)
- Returns the number of s since Jan 1st, 1970.
The given date is converted to GMT and daylight saving is taken into account too.
addEdition
private void addEdition(EditionSelectionDialog.Pair pair)
- Adds the given Pair to the edition tree.
It takes care of creating tree nodes for different dates.
handleMemberSelect
private void handleMemberSelect(org.eclipse.swt.widgets.Widget w)
- Feeds selection from member viewer to edition viewer.
setInput
private void setInput(java.lang.Object input)
feedInput
private void feedInput(org.eclipse.swt.widgets.Widget w)
feedInput2
private void feedInput2(org.eclipse.jface.viewers.ISelection sel)
|
|||||||||
| Home >> All >> org >> eclipse >> [ compare overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC