コード例 #1
0
  public void setLanguageObject(ILanguageObject theLangObj) {
    // language object must be cloned here so that the original isn't modified.
    // this prevents the original from being modified even if the user cancels out of the builder.
    ILanguageObject langObj = (theLangObj == null) ? null : (ILanguageObject) theLangObj.clone();

    savedLangObj = langObj;
    setOriginalSql(langObj);
    setCurrentSql(langObj);
    treeViewer.setLanguageObject(langObj);
    treeViewer.selectRoot();
    treeViewer.expandAll();

    // Defect 22003 - needed a context for the original expression
    // Providing a Lable at the top of the dialog.
    String labelText =
        Util.getString(PREFIX + "initialExpression")
            + //$NON-NLS-1$
            CoreStringUtil.Constants.DBL_SPACE
            + CoreStringUtil.Constants.DBL_SPACE
            + Util.getString(PREFIX + "undefined"); // $NON-NLS-1$
    if (savedLangObj != null) {
      String loString = savedLangObj.toString();
      if (loString.length() > 50) {
        loString = loString.substring(0, 50) + "..."; // $NON-NLS-1$
      }
      labelText =
          Util.getString(PREFIX + "initialExpression")
              + //$NON-NLS-1$
              CoreStringUtil.Constants.DBL_SPACE
              + CoreStringUtil.Constants.DBL_SPACE
              + loString;
    }
    if (originalLanguageObjLabel != null) {
      originalLanguageObjLabel.setText(labelText);
      originalLanguageObjLabel.getParent().layout();
    }
    // select root tree node
    Display.getDefault()
        .asyncExec(
            new Runnable() {
              @Override
              public void run() {
                treeViewer.selectRoot();
              }
            });
  }
コード例 #2
0
  @Override
  public void visitNode(ILanguageObject obj) {
    if (obj == null) {
      append(DisplayNodeConstants.UNDEFINED);
      return;
    }

    if ((obj instanceof IExpressionSymbol && !(obj instanceof IAggregateSymbol))) {
      IQueryService queryService = ModelerCore.getTeiidQueryService();
      ISQLStringVisitor delegate = queryService.getCallbackSQLStringVisitor(this);
      obj.acceptVisitor(delegate);
      return;
    }

    // turn off indenting for nested commands
    int childIndent = indentLevel;
    if ((node.languageObject instanceof ISubqueryContainer
            || node.languageObject instanceof IExpressionStatement)
        && obj instanceof ICommand) {
      childIndent = -1;
    }
    DisplayNode child = DisplayNodeFactory.createDisplayNode(node, obj, childIndent);
    node.addChildNode(child);
  }