/** Create the tableViewer Panel */
  private void createTableViewerPanel(Composite theParent) {
    Composite tablePanel = new Composite(theParent, SWT.NONE);

    // Set the layout
    GridLayout gridLayout = new GridLayout();
    tablePanel.setLayout(gridLayout);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    tablePanel.setLayoutData(gridData);

    // Table Header Label
    WidgetFactory.createLabel(
        tablePanel, GridData.HORIZONTAL_ALIGN_BEGINNING, BINDINGS_TABLE_TITLE_TEXT);

    // Create the table
    createTable(tablePanel);

    // Create and setup the TableViewer
    tableViewer = new TableViewer(table);
    tableViewer.setUseHashlookup(true);

    tableViewer.setColumnProperties(columnNames);
    tableViewer.setContentProvider(new BindingContentProvider());
    tableViewer.setLabelProvider(new BindingLabelProvider(true));
    // The input for the table viewer is the instance of BindingList
    tableViewer.setInput(bindingList);
    updateRowColors();
  }
  /* (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;
  }
  /** Create the Panel for resolving sql symbols */
  private void createResolveSqlPanel(Composite parent) {
    Group newGroup = WidgetFactory.createGroup(parent, RESOLVE_SQL_GROUP_NAME);
    GridLayout gridLayout = new GridLayout();
    newGroup.setLayout(gridLayout);
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 5;
    gridLayout.marginBottom = 5;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    newGroup.setLayoutData(gridData);
    newGroup.setText(SQL_SYMBOL_TXT);
    // SQL Symbol Label
    // --------------------------------------
    sqlSymbolLabel =
        WidgetFactory.createLabel(newGroup, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // $NON-NLS-1$
    GridData gdSSL =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 3, 1);
    sqlSymbolLabel.setLayoutData(gdSSL);
    sqlSymbolLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));

    // Symbol RuntimeType Label
    // --------------------------------------
    Label rtTypeLabel = WidgetFactory.createLabel(newGroup, RUNTIME_TYPE_TXT);
    GridData gdRT =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 2, 1);
    rtTypeLabel.setLayoutData(gdRT);
    // WidgetFactory.createLabel(newGroup, "");

    Binding binding = bindingList.get(0);
    Object symbol = binding.getCurrentSymbol();
    String text = getLabelText(symbol);
    symbolRuntimeTypeLabel =
        WidgetFactory.createLabel(
            newGroup, text, GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);

    // Available Conversion Title Label
    // --------------------------------------
    Label cvLabel =
        WidgetFactory.createLabel(
            newGroup, GridData.HORIZONTAL_ALIGN_BEGINNING, CONVERTED_SYMBOL_TXT);
    GridData gdCV =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 2, 1);
    cvLabel.setLayoutData(gdCV);

    // Available Sql Conversion Text
    // --------------------------------------

    String convertedSymbol = binding.getSqlConversionText();
    int lossOfPrecIndex = convertedSymbol.indexOf('\n');
    String warningText = CoreStringUtil.Constants.EMPTY_STRING;
    if (lossOfPrecIndex > -1) {
      warningText = convertedSymbol.substring(lossOfPrecIndex + 1, convertedSymbol.length());
      convertedSymbol = convertedSymbol.substring(0, lossOfPrecIndex);
    }

    symbolConversionLabel =
        WidgetFactory.createLabel(newGroup, convertedSymbol, GridData.FILL_BOTH);

    symbolWarningLabel = WidgetFactory.createLabel(newGroup, warningText, GridData.FILL_BOTH);
    GridData gdWarning =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 3, 1);
    symbolWarningLabel.setLayoutData(gdWarning);

    // Conversion Buttons Panel
    // --------------------------------------

    // Create the changeSelectedSql Button
    this.convertSelectedSqlButton =
        WidgetFactory.createButton(
            newGroup, CONVERT_SELECTED_SQL_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertSelectedSqlButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertSelectedSqlPressed();
          }
        });

    // Create the changeAllSql Button
    this.convertAllSqlButton =
        WidgetFactory.createButton(
            newGroup, CONVERT_ALL_SQL_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertAllSqlButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertAllSqlPressed();
          }
        });
    sqlGroup = newGroup;
  }
  private void createResolveAttributePanel(Composite parent) {
    if (this.targetLocked) {
      attrGroup = WidgetFactory.createGroup(parent, RESOLVE_ATTR_GROUP_LOCKED_NAME);
    } else {
      attrGroup = WidgetFactory.createGroup(parent, RESOLVE_ATTR_GROUP_NAME);
    }
    GridLayout gridLayout = new GridLayout();
    attrGroup.setLayout(gridLayout);
    gridLayout.numColumns = 4;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 5;
    gridLayout.marginBottom = 5;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    attrGroup.setLayoutData(gridData);

    Binding binding = bindingList.get(0);
    Object attr = binding.getAttribute();
    // Attribute Datatype Label
    EObject datatype = null;
    attr = binding.getAttribute();
    if (TransformationHelper.isSqlColumn(attr)) {
      datatype = TransformationHelper.getSqlColumnDatatype((EObject) attr);
    }
    String datatypeText = getDatatypeText(datatype);
    Image datatypeImage = getDatatypeImage(datatype);

    attrGroup.setText(VIRTUAL_TARGET_ATTRIBUTE_TXT);

    // --------------------------------------
    // SQL Symbol Label
    // --------------------------------------
    attributeLabel =
        WidgetFactory.createLabel(attrGroup, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // $NON-NLS-1$
    GridData attrGD =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 4, 1);
    attributeLabel.setLayoutData(attrGD);
    attributeLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));

    Label rtTypeLabel = WidgetFactory.createLabel(attrGroup, RUNTIME_TYPE_TXT);
    GridData gdRT =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING,
            GridData.VERTICAL_ALIGN_BEGINNING,
            false,
            false,
            2,
            1);
    rtTypeLabel.setLayoutData(gdRT);
    WidgetFactory.createLabel(attrGroup, CoreStringUtil.Constants.EMPTY_STRING);

    // --------------------------------------
    // Attribute RuntimeType Label
    // --------------------------------------
    attrRuntimeTypeLabel =
        WidgetFactory.createLabel(
            attrGroup,
            datatypeText,
            datatypeImage,
            GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);

    // --------------------------------------
    // Attribute Type Chooser Panel
    // --------------------------------------
    // Create the changeSelectedAttribute Button
    this.convertSelectedAttrButton =
        WidgetFactory.createButton(
            attrGroup, CONVERT_SELECTED_ATTR_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertSelectedAttrButton.setEnabled(false);
    this.convertSelectedAttrButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertSelectedAttrPressed();
          }
        });

    // Create the changeAllAttributes Button
    this.convertAllAttrsButton =
        WidgetFactory.createButton(
            attrGroup, CONVERT_ALL_ATTR_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertAllAttrsButton.setEnabled(false);
    this.convertAllAttrsButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertAllAttrsPressed();
          }
        });

    // Create the showDatatypeDialog Button
    this.showDatatypeDialogButton =
        WidgetFactory.createButton(
            attrGroup, "Change", GridData.HORIZONTAL_ALIGN_END); // $NON-NLS-1$
    this.showDatatypeDialogButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            showDatatypeDialogPressed();
          }
        });

    attrDatatypeLabel =
        WidgetFactory.createLabel(
            attrGroup,
            "xxxxxxxxxxxxxxxxxxxxxxx",
            datatypeImage, //$NON-NLS-1$
            GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);
    if (this.targetLocked) {
      this.showDatatypeDialogButton.setEnabled(false);
    } else {
      this.showDatatypeDialogButton.setEnabled(true);
    }
  }
