public Object getAdapter(Class adapter) {
   Object adapterObject = Platform.getAdapterManager().getAdapter(this, adapter);
   if (adapterObject == null) {
     adapterObject = Platform.getAdapterManager().loadAdapter(this, adapter.getName());
   }
   return adapterObject;
 }
Beispiel #2
0
 /**
  * return the IFile corresponding to the selection
  *
  * @param selectedObj selected file
  * @return
  */
 public static IFile getIFile(Object selectedObj) {
   IFile result = null;
   if (selectedObj instanceof IFile) {
     result = (IFile) selectedObj;
   }
   // Try to adapt
   if (result == null && selectedObj instanceof IAdaptable) {
     result = (IFile) ((IAdaptable) selectedObj).getAdapter(IFile.class);
   }
   // adapt in ifile
   if (result == null) {
     result = (IFile) Platform.getAdapterManager().getAdapter(selectedObj, IFile.class);
   }
   if (result == null) {
     // try to check if it is a collection
     Collection<?> collec =
         (Collection<?>) Platform.getAdapterManager().getAdapter(selectedObj, Collection.class);
     if (collec != null) {
       for (Object o : collec) {
         if (o instanceof IFile) {
           IFile f = (IFile) o;
           if ("di".equals(f.getFileExtension())) { // $NON-NLS-1$
             result = f;
             break;
           }
         }
       }
     }
   }
   return result != null && "di".equals(result.getFileExtension())
       ? result //$NON-NLS-1$
       : null;
 }
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
   */
  @Override
  public void start(BundleContext context) throws Exception {
    fgBundleContext = context;
    super.start(context);
    DEBUG =
        "true"
            .equals(
                Platform.getDebugOption(
                    "org.eclipse.cdt.dsf.ui/debug")); //$NON-NLS-1$//$NON-NLS-2$

    fSourceDocumentProvider = new SourceDocumentProvider();

    EvaluationContextManager.startup();

    // Register the DSF backend for our disassembly view (the CDT debug UI
    // plugin registers the CDI one)
    Platform.getAdapterManager()
        .registerAdapters(new DisassemblyBackendDsfFactory(), IDMVMContext.class);
    // Register the factory that provides descriptions of stack frames
    // to the CSourceNotFoundEditor.
    Platform.getAdapterManager()
        .registerAdapters(new CSourceNotFoundDescriptionFactory(), IFrameDMContext.class);

    DsfDebugUITools.enableActivity("org.eclipse.cdt.debug.ui.cdtActivity", true); // $NON-NLS-1$
  }
 private synchronized IConnectionFileManager getConnectionFileManager() {
   if (connectionFileManager == null) {
     // find contributed first
     connectionFileManager =
         (IFTPConnectionFileManager) super.getAdapter(IFTPConnectionFileManager.class);
     if (connectionFileManager == null
         && Platform.getAdapterManager()
             .hasAdapter(this, IFTPConnectionFileManager.class.getName())) {
       connectionFileManager =
           (IFTPConnectionFileManager)
               Platform.getAdapterManager()
                   .loadAdapter(this, IFTPConnectionFileManager.class.getName());
     }
     if (connectionFileManager == null) {
       connectionFileManager = new FTPConnectionFileManager();
     }
     ConnectionContext context = CoreIOPlugin.getConnectionContext(this);
     if (context != null) {
       CoreIOPlugin.setConnectionContext(connectionFileManager, context);
     }
     connectionFileManager.init(
         host, port, path, login, password, passiveMode, transferType, encoding, timezone);
   }
   return connectionFileManager;
 }
  @Override
  public Object execute(final ExecutionEvent event) throws ExecutionException {
    // Get the currently selected item
    final ISelection sel = HandlerUtil.getActiveMenuSelection(event);
    // Get the filter parameter for the command
    final String var = event.getParameter(PlayUsesPortHandler.FILTER_PARAM);
    // Check if we should send each play command individually or as a group
    final boolean sendList =
        Boolean.parseBoolean(event.getParameter(PlayUsesPortHandler.LIST_PARAM));
    // Get the ports variable for the command - this is only used via programmatic command execution
    final Object ports = HandlerUtil.getVariable(event, PlayUsesPortHandler.PORTS_VAR);

    String message = null;
    final List<ScaUsesPort> portList = new ArrayList<ScaUsesPort>();

    // First, check if we're called from a menu
    if ((sel != null) && (sel instanceof IStructuredSelection)) {
      final IStructuredSelection ss = (IStructuredSelection) sel;
      for (final Object element : ss.toList()) {
        if (element instanceof ScaUsesPort) {
          final ScaUsesPort port = (ScaUsesPort) element;
          portList.add(port);
        } else {
          final Object obj = Platform.getAdapterManager().getAdapter(element, ScaUsesPort.class);
          if (obj instanceof ScaUsesPort) {
            portList.add((ScaUsesPort) obj);
          }
        }
      }

      // If it's called programmatically, ports should be a list of ScaPort objects
    } else if ((ports != null) && (ports instanceof List)) {
      for (final Object element : (List<?>) ports) {
        if (element instanceof ScaUsesPort) {
          final ScaUsesPort port = ((ScaUsesPort) element);
          portList.add(port);
        } else {
          final Object obj = Platform.getAdapterManager().getAdapter(element, ScaUsesPort.class);
          if (obj instanceof ScaUsesPort) {
            portList.add((ScaUsesPort) obj);
          }
        }
      }
    } else {
      message = "Unable to determine what to play";
    }

    // Check if we found any ports to play
    if (portList.size() > 0) {
      message = playPort(var, portList, sendList);
    }

    // Any errors will be put into message
    if (message != null) {
      MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Unable to Play", message);
    }
    return null;
  }
  /** @generated */
  static {
    final Class[] supportedTypes = new Class[] {ITabbedPropertySheetPageContributor.class};
    final ITabbedPropertySheetPageContributor propertySheetPageContributor =
        new ITabbedPropertySheetPageContributor() {
          public String getContributorId() {
            return "edu.toronto.cs.se.modelepedia.graph_mavo.diagram"; //$NON-NLS-1$
          }
        };
    Platform.getAdapterManager()
        .registerAdapters(
            new IAdapterFactory() {

              public Object getAdapter(Object adaptableObject, Class adapterType) {
                if (adaptableObject
                        instanceof
                        edu.toronto.cs.se.modelepedia.graph_mavo.diagram.navigator
                            .Graph_MAVOAbstractNavigatorItem
                    && adapterType == ITabbedPropertySheetPageContributor.class) {
                  return propertySheetPageContributor;
                }
                return null;
              }

              public Class[] getAdapterList() {
                return supportedTypes;
              }
            },
            edu.toronto.cs.se.modelepedia.graph_mavo.diagram.navigator
                .Graph_MAVOAbstractNavigatorItem.class);
  }
  /**
   * Copied from Util.getAdapter (from eclipse 3.3: not available in eclipse 3.2)
   *
   * <p>If it is possible to adapt the given object to the given type, this returns the adapter.
   * Performs the following checks:
   *
   * <ol>
   *   <li>Returns <code>sourceObject</code> if it is an instance of the adapter type.
   *   <li>If sourceObject implements IAdaptable, it is queried for adapters.
   *   <li>If sourceObject is not an instance of PlatformObject (which would have already done so),
   *       the adapter manager is queried for adapters
   * </ol>
   *
   * Otherwise returns null.
   *
   * @param sourceObject object to adapt, or null
   * @param adapterType type to adapt to
   * @return a representation of sourceObject that is assignable to the adapter type, or null if no
   *     such representation exists
   */
  public static Object utilGetAdapter(Object sourceObject, Class adapterType) {
    Assert.isNotNull(adapterType);
    if (sourceObject == null) {
      return null;
    }
    if (adapterType.isInstance(sourceObject)) {
      return sourceObject;
    }

    if (sourceObject instanceof IAdaptable) {
      IAdaptable adaptable = (IAdaptable) sourceObject;

      Object result = adaptable.getAdapter(adapterType);
      if (result != null) {
        // Sanity-check
        Assert.isTrue(adapterType.isInstance(result));
        return result;
      }
    }

    if (!(sourceObject instanceof PlatformObject)) {
      Object result = Platform.getAdapterManager().getAdapter(sourceObject, adapterType);
      if (result != null) {
        return result;
      }
    }

    return null;
  }
  /** @generated */
  static {
    @SuppressWarnings("rawtypes")
    final Class[] supportedTypes = new Class[] {View.class, EObject.class};
    Platform.getAdapterManager()
        .registerAdapters(
            new IAdapterFactory() {

              @SuppressWarnings("rawtypes")
              public Object getAdapter(Object adaptableObject, Class adapterType) {
                if (adaptableObject
                        instanceof
                        org.eclipse.papyrus.uml.diagram.profile.navigator.UMLNavigatorItem
                    && (adapterType == View.class || adapterType == EObject.class)) {
                  return ((org.eclipse.papyrus.uml.diagram.profile.navigator.UMLNavigatorItem)
                          adaptableObject)
                      .getView();
                }
                return null;
              }

              @SuppressWarnings("rawtypes")
              public Class[] getAdapterList() {
                return supportedTypes;
              }
            },
            org.eclipse.papyrus.uml.diagram.profile.navigator.UMLNavigatorItem.class);
  }
  /** @generated */
  static {
    final Class[] supportedTypes = new Class[] {View.class, EObject.class};
    Platform.getAdapterManager()
        .registerAdapters(
            new IAdapterFactory() {

              public Object getAdapter(Object adaptableObject, Class adapterType) {
                if (adaptableObject
                        instanceof
                        edu.toronto.cs.se.modelepedia.powerwindow.diagram.navigator
                            .PowerWindowNavigatorItem
                    && (adapterType == View.class || adapterType == EObject.class)) {
                  return ((edu.toronto.cs.se.modelepedia.powerwindow.diagram.navigator
                              .PowerWindowNavigatorItem)
                          adaptableObject)
                      .getView();
                }
                return null;
              }

              public Class[] getAdapterList() {
                return supportedTypes;
              }
            },
            edu.toronto.cs.se.modelepedia.powerwindow.diagram.navigator.PowerWindowNavigatorItem
                .class);
  }
  protected List getContributors(Object object) {
    // Determine is the object is a resource
    Object resource = LegacyResourceSupport.getAdaptedContributorResource(object);

    // Fetch the unique adapters
    List adapters =
        new ArrayList(
            Arrays.asList(Platform.getAdapterManager().computeAdapterTypes(object.getClass())));
    removeCommonAdapters(adapters, Arrays.asList(new Class[] {object.getClass()}));

    List contributors = new ArrayList();

    // Calculate the contributors for this object class
    addAll(contributors, getObjectContributors(object.getClass()));
    // Calculate the contributors for resource classes
    if (resource != null) {
      addAll(contributors, getResourceContributors(resource.getClass()));
    }
    // Calculate the contributors for each adapter type
    if (adapters != null) {
      for (Iterator it = adapters.iterator(); it.hasNext(); ) {
        String adapter = (String) it.next();
        addAll(contributors, getAdaptableContributors(adapter));
      }
    }

    // Remove duplicates.  Note: this -must- maintain the element order to preserve menu order.
    contributors = removeDups(contributors);

    return contributors.isEmpty() ? Collections.EMPTY_LIST : new ArrayList(contributors);
  }
 /* (non-Javadoc)
  * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
  */
 public Object getAdapter(Class adapter) {
   if (adapter == ISharedDocumentAdapter.class) {
     if (isSharedDocumentsEnable()) return getSharedDocumentAdapter();
     else return null;
   }
   return Platform.getAdapterManager().getAdapter(this, adapter);
 }
  /** @generated */
  static {
    final Class[] supportedTypes = new Class[] {ITabbedPropertySheetPageContributor.class};
    final ITabbedPropertySheetPageContributor propertySheetPageContributor =
        new ITabbedPropertySheetPageContributor() {

          public String getContributorId() {
            return "org.eclipse.gmf.graphdef.editor"; //$NON-NLS-1$
          }
        };
    Platform.getAdapterManager()
        .registerAdapters(
            new IAdapterFactory() {

              public Object getAdapter(Object adaptableObject, Class adapterType) {
                if (adaptableObject
                        instanceof
                        org.eclipse.gmf.graphdef.editor.navigator.GMFGraphAbstractNavigatorItem
                    && adapterType == ITabbedPropertySheetPageContributor.class) {
                  return propertySheetPageContributor;
                }
                return null;
              }

              public Class[] getAdapterList() {
                return supportedTypes;
              }
            },
            org.eclipse.gmf.graphdef.editor.navigator.GMFGraphAbstractNavigatorItem.class);
  }
  /** @generated */
  static {
    final Class[] supportedTypes = new Class[] {View.class, EObject.class};
    Platform.getAdapterManager()
        .registerAdapters(
            new IAdapterFactory() {

              public Object getAdapter(Object adaptableObject, Class adapterType) {
                if (adaptableObject
                        instanceof
                        org.spbu.pldoctoolkit.graph.diagram.fproduct.navigator.DrlModelNavigatorItem
                    && (adapterType == View.class || adapterType == EObject.class)) {
                  return ((org.spbu.pldoctoolkit.graph.diagram.fproduct.navigator
                              .DrlModelNavigatorItem)
                          adaptableObject)
                      .getView();
                }
                return null;
              }

              public Class[] getAdapterList() {
                return supportedTypes;
              }
            },
            org.spbu.pldoctoolkit.graph.diagram.fproduct.navigator.DrlModelNavigatorItem.class);
  }
  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
   */
  public void stop(final BundleContext context) throws Exception {
    plugin = null;

    for (final Map.Entry<Class<?>, IAdapterFactory> entry : this.adaperFactories.entrySet()) {
      Platform.getAdapterManager().registerAdapters(entry.getValue(), entry.getKey());
    }

    super.stop(context);
  }
  /**
   * {@inheritDoc}
   *
   * <p>Subclasses may override this method (however, if they do so, they should invoke the method
   * on their superclass to ensure that the Platform's adapter manager is consulted).
   */
  public Object getAdapter(Class adapter) {

    /**
     * This implementation of the method declared by <code>IAdaptable</code> passes the request
     * along to the platform's adapter manager; roughly <code>
     * Platform.getAdapterManager().getAdapter(this, adapter)</code>.
     */
    return Platform.getAdapterManager().getAdapter(this, adapter);
  }
  public Object execute(ExecutionEvent event) throws ExecutionException {
    final Shell activeShell = HandlerUtil.getActiveShell(event);
    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);

    if (currentSelection instanceof IStructuredSelection) {
      IStructuredSelection selection = (IStructuredSelection) currentSelection;
      if (selection.isEmpty()) {
        return null;
      }

      Iterator<?> selectionIterator = selection.iterator();
      while (selectionIterator.hasNext()) {
        Object selectedElement = selectionIterator.next();
        IFile file = (IFile) Platform.getAdapterManager().getAdapter(selectedElement, IFile.class);
        if (file != null && "psf".equals(file.getLocation().getFileExtension())) { // $NON-NLS-1$
          final String fileName = file.getLocation().toString();

          Job job =
              new Job(String.format("Import %s", file.getName())) {

                @Override
                protected IStatus run(IProgressMonitor monitor) {
                  AbstractOperation operation =
                      new ImportProjectSetOperation(getName(), fileName, activeShell);

                  try {
                    final IStatus result =
                        OperationHistoryFactory.getOperationHistory()
                            .execute(operation, monitor, null);

                    if (monitor.isCanceled() || result.getSeverity() == IStatus.CANCEL) {
                      // TODO: Abort or Undo
                    }

                    return result;
                  } catch (ExecutionException ex) {
                    Activator.log.error(ex);
                    return new Status(
                        IStatus.ERROR,
                        Activator.PLUGIN_ID,
                        String.format("An error occurred when importing the PSF %s", fileName),
                        ex);
                  }
                }
              };

          job.setUser(true);
          job.schedule();

          job.setPriority(Job.LONG);
        }
      }
    }

    return null;
  }
  /**
   * Returns the peer node context.
   *
   * @param context The context. Must not be <code>null</code>.
   * @return The peer node context.
   */
  protected IPeerNode getPeerNodeContext(Object context) {
    IPeerNode peerNode = null;
    if (context instanceof IPeerNode) return (IPeerNode) context;
    if (context instanceof IAdaptable)
      peerNode = (IPeerNode) ((IAdaptable) context).getAdapter(IPeerNode.class);
    if (peerNode == null)
      peerNode = (IPeerNode) Platform.getAdapterManager().getAdapter(context, IPeerNode.class);

    return peerNode;
  }
 @SuppressWarnings("unchecked")
 public static <T> T getSingleNavigationSelection(Class<T> clazz) {
   Object o = getNavigationSelectionObject();
   if (o instanceof Collection) {
     Collection<?> col = (Collection<?>) o;
     if (col.isEmpty()) return null;
     o = col.iterator().next();
   }
   return (T) Platform.getAdapterManager().getAdapter(o, clazz);
 }
 protected final IWorkbenchAdapter getAdapter(Object element) {
   IWorkbenchAdapter adapter = null;
   if (element instanceof IAdaptable)
     adapter = (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class);
   if (adapter == null)
     adapter =
         (IWorkbenchAdapter)
             Platform.getAdapterManager().loadAdapter(element, IWorkbenchAdapter.class.getName());
   return adapter;
 }
 private IResource adaptToResource(Object selected) {
   IResource resource;
   if (selected instanceof IResource) {
     resource = (IResource) selected;
   } else if (selected instanceof IAdaptable) {
     resource = (IResource) ((IAdaptable) selected).getAdapter(IRESOURCE_TYPE);
   } else {
     resource = (IResource) Platform.getAdapterManager().getAdapter(selected, IRESOURCE_TYPE);
   }
   return resource;
 }
