List of usage examples for org.eclipse.jdt.core.dom FieldDeclaration setProperty
public final void setProperty(String propertyName, Object data)
null
to clear it. From source file:org.eclipse.wb.internal.rcp.model.jface.DialogButtonIdPropertyEditor.java
License:Open Source License
/** * @return {@link FieldDeclaration}'s with {@link IDialogConstants#CLIENT_ID} based custom button * ID's.// w w w .j av a 2s . c o m */ private static List<FieldDeclaration> getCustomIDs(GenericProperty property) { List<FieldDeclaration> idList = Lists.newArrayList(); TypeDeclaration typeDeclaration = JavaInfoUtils.getTypeDeclaration(property.getJavaInfo()); for (FieldDeclaration fieldDeclaration : typeDeclaration.getFields()) { // check that field is "static final" { int staticFinal = Modifier.STATIC | Modifier.FINAL; if ((fieldDeclaration.getModifiers() & staticFinal) != staticFinal) { continue; } } // check that field has single fragment VariableDeclarationFragment fragment; { List<VariableDeclarationFragment> fragments = DomGenerics.fragments(fieldDeclaration); if (fragments.size() != 1) { continue; } fragment = fragments.get(0); } // check that fragment is initialized with infix expression InfixExpression infixExpression; { Expression initializer = fragment.getInitializer(); if (!(initializer instanceof InfixExpression)) { continue; } infixExpression = (InfixExpression) initializer; } // check that field is based on IDialogConstants.CLIENT_ID Expression leftOperand = infixExpression.getLeftOperand(); Expression rightOperand = infixExpression.getRightOperand(); if (!isDialogConstantsQualifiedName(leftOperand)) { continue; } if (infixExpression.getOperator() != InfixExpression.Operator.PLUS || !(rightOperand instanceof NumberLiteral)) { continue; } QualifiedName qualifiedLeftOperand = (QualifiedName) leftOperand; if (!qualifiedLeftOperand.getName().getIdentifier().equals("CLIENT_ID")) { continue; } // all checks were successful, so add this FieldDeclaration fieldDeclaration.setProperty(BUTTON_NAME_PROPERTY, fragment.getName().getIdentifier()); fieldDeclaration.setProperty(BUTTON_OFFSET_PROPERTY, Integer.valueOf(rightOperand.toString())); idList.add(fieldDeclaration); } return idList; }