private static HashMap<String, String> getFormDefaultKeys( Project project, String formTypeName, HashMap<String, String> defaultValues, int depth) { PhpClass phpClass = FormUtil.getFormTypeToClass(project, formTypeName); if (phpClass == null) { return defaultValues; } String typeClass = phpClass.getPresentableFQN(); attachOnDefaultOptions(project, defaultValues, typeClass); // recursive search for parent form types PsiElement getParent = PhpElementsUtil.getPsiElementsBySignatureSingle( project, "#M#C\\" + phpClass.getPresentableFQN() + ".getParent"); if (getParent != null && depth < 10) { PhpReturn phpReturn = PsiTreeUtil.findChildOfType(getParent, PhpReturn.class); if (phpReturn != null) { PhpPsiElement returnValue = phpReturn.getFirstPsiChild(); if (returnValue instanceof StringLiteralExpression) { getFormDefaultKeys( project, ((StringLiteralExpression) returnValue).getContents(), defaultValues, depth++); } } } return defaultValues; }
private Image getSelectedImage(Hashtable objectTable, SelectionData selData) { String key = SEL_IMAGE_PREFIX + getObjectId(); Image image = getImage(key, objectTable); if (image == null) { image = FormUtil.createAlphaMashImage(selData.display, getImage(objectTable)); if (image != null) objectTable.put(key, image); } return image; }
protected Point getObjectSize(Hashtable resourceTable, int wHint) { Control control = getControl(resourceTable); if (control == null) return new Point(0, 0); int realWhint = FormUtil.getWidthHint(wHint, control); Point size = control.computeSize(realWhint, SWT.DEFAULT); if (realWhint != SWT.DEFAULT && fill) size.x = Math.max(size.x, realWhint); if (width != SWT.DEFAULT) size.x = width; if (height != SWT.DEFAULT) size.y = height; return size; }
/** finishView, buildView: $this->vars */ public static Set<String> getFormViewVars(Project project, String... formTypeNames) { Set<String> stringSet = new HashSet<String>(); ArrayList<PhpClass> phpClasses = new ArrayList<PhpClass>(); // attach core form phpclass // @TODO: add formtype itself PhpClass coreForm = FormUtil.getFormTypeToClass(project, "form"); if (coreForm != null) { phpClasses.add(coreForm); } // for extension can also provide vars for (Map.Entry<String, String> entry : FormOptionsUtil.getFormExtensionKeys(project, formTypeNames).entrySet()) { PhpClass phpClass = PhpElementsUtil.getClassInterface(project, entry.getValue()); if (phpClass != null) { phpClasses.add(phpClass); } } for (PhpClass phpClass : phpClasses) { for (String stringMethod : new String[] {"finishView", "buildView"}) { Method method = PhpElementsUtil.getClassMethod(phpClass, stringMethod); if (method != null) { // self method getMethodVars(stringSet, method); // allow parent:: // @TODO: provide global util method for (ClassReference classReference : PsiTreeUtil.collectElementsOfType(method, ClassReference.class)) { if ("parent".equals(classReference.getName())) { PsiElement methodReference = classReference.getContext(); if (methodReference instanceof MethodReference) { PsiElement parentMethod = ((MethodReference) methodReference).resolve(); if (parentMethod instanceof Method) { getMethodVars(stringSet, (Method) parentMethod); } } } } } } } return stringSet; }