Beispiel #21
0
  @Override
  public void stop(BundleContext context) throws Exception {
    TmfUiTracer.stop();
    TmfUiRefreshHandler.getInstance().dispose();
    plugin = null;

    Platform.getAdapterManager().unregisterAdapters(fTmfEventAdapterFactory);
    TmfTraceAdapterManager.unregisterFactory(fLostEventMarkerEventSourceFactory);
    fLostEventMarkerEventSourceFactory.dispose();
    super.stop(context);
  }
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   ISelection selection =
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
   if (!(selection instanceof StructuredSelection)) return null;
   Object selected = ((StructuredSelection) selection).getFirstElement();
   IResource resource = null;
   String path = "";
   if (selected instanceof IFile) {
     resource = (IResource) Platform.getAdapterManager().getAdapter(selected, IResource.class);
     path = resource.getLocation().toString();
     new ResultGenerator().parser(path);
   } else if (selected instanceof PlatformObject) {
     resource = (IResource) Platform.getAdapterManager().getAdapter(selected, IResource.class);
     path = resource.getLocation().toString();
     if (resource.getFileExtension() != null && resource.getFileExtension().equals("jar")) {
       new ResultGenerator().parser(path);
     }
   }
   return null;
 }
Beispiel #23
0
  protected boolean isPage(EObject element, IPageManager pageManager) {
    if (element == null) {
      return false;
    }

    if (pageManager.allPages().contains(element)) {
      return true;
    }

    Object openable = Platform.getAdapterManager().getAdapter(element, IOpenable.class);
    return openable instanceof IOpenable;
  }
