Class CompareUIPlugin
- All Implemented Interfaces:
BundleActivator
The Compare UI provides a registry for content and structure compare viewers, which is initialized from extensions contributed to extension points declared by this plug-in.
This class is the plug-in runtime class for the
"org.eclipse.compare"
plug-in.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Status code describing an internal errorstatic final int
static final String
Fields inherited from class org.eclipse.core.runtime.Plugin
PLUGIN_PREFERENCE_SCOPE, PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME
-
Constructor Summary
ConstructorDescriptionCreates theCompareUIPlugin
object and registers all structure creators, content merge viewers, and structure merge viewers contributed to this plug-in's extension points. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStructureViewerAlias
(String type, String alias) boolean
compareResultOK
(CompareEditorInput input, IRunnableContext context) createStreamMerger
(String type) Returns a stream merger for the given type.Returns a stream merger for the given content type.static void
disposeOnShutdown
(Image image) Registers the given image for being disposed when this plug-in is shutdown.boolean
findContentViewer
(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) Returns a content compare viewer based on an old viewer and an input object.findContentViewerDescriptor
(Viewer oldViewer, Object in, CompareConfiguration cc) findStructureViewer
(Viewer oldViewer, ICompareInput input, Composite parent, CompareConfiguration configuration) Returns a structure compare viewer based on an old viewer and an input object.findStructureViewerDescriptor
(Viewer oldViewer, ICompareInput input, CompareConfiguration configuration) static IWorkbench
static IWorkbenchWindow
static CompareUIPlugin
Returns the singleton instance of this plug-in runtime class.static IEditorPart[]
Returns an array of all editors that have an unsaved content.static Image
Returns a shared image for the given type, or a generic image if none has been registered for the given type.static Image
getImage
(IAdaptable adaptable) Returns a shared image for the given adaptable.static ImageDescriptor
getImageDescriptor
(String relativePath) static String
Returns this plug-in's unique identifier.Returns this plug-in's resource bundle.static Shell
getShell()
If the workbench is running returns the SWT Shell of the active workbench window ornull
if no workbench window is active.getStructureCreator
(String type) Returns an structure creator descriptor for the given type.protected void
static void
static void
static void
logErrorMessage
(String message) void
Performs the comparison described by the given input and opens a compare dialog on the result.void
openCompareEditor
(CompareEditorInput input, IWorkbenchPage page, IReusableEditor editor, boolean activate) Performs the comparison described by the given input and opens a compare editor on the result.prepareInput
(CompareEditorInput input, IProgressMonitor monitor) static void
registerImageDescriptor
(String type, ImageDescriptor descriptor) Registers an image descriptor for the given type.void
void
start
(BundleContext context) TheAbstractUIPlugin
implementation of thisPlugin
method refreshes the plug-in actions.void
stop
(BundleContext context) TheAbstractUIPlugin
implementation of thisPlugin
method saves this plug-in's preference and dialog stores and shuts down its image registry (if they are in use).Methods inherited from class org.eclipse.ui.plugin.AbstractUIPlugin
createImageRegistry, getDialogSettings, getImageRegistry, getPreferenceStore, getWorkbench, imageDescriptorFromPlugin, initializeDefaultPluginPreferences, initializeDefaultPreferences, initializeImageRegistry, loadDialogSettings, loadPreferenceStore, refreshPluginActions, saveDialogSettings, savePreferenceStore, shutdown, startup
Methods inherited from class org.eclipse.core.runtime.Plugin
find, find, getBundle, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString
-
Field Details
-
INTERNAL_ERROR
public static final int INTERNAL_ERRORStatus code describing an internal error- See Also:
-
PLUGIN_ID
- See Also:
-
NO_DIFFERENCE
public static final int NO_DIFFERENCE- See Also:
-
-
Constructor Details
-
CompareUIPlugin
public CompareUIPlugin()Creates theCompareUIPlugin
object and registers all structure creators, content merge viewers, and structure merge viewers contributed to this plug-in's extension points.Note that instances of plug-in runtime classes are automatically created by the platform in the course of plug-in activation.
-
-
Method Details
-
start
Description copied from class:AbstractUIPlugin
TheAbstractUIPlugin
implementation of thisPlugin
method refreshes the plug-in actions. Subclasses may extend this method, but must send super first. Starts up this plug-in.This method should be overridden in subclasses that need to do something when this plug-in is started. Implementors should call the inherited method at the first possible point to ensure that any system requirements can be met.
If this method throws an exception, it is taken as an indication that plug-in initialization has failed; as a result, the plug-in will not be activated; moreover, the plug-in will be marked as disabled and ineligible for activation for the duration.
Note 1: This method is automatically invoked by the platform the first time any code in the plug-in is executed.
Note 2: This method is intended to perform simple initialization of the plug-in environment. The platform may terminate initializers that do not complete in a timely fashion.
Note 3: The class loader typically has monitors acquired during invocation of this method. It is strongly recommended that this method avoid synchronized blocks or other thread locking mechanisms, as this would lead to deadlock vulnerability.
Note 4: The supplied bundle context represents the plug-in to the OSGi framework. For security reasons, it is strongly recommended that this object should not be divulged.
Note 5: This method and the
Clients must never explicitly call this method.Plugin.stop(BundleContext)
may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.- Specified by:
start
in interfaceBundleActivator
- Overrides:
start
in classAbstractUIPlugin
- Parameters:
context
- the bundle context for this plug-in- Throws:
Exception
- if this plug-in did not start up properly
-
stop
Description copied from class:AbstractUIPlugin
TheAbstractUIPlugin
implementation of thisPlugin
method saves this plug-in's preference and dialog stores and shuts down its image registry (if they are in use). Subclasses may extend this method, but must send super last. A try-finally statement should be used where necessary to ensure thatsuper.stop()
is always done. Stops this plug-in.This method should be re-implemented in subclasses that need to do something when the plug-in is shut down. Implementors should call the inherited method as late as possible to ensure that any system requirements can be met.
Plug-in shutdown code should be robust. In particular, this method should always make an effort to shut down the plug-in. Furthermore, the code should not assume that the plug-in was started successfully.
Note 1: If a plug-in has been automatically started, this method will be automatically invoked by the platform when the platform is shut down.
Note 2: This method is intended to perform simple termination of the plug-in environment. The platform may terminate invocations that do not complete in a timely fashion.
Note 3: The supplied bundle context represents the plug-in to the OSGi framework. For security reasons, it is strongly recommended that this object should not be divulged.
Note 4: This method and the
Clients must never explicitly call this method.Plugin.start(BundleContext)
may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.- Specified by:
stop
in interfaceBundleActivator
- Overrides:
stop
in classAbstractUIPlugin
- Parameters:
context
- the bundle context for this plug-in- Throws:
Exception
- if this method fails to shut down this plug-in
-
getDefault
Returns the singleton instance of this plug-in runtime class.- Returns:
- the compare plug-in instance
-
getResourceBundle
Returns this plug-in's resource bundle.- Returns:
- the plugin's resource bundle
-
getPluginId
Returns this plug-in's unique identifier.- Returns:
- the plugin's unique identifier
-
getActiveWorkbench
-
getActiveWorkbenchWindow
-
getShell
If the workbench is running returns the SWT Shell of the active workbench window ornull
if no workbench window is active. If the workbench is not running, returns the shell of the default display.- Returns:
- If the workbench is running, returns the SWT Shell of the active workbench window, or
null
if no workbench window is active. Otherwise returns the shell of the default display.
-
disposeOnShutdown
Registers the given image for being disposed when this plug-in is shutdown.- Parameters:
image
- the image to register for disposal
-
openCompareEditor
public void openCompareEditor(CompareEditorInput input, IWorkbenchPage page, IReusableEditor editor, boolean activate) Performs the comparison described by the given input and opens a compare editor on the result.- Parameters:
input
- the input on which to open the compare editorpage
- the workbench page on which to create a new compare editoreditor
- if not null the input is opened in this editoractivate
- iftrue
the editor will be activated- See Also:
-
openCompareDialog
Performs the comparison described by the given input and opens a compare dialog on the result.- Parameters:
input
- the input on which to open the compare editor- See Also:
-
prepareInput
-
compareResultOK
-
registerImageDescriptor
Registers an image descriptor for the given type.- Parameters:
type
- the typedescriptor
- the image descriptor
-
getImageDescriptor
-
getImage
Returns a shared image for the given type, or a generic image if none has been registered for the given type.Note: Images returned from this method will be automatically disposed of when this plug-in shuts down. Callers must not dispose of these images themselves.
- Parameters:
type
- the type- Returns:
- the image
-
getImage
Returns a shared image for the given adaptable. This convenience method queries the given adaptable for itsIWorkbenchAdapter.getImageDescriptor
, which it uses to create an image if it does not already have one.Note: Images returned from this method will be automatically disposed of when this plug-in shuts down. Callers must not dispose of these images themselves.
- Parameters:
adaptable
- the adaptable for which to find an image- Returns:
- an image
-
getStructureCreator
Returns an structure creator descriptor for the given type.- Parameters:
type
- the type for which to find a descriptor- Returns:
- a descriptor for the given type, or
null
if no descriptor has been registered
-
createStreamMerger
Returns a stream merger for the given type.- Parameters:
type
- the type for which to find a stream merger- Returns:
- a stream merger for the given type, or
null
if no stream merger has been registered
-
createStreamMerger
Returns a stream merger for the given content type.- Parameters:
type
- the type for which to find a stream merger- Returns:
- a stream merger for the given type, or
null
if no stream merger has been registered
-
findStructureViewerDescriptor
public ViewerDescriptor[] findStructureViewerDescriptor(Viewer oldViewer, ICompareInput input, CompareConfiguration configuration) -
findStructureViewer
public Viewer findStructureViewer(Viewer oldViewer, ICompareInput input, Composite parent, CompareConfiguration configuration) Returns a structure compare viewer based on an old viewer and an input object. If the old viewer is suitable for showing the input, the old viewer is returned. Otherwise, the input's type is used to find a viewer descriptor in the registry which in turn is used to create a structure compare viewer under the given parent composite. If no viewer descriptor can be foundnull
is returned.- Parameters:
oldViewer
- a new viewer is only created if this old viewer cannot show the given inputinput
- the input object for which to find a structure viewerparent
- the SWT parent composite under which the new viewer is createdconfiguration
- a configuration which is passed to a newly created viewer- Returns:
- the compare viewer which is suitable for the given input object or
null
-
findCompareFilters
-
findContentViewerDescriptor
public ViewerDescriptor[] findContentViewerDescriptor(Viewer oldViewer, Object in, CompareConfiguration cc) -
findContentViewer
public Viewer findContentViewer(Viewer oldViewer, Object in, Composite parent, CompareConfiguration cc) Returns a content compare viewer based on an old viewer and an input object. If the old viewer is suitable for showing the input the old viewer is returned. Otherwise the input's type is used to find a viewer descriptor in the registry which in turn is used to create a content compare viewer under the given parent composite. If no viewer descriptor can be foundnull
is returned.- Parameters:
oldViewer
- a new viewer is only created if this old viewer cannot show the given inputin
- the input object for which to find a content viewerparent
- the SWT parent composite under which the new viewer is createdcc
- a configuration which is passed to a newly created viewer- Returns:
- the compare viewer which is suitable for the given input object or
null
-
addStructureViewerAlias
-
removeAllStructureViewerAliases
-
filter
-
handleNoDifference
protected void handleNoDifference() -
getDirtyEditors
Returns an array of all editors that have an unsaved content. If the identical content is presented in more than one editor, only one of those editor parts is part of the result.- Returns:
- an array of all dirty editor parts.
-
logErrorMessage
-
log
-
log
-