/** {@inheritDoc} */
  public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);
    /*
     * We set the color as it's a InterpretedExpression
     */
    text.setBackground(SiriusEditor.getColorRegistry().get("yellow"));

    text.setToolTipText(getToolTipText());

    help = getWidgetFactory().createCLabel(composite, "");
    FormData data = new FormData();
    data.top = new FormAttachment(text, 0, SWT.TOP);
    data.left = new FormAttachment(nameLabel);
    help.setLayoutData(data);
    help.setImage(getHelpIcon());
    help.setToolTipText(getToolTipText());
    nameLabel.setFont(SiriusEditor.getFontRegistry().get("required"));

    TypeContentProposalProvider.bindPluginsCompletionProcessors(this, text);

    // Start of user code create controls

    // End of user code create controls

  }
  /** @see org.eclipse.ui.views.properties.tabbed.view.ITabbedPropertySection#refresh() */
  public void refresh() {
    super.refresh();

    final String tooltip = getToolTipText();
    if (tooltip != null && help != null) {
      help.setToolTipText(getToolTipText());
    }
  }
  /** {@inheritDoc} */
  public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);
    combo.setToolTipText(
        "Tool to call when the user ask for deletion. If you don't set this reference then\nthe default behavior is to remove all the associated semantic elements.");

    CLabel help = getWidgetFactory().createCLabel(composite, "");
    FormData data = new FormData();
    data.top = new FormAttachment(combo, 0, SWT.TOP);
    data.left = new FormAttachment(nameLabel);
    help.setLayoutData(data);
    help.setImage(getHelpIcon());
    help.setToolTipText(
        "Tool to call when the user ask for deletion. If you don't set this reference then\nthe default behavior is to remove all the associated semantic elements.");
    // Start of user code create controls

    // End of user code create controls
  }
  /**
   * Updates the message label widget.
   *
   * @since 3.0
   */
  private void updateMessageLabel() {
    if (fLabel != null && !fLabel.isDisposed()) {
      Display display = fLabel.getDisplay();
      if ((fErrorText != null && fErrorText.length() > 0) || fErrorImage != null) {
        String escapedErrorText = escape(fErrorText);
        fLabel.setForeground(JFaceColors.getErrorText(display));
        fLabel.setText(escapedErrorText);
        fLabel.setImage(fErrorImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fErrorText.length() > fWidthInChars) fLabel.setToolTipText(escapedErrorText);
        else fLabel.setToolTipText(null);

      } else {
        String escapedText = escape(fText);
        fLabel.setForeground(fLabel.getParent().getForeground());
        fLabel.setText(escapedText);
        fLabel.setImage(fImage);
        if (fToolTipText != null) fLabel.setToolTipText(escape(fToolTipText));
        else if (fText != null && fText.length() > fWidthInChars)
          fLabel.setToolTipText(escapedText);
        else fLabel.setToolTipText(null);
      }
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createDialogArea(Composite theParent) {
    originalLanguageObjLabel =
        WidgetFactory.createLabel(theParent, CoreStringUtil.Constants.EMPTY_STRING);
    Composite pnlContents = (Composite) super.createDialogArea(theParent);

    //
    // main panel contents
    //

    CTabFolder tabFolder = WidgetFactory.createTabFolder(pnlContents);

    //
    // tabFolder contents - 2 tabs (Tree, SQL Text), each with a splitter
    //

    CTabItem treeTab =
        WidgetFactory.createTab(tabFolder, Util.getString(PREFIX + "treeTab")); // $NON-NLS-1$
    treeTab.setToolTipText(Util.getString(PREFIX + "treeTab.tip")); // $NON-NLS-1$

    SashForm treeTabSash = new SashForm(tabFolder, SWT.VERTICAL);
    treeTabSash.setLayoutData(new GridData(GridData.FILL_BOTH));
    treeTab.setControl(treeTabSash);

    CTabItem sqlTab =
        WidgetFactory.createTab(tabFolder, Util.getString(PREFIX + "sqlTab")); // $NON-NLS-1$
    sqlTab.setToolTipText(Util.getString(PREFIX + "sqlTab.tip")); // $NON-NLS-1$

    SashForm sqlTabSash = new SashForm(tabFolder, SWT.VERTICAL);
    sqlTabSash.setLayoutData(new GridData(GridData.FILL_BOTH));
    sqlTab.setControl(sqlTabSash);

    //
    // treeTab contents
    //

    ViewForm formTree = new ViewForm(treeTabSash, SWT.BORDER);
    Composite pnlTree = new Composite(formTree, SWT.NO_TRIM);
    formTree.setContent(pnlTree);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    pnlTree.setLayout(layout);
    pnlTree.setLayoutData(new GridData(GridData.FILL_BOTH));

    ViewForm formEditor = new ViewForm(treeTabSash, SWT.BORDER);
    pnlEditor = new Composite(formEditor, SWT.NO_TRIM);
    formEditor.setContent(pnlEditor);
    pnlEditor.setLayoutData(new GridData(GridData.FILL_BOTH));

    lblTitle = new Label(formEditor, SWT.CENTER);
    lblTitle.setBackground(BuilderUtils.COLOR_HIGHLIGHT);
    formEditor.setTopLeft(lblTitle);

    treeTabSash.setWeights(new int[] {30, 70});

    //
    // sqlTab contents
    //

    ViewForm formCurrentSql = new ViewForm(sqlTabSash, SWT.BORDER);
    ViewForm formOriginalSql = new ViewForm(sqlTabSash, SWT.BORDER);

    //
    // formCurrentSql contents
    //

    Composite pnlCurrentSql = new Composite(formCurrentSql, SWT.NONE);
    formCurrentSql.setContent(pnlCurrentSql);
    pnlCurrentSql.setLayout(new GridLayout());
    pnlCurrentSql.setLayoutData(new GridData(GridData.FILL_BOTH));

    currentSql = new SqlDisplayPanel(pnlCurrentSql);
    currentSql.setLayoutData(new GridData(GridData.FILL_BOTH));

    CLabel lblCurrent = new CLabel(formCurrentSql, SWT.NONE);
    lblCurrent.setBackground(BuilderUtils.COLOR_HIGHLIGHT);
    lblCurrent.setText(Util.getString(PREFIX + "lblCurrent")); // $NON-NLS-1$
    lblCurrent.setToolTipText(Util.getString(PREFIX + "lblCurrent.tip")); // $NON-NLS-1$
    formCurrentSql.setTopLeft(lblCurrent);

    //
    // formOriginalSql contents
    //

    Composite pnlOriginalSql = new Composite(formOriginalSql, SWT.NONE);
    formOriginalSql.setContent(pnlOriginalSql);
    pnlOriginalSql.setLayout(new GridLayout());
    pnlOriginalSql.setLayoutData(new GridData(GridData.FILL_BOTH));

    originalSql = new SqlDisplayPanel(pnlOriginalSql);
    originalSql.setLayoutData(new GridData(GridData.FILL_BOTH));

    CLabel lblOriginal = new CLabel(formOriginalSql, SWT.NONE);
    lblOriginal.setBackground(BuilderUtils.COLOR_HIGHLIGHT);
    lblOriginal.setText(Util.getString(PREFIX + "lblOriginal")); // $NON-NLS-1$
    lblOriginal.setToolTipText(Util.getString(PREFIX + "lblOriginal.tip")); // $NON-NLS-1$
    formOriginalSql.setTopLeft(lblOriginal);

    //
    // pnlTree contents - 2 columns (tree viewer, button panel)
    //

    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    pnlTree.setLayout(layout);

    treeViewer = new LanguageObjectBuilderTreeViewer(pnlTree);
    treeViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent theEvent) {
            handleTreeSelection();
          }
        });

    MenuManager menuMgr = new MenuManager();
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(
        new IMenuListener() {
          @Override
          public void menuAboutToShow(IMenuManager theMenuMgr) {
            fillContextMenu(theMenuMgr);
          }
        });
    treeViewer.getTree().setMenu(menuMgr.createContextMenu(treeViewer.getTree()));

    Composite pnlButtons = new Composite(pnlTree, SWT.NONE);
    pnlButtons.setLayout(new GridLayout());

    createTreeButtons(pnlButtons);

    //
    // pnlEditor contents
    //

    layout = new GridLayout();
    layout.numColumns = 2;
    pnlEditor.setLayout(layout);

    pnlEditorDetail = new Composite(pnlEditor, SWT.NONE);
    pnlEditorDetail.setLayoutData(new GridData(GridData.FILL_BOTH));
    pnlEditorDetail.setLayout(new GridLayout());
    return pnlContents;
  }
  /**
   * Method createControls.
   *
   * @param parent Composite
   * @param aTabbedPropertySheetPage TabbedPropertySheetPage
   * @see org.eclipse.ui.views.properties.tabbed.ISection#createControls(Composite,
   *     TabbedPropertySheetPage)
   */
  @Override
  public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);

    // Tell element to build its own detailed tab layout
    final TabbedPropertySheetWidgetFactory widgetFactory =
        aTabbedPropertySheetPage.getWidgetFactory();
    final Composite composite = widgetFactory.createFlatFormComposite(parent);
    FormData data = null;

    // Position (read-only)
    widgetFactory.setBorderStyle(SWT.NULL);
    fPositionText = widgetFactory.createText(composite, "", SWT.NULL);
    data = new FormData();
    data.left = new FormAttachment(0, R4EUIConstants.TABBED_PROPERTY_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0); // $codepro.audit.disable numericLiterals
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    fPositionText.setEditable(false);
    fPositionText.setToolTipText(R4EUIConstants.CONTENTS_POSITION_TOOLTIP);
    fPositionText.setLayoutData(data);

    final CLabel positionLabel =
        widgetFactory.createCLabel(composite, R4EUIConstants.POSITION_LABEL);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(fPositionText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(fPositionText, 0, SWT.CENTER);

    positionLabel.setToolTipText(R4EUIConstants.CONTENTS_POSITION_TOOLTIP);
    positionLabel.setLayoutData(data);

    // Assigned To
    fAssignedToComposite = widgetFactory.createComposite(composite);
    data = new FormData();
    data.left = new FormAttachment(0, R4EUIConstants.TABBED_PROPERTY_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0); // $codepro.audit.disable numericLiterals
    data.top = new FormAttachment(fPositionText, ITabbedPropertyConstants.VSPACE);
    fAssignedToComposite.setToolTipText(R4EUIConstants.ASSIGNED_TO_TOOLTIP);
    fAssignedToComposite.setLayoutData(data);
    fAssignedToComposite.setLayout(new GridLayout(3, false));

    widgetFactory.setBorderStyle(SWT.BORDER);
    fAssignedToText = widgetFactory.createText(fAssignedToComposite, "");
    fAssignedToText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    fAssignedToText.setEditable(false);
    fAssignedToButton =
        widgetFactory.createButton(fAssignedToComposite, R4EUIConstants.ADD_LABEL, SWT.NONE);
    fAssignedToButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    fAssignedToButton.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            ((R4EUIContent) fProperties.getElement()).addAssignees(UIUtils.getAssignParticipants());
            refresh();
            R4EUIModelController.getNavigatorView().getTreeViewer().refresh();
          }
        });

    fUnassignedFromButton =
        widgetFactory.createButton(fAssignedToComposite, R4EUIConstants.REMOVE_LABEL, SWT.NONE);
    fUnassignedFromButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    fUnassignedFromButton.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            ((R4EUIContent) fProperties.getElement())
                .removeAssignees(UIUtils.getUnassignParticipants(fProperties.getElement()));
            refresh();
            R4EUIModelController.getNavigatorView().getTreeViewer().refresh();
          }
        });

    final CLabel assignedToLabel =
        widgetFactory.createCLabel(composite, R4EUIConstants.ASSIGNED_TO_LABEL);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(fAssignedToComposite, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(fAssignedToComposite, 0, SWT.CENTER);
    assignedToLabel.setToolTipText(R4EUIConstants.ASSIGNED_TO_TOOLTIP);
    assignedToLabel.setLayoutData(data);
  }
  @Override
  public void createPartControl(Composite parent) {

    final Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new GridLayout());
    GridUtils.removeMargins(main);

    final Composite tools = new Composite(main, SWT.RIGHT);
    tools.setLayout(new GridLayout(2, false));
    GridUtils.removeMargins(tools);
    tools.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    this.messageLabel = new CLabel(tools, SWT.NONE);
    final GridData gridData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gridData.widthHint = 230;
    messageLabel.setLayoutData(gridData);
    messageLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
    messageLabel.setToolTipText(
        "Insert variables to the template xml on the right,\nthis will be replaced and sent to EDNA when the workflow is run.");

    ToolBarManager toolMan = new ToolBarManager(SWT.FLAT | SWT.LEFT);
    final ToolBar toolBar = toolMan.createControl(tools);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
    EdnaActorActions.createInputActions(toolMan);

    final SashForm sash = new SashForm(main, SWT.HORIZONTAL);
    sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    this.viewer =
        new TableViewer(
            sash, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    createColumns(viewer);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);

    final Composite right = new Composite(sash, SWT.NONE);
    right.setLayout(new FillLayout());
    super.createPartControl(right);

    sash.setWeights(new int[] {20, 80});

    // Attached a painter to highlight the replacements
    final VariableCharacterMatcher matcher =
        new VariableCharacterMatcher(((SourceViewer) getSourceViewer()));
    final VariablePainter painter = new VariablePainter(getSourceViewer(), matcher);
    ((SourceViewer) getSourceViewer()).addPainter(painter);
    viewer.addSelectionChangedListener(matcher);
    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            doInsert();
          }
        });
    ((SourceViewer) getSourceViewer())
        .addSelectionChangedListener(
            new ISelectionChangedListener() {
              @Override
              public void selectionChanged(SelectionChangedEvent event) {
                final ISelection sel = event.getSelection();
                if (sel instanceof TextSelection) {
                  XMLSubstitutionEditor.this.currentSelectedText = (TextSelection) sel;
                  updateMessageLabel();
                  return;
                }
                XMLSubstitutionEditor.this.currentSelectedText = null;
                updateMessageLabel();
              }
            });

    toolMan.update(true);
    setWritable(true);
    getSite().setSelectionProvider(viewer);
    createUndoRedoActions();
    createRightClickMenu();
  }