List of usage examples for org.eclipse.jdt.core.dom FieldDeclaration getProperty
public final Object getProperty(String propertyName)
null if none. From source file:org.eclipse.wb.tests.designer.rcp.model.jface.DialogTest.java
License:Open Source License
/** * Test for {@link DialogButtonIdPropertyEditor#getCustomIDs(GenericProperty)}. *//*from ww w. j a v a 2s . c o m*/ @SuppressWarnings("unchecked") public void test_getCustomIDs() throws Exception { DialogInfo dialog = parseJavaInfo("import org.eclipse.jface.dialogs.*;", "public class Test extends org.eclipse.jface.dialogs.Dialog {", " private int NOT_FINAL_STATIC;", " private static int NOT_FINAL;", " private final int NOT_STATIC = 0;", " private static final int TWO = 0, FRAGMENTS = 1;", " private static final int NOT_INFIX = 0;", " private static final int NOT_DIALOG_CONSTANTS = 1 + 2;", " private static final int NOT_CLIENT = IDialogConstants.YES_ID + 2;", " private static final int NOT_RIGHT_NUMBER = IDialogConstants.CLIENT_ID + (2);", " private static final int GOOD = IDialogConstants.CLIENT_ID + 2;", " public Test(Shell parentShell) {", " super(parentShell);", " }", "}"); List<FieldDeclaration> idList = (List<FieldDeclaration>) ReflectionUtils.invokeMethod2( DialogButtonIdPropertyEditor.class, "getCustomIDs", GenericProperty.class, dialog.getPropertyByTitle("blockOnOpen")); assertThat(idList).hasSize(1); FieldDeclaration fieldDeclaration = idList.get(0); assertEquals("GOOD", DomGenerics.fragments(fieldDeclaration).get(0).getName().getIdentifier()); { String nameKey = (String) ReflectionUtils.getFieldObject(DialogButtonIdPropertyEditor.class, "BUTTON_NAME_PROPERTY"); assertEquals("GOOD", fieldDeclaration.getProperty(nameKey)); } { String offsetKey = (String) ReflectionUtils.getFieldObject(DialogButtonIdPropertyEditor.class, "BUTTON_OFFSET_PROPERTY"); assertEquals(2, fieldDeclaration.getProperty(offsetKey)); } }