/**
  * Constructor.
  *
  * @param parent
  * @param style
  */
 public ContextNebulaGridComposite(Composite parent, IContextModelManager manager) {
   super(parent, SWT.NONE);
   modelManager = manager;
   buttonList = new ArrayList<Button>();
   this.helper = new ContextManagerHelper(manager.getContextManager());
   this.setLayout(GridLayoutFactory.swtDefaults().spacing(0, 0).create());
   initializeUI();
   // for bug TDI-32674 to set different bgColor of ContextView and RepositoryContextComposite.
   if (modelManager instanceof ContextComposite
       && ((ContextComposite) modelManager).isRepositoryContext()) {
     this.setBackground(parent.getBackground());
   } else {
     // CSS
     CoreUIPlugin.setCSSClass(this, this.getClass().getSimpleName());
   }
 }
  /**
   * ggu Comment method "changeContextOrder".
   *
   * <p>order the context parameter
   */
  public static boolean changeContextOrder(
      TreeViewer viewer, IContextModelManager modelManager, boolean up) {
    if (viewer == null || modelManager == null) {
      return false;
    }
    final ISelection selection = viewer.getSelection();
    if (selection == null || selection.isEmpty()) {
      return false;
    }
    if (!(selection instanceof IStructuredSelection)) {
      return false;
    }
    IStructuredSelection sSection = (IStructuredSelection) selection;
    if (sSection.size() != 1) { // not support multi-selection
      return false;
    }

    Object element = sSection.getFirstElement();
    IContextParameter movedParam = null;
    if (element instanceof ContextVariableTabParentModel) {
      movedParam = ((ContextVariableTabParentModel) element).getContextParameter();
    }

    if (element instanceof ContextTableTabParentModel) {
      movedParam = ((ContextTableTabParentModel) element).getContextParameter();
    }
    if (movedParam == null) {
      return false;
    }

    OrderContextParameterCommand orderCommand =
        new OrderContextParameterCommand(modelManager.getContextManager(), movedParam, up);
    final CommandStack commandStack = modelManager.getCommandStack();
    if (commandStack != null) {
      commandStack.execute(orderCommand);
    } else {
      orderCommand.execute();
    }
    //
    modelManager.refresh();

    revertTreeSelection(viewer, movedParam);

    return orderCommand.isExecution();
  }
  /**
   * ggu Comment method "changeContextOrder".
   *
   * <p>order the context parameter
   */
  public static boolean changeContextOrder(
      ISelection selObj, IContextModelManager modelManager, boolean up) {
    if (selObj == null || selObj.isEmpty()) {
      return false;
    }
    if (!(selObj instanceof IStructuredSelection)) {
      return false;
    }
    IStructuredSelection sSection = (IStructuredSelection) selObj;
    if (sSection.size() != 1) { // not support multi-selection
      return false;
    }

    Object element = sSection.getFirstElement();
    Object model = ((ContextTreeNode) element).getTreeData();
    IContextParameter movedParam = null;

    if (model instanceof ContextTableTabParentModel) {
      movedParam = ((ContextTableTabParentModel) model).getContextParameter();
    } else if (model instanceof ContextTableTabChildModel) { // for bug TDI-32821
      movedParam = ((ContextTableTabChildModel) model).getContextParameter();
    }
    if (movedParam == null) {
      return false;
    }

    OrderContextParameterCommand orderCommand =
        new OrderContextParameterCommand(modelManager.getContextManager(), movedParam, up);
    final CommandStack commandStack = modelManager.getCommandStack();
    if (commandStack != null) {
      commandStack.execute(orderCommand);
    } else {
      orderCommand.execute();
    }

    modelManager.refresh();

    return orderCommand.isExecution();
  }
 public IContextManager getContextManager() {
   return modelManager.getContextManager();
 }