Class CommonUI

java.lang.Object
org.eclipse.core.runtime.Plugin
org.eclipse.ui.plugin.AbstractUIPlugin
com._1c.g5.v8.dt.common.ui.CommonUI
All Implemented Interfaces:
org.osgi.framework.BundleActivator

public class CommonUI extends org.eclipse.ui.plugin.AbstractUIPlugin
Activator.
See Also:
  • AbstractUIPlugin
  • Field Details

  • Constructor Details

    • CommonUI

      public CommonUI()
  • Method Details

    • log

      public static void log(org.eclipse.core.runtime.IStatus status)
    • createErrorStatus

      public static org.eclipse.core.runtime.IStatus createErrorStatus(String msg, Throwable e)
    • createWarningStatus

      public static org.eclipse.core.runtime.IStatus createWarningStatus(String msg)
    • start

      public void start(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      start in interface org.osgi.framework.BundleActivator
      Overrides:
      start in class org.eclipse.ui.plugin.AbstractUIPlugin
      Throws:
      Exception
    • stop

      public void stop(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      stop in interface org.osgi.framework.BundleActivator
      Overrides:
      stop in class org.eclipse.ui.plugin.AbstractUIPlugin
      Throws:
      Exception
    • getBundledImage

      public org.eclipse.swt.graphics.Image getBundledImage(String path)
    • getImage

      public static org.eclipse.swt.graphics.Image getImage(String path)
    • getImageDescriptor

      public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(String path)
      Provides ImageDescriptor by image path
      Parameters:
      path - the image path, cannot be null
      Returns:
      ImageDescriptor, never null
    • getInstance

      public static CommonUI getInstance()
    • initializeImageRegistry

      protected void initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry reg)
      Overrides:
      initializeImageRegistry in class org.eclipse.ui.plugin.AbstractUIPlugin
    • syncRefresh

      public static void syncRefresh(Viewer viewer)
      Synchronously refreshes the given viewer.
      Parameters:
      viewer - the viewer to refresh.
    • asyncRefresh

      public static void asyncRefresh(Viewer viewer)
      Asynchronously refreshes the given viewer.
      Parameters:
      viewer - the viewer to refresh.
    • asyncRefresh

      public static void asyncRefresh(StructuredViewer viewer, Object element)
      Asynchronously refreshes the element of given viewer.
      Parameters:
      viewer - the viewer to refresh the element of.
      element - the element to refresh.
    • syncUpdateSelection

      public static void syncUpdateSelection(Viewer viewer, ISelection selection)
      Synchronously updates the selection of the given viewer.
      Parameters:
      viewer - the viewer to update the selection of.
      selection - the new selection.
    • asyncExec

      public static void asyncExec(Viewer viewer, Runnable runnable)
      Executes the given runnable asynchronously on a UI thread associated with the given viewer. Execution request is ignored if the viewer's control is disposed or workbench is not running.
      Parameters:
      viewer - the viewer to obtain a UI thread from.
      runnable - the runnable to execute.
    • syncExec

      public static void syncExec(Viewer viewer, Runnable runnable)
      Executes the given runnable synchronously on the UI thread associated with the given viewer. Execution request is ignored if the viewer's control is disposed or workbench is not running.
      Parameters:
      viewer - the viewer to obtain a UI thread from.
      runnable - the runnable to execute.
    • createNavigatorContentService

      public static org.eclipse.ui.navigator.INavigatorContentService createNavigatorContentService()
      Creates DT navigator content service. Each invocation creates a new content service instance which must be disposed when no longer needed. Content and label providers created via the returned service must be disposed as well.
      Returns:
      the created content service.
    • createNavigatorContentService

      public static org.eclipse.ui.navigator.INavigatorContentService createNavigatorContentService(StructuredViewer viewer)
      Creates DT navigator content service for the given viewer. Each invocation creates a new content service instance which must be disposed when no longer needed. Content and label providers created via the returned service must be disposed as well.
      Returns:
      the created content service.
    • runDeferredLayouts

      public static void runDeferredLayouts(org.eclipse.swt.widgets.Display display)
      Runs deferred layout for the given display. Use it as a workaround for the following Eclipse layout bug:
      1. User presses the mouse button on Navigator to select something in it. Eclipse makes call to Shell.setLayoutDeferred(true) to reduce the flickering of the toolbar while updating toolbar actions.
      2. While updating actions Eclipse also calls layout procedure with SWT.DEFER flag, that increases the number of deferred layout operations for the Shell.
      3. After that, subsequent call to Shell.setLayoutDeferred(false) will not trigger the replay of deferred layout operations since there were calls with SWT.DEFER flag. Such calls are replayed internally by the Display.runDeferredLayouts() on each attempt to process Display event queue events.
      4. DND subsystem disables the event processing while the mouse button is down. So the Display.runDeferredLayouts() call will not be made until user will release the mouse button.
      5. Eclipse totally disables the layout processing while user holds the mouse button down.
      Parameters:
      display - display to run deferred layouts for.
    • getCheckedStateImage

      public static org.eclipse.swt.graphics.Image getCheckedStateImage(CommonUI.CheckState checkState)
      Gets check state image.
      Parameters:
      checkState - the check state
      Returns:
      the image, may be null
    • getCheckedStateImage

      public static org.eclipse.swt.graphics.Image getCheckedStateImage(Boolean state)
      Gets the check state image from Boolean.
      Parameters:
      state - true to get the checked image, false to get the unchecked image, null to get the grayed/mixed/indeterminate image.
      Returns:
      the image, may not be null
    • clearSelectionOnRightClick

      public static void clearSelectionOnRightClick(org.eclipse.swt.widgets.Control control)
      Adds a mouse listener that clears selection for the given control if the mouse down event coordinates corresponds to empty space of the control.
      Parameters:
      control - the control, can be Table or Tree instance only.
      Throws:
      IllegalArgumentException - if the given control is not Table or Tree.
    • getColor

      public org.eclipse.swt.graphics.Color getColor(org.eclipse.swt.graphics.RGB rgb)
      Returns color for given rgb. User should not dispose returned color.
      Parameters:
      rgb - - rgb to get color.
      Returns:
      color for given rgb. Can't return null.