コード例 #1
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.WorkbenchPart#dispose()
   */
  @Override
  public void dispose() {
    // Dispose the constraint panel
    constraintPanel.dispose();

    // Remove the selection listener
    getSite().getPage().removePostSelectionListener(this);
  }
コード例 #2
0
  /*
   *  As the selection changes, we see if the selection contains an EObject and update the context of the constraint panel
   *  with this object.
   */
  @Override
  public void selectionChanged(final IWorkbenchPart p_part, final ISelection p_selection) {
    // Reset the context for evaluating the entered constraint.
    EObject context = null;

    if (p_selection instanceof IStructuredSelection) {
      final IStructuredSelection structSel = (IStructuredSelection) p_selection;

      if (structSel.size() == 1) {
        final Object element =
            AdapterFactoryEditingDomain.unwrap(
                ((IStructuredSelection) p_selection).getFirstElement());

        // Set the context as the selected EObject if any.
        if (element instanceof EObject) {
          context = (EObject) element;
        } else if (element instanceof IAdaptable) {
          context = (EObject) ((IAdaptable) element).getAdapter(EObject.class);
        }
      }
    }

    constraintPanel.getActionHandler().setContext(context);
  }
コード例 #3
0
 /** Passing the focus request to the viewer's control. */
 @Override
 public void setFocus() {
   constraintPanel.setFocus();
 }