Package org.eclipse.compare.internal
Class Utilities
java.lang.Object
org.eclipse.compare.internal.Utilities
Convenience and utility methods.
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
Constant used to indicate that tests are being run.static boolean
Constant used while testing the indicate that changes should be flushed when the compare input changes and a viewer is dirty. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
applyCompareFilters
(String thisLine, char thisContributor, String otherLine, char otherContributor, ICompareFilter[] filters) Applies the compare filters to the lines of text taken from the specified contributorsstatic void
close
(InputStream is) static void
executeRunnable
(IRunnableWithProgress runnable) Executes the given runnable.static void
executeRunnable
(IRunnableWithProgress runnable, boolean fork, boolean cancelable) Executes the given runnable.static IActionBars
static IWorkbenchPartSite
static void
firePropertyChange
(ListenerList<IPropertyChangeListener> listenerList, Object source, String property, Object old, Object newValue) static void
firePropertyChange
(ListenerList<IPropertyChangeListener> listenerList, PropertyChangeEvent event) static boolean
getBoolean
(CompareConfiguration cc, String key, boolean dflt) static byte[]
static String
getCharset
(Object resource) static ICompareFilter[]
Returns the active compare filters for the compare configurationstatic IDocument
getDocument
(char type, Object element, boolean isUsingDefaultContentProvider, boolean canHaveSharedDocument) static IFile[]
getFiles
(ISelection selection) static IResource
getFirstResource
(ISelection selection) static String
getFormattedString
(String key, String arg) static String
getFormattedString
(String key, String arg0, String arg1) static String
getFormattedString
(ResourceBundle bundle, String key, String arg) static IPath
getIconPath
(Display display) static int
getInteger
(ResourceBundle bundle, String key, int dfltValue) static ITypedElement
static IResource[]
getResources
(ISelection selection) static String
static String
getString
(ResourceBundle bundle, String key) static String
getString
(ResourceBundle bundle, String key, String dfltValue) static String
getURLContents
(URL url, IRunnableContext context) Loads content of file underurl
displaying progress on given context.static void
initAction
(IAction a, ResourceBundle bundle, String prefix) static void
initToggleAction
(IAction a, ResourceBundle bundle, String prefix, boolean checked) static boolean
Return whether either the left or right sides of the given input represents a hunk.static boolean
static boolean
static String
readString
(InputStream is, String encoding) static String
readString
(InputStream is, String encoding, int length, IProgressMonitor monitor) static String
static String
readString
(IStreamContentAccessor sca, String encoding) static void
runInUIThread
(Runnable runnable) static void
schedule
(Job job, IWorkbenchSite site) static void
setEnableComposite
(Composite composite, boolean enable) static void
setMenuImage
(Item item) Sets the menu image for the givenItem
.static boolean
setReadTimeout
(URLConnection connection, int timeout) static boolean
validateResource
(IResource resource, Shell shell, String title) static boolean
validateResources
(List<IResource> resources, Shell shell, String title) static boolean
validateResources
(IResource[] resources, Shell shell, String title)
-
Field Details
-
RUNNING_TESTS
public static boolean RUNNING_TESTSConstant used to indicate that tests are being run. -
TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE
public static boolean TESTING_FLUSH_ON_COMPARE_INPUT_CHANGEConstant used while testing the indicate that changes should be flushed when the compare input changes and a viewer is dirty.
-
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
findSite
-
findActionBars
-
setEnableComposite
-
getBoolean
-
getCompareFilters
Returns the active compare filters for the compare configuration- Returns:
- the active compare filters
-
firePropertyChange
public static void firePropertyChange(ListenerList<IPropertyChangeListener> listenerList, Object source, String property, Object old, Object newValue) -
firePropertyChange
public static void firePropertyChange(ListenerList<IPropertyChangeListener> listenerList, PropertyChangeEvent event) -
okToUse
-
getResources
-
getFiles
-
getIconPath
-
initAction
-
initToggleAction
public static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) -
getString
-
getFormattedString
-
getString
-
getFormattedString
-
getFormattedString
-
getString
-
getInteger
-
validateResource
-
validateResources
-
validateResources
-
readString
- Throws:
CoreException
-
readString
- Throws:
IOException
-
readString
public static String readString(InputStream is, String encoding, int length, IProgressMonitor monitor) throws IOException - Throws:
IOException
-
getCharset
-
getBytes
-
readString
- Throws:
CoreException
-
close
-
getFirstResource
-
getLeg
-
getDocument
-
isHunk
Return whether either the left or right sides of the given input represents a hunk. A hunk is a portion of a file.- Parameters:
input
- the compare input- Returns:
- whether the left or right side of the input represents a hunk
-
isHunkOk
-
schedule
-
runInUIThread
-
setReadTimeout
- Parameters:
connection
- a connection for which the timeout is settimeout
- an int that specifies the connect timeout value in milliseconds- Returns:
- whether the timeout has been successfully set
-
getURLContents
public static String getURLContents(URL url, IRunnableContext context) throws InvocationTargetException, OperationCanceledException, InterruptedException Loads content of file underurl
displaying progress on given context.- Returns:
- the content of file under given URL, or
null
if URL could not be loaded - Throws:
InvocationTargetException
- thrown on errors while URL loadingOperationCanceledException
InterruptedException
-
applyCompareFilters
public static String applyCompareFilters(String thisLine, char thisContributor, String otherLine, char otherContributor, ICompareFilter[] filters) Applies the compare filters to the lines of text taken from the specified contributors- Parameters:
filters
- may be null- Returns:
- returns the result of applying the filters to the line from the contributor
-
executeRunnable
public static void executeRunnable(IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException Executes the given runnable. Uses theIProgressService
if available.- Parameters:
runnable
- TheIRunnableWithProgress
to execute.- Throws:
InvocationTargetException
InterruptedException
-
executeRunnable
public static void executeRunnable(IRunnableWithProgress runnable, boolean fork, boolean cancelable) throws InvocationTargetException, InterruptedException Executes the given runnable. Uses theIProgressService
if available.- Parameters:
runnable
- TheIRunnableWithProgress
to execute.fork
- indicates whether to run within a separate thread.cancelable
- indicates whether the operation shall be cancelable- Throws:
InvocationTargetException
InterruptedException
-
setMenuImage
Sets the menu image for the givenItem
. Uses the workbench shared image if available, otherwise creates a new image and adds a dispose listener.- Parameters:
item
- TheItem
for which the menu image is to be set.
-