Examples of AstEditor


Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  }

  private void command_ANCHOR_horizontal(WidgetInfo widget, Anchor anchor) throws Exception {
    MethodInvocation invocation;
    Rectangle bounds = widget.getBounds();
    AstEditor editor = getEditor();
    if ((invocation = getWidgetInvocation(widget, "setWidgetLeftWidth")) != null) {
      if (anchor == Anchor.NONE) {
        editor.removeEnclosingStatement(invocation);
      }
      if (anchor == Anchor.TRAILING) {
        int right = getBounds().width - bounds.right();
        editor.replaceInvocationName(invocation, "setWidgetRightWidth");
        setInvocationArgument(invocation, 1, right, true);
      }
      if (anchor == Anchor.BOTH) {
        int right = getBounds().width - bounds.right();
        editor.replaceInvocationName(invocation, "setWidgetLeftRight");
        setInvocationArgument(invocation, 3, right, true);
      }
      return;
    }
    if ((invocation = getWidgetInvocation(widget, "setWidgetRightWidth")) != null) {
      if (anchor == Anchor.NONE) {
        editor.removeEnclosingStatement(invocation);
      }
      if (anchor == Anchor.LEADING) {
        int left = bounds.left();
        editor.replaceInvocationName(invocation, "setWidgetLeftWidth");
        setInvocationArgument(invocation, 1, left, true);
      }
      if (anchor == Anchor.BOTH) {
        editor.replaceInvocationName(invocation, "setWidgetLeftRight");
        {
          Expression rightExpression = DomGenerics.arguments(invocation).get(1);
          editor.replaceInvocationArgument(invocation, 3, editor.getSource(rightExpression));
        }
        setInvocationArgument(invocation, 1, bounds.left(), true);
      }
      return;
    }
    if ((invocation = getWidgetInvocation(widget, "setWidgetLeftRight")) != null) {
      if (anchor == Anchor.NONE) {
        editor.removeEnclosingStatement(invocation);
      }
      if (anchor == Anchor.LEADING) {
        editor.replaceInvocationName(invocation, "setWidgetLeftWidth");
        // use same unit for left/width
        Object unit = getUnit(invocation, 2);
        setInvocationUnit(invocation, 4, unit);
        // set width
        setInvocationArgument(invocation, 3, bounds.width, true);
      }
      if (anchor == Anchor.TRAILING) {
        editor.replaceInvocationName(invocation, "setWidgetRightWidth");
        // use same unit for right/width
        Object unit = getUnit(invocation, 4);
        setInvocationUnit(invocation, 2, unit);
        // set right/width
        {
          Expression rightExpression = DomGenerics.arguments(invocation).get(3);
          editor.replaceInvocationArgument(invocation, 1, editor.getSource(rightExpression));
        }
        // set width
        setInvocationArgument(invocation, 3, bounds.width, true);
      }
      return;
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

    return null;
  }

  @Override
  public boolean setExpression(final JavaInfo javaInfo, final String source) throws Exception {
    final AstEditor editor = javaInfo.getEditor();
    // check for existing invocation
    {
      final Expression expression = getExpression(javaInfo);
      if (expression != null) {
        if (source != null) {
          ExecutionUtils.run(javaInfo, new RunnableEx() {
            public void run() throws Exception {
              editor.replaceExpression(expression, source);
            }
          });
        } else {
          ExecutionUtils.run(javaInfo, new RunnableEx() {
            public void run() throws Exception {
              editor.removeEnclosingStatement(expression);
            }
          });
        }
        return true;
      }
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  }

  private void command_ANCHOR_vertical(WidgetInfo widget, Anchor anchor) throws Exception {
    MethodInvocation invocation;
    Rectangle bounds = widget.getBounds();
    AstEditor editor = getEditor();
    if ((invocation = getWidgetInvocation(widget, "setWidgetTopHeight")) != null) {
      int bottom = getBounds().height - bounds.bottom();
      if (anchor == Anchor.NONE) {
        editor.removeEnclosingStatement(invocation);
      }
      if (anchor == Anchor.TRAILING) {
        editor.replaceInvocationName(invocation, "setWidgetBottomHeight");
        setInvocationArgument(invocation, 1, bottom, true);
      }
      if (anchor == Anchor.BOTH) {
        editor.replaceInvocationName(invocation, "setWidgetTopBottom");
        setInvocationArgument(invocation, 3, bottom, true);
      }
      return;
    }
    if ((invocation = getWidgetInvocation(widget, "setWidgetBottomHeight")) != null) {
      if (anchor == Anchor.NONE) {
        editor.removeEnclosingStatement(invocation);
      }
      if (anchor == Anchor.LEADING) {
        editor.replaceInvocationName(invocation, "setWidgetTopHeight");
        setInvocationArgument(invocation, 1, bounds.top(), true);
      }
      if (anchor == Anchor.BOTH) {
        editor.replaceInvocationName(invocation, "setWidgetTopBottom");
        {
          Expression rightExpression = DomGenerics.arguments(invocation).get(1);
          editor.replaceInvocationArgument(invocation, 3, editor.getSource(rightExpression));
        }
        setInvocationArgument(invocation, 1, bounds.top(), true);
      }
      return;
    }
    if ((invocation = getWidgetInvocation(widget, "setWidgetTopBottom")) != null) {
      if (anchor == Anchor.NONE) {
        editor.removeEnclosingStatement(invocation);
      }
      if (anchor == Anchor.LEADING) {
        editor.replaceInvocationName(invocation, "setWidgetTopHeight");
        // use same unit for top/height
        Object unit = getUnit(invocation, 2);
        setInvocationUnit(invocation, 4, unit);
        // set height
        setInvocationArgument(invocation, 3, bounds.height, true);
      }
      if (anchor == Anchor.TRAILING) {
        editor.replaceInvocationName(invocation, "setWidgetBottomHeight");
        // use same unit for bottom/height
        Object unit = getUnit(invocation, 4);
        setInvocationUnit(invocation, 2, unit);
        // set bottom/height
        {
          Expression bottomExpression = DomGenerics.arguments(invocation).get(3);
          editor.replaceInvocationArgument(invocation, 1, editor.getSource(bottomExpression));
        }
        // set height
        setInvocationArgument(invocation, 3, bounds.height, true);
      }
    }
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

          int row,
          int cell) throws Exception {
        if (row == m_row) {
          int column = m_panel.getStatus().getColumnOfCell(row, cell);
          if (column == m_column) {
            AstEditor editor = m_panel.getEditor();
            if (methodDescription.getSignature().equals(SET_HOR_ALIGNMENT)) {
              editor.removeEnclosingStatement(invocation);
            } else if (methodDescription.getSignature().equals(SET_ALIGNMENT)) {
              editor.replaceInvocationName(invocation, "setVerticalAlignment");
              editor.removeInvocationArgument(invocation, 2);
              editor.replaceInvocationBinding(invocation);
            }
          }
        }
      }
    });
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

          int row,
          int cell) throws Exception {
        if (row == m_row) {
          int column = m_panel.getStatus().getColumnOfCell(row, cell);
          if (column == m_column) {
            AstEditor editor = m_panel.getEditor();
            if (methodDescription.getSignature().equals(SET_VER_ALIGNMENT)) {
              editor.removeEnclosingStatement(invocation);
            } else if (methodDescription.getSignature().equals(SET_ALIGNMENT)) {
              editor.removeInvocationArgument(invocation, 3);
              editor.replaceInvocationName(invocation, "setHorizontalAlignment");
              editor.replaceInvocationBinding(invocation);
            }
          }
        }
      }
    });
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  }

  private boolean setSizeInts(int width, int height) throws Exception {
    MethodInvocation invocation = m_window.getMethodInvocation("setSize(int,int)");
    if (invocation != null) {
      AstEditor editor = m_window.getEditor();
      editor.replaceExpression((Expression) invocation.arguments().get(0), Integer.toString(width));
      editor.replaceExpression((Expression) invocation.arguments().get(1), Integer.toString(height));
      return true;
    }
    // not found
    return false;
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  private boolean setSizeStrings(int width, int height) throws Exception {
    MethodInvocation invocation =
        m_window.getMethodInvocation("setSize(java.lang.String,java.lang.String)");
    if (invocation != null) {
      AstEditor editor = m_window.getEditor();
      editor.replaceExpression(
          (Expression) invocation.arguments().get(0),
          "\"" + Integer.toString(width) + "px\"");
      editor.replaceExpression(
          (Expression) invocation.arguments().get(1),
          "\"" + Integer.toString(height) + "px\"");
      return true;
    }
    // not found
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  }

  private boolean setWidthInt(int width) throws Exception {
    MethodInvocation invocation = m_window.getMethodInvocation("setWidth(int)");
    if (invocation != null) {
      AstEditor editor = m_window.getEditor();
      editor.replaceExpression((Expression) invocation.arguments().get(0), Integer.toString(width));
      return true;
    }
    // not found
    return false;
  }
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  }

  private boolean setWidthString(int width) throws Exception {
    MethodInvocation invocation = m_window.getMethodInvocation("setWidth(java.lang.String)");
    if (invocation != null) {
      AstEditor editor = m_window.getEditor();
      editor.replaceExpression(
          (Expression) invocation.arguments().get(0),
          "\"" + Integer.toString(width) + "px\"");
      return true;
    }
    // not found
View Full Code Here

Examples of org.eclipse.wb.internal.core.utils.ast.AstEditor

  }

  private boolean setHeightInt(int height) throws Exception {
    MethodInvocation invocation = m_window.getMethodInvocation("setHeight(int)");
    if (invocation != null) {
      AstEditor editor = m_window.getEditor();
      editor.replaceExpression((Expression) invocation.arguments().get(0), Integer.toString(height));
      return true;
    }
    // not found
    return false;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.