Beispiel #24
0
 private void addCandidates(
     IStructuredSelection selection, IContextFilter filter, List<IPeerNode> candidates) {
   if (selection != null) {
     Iterator<Object> it = selection.iterator();
     while (it.hasNext()) {
       addCandidate(
           (IPeerNode) Platform.getAdapterManager().getAdapter(it.next(), IPeerNode.class),
           filter,
           candidates);
     }
   }
 }
 protected void treeItemSelected(SelectionEvent e) {
   if (e.detail == SWT.CHECK && isChecking == false) {
     isChecking = true;
     try {
       Object data = e.item.getData();
       ViewInfo viewInfo =
           (ViewInfo) Platform.getAdapterManager().getAdapter(data, ViewInfo.class);
       TreeItem item = (TreeItem) Platform.getAdapterManager().getAdapter(e.item, TreeItem.class);
       if (viewInfo != null && item != null && getTreeViewer().getTree().getItems() != null) {
         if (viewInfo.isSelectable()) {
           setAllVisualIDsChecked(
               getTreeViewer().getTree().getItems(), viewInfo.getVisualID(), item.getChecked());
         } else {
           item.setChecked(!item.getChecked());
         }
       }
     } finally {
       isChecking = false;
     }
   }
 }
  /**
   * Retrieve the contributor from the selection.
   *
   * @param object - the selected element
   * @return the TabbedPropertySheetPageContributor or null if not applicable
   */
  private ITabbedPropertySheetPageContributor getTabbedPropertySheetPageContributor(
      final Object object) {
    if (object instanceof ITabbedPropertySheetPageContributor) {
      return (ITabbedPropertySheetPageContributor) object;
    }

    if (object instanceof IAdaptable
        && ((IAdaptable) object).getAdapter(ITabbedPropertySheetPageContributor.class) != null) {
      return (ITabbedPropertySheetPageContributor)
          ((IAdaptable) object).getAdapter(ITabbedPropertySheetPageContributor.class);
    }

    if (Platform.getAdapterManager()
        .hasAdapter(object, ITabbedPropertySheetPageContributor.class.getName())) {
      return (ITabbedPropertySheetPageContributor)
          Platform.getAdapterManager()
              .loadAdapter(object, ITabbedPropertySheetPageContributor.class.getName());
    }

    return null;
  }
