コード例 #1
0
  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);
    }
  }
コード例 #2
0
  /** 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;
  }
コード例 #3
0
ファイル: TeiidView.java プロジェクト: bxvs888/teiid-designer
  /** 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);
  }