本文整理匯總了Java中com.intellij.uiDesigner.FormEditingUtil.isBindingUnique方法的典型用法代碼示例。如果您正苦於以下問題:Java FormEditingUtil.isBindingUnique方法的具體用法?Java FormEditingUtil.isBindingUnique怎麽用?Java FormEditingUtil.isBindingUnique使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.uiDesigner.FormEditingUtil
的用法示例。
在下文中一共展示了FormEditingUtil.isBindingUnique方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setValueImpl
import com.intellij.uiDesigner.FormEditingUtil; //導入方法依賴的package包/類
protected void setValueImpl(final RadComponent component, final String value) throws Exception {
if (Comparing.strEqual(value, component.getBinding(), true)) {
return;
}
if (value.length() > 0 && !PsiNameHelper.getInstance(component.getProject()).isIdentifier(value)) {
throw new Exception("Value '" + value + "' is not a valid identifier");
}
final RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
final String oldBinding = getValue(component);
// Check that binding remains unique
if (value.length() > 0) {
if (!FormEditingUtil.isBindingUnique(component, value, root)) {
throw new Exception(UIDesignerBundle.message("error.binding.not.unique"));
}
component.setBinding(value);
component.setDefaultBinding(false);
}
else {
if (component.isCustomCreateRequired()) {
throw new Exception(UIDesignerBundle.message("error.custom.create.binding.required"));
}
component.setBinding(null);
component.setCustomCreate(false);
}
// Set new value or rename old one. It means that previous binding exists
// and the new one doesn't exist we need to ask user to create new field
// or rename old one.
updateBoundFieldName(root, oldBinding, value, component.getComponentClassName());
}
示例2: getFieldNames
import com.intellij.uiDesigner.FormEditingUtil; //導入方法依賴的package包/類
private static String[] getFieldNames(final RadComponent component, final String currentName) {
final ArrayList<String> result = new ArrayList<String>();
if (currentName != null){
result.add(currentName);
}
final IRootContainer root = FormEditingUtil.getRoot(component);
final String className = root.getClassToBind();
if (className == null) {
return ArrayUtil.toStringArray(result);
}
final PsiClass aClass = FormEditingUtil.findClassToBind(component.getModule(), className);
if (aClass == null) {
return ArrayUtil.toStringArray(result);
}
final PsiField[] fields = aClass.getFields();
for (final PsiField field : fields) {
if (field.hasModifierProperty(PsiModifier.STATIC)) {
continue;
}
final String fieldName = field.getName();
if (Comparing.equal(currentName, fieldName)) {
continue;
}
if (!FormEditingUtil.isBindingUnique(component, fieldName, root)) {
continue;
}
final String componentClassName;
if (component instanceof RadErrorComponent) {
componentClassName = component.getComponentClassName();
}
else if (component instanceof RadHSpacer || component instanceof RadVSpacer) {
componentClassName = Spacer.class.getName();
}
else {
componentClassName = component.getComponentClass().getName();
}
final PsiType componentType;
try {
componentType =
JavaPsiFacade.getInstance(component.getProject()).getElementFactory().createTypeFromText(componentClassName, null);
}
catch (IncorrectOperationException e) {
continue;
}
final PsiType fieldType = field.getType();
if (!fieldType.isAssignableFrom(componentType)) {
continue;
}
result.add(fieldName);
}
String text = FormInspectionUtil.getText(component.getModule(), component);
if (text != null) {
String binding = BindingProperty.suggestBindingFromText(component, text);
if (binding != null && !result.contains(binding)) {
result.add(binding);
}
}
final String[] names = ArrayUtil.toStringArray(result);
Arrays.sort(names);
return names;
}