Example #5
0
  /** This is a callback that will allow us to create the viewer and initialize it. */
  @Override
  public void createPartControl(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());

    Composite frame = toolkit.createComposite(parent, SWT.BORDER);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(frame);

    Composite comboDescFrame = toolkit.createComposite(frame, SWT.NONE);
    GridDataFactory.fillDefaults().applyTo(comboDescFrame);
    GridLayoutFactory.fillDefaults()
        .margins(5, 20)
        .spacing(SWT.DEFAULT, 25)
        .applyTo(comboDescFrame);

    Composite comboFrame = toolkit.createComposite(comboDescFrame, SWT.NONE);
    GridDataFactory.fillDefaults().applyTo(comboFrame);
    GridLayoutFactory.fillDefaults().applyTo(comboFrame);

    Composite labelFrame = toolkit.createComposite(comboFrame, SWT.NONE);
    GridDataFactory.fillDefaults().applyTo(labelFrame);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(labelFrame);

    Label jbLabel =
        WidgetFactory.createLabel(
            labelFrame, UTIL.getString("TeiidServerOverviewSection.jbLabel")); // $NON-NLS-1$
    jbLabel.setForeground(labelFrame.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE));
    GridDataFactory.swtDefaults().grab(false, false).applyTo(jbLabel);

    newServerOrOpenServerViewHyperlink =
        toolkit.createHyperlink(labelFrame, EDIT_SERVER_LABEL, SWT.NONE);
    GridDataFactory.swtDefaults().applyTo(newServerOrOpenServerViewHyperlink);
    newServerOrOpenServerViewHyperlink.addHyperlinkListener(
        new HyperlinkAdapter() {

          @Override
          public void linkActivated(HyperlinkEvent e) {
            if (serverMap.isEmpty()) {
              // There are no servers so open the server wizard
              NewServerAction action =
                  new NewServerAction(getViewSite().getShell(), getServerManager());
              action.run();
            } else {
              // open the servers view
              IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
              try {
                window
                    .getActivePage()
                    .showView("org.eclipse.wst.server.ui.ServersView"); // $NON-NLS-1$
              } catch (PartInitException ex) {
                UTIL.log(ex);
              }
            }
          }
        });

    jbossServerCombo = new Combo(comboFrame, SWT.READ_ONLY | SWT.DROP_DOWN);
    toolkit.adapt(jbossServerCombo);
    GridDataFactory.swtDefaults().minSize(250, 30).grab(true, false).applyTo(jbossServerCombo);
    jbossServerCombo.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            handleServerComboSelection();
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            handleServerComboSelection();
          }
        });

    Text descriptionText =
        toolkit.createText(
            comboDescFrame,
            UTIL.getString("TeiidServerOverviewSection.description"), // $NON-NLS-1$
            SWT.MULTI | SWT.WRAP);
    descriptionText.setForeground(comboDescFrame.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE));
    GridDataFactory.fillDefaults()
        .grab(false, true)
        .hint(100, SWT.DEFAULT)
        .applyTo(descriptionText);

    super.createPartControl(frame);

    viewer = getCommonViewer();
    GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());

    viewer.setSorter(new NameSorter());

    DqpPlugin.getInstance().getServersProvider().addServerLifecycleListener(serversListener);

    // Populate the jboss server combo box which
    // should also populate the viewer as well
    populateJBossServerCombo();

    viewer.expandToLevel(3);
  }
  /**
   * @param parent
   * @return composite the page
   * @since 4.0
   */
  @SuppressWarnings({"unused", "unchecked"})
  Composite createPageControl(final Composite parent) {
    // Create page
    final Composite mainPanel = new Composite(parent, SWT.NONE);
    mainPanel.setLayout(new GridLayout(COLUMN_COUNT, false));
    // Add widgets to page
    WidgetFactory.createLabel(mainPanel, FOLDER_LABEL);
    final String name =
        (this.folder == null ? null : this.folder.getFullPath().makeRelative().toString());
    this.folderText =
        WidgetFactory.createTextField(mainPanel, GridData.FILL_HORIZONTAL, 1, name, SWT.READ_ONLY);
    this.folderText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            folderModified();
          }
        });
    btnBrowse = WidgetFactory.createButton(mainPanel, BROWSE_BUTTON);
    btnBrowse.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            browseButtonSelected();
          }
        });
    WidgetFactory.createLabel(mainPanel, NAME_LABEL);
    this.nameText =
        WidgetFactory.createTextField(mainPanel, GridData.HORIZONTAL_ALIGN_FILL, COLUMN_COUNT - 1);
    this.nameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            nameModified();
          }
        });

    // set focus to browse button if no folder selected. otherwise set focus to text field
    if (folder == null) {
      btnBrowse.setFocus();
    } else {
      nameText.setFocus();
    }

    DESCRIPTION_GROUP:
    {
      final Group descGroup =
          WidgetFactory.createGroup(
              mainPanel, getString("description"), GridData.FILL_HORIZONTAL, 3); // $NON-NLS-1$
      descriptionTextEditor =
          new StyledTextEditor(
              descGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
      final GridData descGridData = new GridData(GridData.FILL_BOTH);
      descGridData.horizontalSpan = 1;
      descGridData.heightHint = 50;
      descGridData.minimumHeight = 30;
      descGridData.grabExcessVerticalSpace = true;
      descriptionTextEditor.setLayoutData(descGridData);
      descriptionTextEditor.setText(""); // $NON-NLS-1$
    }

    MODELS_GROUP:
    {
      Group group =
          WidgetFactory.createGroup(
              mainPanel,
              getString("selectedModelsGroupTitle"),
              GridData.FILL_BOTH,
              COLUMN_COUNT,
              COLUMN_COUNT); //$NON-NLS-1$
      group.setLayout(new GridLayout(2, false));
      GridData gd = new GridData(GridData.FILL_BOTH);
      gd.heightHint = 200;
      gd.horizontalSpan = 3;
      group.setLayoutData(gd);

      Composite leftToolbarPanel = new Composite(group, SWT.NONE);
      leftToolbarPanel.setLayout(new GridLayout());
      GridData ltpGD = new GridData(GridData.FILL_VERTICAL);
      ltpGD.heightHint = 120;
      leftToolbarPanel.setLayoutData(ltpGD);

      addModelsButton = new Button(leftToolbarPanel, SWT.PUSH);
      addModelsButton.setText(getString("add")); // $NON-NLS-1$
      addModelsButton.setToolTipText(getString("addModelsTooltip")); // $NON-NLS-1$
      addModelsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      addModelsButton.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              handleAddModelsSelected();
              if (!modelsViewer.getSelection().isEmpty()) {
                removeModelsButton.setEnabled(true);
              }
            }
          });

      removeModelsButton = new Button(leftToolbarPanel, SWT.PUSH);
      removeModelsButton.setText(getString("remove")); // $NON-NLS-1$
      removeModelsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      removeModelsButton.setEnabled(false);
      removeModelsButton.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              Collection<IResource> models = new ArrayList<IResource>();

              IStructuredSelection selection = (IStructuredSelection) modelsViewer.getSelection();
              for (Object obj : selection.toArray()) {
                if (obj instanceof IResource) {
                  models.add((IResource) obj);
                }
              }
              removeModels(models);
              removeModelsButton.setEnabled(false);
            }
          });

      this.modelsViewer = new TableViewer(group);
      GridData gdv = new GridData(GridData.FILL_BOTH);
      // gdv.horizontalSpan = COLUMN_COUNT;
      modelsViewer.getControl().setLayoutData(gdv);
      modelsViewer.setContentProvider(new ListContentProvider());
      modelsViewer.setLabelProvider(new ModelExplorerLabelProvider());
      // Add Models from properties if available
      if (this.designerProperties != null && !this.designerProperties.isEmpty()) {
        IFile sourceMdl = DesignerPropertiesUtil.getSourceModel(this.designerProperties);
        IFile viewMdl = DesignerPropertiesUtil.getViewModel(this.designerProperties);
        if (sourceMdl != null) this.modelsForVdb.add(sourceMdl);
        if (viewMdl != null) this.modelsForVdb.add(viewMdl);
      } else {
        this.modelsForVdb.addAll(SelectionUtilities.getSelectedIResourceObjects(initialSelection));
      }
      modelsViewer.setInput(this.modelsForVdb);
      modelsViewer.addSelectionChangedListener(
          new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              removeModelsButton.setEnabled(!event.getSelection().isEmpty());
            }
          });
    }

    updateForProperties();
    return mainPanel;
  }
  /** Create the tableViewer Panel */
  @SuppressWarnings("unused")
  private void createTableViewerPanel(Composite theParent) {
    Composite tablePanel = new Composite(theParent, SWT.NONE);

    // Set the layout
    GridLayout gridLayout = new GridLayout();
    tablePanel.setLayout(gridLayout);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    tablePanel.setLayoutData(gridData);

    // Add header panel

    HEADER_PANEL:
    {
      Composite headerPanel = WidgetFactory.createPanel(tablePanel);
      // ------------------------------
      // Set layout for the Composite
      // ------------------------------
      headerPanel.setLayout(new GridLayout());
      ((GridLayout) headerPanel.getLayout()).numColumns = 3;
      headerPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
      ((GridData) headerPanel.getLayoutData()).minimumHeight = 80;
      // ((GridData)headerPanel.getLayoutData()).grabExcessHorizontalSpace = true;

      // Add general info/instructions text box
      {
        helpText = new Text(headerPanel, SWT.WRAP | SWT.READ_ONLY);
        helpText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
        helpText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
        helpText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        ((GridData) helpText.getLayoutData()).horizontalSpan = 3;
        ((GridData) helpText.getLayoutData()).heightHint = 40;
        ((GridData) helpText.getLayoutData()).widthHint = 360;

        helpText.setText(Messages.datatypeReconciler_helpText);
      }

      // Add button bar containing:
      // [CHANGE ALL COLUMN DATATYPES] - or - [CONVERT ALL SQL SYMBOLS]
      this.convertAllSqlSymbolsButton =
          WidgetFactory.createButton(
              headerPanel, Messages.datatypeReconciler_convertAllSqlSymbolsLabel);
      this.convertAllSqlSymbolsButton.setToolTipText(
          Messages.datatypeReconciler_convertAllSqlSymbolsTooltip);
      this.convertAllSqlSymbolsButton.setImage(
          UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_LEFT_ICON));

      this.convertAllSqlSymbolsButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
              changeAllColumnDatatypesButtonPressed();
            }
          });

      WidgetFactory.createLabel(headerPanel, "   - or -   "); // $NON-NLS-1$

      this.changeAllColumnDatatypesButton =
          WidgetFactory.createButton(
              headerPanel, Messages.datatypeReconciler_convertAllColumnDatatypesLabel);
      this.changeAllColumnDatatypesButton.setToolTipText(
          Messages.datatypeReconciler_convertAllColumnDatatypesTooltip);
      this.changeAllColumnDatatypesButton.setImage(
          UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_RIGHT_ICON));
      this.changeAllColumnDatatypesButton.setEnabled(false);
      this.changeAllColumnDatatypesButton.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
              changeAllColumnDatatypesPressed();
            }
          });
    }

    BINDING_TABLE:
    {
      table = new Table(tablePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
      table.setHeaderVisible(true);
      table.setLinesVisible(true);
      table.setLayout(new TableLayout());
      GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
      gd.heightHint = 200;
      table.setLayoutData(gd);

      this.bindingTableViewer = new TableViewer(table);
      this.bindingTableViewer.getControl().setLayoutData(gd);

      this.bindingContentProvider = new BindingContentProvider();

      // create columns

      // | status icon | Source SQL Symbol | <-- | Matched Datatype | ->  | Target Column

      // COLUMN 0 :  STATUS ICON Button
      TableViewerColumn column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.setLabelProvider(new TheBindingColumnLabelProvider(0));
      column.getColumn().setText(getSpaces(8));
      column.getColumn().pack();

      // COLUMN 1 : SOURCE SQL SYMBOL
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(Messages.datatypeReconciler_sourceSqlSymbolLabel + getSpaces(100));
      column.setLabelProvider(new TheBindingColumnLabelProvider(1));
      column.getColumn().pack();

      // COLUMN 2 :  LEFT ARROW Button
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(getSpaces(8));
      column.setLabelProvider(new TheBindingColumnLabelProvider(2));
      column.setEditingSupport(new ConvertSymbolEditingSupport(this.bindingTableViewer));
      column.getColumn().pack();
      column.getColumn().setToolTipText(Messages.datatypeReconciler_convertSourceDatatypeTooltip);

      // COLUMN 3 : Matched datatype
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(Messages.datatypeReconciler_matchedTypeLabel + getSpaces(60));
      column.setLabelProvider(new TheBindingColumnLabelProvider(3));
      column.setEditingSupport(new ChangeProposedDatatypeEditingSupport(this.bindingTableViewer));
      column.getColumn().pack();
      column.getColumn().setToolTipText(Messages.datatypeReconciler_matchedDatatypeTooltip);

      // COLUMN 4 : RIGHT ARROW Button
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(getSpaces(8));
      column.setLabelProvider(new TheBindingColumnLabelProvider(4));
      column.setEditingSupport(new ChangeDatatypeEditingSupport(this.bindingTableViewer));
      column.getColumn().pack();
      column.getColumn().setToolTipText(Messages.datatypeReconciler_changeTargetDatatypeTooltip);

      // COLUMN 5 :  Target Column Definition
      column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT);
      column.getColumn().setText(Messages.datatypeReconciler_targetColumnLabel + getSpaces(25));
      column.setLabelProvider(new TheBindingColumnLabelProvider(5));
      column.getColumn().pack();

      bindingTableViewer.setUseHashlookup(true);
      bindingTableViewer.setContentProvider(this.bindingContentProvider);
      bindingTableViewer.setInput(this.bindingListInput);

      updateRowColors();
    }

    // Panel to display selection details
    SELECTION_STATUS_PANEL:
    {
      Composite selectionPanel =
          WidgetFactory.createGroup(
              tablePanel, Messages.datatypeReconciler_selectionPanelInfoLabel);
      // ------------------------------
      // Set layout for the Composite
      // ------------------------------
      selectionPanel.setLayout(new GridLayout());
      ((GridLayout) selectionPanel.getLayout()).numColumns = 2;
      selectionPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
      ((GridData) selectionPanel.getLayoutData()).minimumHeight = 80;

      //			Label selectedSymbolLabel = new Label(selectionPanel, SWT.NONE);
      //			selectedSymbolLabel.setText("Selected Symbol: ");

      symbolConversionLabel = new Label(selectionPanel, SWT.NONE);
      symbolConversionLabel.setText(PluginConstants.EMPTY_STRING);
      symbolConversionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      symbolConversionLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));

      Label messageLabel = new Label(selectionPanel, SWT.NONE);
      //			messageLabel.setText("Status: ");

      symbolWarningLabel = new Label(selectionPanel, SWT.NONE);
      symbolWarningLabel.setText(PluginConstants.EMPTY_STRING);
      symbolWarningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      symbolWarningLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
    }
  }