Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IField


      boolean needsSave = cu.isWorkingCopy();
      ImportsManager imports = new ImportsManager(cu);
      lineDelimiter = StubUtility.getLineDelimiterUsed(aspect);

      // Write crosscut and format it
      IField field = fCrosscutPage.writeCrosscut(aspect, fCrosscutTypeDialogField.getSelectionIndex(), imports,
          new SubProgressMonitor(monitor, 2), lineDelimiter);
      ISourceRange range = field.getSourceRange();
      IBuffer buf = cu.getBuffer();
      String originalContent = buf.getText(range.getOffset(), range.getLength());
      String formattedContent = CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARATIONS, originalContent, 1, null,
          lineDelimiter, field.getJavaProject());
      buf.replace(range.getOffset(), range.getLength(), formattedContent);
      if (!cu.isWorkingCopy())
        buf.save(null, false);

      imports.create(needsSave, new SubProgressMonitor(monitor, 1));
View Full Code Here


     * @return Unique field name
     */
    public String getUniqueFieldName(IType aspect) {
        int fieldCount = 1;
        String result;
        IField field;
        do {
            result = "c" + fieldCount++;
            field = aspect.getField(result);
        } while (field.exists());
        return result;
    }
View Full Code Here

        String fieldName = getFieldName();
        IType[] allTypes = getAllTypes(cu);
        for (int i = 0; i < allTypes.length; i++) {
            IType type = allTypes[i];
            IField field = type.getField(fieldName);
            if (field == null) {
                continue;
            }
            String constant = (String) field.getConstant();
            if(constant != null){
                constant = constant.substring(1, constant.length() - 1);
            }
            String expectedPath = packagePath + constant + ".class";
            String name = JdtUtils.getByteCodePath(type);
View Full Code Here

 
  public boolean renameField(IType type, IProgressMonitor monitor) {
    String lastName = adapter.getLastName();
    String name = adapter.getName();
    if (lastName != null && !lastName.equals(name)) {
      IField lastField = type.getField(lastName);
      try {
        int flags = RenameSupport.UPDATE_GETTER_METHOD
            | RenameSupport.UPDATE_REFERENCES
            | RenameSupport.UPDATE_SETTER_METHOD;
        RenameSupport rs = RenameSupport.create(lastField, name, flags);
View Full Code Here

 
  public boolean generateCode(IType type, ImportRewrite imports,
      IProgressMonitor monitor) {
    boolean success = true;
    String id = adapter.getID();
    IField field = type.getField(id);
    IJavaElement sibling = null;
    if (field != null && !field.exists()) {
      StringBuilder builder = new StringBuilder();
      builder.append("private");
      builder.append(" ");
      String fqcn = "javax.swing.ButtonGroup";
      String beanName = imports.addImport(fqcn);
View Full Code Here

      return null;
    }
  }

  private void createPreferredLnf(WidgetAdapter root, IProgressMonitor monitor, IType type, ImportRewrite imports) throws JavaModelException {
    IField lnfField = type.getField("PREFERRED_LOOK_AND_FEEL"); //$NON-NLS-1$   
    String className = (String) root.getPreferredLookAndFeel();
    if (lnfField.exists()) {
      lnfField.delete(false, monitor);
      createLnfField(monitor, type, imports, className);
    } else if (!isCross(className)) {
      createLnfField(monitor, type, imports, className);
    }
  }
View Full Code Here

  private void removeRemovedComponent(WidgetAdapter root, IProgressMonitor monitor, ICompilationUnit unit, IType type) {
    List<String> removedNames = (List<String>) root.getProperty("removed.components");
    if (removedNames != null) {
      List<String> nonExistingFields = new ArrayList<String>();
      for (String name : removedNames) {
        IField field = type.getField(name);
        if (field == null || !field.exists())
          nonExistingFields.add(name);
      }
      for (String nonfield : nonExistingFields) {
        removedNames.remove(nonfield);
      }
View Full Code Here

    }
    return null;
  }

  private void removeField(IType type, String fieldName, String methodName, IProgressMonitor monitor) {
    IField field = type.getField(fieldName);
    if (field != null && field.exists()) {
      try {
        field.delete(true, monitor);
      } catch (JavaModelException e) {
        ParserPlugin.getLogger().error(e);
        return;
      }
    }
View Full Code Here

 
  public boolean renameField(IType type, IProgressMonitor monitor) {
    String lastName = adaptable.getLastName();
    String name = adaptable.getName();
    if (lastName != null && !lastName.equals(name)) {
      IField lastField = type.getField(lastName);
      try {
        int flags = RenameSupport.UPDATE_GETTER_METHOD | RenameSupport.UPDATE_REFERENCES | RenameSupport.UPDATE_SETTER_METHOD;
        RenameSupport rs = RenameSupport.create(lastField, name, flags);
        if (rs.preCheck().isOK()) {
          IWorkbenchWindow window = JavaUtil.getEclipseWindow();
View Full Code Here

      return true;
  }

  private boolean createNonRootCode(IType type, ImportRewrite imports, IProgressMonitor monitor) {
    String name = adaptable.getID();
    IField field = type.getField(name);
    if (field != null) {
      if (!field.exists()) {
        if (!createField(type, imports, monitor))
          return false;
      } else {
        try {
          int flags = field.getFlags();
          int access_code = getAccessModifier(flags);
          if (adaptable.getFieldAccess() != access_code) {
            field.delete(true, monitor);
            if (!createField(type, imports, monitor))
              return false;
          }
        } catch (Exception e) {
          ParserPlugin.getLogger().error(e);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IField

Copyright © 2018 www.massapicom. 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.