Beispiel #27
0
 @SuppressWarnings("rawtypes")
 private Object getContributedAdapter(Class clazz) {
   Object adapter = null;
   IAdapterManager manager = Platform.getAdapterManager();
   if (manager.hasAdapter(this, clazz.getName())) {
     adapter = manager.getAdapter(this, clazz.getName());
     if (adapter == null) {
       adapter = manager.loadAdapter(this, clazz.getName());
     }
   }
   return adapter;
 }
  /**
   * Adapt the specified object to the requested type, if possible. Return null if the object can't
   * be adapted.
   *
   * @param object
   * @param expectedClassType
   * @return The adapted object, or null.
   */
  private <T> T adapt(Object object, Class<T> expectedClassType) {

    if (object instanceof IAdaptable) {
      @SuppressWarnings("unchecked")
      T ele = (T) ((IAdaptable) object).getAdapter(expectedClassType);
      if (ele != null) {
        return ele;
      }
      // Try as EObject if the expectedClasType is sub-type of EObject.
      if (EObject.class.isAssignableFrom(expectedClassType)) {
        // to EObject
        EObject eobject = (EObject) ((IAdaptable) object).getAdapter(EObject.class);

        if (eobject != null && expectedClassType.isInstance(eobject)) {
          return (T) eobject;
        }
      }
    }

    // Try global mechanism
    {
      @SuppressWarnings("unchecked")
      T ele = (T) Platform.getAdapterManager().getAdapter(object, expectedClassType);
      if (ele != null) {
        return ele;
      }
      // Try as EObject if the expectedClasType is sub-type of EObject.
      if (EObject.class.isAssignableFrom(expectedClassType)) {
        // to EObject
        EObject eobject = (EObject) Platform.getAdapterManager().getAdapter(object, EObject.class);

        if (eobject != null && expectedClassType.isInstance(eobject)) {

          return (T) eobject;
        }
      }
    }
    // Can't be adapted
    return null;
  }
