Package org.eclipse.compare.internal
Class Utilities
java.lang.Object
org.eclipse.compare.internal.Utilities
Convenience and utility methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanConstant used to indicate that tests are being run.static booleanConstant used while testing the indicate that changes should be flushed when the compare input changes and a viewer is dirty. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringapplyCompareFilters(String thisLine, char thisContributor, String otherLine, char otherContributor, ICompareFilter[] filters) Applies the compare filters to the lines of text taken from the specified contributorsstatic voidclose(InputStream is) static voidexecuteRunnable(IRunnableWithProgress runnable) Executes the given runnable.static voidexecuteRunnable(IRunnableWithProgress runnable, boolean fork, boolean cancelable) Executes the given runnable.static IActionBarsstatic IWorkbenchPartSitestatic voidfirePropertyChange(ListenerList<IPropertyChangeListener> listenerList, Object source, String property, Object old, Object newValue) static voidfirePropertyChange(ListenerList<IPropertyChangeListener> listenerList, PropertyChangeEvent event) static booleangetBoolean(CompareConfiguration cc, String key, boolean dflt) static byte[]static StringgetCharset(Object resource) static ICompareFilter[]Returns the active compare filters for the compare configurationstatic IDocumentgetDocument(char type, Object element, boolean isUsingDefaultContentProvider, boolean canHaveSharedDocument) static IFile[]getFiles(ISelection selection) static IResourcegetFirstResource(ISelection selection) static StringgetFormattedString(String key, String arg) static StringgetFormattedString(String key, String arg0, String arg1) static StringgetFormattedString(ResourceBundle bundle, String key, String arg) static IPathgetIconPath(Display display) static intgetInteger(ResourceBundle bundle, String key, int dfltValue) static ITypedElementstatic IResource[]getResources(ISelection selection) static Stringstatic StringgetString(ResourceBundle bundle, String key) static StringgetString(ResourceBundle bundle, String key, String dfltValue) static StringgetURLContents(URL url, IRunnableContext context) Loads content of file underurldisplaying progress on given context.static voidinitAction(IAction a, ResourceBundle bundle, String prefix) static voidinitToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) static booleanReturn whether either the left or right sides of the given input represents a hunk.static booleanstatic booleanstatic StringreadString(InputStream is, String encoding) static StringreadString(InputStream is, String encoding, int length, IProgressMonitor monitor) static Stringstatic StringreadString(IStreamContentAccessor sca, String encoding) static voidrunInUIThread(Runnable runnable) static voidschedule(Job job, IWorkbenchSite site) static voidsetEnableComposite(Composite composite, boolean enable) static voidsetMenuImage(Item item) Sets the menu image for the givenItem.static booleansetReadTimeout(URLConnection connection, int timeout) static booleanvalidateResource(IResource resource, Shell shell, String title) static booleanvalidateResources(List<IResource> resources, Shell shell, String title) static booleanvalidateResources(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 underurldisplaying progress on given context.- Returns:
- the content of file under given URL, or
nullif URL could not be loaded - Throws:
InvocationTargetException- thrown on errors while URL loadingOperationCanceledExceptionInterruptedException
-
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 theIProgressServiceif available.- Parameters:
runnable- TheIRunnableWithProgressto execute.- Throws:
InvocationTargetExceptionInterruptedException
-
executeRunnable
public static void executeRunnable(IRunnableWithProgress runnable, boolean fork, boolean cancelable) throws InvocationTargetException, InterruptedException Executes the given runnable. Uses theIProgressServiceif available.- Parameters:
runnable- TheIRunnableWithProgressto execute.fork- indicates whether to run within a separate thread.cancelable- indicates whether the operation shall be cancelable- Throws:
InvocationTargetExceptionInterruptedException
-
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- TheItemfor which the menu image is to be set.
-