Beispiel #29
0
  @Override
  public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    TmfUiRefreshHandler.getInstance(); // to classload/initialize it
    TmfUiTracer.init();
    TmfTraceElement.init();
    TmfExperimentElement.init();

    fTmfEventAdapterFactory = new TmfEventAdapterFactory();
    Platform.getAdapterManager().registerAdapters(fTmfEventAdapterFactory, ITmfEvent.class);
    fLostEventMarkerEventSourceFactory = new LostEventsMarkerEventSourceFactory();
    TmfTraceAdapterManager.registerFactory(fLostEventMarkerEventSourceFactory, ITmfTrace.class);
  }
 /**
  * When one element from the tree is selected, all elements with the same VisualID are put into
  * the same state (checked or unchecked).
  *
  * @param items
  * @param visualID
  * @param check
  */
 protected void setAllVisualIDsChecked(TreeItem[] items, int visualID, boolean check) {
   ViewInfo viewInfo = null;
   for (TreeItem item : items) {
     if (item != null) {
       viewInfo =
           (ViewInfo) Platform.getAdapterManager().getAdapter(item.getData(), ViewInfo.class);
       if (viewInfo != null && visualID == viewInfo.getVisualID()) {
         item.setChecked(check);
       }
       if (item.getItems() != null) {
         setAllVisualIDsChecked(item.getItems(), visualID, check);
       }
     }
   }
 }